commit 7a2897c5b74e2e0ea53254c0eb6d8d58e50da8e2
parent 5b7bd0f5c338ca4b909167a69cf1401bc675b450
Author: Matsuda Kenji <info@mtkn.jp>
Date: Tue, 19 Mar 2024 12:03:47 +0900
divide make rules
Diffstat:
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,3 +1 @@
-image
-disk.img
include
diff --git a/Makefile b/Makefile
@@ -6,7 +6,16 @@ OBJCOPY = objcopy
SRC = loader.c utils.c
HDR = uefi.h
-all: loader.efi
+all: disk.img
+
+disk.img: loader.efi
+ qemu-img create -f raw disk.img 200M
+ mkfs.fat -n 'setos' -s 2 -f 2 -R 32 -F 32 disk.img
+ mkdir -p image
+ doas mount disk.img image
+ doas mkdir -p image/EFI/BOOT
+ doas cp loader.efi image/EFI/BOOT/BOOTX64.EFI
+ doas umount image
loader.dll: $(SRC) $(HDR)
$(CC) $(CFLAGS) -o $@ $(SRC)
@@ -14,12 +23,7 @@ loader.dll: $(SRC) $(HDR)
loader.efi: loader.dll
$(OBJCOPY) --target=efi-app-x86_64 $< $@
-run: loader.efi
- mkdir -p image
- doas mount disk.img image
- doas mkdir -p image/EFI/BOOT
- doas cp loader.efi image/EFI/BOOT/BOOTX64.EFI
- doas umount image
+run: disk.img
qemu-system-x86_64 \
-bios /usr/share/edk2/x64/OVMF.fd \
-drive format=raw,file=disk.img
@@ -28,5 +32,5 @@ test: test/* $(SRC) $(HDR)
(cd test && make)
clean:
- rm -f *.o *.efi *.dll
+ rm -rf *.o *.efi *.dll disk.img image
(cd test && make clean)
\ No newline at end of file
diff --git a/kernel.c b/kernel.c
@@ -0,0 +1,6 @@
+void
+kernel_main(void)
+{
+ for(;1;)
+ ;
+}
+\ No newline at end of file