diff --git a/kernel/Makefile b/kernel/Makefile index 69c9fc1..b625918 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -98,133 +98,134 @@ export DTB = $(dtb) qemu_opts := \ -smp cores=$(smp) qemu_net_opts := -qemu_ui_opts := +qemu_ui_opts := ifeq ($(arch), x86_64) -qemu_opts += \ - -drive format=raw,file=$(bootimage) \ - -serial mon:stdio \ - -m 4G \ - -device isa-debug-exit -ifeq ($(board), none) -qemu_opts += \ - -drive format=qcow2,file=$(SFSIMG),media=disk,cache=writeback,id=sfsimg,if=none \ - -device ahci,id=ahci0 \ - -device ide-drive,drive=sfsimg,bus=ahci0.0 -endif -ifeq ($(pci_passthru), ) -qemu_net_opts += \ - -netdev type=tap,id=net0,script=no,downscript=no \ - -device e1000e,netdev=net0 -else -qemu_opts += \ - -machine accel=kvm -qemu_net_opts += \ - -device vfio-pci,host=$(pci_passthru) -qemu_ui_opts += \ - -vga std -endif -ifeq ($(extra_nic), on) -qemu_net_opts += \ - -netdev type=tap,id=net1,script=no,downscript=no \ - -device e1000e,netdev=net1 -endif + qemu_opts += \ + -drive format=raw,file=$(bootimage) \ + -serial mon:stdio \ + -m 4G \ + -device isa-debug-exit + ifeq ($(board), none) + qemu_opts += \ + -drive format=qcow2,file=$(SFSIMG),media=disk,cache=writeback,id=sfsimg,if=none \ + -device ahci,id=ahci0 \ + -device ide-drive,drive=sfsimg,bus=ahci0.0 + endif + + ifeq ($(pci_passthru), ) + qemu_net_opts += \ + -netdev type=tap,id=net0,script=no,downscript=no \ + -device e1000e,netdev=net0 + else + qemu_opts += \ + -machine accel=kvm + qemu_net_opts += \ + -device vfio-pci,host=$(pci_passthru) + qemu_ui_opts += \ + -vga std + endif + + ifeq ($(extra_nic), on) + qemu_net_opts += \ + -netdev type=tap,id=net1,script=no,downscript=no \ + -device e1000e,netdev=net1 + endif else ifeq ($(arch), riscv32) -qemu_opts += \ - -machine virt \ - -serial mon:stdio \ - -kernel ../tools/opensbi/virt_rv32.elf \ - -device loader,addr=0x80400000,file=$(kernel_img) \ - -drive file=$(SFSIMG),format=qcow2,id=sfs \ - -device virtio-blk-device,drive=sfs -qemu_net_opts += \ - -netdev type=tap,id=net0,script=no,downscript=no \ - -device virtio-net-device,netdev=net0 -qemu_ui_opts += \ - -device virtio-gpu-device \ - -device virtio-mouse-device + qemu_opts += \ + -machine virt \ + -serial mon:stdio \ + -kernel ../tools/opensbi/virt_rv32.elf \ + -device loader,addr=0x80400000,file=$(kernel_img) \ + -drive file=$(SFSIMG),format=qcow2,id=sfs \ + -device virtio-blk-device,drive=sfs + qemu_net_opts += \ + -netdev type=tap,id=net0,script=no,downscript=no \ + -device virtio-net-device,netdev=net0 + qemu_ui_opts += \ + -device virtio-gpu-device \ + -device virtio-mouse-device else ifeq ($(arch), riscv64) -ifeq ($(board), u540) -qemu_opts += \ - -machine virt \ - -serial mon:stdio \ - -kernel ../tools/opensbi/fu540.elf \ - -device loader,addr=0x80200000,file=$(kernel_img) -else -qemu_opts += \ - -machine virt \ - -serial mon:stdio \ - -kernel ../tools/opensbi/virt_rv64.elf \ - -device loader,addr=0x80200000,file=$(kernel_img) \ - -drive file=$(SFSIMG),format=qcow2,id=sfs \ - -device virtio-blk-device,drive=sfs -endif -qemu_net_opts += \ - -netdev type=tap,id=net0,script=no,downscript=no \ - -device virtio-net-device,netdev=net0 -qemu_ui_opts += \ - -device virtio-gpu-device \ - -device virtio-mouse-device - + ifeq ($(board), u540) + qemu_opts += \ + -machine virt \ + -serial mon:stdio \ + -kernel ../tools/opensbi/fu540.elf \ + -device loader,addr=0x80200000,file=$(kernel_img) + else + qemu_opts += \ + -machine virt \ + -serial mon:stdio \ + -kernel ../tools/opensbi/virt_rv64.elf \ + -device loader,addr=0x80200000,file=$(kernel_img) \ + -drive file=$(SFSIMG),format=qcow2,id=sfs \ + -device virtio-blk-device,drive=sfs + endif + + qemu_net_opts += \ + -netdev type=tap,id=net0,script=no,downscript=no \ + -device virtio-net-device,netdev=net0 + qemu_ui_opts += \ + -device virtio-gpu-device \ + -device virtio-mouse-device else ifeq ($(arch), aarch64) -qemu_opts += \ - -machine $(board) \ - -serial null -serial mon:stdio \ - -kernel $(kernel_img) -ifneq ($(u_boot), ) -qemu_opts += \ - -sd $(bootloader) -endif - + qemu_opts += \ + -machine $(board) \ + -serial null -serial mon:stdio \ + -kernel $(kernel_img) + ifneq ($(u_boot), ) + qemu_opts += \ + -sd $(bootloader) + endif else ifeq ($(arch), mipsel) -ifeq ($(board), malta) -qemu_opts += \ - -machine $(board) -device VGA \ - -serial null -serial null -serial mon:stdio \ - -kernel $(kernel_img) -endif -ifeq ($(board), mipssim) -qemu_opts += \ - -machine $(board) \ - -serial mon:stdio \ - -kernel $(kernel_img) -endif + ifeq ($(board), malta) + qemu_opts += \ + -machine $(board) -device VGA \ + -serial null -serial null -serial mon:stdio \ + -kernel $(kernel_img) + endif + ifeq ($(board), mipssim) + qemu_opts += \ + -machine $(board) \ + -serial mon:stdio \ + -kernel $(kernel_img) + endif endif ifdef d -qemu_opts += -d $(d) + qemu_opts += -d $(d) endif ifeq ($(graphic), off) -qemu_opts += -nographic + qemu_opts += -nographic endif ### build args ### ifeq ($(graphic), off) -features += nographic + features += nographic endif ifeq ($(graphic), console) -features += consolegraphic + features += consolegraphic endif ifneq ($(init), ) -features += run_cmdline + features += run_cmdline endif ifeq ($(board), raspi3) -# qemu only has generic timer -# TODO: configure system/generic timer automatically -raspi3_timer ?= generic -ifeq ($(raspi3_timer), generic) -features += raspi3_use_generic_timer -endif + # qemu only has generic timer + # TODO: configure system/generic timer automatically + raspi3_timer ?= generic + ifeq ($(raspi3_timer), generic) + features += raspi3_use_generic_timer + endif endif ifneq ($(board), none) -features += board_$(board) + features += board_$(board) endif features += $(extra_features) @@ -232,25 +233,25 @@ features += $(extra_features) build_args := --target targets/$(target).json --features "$(features)" ifeq ($(mode), release) -build_args += --release + build_args += --release endif ### prefix ### ifeq ($(arch), x86_64) -ifeq ($(uname), Darwin) -prefix := x86_64-elf- -endif + ifeq ($(uname), Darwin) + prefix := x86_64-elf- + endif else ifeq ($(arch), riscv32) -prefix := riscv64-unknown-elf- + prefix := riscv64-unknown-elf- else ifeq ($(arch), riscv64) -prefix := riscv64-unknown-elf- + prefix := riscv64-unknown-elf- else ifeq ($(arch), mipsel) -prefix ?= mipsel-linux-musln32- + prefix ?= mipsel-linux-musln32- else ifeq ($(arch), aarch64) -prefix ?= aarch64-none-elf- -ifeq (,$(shell which $(prefix)ld)) - prefix := aarch64-elf- -endif + prefix ?= aarch64-none-elf- + ifeq (,$(shell which $(prefix)ld)) + prefix := aarch64-elf- + endif endif gdb := $(prefix)gdb @@ -374,9 +375,9 @@ ifeq ($(board), raspi3) sd_card ?= ifeq ($(shell uname), Darwin) -sd_card := /Volumes/boot + sd_card := /Volumes/boot else ifeq ($(shell uname), Linux) -sd_card := /media/$(shell whoami)/boot + sd_card := /media/$(shell whoami)/boot endif ifdef sd_card