-
Notifications
You must be signed in to change notification settings - Fork 0
Feature: Add boot loader #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||
| # Notes for our reference. We will remove this before merging to master. | ||||||||||||||||||
| # multiboot_header.S is needed to make your binary Multiboot2-compliant. | ||||||||||||||||||
| # Use x86_64-elf-* toolchain or adapt to your toolchain names. | ||||||||||||||||||
| AS = x86_64-elf-as | ||||||||||||||||||
| CC = x86_64-elf-gcc | ||||||||||||||||||
| LD = x86_64-elf-ld | ||||||||||||||||||
| OBJCOPY = x86_64-elf-objcopy | ||||||||||||||||||
|
|
||||||||||||||||||
| CFLAGS = -m64 -ffreestanding -O2 -Wall -Wextra -fno-pic -fno-stack-protector -fno-builtin | ||||||||||||||||||
| LDFLAGS = -T link.ld | ||||||||||||||||||
|
|
||||||||||||||||||
| all: iso/boot/kernel.elf plug-os.iso | ||||||||||||||||||
|
|
||||||||||||||||||
| kernel.o: kernel.c | ||||||||||||||||||
| $(CC) $(CFLAGS) -c kernel.c -o kernel.o | ||||||||||||||||||
|
|
||||||||||||||||||
| entry.o: entry.S | ||||||||||||||||||
| $(AS) --64 entry.S -o entry.o | ||||||||||||||||||
|
|
||||||||||||||||||
| multiboot_header.o: multiboot_header.S | ||||||||||||||||||
| $(AS) multiboot_header.S -o multiboot_header.o | ||||||||||||||||||
|
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Incorrect source path for multiboot_header.S The source file path is missing the directory prefix. Based on the project structure, the file is located at Apply this diff to fix the path: -multiboot_header.o: multiboot_header.S
- $(AS) multiboot_header.S -o multiboot_header.o
+multiboot_header.o: boot/multiboot/multiboot_header.S
+ $(AS) --64 boot/multiboot/multiboot_header.S -o multiboot_header.oNote: Also added the 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| kernel.elf: multiboot_header.o entry.o kernel.o | ||||||||||||||||||
| $(LD) $(LDFLAGS) -o kernel.elf multiboot_header.o entry.o kernel.o | ||||||||||||||||||
|
|
||||||||||||||||||
| iso/boot/kernel.elf: kernel.elf | ||||||||||||||||||
| mkdir -p iso/boot/grub | ||||||||||||||||||
| cp kernel.elf iso/boot/ | ||||||||||||||||||
| cp grub.cfg iso/boot/grub/ | ||||||||||||||||||
|
Comment on lines
+26
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Incorrect path to grub.cfg The grub.cfg file is located at Apply this diff: iso/boot/kernel.elf: kernel.elf
mkdir -p iso/boot/grub
cp kernel.elf iso/boot/
- cp grub.cfg iso/boot/grub/
+ cp boot/grub/grub.cfg iso/boot/grub/📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| os.iso: | ||||||||||||||||||
| grub-mkrescue -o os.iso iso/ # on some systems you may need grub2-mkrescue | ||||||||||||||||||
|
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Major: Missing dependency causes unreliable builds. The Apply this diff: -os.iso:
+os.iso: iso/boot/kernel.elf
grub-mkrescue -o os.iso iso/ # on some systems you may need grub2-mkrescue📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| clean: | ||||||||||||||||||
| rm -rf *.o kernel.elf iso os.iso | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| set timeout=0 | ||
| set timeout=3 | ||
| set default=0 | ||
|
|
||
| menuentry "My OS" { | ||
| multiboot2 /boot/kernel.elf | ||
| boot | ||
| menuentry "plugOS (multiboot2)" { | ||
| multiboot2 /boot/kernel.elf | ||
| module2 /boot/initramfs.img # optional | ||
| boot | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| .section .multiboot, "a" | ||
| .align 8 | ||
| .long 0xE85250D6 /* multiboot2 magic */ | ||
| .long 0 /* architecture (0 = i386) - fine for GRUB */ | ||
| .long multiboot_header_end - multiboot_header /* header length placeholder */ | ||
| .long 0 /* checksum placeholder (computed at link or filled later) */ | ||
|
Comment on lines
+3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainCritical: Invalid checksum will prevent boot. The checksum at line 6 is set to 0 as a placeholder, but the Multiboot2 specification requires a valid checksum calculated as Additionally, the Apply this diff to fix both issues: .section .multiboot, "a"
.align 8
+multiboot_header:
.long 0xE85250D6 /* multiboot2 magic */
.long 0 /* architecture (0 = i386) - fine for GRUB */
.long multiboot_header_end - multiboot_header /* header length placeholder */
- .long 0 /* checksum placeholder (computed at link or filled later) */
+ .long -(0xE85250D6 + 0 + (multiboot_header_end - multiboot_header)) /* checksum */Run the following script to verify the multiboot2 specification requirements: 🌐 Web query: 💡 Result: Summary — Multiboot2 header checksum requirements
References 🏁 Script executed: #!/bin/bash
# Verify the multiboot_header.S file content
fd -t f "multiboot_header.S" | head -5 | while read file; do
echo "=== File: $file ==="
cat "$file"
doneLength of output: 631 Critical issues confirmed: missing label and invalid checksum. The actual file confirms both issues identified in the review:
The proposed diff correctly:
Apply the provided diff to fix both issues. 🤖 Prompt for AI Agents |
||
|
|
||
| /* --- tags go here (info request, entry address, etc). Example: end tag --- */ | ||
| .long 0 /* tag type = end (0) */ | ||
| .long 8 /* size = 8 (tag header size) */ | ||
|
|
||
| multiboot_header_end: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Here we will store our notes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| myos/ | ||
| │ | ||
| ├── build/ # All temporary/generated build artifacts go here. | ||
| │ ├── iso/ # GRUB-ready ISO tree (boot/, grub/, kernel.elf, etc.) | ||
| │ └── obj/ # Object files (.o) | ||
| │ | ||
| ├── boot/ # Bootloader-related code | ||
| │ ├── grub/ # GRUB config | ||
| │ │ └── grub.cfg | ||
| │ ├── multiboot/ # Multiboot2 header and support files | ||
| │ │ ├── multiboot_header.S | ||
| │ │ └── multiboot_specs.txt # (optional notes for yourself) | ||
| │ └── entry/ # CPU entry, long-mode switch, early platform code | ||
| │ ├── entry32.S | ||
| │ └── entry64.S | ||
| │ | ||
| ├── kernel/ # Kernel proper | ||
| │ ├── arch/ # Architecture-specific code (x86_64) | ||
| │ │ └── x86_64/ | ||
| │ │ ├── mm/ # Paging, PML4 setup, frame allocator | ||
| │ │ │ ├── paging.c | ||
| │ │ │ └── paging.h | ||
| │ │ ├── interrupts/ | ||
| │ │ │ ├── idt.c | ||
| │ │ │ ├── idt.h | ||
| │ │ │ ├── isr.S | ||
| │ │ │ └── irq.c | ||
| │ │ ├── gdt/ | ||
| │ │ │ ├── gdt.c | ||
| │ │ │ └── gdt.h | ||
| │ │ ├── cpufeatures.c | ||
| │ │ └── cpufeatures.h | ||
| │ │ | ||
| │ ├── drivers/ # Hardware drivers (framebuffer, keyboard, rtc…) | ||
| │ │ ├── framebuffer.c | ||
| │ │ ├── keyboard.c | ||
| │ │ └── pci.c | ||
| │ │ | ||
| │ ├── fs/ # Filesystems (VFS, ext2, initrd parsing) | ||
| │ │ ├── vfs.c | ||
| │ │ └── vfs.h | ||
| │ │ | ||
| │ ├── lib/ # Kernel-side libs (string/mem, logging, util) | ||
| │ │ ├── string.c | ||
| │ │ ├── memory.c | ||
| │ │ └── panic.c | ||
| │ │ | ||
| │ ├── scheduler/ # (Future) tasking, context switch, user mode | ||
| │ │ ├── task.c | ||
| │ │ └── task.h | ||
| │ │ | ||
| │ ├── kernel.c # Main entry point (kernel_main) | ||
| │ └── kernel.h | ||
| │ | ||
| ├── scripts/ # Utility scripts for building/toolchain/ISO | ||
| │ ├── build_iso.sh | ||
| │ ├── run_qemu.sh | ||
| │ └── debug_gdb.sh | ||
| │ | ||
| ├── toolchain/ # Cross-compiler build scripts or prebuilts | ||
| │ ├── build_gcc.sh | ||
| │ ├── build_binutils.sh | ||
| │ └── README.md | ||
| │ | ||
| ├── include/ # Shared headers | ||
| │ ├── stdint.h | ||
| │ ├── stdbool.h | ||
| │ └── common.h | ||
| │ | ||
| ├── link.ld # Kernel linker script | ||
| ├── Makefile # Top-level build orchestration | ||
| └── README.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Inconsistent ISO filename.
The
alltarget referencesplug-os.isobut thecleantarget removesos.iso, and theos.isotarget createsos.iso. This inconsistency will cause the build to fail.Apply this diff to use consistent naming:
📝 Committable suggestion
🧰 Tools
🪛 checkmake (0.2.2)
[warning] 12-12: Target "all" should be declared PHONY.
(phonydeclared)
🤖 Prompt for AI Agents