2020-02-13 08:42:22 +00:00
|
|
|
.PHONY: setup image qemu
|
|
|
|
.EXPORT_ALL_VARIABLES:
|
|
|
|
|
|
|
|
setup:
|
2023-06-13 22:40:48 +00:00
|
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
|
|
|
|
rustup show
|
2020-07-31 08:31:59 +00:00
|
|
|
cargo install bootimage
|
2020-02-13 08:42:22 +00:00
|
|
|
|
2022-08-25 07:08:04 +00:00
|
|
|
# Compilation options
|
2022-11-05 08:40:02 +00:00
|
|
|
memory = 32
|
2022-08-25 11:48:23 +00:00
|
|
|
output = video# video, serial
|
|
|
|
keyboard = qwerty# qwerty, azerty, dvorak
|
2022-09-03 13:36:53 +00:00
|
|
|
mode = release
|
2022-08-25 07:08:04 +00:00
|
|
|
|
|
|
|
# Emulation options
|
2024-04-08 13:23:40 +00:00
|
|
|
nic = rtl8139# rtl8139, pcnet, e1000
|
2022-08-25 11:48:23 +00:00
|
|
|
audio = sdl# sdl, coreaudio
|
2024-04-08 13:23:40 +00:00
|
|
|
signal = off# on
|
2022-08-25 07:08:04 +00:00
|
|
|
kvm = false
|
2022-09-03 13:36:53 +00:00
|
|
|
pcap = false
|
2024-04-08 13:23:40 +00:00
|
|
|
trace = false# e1000
|
2023-04-27 17:34:05 +00:00
|
|
|
monitor = false
|
2020-02-13 08:42:22 +00:00
|
|
|
|
2022-11-09 08:29:06 +00:00
|
|
|
export MOROS_VERSION = $(shell git describe --tags | sed "s/^v//")
|
2022-11-05 08:40:02 +00:00
|
|
|
export MOROS_MEMORY = $(memory)
|
2022-11-09 08:29:06 +00:00
|
|
|
export MOROS_KEYBOARD = $(keyboard)
|
2021-08-04 20:07:26 +00:00
|
|
|
|
2021-09-24 16:19:37 +00:00
|
|
|
# Build userspace binaries
|
2021-10-14 07:49:30 +00:00
|
|
|
user-nasm:
|
|
|
|
basename -s .s dsk/src/bin/*.s | xargs -I {} \
|
2022-06-09 20:59:33 +00:00
|
|
|
nasm dsk/src/bin/{}.s -o dsk/bin/{}.tmp
|
|
|
|
basename -s .s dsk/src/bin/*.s | xargs -I {} \
|
|
|
|
sh -c "printf '\x7FBIN' | cat - dsk/bin/{}.tmp > dsk/bin/{}"
|
|
|
|
rm dsk/bin/*.tmp
|
2021-10-14 07:49:30 +00:00
|
|
|
user-rust:
|
|
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
|
|
|
touch dsk/bin/{}
|
|
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
2023-11-20 19:44:05 +00:00
|
|
|
cargo rustc --no-default-features --features userspace --release --bin {}
|
2021-10-14 07:49:30 +00:00
|
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
|
|
|
cp target/x86_64-moros/release/{} dsk/bin/{}
|
2024-02-18 20:41:03 +00:00
|
|
|
basename -s .rs src/bin/*.rs | xargs -I {} \
|
|
|
|
strip dsk/bin/{}
|
2021-09-24 16:19:37 +00:00
|
|
|
|
2022-09-03 13:36:53 +00:00
|
|
|
bin = target/x86_64-moros/$(mode)/bootimage-moros.bin
|
2021-08-04 20:07:26 +00:00
|
|
|
img = disk.img
|
2020-02-13 08:42:22 +00:00
|
|
|
|
|
|
|
$(img):
|
|
|
|
qemu-img create $(img) 32M
|
|
|
|
|
2022-09-03 13:36:53 +00:00
|
|
|
|
|
|
|
cargo-opts = --no-default-features --features $(output) --bin moros
|
|
|
|
ifeq ($(mode),release)
|
|
|
|
cargo-opts += --release
|
|
|
|
endif
|
|
|
|
|
2020-02-13 08:42:22 +00:00
|
|
|
# Rebuild MOROS if the features list changed
|
|
|
|
image: $(img)
|
|
|
|
touch src/lib.rs
|
2021-08-04 20:07:26 +00:00
|
|
|
env | grep MOROS
|
2022-09-03 13:36:53 +00:00
|
|
|
cargo bootimage $(cargo-opts)
|
2020-02-13 08:42:22 +00:00
|
|
|
dd conv=notrunc if=$(bin) of=$(img)
|
|
|
|
|
2022-11-05 08:40:02 +00:00
|
|
|
qemu-opts = -m $(memory) -drive file=$(img),format=raw \
|
2022-08-25 11:48:23 +00:00
|
|
|
-audiodev $(audio),id=a0 -machine pcspk-audiodev=a0 \
|
2022-08-25 06:42:35 +00:00
|
|
|
-netdev user,id=e0,hostfwd=tcp::8080-:80 -device $(nic),netdev=e0
|
2022-08-11 06:44:07 +00:00
|
|
|
ifeq ($(kvm),true)
|
2022-09-03 13:36:53 +00:00
|
|
|
qemu-opts += -cpu host -accel kvm
|
2022-08-11 06:44:07 +00:00
|
|
|
else
|
2024-04-08 13:23:40 +00:00
|
|
|
qemu-opts += -cpu core2duo
|
2022-08-11 06:44:07 +00:00
|
|
|
endif
|
|
|
|
|
2022-08-27 10:36:20 +00:00
|
|
|
ifeq ($(pcap),true)
|
2022-09-03 13:36:53 +00:00
|
|
|
qemu-opts += -object filter-dump,id=f1,netdev=e0,file=/tmp/qemu.pcap
|
2022-08-27 10:36:20 +00:00
|
|
|
endif
|
|
|
|
|
2023-04-27 17:34:05 +00:00
|
|
|
ifeq ($(monitor),true)
|
|
|
|
qemu-opts += -monitor telnet:127.0.0.1:7777,server,nowait
|
|
|
|
endif
|
|
|
|
|
2020-02-13 08:42:22 +00:00
|
|
|
ifeq ($(output),serial)
|
2024-04-08 13:23:40 +00:00
|
|
|
qemu-opts += -display none
|
|
|
|
qemu-opts += -chardev stdio,id=s0,signal=$(signal) -serial chardev:s0
|
2020-02-13 08:42:22 +00:00
|
|
|
endif
|
|
|
|
|
2022-09-03 13:36:53 +00:00
|
|
|
ifeq ($(mode),debug)
|
|
|
|
qemu-opts += -s -S
|
|
|
|
endif
|
|
|
|
|
2024-04-08 13:23:40 +00:00
|
|
|
ifeq ($(trace),e1000)
|
|
|
|
qemu-opts += -trace 'e1000*'
|
|
|
|
endif
|
|
|
|
|
2022-09-03 13:36:53 +00:00
|
|
|
# In debug mode, open another terminal with the following command
|
|
|
|
# and type `continue` to start the boot process:
|
|
|
|
# > gdb target/x86_64-moros/debug/moros -ex "target remote :1234"
|
|
|
|
|
2020-02-13 08:42:22 +00:00
|
|
|
qemu:
|
2022-09-03 13:36:53 +00:00
|
|
|
qemu-system-x86_64 $(qemu-opts)
|
2020-11-14 20:52:07 +00:00
|
|
|
|
|
|
|
test:
|
2022-05-05 21:05:39 +00:00
|
|
|
cargo test --release --lib --no-default-features --features serial -- \
|
2024-04-08 13:23:40 +00:00
|
|
|
-m $(memory) -display none -serial stdio \
|
|
|
|
-device isa-debug-exit,iobase=0xF4,iosize=0x04
|
2021-02-04 09:06:06 +00:00
|
|
|
|
2023-04-27 17:34:05 +00:00
|
|
|
website:
|
|
|
|
cd www && sh build.sh
|
|
|
|
|
2021-02-04 09:06:06 +00:00
|
|
|
clean:
|
|
|
|
cargo clean
|
2023-11-19 20:03:10 +00:00
|
|
|
rm -f www/*.html www/images/*.png
|