From c54fde90511092738ba3955e46948a5a19e74755 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Wed, 5 May 2021 13:50:24 +1000 Subject: [PATCH] revised to build raw EFI disk --- Makefile | 55 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 3f6972b..3d9b5b5 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,44 @@ +default: out/main + +# asm and init order is important +src/main.asm: src/uefi.asm src/impl.asm src/bootstrap.asm +src/main.asm: init/sys.f init/uefi.f + +out: + mkdir -p out + +out/main: src/main.asm | out + fasm $< $@ + +# Start script +out/startup.nsh: out + echo 'fs0:main' > $@ + .PHONY: qemu + +# Based on https://wiki.osdev.org/UEFI#Emulation_with_QEMU_and_OVMF +qemu: ARGS = -cpu qemu64 +qemu: ARGS += -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on +qemu: ARGS += -drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd +qemu: ARGS += -net none +qemu: ARGS += -drive format=raw,file=fat:rw:out +qemu: ARGS += -display type=gtk,zoom-to-fit=on qemu: out/main out/startup.nsh OVMF_CODE.fd OVMF_VARS.fd - # Based on https://wiki.osdev.org/UEFI#Emulation_with_QEMU_and_OVMF - qemu-system-x86_64 -cpu qemu64 \ - -drive if=pflash,format=raw,unit=0,file=OVMF_CODE.fd,readonly=on \ - -drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd \ - -net none \ - -drive format=raw,file=fat:rw:out \ - -display type=gtk,zoom-to-fit=on - -# Assuming 'ovmf' package on Arch Linux is installed. -OVMF_CODE.fd: /usr/share/ovmf/x64/OVMF_CODE.fd - cp $< $@ -OVMF_VARS.fd: /usr/share/ovmf/x64/OVMF_VARS.fd + qemu-system-x86_64 $(ARGS) + +OVMF_CODE.fd OVMF_VARS.fd: %: /usr/share/OVMF/% cp $< $@ -out/main: src/main.asm src/impl.asm src/bootstrap.asm src/uefi.asm init/sys.f init/uefi.f - mkdir -p out - fasm $< $@ +OVMF: OVMF_CODE.fd OVMF_VARS.fd -out/startup.nsh: - mkdir -p out - echo 'fs0:main' >out/startup.nsh +EFI.raw: out/main + mkfs.fat -C $@ 2048 # =1Mb + mmd -i "$@" ::efi + mmd -i "$@" ::efi/boot + mcopy -i "$@" out/main "::EFI/BOOT/bootx64.efi" .PHONY: clean clean: - rm -rf out OVMF_CODE.fd OVMF_VARS.fd + rm -rf out OVMF_CODE.fd OVMF_VARS.fd EFI.raw + + -- 2.39.2