redox/mk/qemu.mk

150 lines
3.9 KiB
Makefile
Raw Normal View History

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
2022-08-21 22:57:56 +02:00
QEMU_MACHINE=q35
2022-07-29 20:13:32 +02:00
QEMU_CPU=pentium2
2022-08-26 16:25:46 +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
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
QEMUFLAGS=-smp 1 -m 2048
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
ifeq ($(live),yes)
HARDDRIVE=build/livedisk-efi.bin
2022-08-24 14:23:57 +02:00
else
HARDDRIVE=build/harddrive-efi.bin
2022-08-24 14:22:40 +02:00
endif
else
FIRMWARE=
ifeq ($(live),yes)
HARDDRIVE=build/livedisk.bin
2022-08-24 14:23:57 +02:00
else
HARDDRIVE=build/harddrive.bin
2022-08-24 14:22:40 +02:00
endif
endif
2022-07-29 18:11:32 +02:00
QEMU=SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-$(QEMU_ARCH)
2022-08-04 18:21:52 +02:00
QEMUFLAGS+=-d cpu_reset,guest_errors
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
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
2017-06-18 00:59:01 +02:00
ifneq ($(audio),no)
QEMUFLAGS+=-device ich9-intel-hda -device hda-duplex
endif
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
ifeq ($(vga),no)
QEMUFLAGS+=-nographic -vga none
endif
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
2019-09-08 04:01:03 +02:00
ifeq ($(gdb),yes)
2022-08-21 22:57:56 +02:00
QEMUFLAGS+=-s -S
endif
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
#,int,pcall
#-device intel-iommu
ifeq ($(UNAME),Linux)
2019-09-15 21:41:21 +02:00
build/extra.bin:
fallocate --posix --length 1G $@
else
build/extra.bin:
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-08-24 14:22:40 +02:00
qemu: $(HARDDRIVE) $(FIRMWARE) build/extra.bin
$(QEMU) $(QEMUFLAGS) \
2022-08-24 14:22:40 +02:00
-drive file=$(HARDDRIVE),format=raw \
2019-09-15 21:41:21 +02:00
-drive file=build/extra.bin,format=raw
2017-01-13 19:08:44 +01:00
2022-08-24 14:22:40 +02:00
qemu_no_build: $(FIRMWARE) build/extra.bin
2020-01-14 11:56:09 +01:00
$(QEMU) $(QEMUFLAGS) \
2022-08-24 14:22:40 +02:00
-drive file=$(HARDDRIVE),format=raw \
2020-01-14 11:56:09 +01:00
-drive file=build/extra.bin,format=raw
2022-08-24 14:22:40 +02:00
qemu_nvme: $(HARDDRIVE) $(FIRMWARE) build/extra.bin
$(QEMU) $(QEMUFLAGS) \
2022-08-24 14:22:40 +02:00
-drive file=$(HARDDRIVE),format=raw,if=none,id=drv0 -device nvme,drive=drv0,serial=NVME_SERIAL \
-drive file=build/extra.bin,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA
2022-08-24 14:22:40 +02:00
qemu_nvme_no_build: $(FIRMWARE) build/extra.bin
$(QEMU) $(QEMUFLAGS) \
2022-08-24 14:22:40 +02:00
-drive file=$(HARDDRIVE),format=raw,if=none,id=drv0 -device nvme,drive=drv0,serial=NVME_SERIAL \
-drive file=build/extra.bin,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA
2022-08-24 14:22:40 +02:00
qemu_iso: build/livedisk.iso $(FIRMWARE) build/extra.bin
2018-04-13 05:24:07 +02:00
$(QEMU) $(QEMUFLAGS) \
-boot d -cdrom build/livedisk.iso \
2019-09-15 21:41:21 +02:00
-drive file=build/extra.bin,format=raw
2018-04-13 05:24:07 +02:00
2022-08-24 14:22:40 +02:00
qemu_iso_no_build: $(FIRMWARE) build/extra.bin
2018-04-13 05:24:07 +02:00
$(QEMU) $(QEMUFLAGS) \
-boot d -cdrom build/livedisk.iso \
2019-09-15 21:41:21 +02:00
-drive file=build/extra.bin,format=raw
2018-04-13 05:24:07 +02:00
2022-08-24 14:22:40 +02:00
qemu_extra: $(FIRMWARE) build/extra.bin
$(QEMU) $(QEMUFLAGS) \
2019-09-15 21:41:21 +02:00
-drive file=build/extra.bin,format=raw
2022-08-24 14:22:40 +02:00
qemu_nvme_extra: $(FIRMWARE) build/extra.bin
2019-09-15 21:41:21 +02:00
$(QEMU) $(QEMUFLAGS) \
-drive file=build/extra.bin,format=raw,if=none,id=drv1 -device nvme,drive=drv1,serial=NVME_EXTRA