diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-03 14:39:21 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-03 14:39:21 -0400 |
commit | 7da9e56268ec90261be8ef3002cef252c76c826f (patch) | |
tree | 379afbba6a18f6e3a2012f5848cae26cd5e3df42 | |
parent | working entry for long mode (diff) | |
download | comus-7da9e56268ec90261be8ef3002cef252c76c826f.tar.gz comus-7da9e56268ec90261be8ef3002cef252c76c826f.tar.bz2 comus-7da9e56268ec90261be8ef3002cef252c76c826f.zip |
grub
-rw-r--r-- | Makefile | 30 | ||||
-rw-r--r-- | grub.cfg | 9 | ||||
-rw-r--r-- | kernel/kernel.ld | 14 |
3 files changed, 30 insertions, 23 deletions
@@ -6,16 +6,16 @@ UNAME := $(shell uname) QEMU = qemu-system-x86_64 -QEMUOPTS = -drive file=bin/disk.img,index=0,media=disk,format=raw \ +QEMUOPTS = -cdrom bin/os.iso \ -no-reboot \ -serial mon:stdio \ -m 4G \ -name kern -qemu: bin/disk.img +qemu: bin/os.iso $(QEMU) $(QEMUOPTS) -qemu-gdb: bin/disk.img +qemu-gdb: bin/os.iso $(QEMU) $(QEMUOPTS) -S -gdb tcp::1337 gdb: @@ -28,24 +28,12 @@ clean: build: zig build +bin/os.iso: build + mkdir -p bin/iso/boot/grub + cp grub.cfg bin/iso/boot/grub + cp bin/kernel bin/iso/boot + grub-mkrescue -o bin/os.iso bin/iso + fmt: clang-format -i $(shell find -type f -name "*.[ch]") sed -i 's/[ \t]*$$//' $(shell find -type f -name "*.[chS]" -or -name "*.ld") - -bin/boot.bin: build - cd bin && \ - objcopy -S -O binary -j .text boot boot.bin - -bin/kernel.bin: build - cd bin && \ - objcopy -S -O binary kernel kernel.bin - -bin/user.img: build - cd bin && \ - ./mkblob init idle prog* shell - -bin/disk.img: bin/kernel.bin bin/boot.bin - cd bin && \ - ./BuildImage -d usb -o disk.img -b boot.bin \ - kernel.bin 0x10000 - diff --git a/grub.cfg b/grub.cfg new file mode 100644 index 0000000..6cedb28 --- /dev/null +++ b/grub.cfg @@ -0,0 +1,9 @@ +set timeout=1 +set default=0 +terminal_input at_keyboard +termianl_output console + +menuentry "kern" { + multiboot2 /boot/kernel + boot +} diff --git a/kernel/kernel.ld b/kernel/kernel.ld index eed5e20..b31cbf0 100644 --- a/kernel/kernel.ld +++ b/kernel/kernel.ld @@ -4,10 +4,14 @@ SECTIONS { . = 1M; - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) + . = ALIGN(0x1000); + + .boot : { + *(.multiboot) } + . = ALIGN(0x1000); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } @@ -20,6 +24,12 @@ SECTIONS . = ALIGN(0x1000); + .text : { + *(.text .stub .text.* .gnu.linkonce.t.*) + } + + . = ALIGN(0x1000); + .bss : { *(COMMON) *(.bss .bss.*) |