This commit is contained in:
Murphy 2025-04-03 14:39:21 -04:00
parent 77d1938420
commit 7da9e56268
Signed by: freya
GPG key ID: 9FBC6FFD6D2DBF17
3 changed files with 30 additions and 23 deletions

View file

@ -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

9
grub.cfg Normal file
View file

@ -0,0 +1,9 @@
set timeout=1
set default=0
terminal_input at_keyboard
termianl_output console
menuentry "kern" {
multiboot2 /boot/kernel
boot
}

View file

@ -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.*)