redox/mk/qemu.mk

158 lines
3.9 KiB
Makefile
Raw Normal View History

2022-08-30 19:09:49 +02:00
QEMU=SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-$(QEMU_ARCH)
2022-08-31 18:56:50 +02:00
QEMUFLAGS=-d cpu_reset,guest_errors
2022-08-30 19:09:49 +02:00
2022-07-29 18:11:32 +02:00
ifeq ($(ARCH),i686)
2022-08-24 14:26:27 +02:00
efi=no
2022-07-29 20:13:32 +02:00
QEMU_ARCH=i386
QEMU_MACHINE?=pc
QEMU_CPU?=pentium2
2022-08-30 19:09:49 +02:00
QEMUFLAGS+=-smp 4 -m 2048
2022-07-29 18:15:18 +02:00
else ifeq ($(ARCH),x86_64)
2022-07-29 20:13:32 +02:00
QEMU_ARCH=x86_64
QEMU_MACHINE?=q35
QEMU_CPU?=core2duo
2022-07-29 20:13:32 +02:00
QEMU_EFI=/usr/share/OVMF/OVMF_CODE.fd
2022-08-30 19:09:49 +02:00
QEMUFLAGS+=-smp 4 -m 2048
2022-07-29 18:15:18 +02:00
else ifeq ($(ARCH),aarch64)
2022-08-24 14:22:40 +02:00
efi=yes
2022-07-29 20:13:32 +02:00
kvm=no
2022-08-26 19:30:14 +02:00
live=yes
2022-08-24 14:22:40 +02:00
#TODO: support vga
vga=no
2022-07-29 20:13:32 +02:00
QEMU_ARCH=aarch64
QEMU_MACHINE=virt
QEMU_CPU=max
QEMU_EFI=/usr/share/AAVMF/AAVMF_CODE.fd
2022-08-30 19:09:49 +02:00
QEMUFLAGS+=-smp 1 -m 2048
2022-07-29 20:13:32 +02:00
ifneq ($(vga),no)
QEMUFLAGS+=-device virtio-gpu-pci
endif
2022-08-24 14:22:40 +02:00
ifneq ($(usb),no)
QEMUFLAGS+=-device usb-ehci -device usb-kbd -device usb-mouse
endif
2022-07-29 18:11:32 +02:00
else
2022-07-29 20:13:32 +02:00
$(error Unsupported ARCH for QEMU "$(ARCH)"))
2022-07-29 18:11:32 +02:00
endif
2022-07-29 18:15:18 +02:00
2022-08-24 14:22:40 +02:00
ifeq ($(efi),yes)
FIRMWARE=build/firmware.rom
QEMUFLAGS+=-bios build/firmware.rom
else
FIRMWARE=
endif
ifeq ($(live),yes)
2022-09-07 16:28:12 +02:00
DISK=build/livedisk.iso
else
2022-09-07 16:28:12 +02:00
DISK=build/harddrive.img
2022-08-24 14:22:40 +02:00
endif
2019-03-12 02:55:10 +01:00
ifeq ($(serial),no)
QEMUFLAGS+=-chardev stdio,id=debug -device isa-debugcon,iobase=0x402,chardev=debug
else
QEMUFLAGS+=-chardev stdio,id=debug,signal=off,mux=on,"$(if $(qemu_serial_logfile),logfile=$(qemu_serial_logfile))"
QEMUFLAGS+=-serial chardev:debug -mon chardev=debug
2019-03-12 02:55:10 +01:00
endif
2022-08-30 19:09:49 +02:00
2017-01-05 22:07:20 +01:00
ifeq ($(iommu),yes)
2022-07-29 18:11:32 +02:00
QEMUFLAGS+=-machine $(QEMU_MACHINE),iommu=on
2017-01-05 22:07:20 +01:00
else
2022-07-29 18:11:32 +02:00
QEMUFLAGS+=-machine $(QEMU_MACHINE)
2017-01-05 22:07:20 +01:00
endif
2022-08-30 19:09:49 +02:00
2017-06-18 00:59:01 +02:00
ifneq ($(audio),no)
QEMUFLAGS+=-device ich9-intel-hda -device hda-duplex
endif
2022-08-30 19:09:49 +02:00
2017-01-05 22:07:20 +01:00
ifeq ($(net),no)
QEMUFLAGS+=-net none
else
ifneq ($(bridge),)
QEMUFLAGS+=-netdev bridge,br=$(bridge),id=net0 -device e1000,netdev=net0,id=nic0
else
2020-06-17 19:04:24 +02:00
ifeq ($(net),redir)
# port 8080 and 8083 - webservers
# port 64126 - our gdbserver implementation
QEMUFLAGS+=-netdev user,id=net0,hostfwd=tcp::8080-:8080,hostfwd=tcp::8083-:8083,hostfwd=tcp::64126-:64126 -device e1000,netdev=net0,id=nic0
else
QEMUFLAGS+=-netdev user,id=net0 -device e1000,netdev=net0 \
-object filter-dump,id=f1,netdev=net0,file=build/network.pcap
endif
2017-01-05 22:07:20 +01:00
endif
endif
2022-08-30 19:09:49 +02:00
2017-01-05 22:07:20 +01:00
ifeq ($(vga),no)
QEMUFLAGS+=-nographic -vga none
endif
2022-08-30 19:09:49 +02:00
2017-01-11 04:49:18 +01:00
ifneq ($(usb),no)
QEMUFLAGS+=-device nec-usb-xhci,id=xhci
2017-01-11 04:49:18 +01:00
endif
2022-08-30 19:09:49 +02:00
2019-09-08 04:01:03 +02:00
ifeq ($(gdb),yes)
2022-08-21 22:57:56 +02:00
QEMUFLAGS+=-s -S
endif
2022-08-30 19:09:49 +02:00
2017-01-05 22:07:20 +01:00
ifeq ($(UNAME),Linux)
ifneq ($(kvm),no)
QEMUFLAGS+=-enable-kvm -cpu host
else
2022-07-29 18:11:32 +02:00
QEMUFLAGS+=-cpu $(QEMU_CPU)
2017-01-05 22:07:20 +01:00
endif
endif
ifeq ($(UNAME),Linux)
2022-09-07 16:28:12 +02:00
build/extra.img:
2019-09-15 21:41:21 +02:00
fallocate --posix --length 1G $@
else
2022-09-07 16:28:12 +02:00
build/extra.img:
truncate -s 1g $@
endif
2017-01-05 22:07:20 +01:00
2022-07-29 20:13:32 +02:00
build/firmware.rom:
cp $(QEMU_EFI) $@
2022-09-07 16:28:12 +02:00
qemu: $(DISK) $(FIRMWARE) build/extra.img
$(QEMU) $(QEMUFLAGS) \
2022-11-02 21:37:30 +01:00
-hdc $(DISK)
echo -drive file=$(DISK),format=raw \
2022-09-07 16:28:12 +02:00
-drive file=build/extra.img,format=raw
2017-01-13 19:08:44 +01:00
2022-09-07 16:28:12 +02:00
qemu_no_build: $(FIRMWARE) build/extra.img
2020-01-14 11:56:09 +01:00
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-drive file=$(DISK),format=raw \
-drive file=build/extra.img,format=raw
2020-01-14 11:56:09 +01:00
2022-09-07 16:28:12 +02:00
qemu_cdrom: $(DISK) $(FIRMWARE) build/extra.img
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-boot d -cdrom $(DISK) \
-drive file=build/extra.img,format=raw
2022-09-07 16:28:12 +02:00
qemu_cdrom_no_build: $(FIRMWARE) build/extra.img
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-boot d -cdrom $(DISK) \
-drive file=build/extra.img,format=raw
2022-09-07 16:28:12 +02:00
qemu_nvme: $(DISK) $(FIRMWARE) build/extra.img
2018-04-13 05:24:07 +02:00
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-drive file=$(DISK),format=raw,if=none,id=drv0 -device nvme,drive=drv0,serial=NVME_SERIAL \
-drive file=build/extra.img,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA
2018-04-13 05:24:07 +02:00
2022-09-07 16:28:12 +02:00
qemu_nvme_no_build: $(FIRMWARE) build/extra.img
2018-04-13 05:24:07 +02:00
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-drive file=$(DISK),format=raw,if=none,id=drv0 -device nvme,drive=drv0,serial=NVME_SERIAL \
-drive file=build/extra.img,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA
2018-04-13 05:24:07 +02:00
2022-09-07 16:28:12 +02:00
qemu_usb: $(DISK) $(FIRMWARE)
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-drive if=none,id=usbstick,format=raw,file=$(DISK) \
-device usb-storage,drive=usbstick
2019-09-15 21:41:21 +02:00
2022-09-07 16:28:12 +02:00
qemu_extra: $(FIRMWARE) build/extra.img
2019-09-15 21:41:21 +02:00
$(QEMU) $(QEMUFLAGS) \
2022-09-07 16:28:12 +02:00
-drive file=build/extra.img,format=raw
qemu_nvme_extra: $(FIRMWARE) build/extra.img
$(QEMU) $(QEMUFLAGS) \
-drive file=build/extra.img,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA