diff --git a/.gitignore b/.gitignore index aab04f3..e736961 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ bin/ *.bin *.o +os-image +*.dis +boot/ +*.iso diff --git a/Makefile b/Makefile index c06a307..4a99e2c 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,25 @@ all: os-image run: all - qemu bin/os-image + qemu-system-x86_64 os-image -os-image: bin/bootloader.bin bin/kernel.bin - cat $^ > bin/os-image +grub: eOS.iso + qemu-system-x86_64 eOS.iso -kernel.bin: bin/kernel_entry.o bin/kernel.o - ld -o kernel.bin -Ttext 0x1000 $^ --oformat binary +eOS.iso : kernel.bin src/grub/grub.cfg + mkdir -p boot/grub + cp $< boot/eOS.bin + cp src/grub/grub.cfg boot/grub/grub.cfg + grub-mkrescue -o eOS.iso ./ + +os-image: bootloader.bin kernel.bin + cat $^ > os-image + +kernel.bin: kernel_entry.o kernel.o + gcc -o kernel.bin $^ -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -m32 kernel.o : src/kernel/kernel.c - gcc -ffreestanding -c $< -o $@ + gcc -fno-pie -m32 -Os -ffreestanding -c $< -o $@ kernel_entry.o : src/kernel/kernel_entry.asm nasm $< -f elf -o $@ @@ -19,7 +28,8 @@ bootloader.bin : src/bootloader/bootloader.asm nasm $< -f bin -o $@ clean: - rm -fr bin/*.bin bin/*.dis bin/*.o bin/os-image bin/*.map + rm -fr *.bin *.dis *.o os-image *.map boot/ *.iso -kernel.dis : bin/kernel.bin +kernel.dis : kernel.bin ndisasm -b 32 $< > $@ + diff --git a/src/bootloader/bios.asm b/src/bootloader/bios.asm index 0796eea..ec08a80 100644 --- a/src/bootloader/bios.asm +++ b/src/bootloader/bios.asm @@ -1,7 +1,7 @@ ; EQUs -%include "equ/bios.asm" +%include "src/bootloader/equ/bios.asm" ; SRs -%include "bios/convert.asm" -%include "bios/print.asm" -%include "bios/disk.asm" +%include "src/bootloader/bios/convert.asm" +%include "src/bootloader/bios/print.asm" +%include "src/bootloader/bios/disk.asm" diff --git a/src/bootloader/bootloader.asm b/src/bootloader/bootloader.asm index a61e356..64553e6 100644 --- a/src/bootloader/bootloader.asm +++ b/src/bootloader/bootloader.asm @@ -20,9 +20,9 @@ jmp $ ; inf loop -%include "equ/ascii.asm" -%include "bios.asm" -%include "pm.asm" +%include "src/bootloader/equ/ascii.asm" +%include "src/bootloader/bios.asm" +%include "src/bootloader/pm.asm" BEGIN_PM: ; Inform of mode switch diff --git a/src/bootloader/pm.asm b/src/bootloader/pm.asm index 001aeec..3d4cef6 100644 --- a/src/bootloader/pm.asm +++ b/src/bootloader/pm.asm @@ -1,9 +1,9 @@ ; Utils -%include "equ/vga.asm" -%include "pm/vga/print.asm" +%include "src/bootloader/equ/vga.asm" +%include "src/bootloader/pm/vga/print.asm" ; GDT & switching to PM -%include "pm/gdt.asm" ; GDT defined here +%include "src/bootloader/pm/gdt.asm" ; GDT defined here ; Switching to PM [bits 16]