From 9ae4341f58a98c049c2744e365caffc6b64f342d Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 13 Aug 2021 23:17:49 +0200 Subject: [PATCH 1/2] Makefile --- Makefile | 25 +++++++++++++++++++++++++ src/kernel/kernel_entry.asm | 5 +++++ 2 files changed, 30 insertions(+) create mode 100644 Makefile create mode 100644 src/kernel/kernel_entry.asm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..47302fe --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +all: os-image + +run: all + qemu bin/os-image + +os-image: bin/bootloader.bin bin/kernel.bin + cat $^ > bin/os-image + +kernel.bin: bin/kernel_entry.o bin/kernel.o + ld -o kernel.bin -Ttext 0x1000 $^ --oformat binary + +kernel.o : src/kernel/kernel.c + gcc -ffreestanding -c $< -o $@ + +kernel_entry.o : src/kernel/kernel_entry.asm + nasm $< -f elf -o $@ + +bootloader.bin : src/bootloader/bootloader.asm + nasm $< -o $@ + +clean: + rm -fr bin/*.bin bin/*.dis bin/*.o bin/os-image bin/*.map + +kernel.dis : bin/kernel.bin + ndisasm -b 32 $< > $@ diff --git a/src/kernel/kernel_entry.asm b/src/kernel/kernel_entry.asm new file mode 100644 index 0000000..3d2fa88 --- /dev/null +++ b/src/kernel/kernel_entry.asm @@ -0,0 +1,5 @@ +[bits 32] +[extern main] + +call main +jmp $ From 4413465edfae47e57d2c43ae08d4dab6363582f6 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 13 Aug 2021 23:22:59 +0200 Subject: [PATCH 2/2] Makefile changes --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 47302fe..c06a307 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ kernel_entry.o : src/kernel/kernel_entry.asm nasm $< -f elf -o $@ bootloader.bin : src/bootloader/bootloader.asm - nasm $< -o $@ + nasm $< -f bin -o $@ clean: rm -fr bin/*.bin bin/*.dis bin/*.o bin/os-image bin/*.map