From f9a0b07bdacaba35809fafc4557fd31d8d6edc7b Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 12 Aug 2021 12:57:30 +0200 Subject: [PATCH] GRUB & cleanup --- compile.sh | 10 +++++----- grub_compile.sh | 20 ++++++++++++++++++++ src/grub/grub.cfg | 3 +++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100755 grub_compile.sh create mode 100644 src/grub/grub.cfg diff --git a/compile.sh b/compile.sh index 9671ad1..8360c7d 100755 --- a/compile.sh +++ b/compile.sh @@ -1,21 +1,21 @@ #!/usr/bin/bash -srcDir=src -binDir=bin +srcdir=src +bindir=bin compile_bootloader() { echo "Compiling bootloader... " - nasm -f bin $srcDir/bootloader/bootloader.asm -i $srcDir/bootloader -o $binDir/bootloader.bin + nasm -f bin $srcdir/bootloader/bootloader.asm -i $srcdir/bootloader -o $bindir/bootloader.bin } compile_kernel() { echo "Compiling kernel... " - gcc -fno-pie -m32 -Os -ffreestanding -c $srcDir/kernel/kernel.c -o $binDir/kernel.o && gcc -o $binDir/kernel.bin $binDir/kernel.o -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 + gcc -fno-pie -m32 -Os -ffreestanding -c $srcdir/kernel/kernel.c -o $bindir/kernel.o && gcc -o $bindir/kernel.bin $bindir/kernel.o -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 } create_os_image() { echo "Creating OS image... " - cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image + cat $bindir/bootloader.bin $bindir/kernel.bin > $bindir/os-image } diff --git a/grub_compile.sh b/grub_compile.sh new file mode 100755 index 0000000..b360f69 --- /dev/null +++ b/grub_compile.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +srcdir=src +bindir=bin + +make_grub() { + echo "Making GRUB..." + mkdir -p $bindir/boot/grub + cp $bindir/kernel.bin $bindir/boot/kernel.bin + cp $srcdir/grub/grub.cfg $bindir/boot/grub/grub.cfg + grub-mkrescue -o $bindir/eOS.iso $bindir +} + +compile_kernel() { + echo "Compiling kernel... " + gcc -fno-pie -m32 -Os -ffreestanding -c $srcdir/kernel/kernel.c -o $bindir/kernel.o && gcc -o $bindir/kernel.bin $bindir/kernel.o -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 +} + +compile_kernel +make_grub diff --git a/src/grub/grub.cfg b/src/grub/grub.cfg new file mode 100644 index 0000000..c3ebe15 --- /dev/null +++ b/src/grub/grub.cfg @@ -0,0 +1,3 @@ +menuentry "eOS" { + multiboot /boot/eOS.bin +}