diff --git a/compile.sh b/compile.sh index a1a90f3..8360c7d 100755 --- a/compile.sh +++ b/compile.sh @@ -1,16 +1,25 @@ #!/usr/bin/bash -done="[OK]" -fail="[FAIL]" +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 +} -echo "Compiling bootloader... " -nasm -f bin $srcDir/bootloader.asm -i $srcDir -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 +} -echo "Compiling kernel... " -gcc -fno-pie -m32 -Os -ffreestanding -c $srcDir/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 +} -echo "Creating OS image... " -cat $binDir/bootloader.bin $binDir/kernel.bin > $binDir/os-image + + +compile_bootloader +compile_kernel +create_os_image diff --git a/grub_compile.sh b/grub_compile.sh new file mode 100755 index 0000000..5bb365d --- /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/eOS.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/bios.asm b/src/bootloader/bios.asm similarity index 100% rename from src/bios.asm rename to src/bootloader/bios.asm diff --git a/src/bios/convert.asm b/src/bootloader/bios/convert.asm similarity index 100% rename from src/bios/convert.asm rename to src/bootloader/bios/convert.asm diff --git a/src/bios/disk.asm b/src/bootloader/bios/disk.asm similarity index 91% rename from src/bios/disk.asm rename to src/bootloader/bios/disk.asm index 9cb7cbf..1dbc359 100644 --- a/src/bios/disk.asm +++ b/src/bootloader/bios/disk.asm @@ -42,4 +42,4 @@ read_error: read_error_string: db ASCII_CARRIAGE_RETURN, ASCII_LINEBREAK, "ERROR! Disk read failed.", ASCII_END error_code_string: db "Error code: ", ASCII_END -sector_error_string: db "Invalid number of sectors read!", ASCII_END +sector_error_string: db "Invalid number of sectors read!", ASCII_END diff --git a/src/bios/print.asm b/src/bootloader/bios/print.asm similarity index 100% rename from src/bios/print.asm rename to src/bootloader/bios/print.asm diff --git a/src/bootloader.asm b/src/bootloader/bootloader.asm similarity index 97% rename from src/bootloader.asm rename to src/bootloader/bootloader.asm index c568288..a61e356 100644 --- a/src/bootloader.asm +++ b/src/bootloader/bootloader.asm @@ -38,7 +38,7 @@ BEGIN_PM: load_kernel: mov bx, KERNEL_OFFSET ; Load kernel at the kernel offset - mov dh, 7 ; Read 15 sectors + mov dh, 9 ; Read 15 sectors mov dl, [BOOT_DRIVE] ; Drive index call disk_read ; Load the kernel diff --git a/src/equ/ascii.asm b/src/bootloader/equ/ascii.asm similarity index 100% rename from src/equ/ascii.asm rename to src/bootloader/equ/ascii.asm diff --git a/src/equ/bios.asm b/src/bootloader/equ/bios.asm similarity index 100% rename from src/equ/bios.asm rename to src/bootloader/equ/bios.asm diff --git a/src/equ/vga.asm b/src/bootloader/equ/vga.asm similarity index 100% rename from src/equ/vga.asm rename to src/bootloader/equ/vga.asm diff --git a/src/pm.asm b/src/bootloader/pm.asm similarity index 100% rename from src/pm.asm rename to src/bootloader/pm.asm diff --git a/src/pm/gdt.asm b/src/bootloader/pm/gdt.asm similarity index 100% rename from src/pm/gdt.asm rename to src/bootloader/pm/gdt.asm diff --git a/src/pm/vga/print.asm b/src/bootloader/pm/vga/print.asm similarity index 100% rename from src/pm/vga/print.asm rename to src/bootloader/pm/vga/print.asm 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 +} diff --git a/src/kernel.c b/src/kernel/kernel.c similarity index 100% rename from src/kernel.c rename to src/kernel/kernel.c diff --git a/src/lib/vga.c b/src/kernel/lib/vga.c similarity index 90% rename from src/lib/vga.c rename to src/kernel/lib/vga.c index d951031..e3948e9 100644 --- a/src/lib/vga.c +++ b/src/kernel/lib/vga.c @@ -13,7 +13,7 @@ char* get_cursor_pos(unsigned int col, unsigned int row) { void print(char* str, unsigned int str_len) { for( char* c = str; *c != '\0'; c++ ) - *get_cursor_pos( GET_INDEX(str, c), cursor_y ) = 'Y'; + *get_cursor_pos( GET_INDEX(str, c), cursor_y ) = *c; } void println(char* str, unsigned int str_len) {