From d8392002629bc97c05ca82961c7ab3439ed7248e Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 17 Jul 2025 19:20:28 +0200 Subject: Start writing the kernel and add a linker script Move the code unders [BITS 32] label to its own file to be loaded as a kernel by the boot loader. Add a linker script to link the bootloader and the kernel in a single binary file. Add a build script to make it easier to use the cross compiler Update the Makefile to build everything and pack it into the os.bin Signed-off-by: Carlos Maiolino --- Makefile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4df65dd..8f4b284 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,24 @@ +FILLES = ./build/kernel.asm.o + BOOTLOADER=./src/boot/bootloader.asm TARGET=./bin/boot.bin -all: +all: ./bin/boot.bin ./bin/kernel.bin + rm -rf ./bin/os.bin + dd if=./bin/boot.bin >> ./bin/os.bin + dd if=./bin/kernel.bin >> ./bin/os.bin + dd if=/dev/zero bs=512 count=100 >> ./bin/os.bin +./bin/kernel.bin: ./build/kernel.asm.o + i686-elf-ld -g -relocatable ./build/kernel.asm.o -o ./build/cemOS.o + i686-elf-gcc -T ./src/linker.ld -o ./bin/kernel.bin -ffreestanding -O0 -nostdlib ./build/cemOS.o + +./bin/boot.bin: ./src/boot/bootloader.asm nasm -f bin $(BOOTLOADER) -o $(TARGET) + +./build/kernel.asm.o: ./src/kernel.asm + nasm -f elf -g ./src/kernel.asm -o ./build/kernel.asm.o + clean: rm -f $(TARGET) + rm -f build/cemOS.o + rm -f build/kernel.asm.o -- cgit v1.2.3