From fe69547f2df151b371acdd99adb7167842382136 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Tue, 10 Aug 2021 23:07:19 +0200 Subject: [PATCH] Kernel & compiling script rework --- compile.sh | 12 +++++++++++- src/kernel.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/kernel.c diff --git a/compile.sh b/compile.sh index b009096..ccdc9cd 100755 --- a/compile.sh +++ b/compile.sh @@ -1,6 +1,16 @@ #!/usr/bin/bash +done="[OK]" +fail="[FAIL]" + srcDir=src binDir=bin -nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin +echo -n "Compiling bootloader... " +nasm -f bin $srcDir/bootloader.asm -i $srcDir -o $binDir/bootloader.bin && echo $done + +echo -n "Compiling kernel... " +gcc -ffreestanding -c $srcDir/kernel.c -o $binDir/kernel.o && ld -o $binDir/kernel.bin -Ttext 0x1000 $binDir/kernel.o --oformat binary 2>/dev/null && echo $done + +echo -n "Creating kernel image... " +cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image && echo $done diff --git a/src/kernel.c b/src/kernel.c new file mode 100644 index 0000000..c5bc72d --- /dev/null +++ b/src/kernel.c @@ -0,0 +1,7 @@ +// VGA base address: 0xb8000 +// Charpos = 0xb8000 + 2(row*80 + col) + +void main() { + char* video_mem = (char*)0xb8000; // VGA Video Memory location + *video_mem = 'X'; +}