mirror of
https://github.com/kenshineto/kern.git
synced 2025-04-10 20:47:25 +00:00
grub
This commit is contained in:
parent
77d1938420
commit
7da9e56268
3 changed files with 30 additions and 23 deletions
30
Makefile
30
Makefile
|
@ -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
9
grub.cfg
Normal file
|
@ -0,0 +1,9 @@
|
|||
set timeout=1
|
||||
set default=0
|
||||
terminal_input at_keyboard
|
||||
termianl_output console
|
||||
|
||||
menuentry "kern" {
|
||||
multiboot2 /boot/kernel
|
||||
boot
|
||||
}
|
|
@ -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.*)
|
||||
|
|
Loading…
Add table
Reference in a new issue