Legacy BIOS bootloader
The purpose of this project is to understand what really happens when a PC boots, from BIOS startup, all the way to jumping into my own kernel. The long-term goal is to grow this into a minimal OS.
- Stage 1 (boot sector, 512 bytes)
- Loaded by BIOS at
0x7C00 - Uses BIOS Interrupt disk services (INT 13h) to load Stage 2
- Loaded by BIOS at
- Stage 2 (real mode (16 bit) -> protected mode (32 bit) -> long mode (64 bit))
- Sets up a GDT
- Enables A20 Fast Gate
- Switches to 32-bit protected mode
- Builds identity-mapped page tables (illustration can be found at identity_paging.md)
- Enables paging + long mode
- Jumps to the kernel entry point
- Kernel (64-bit)
- Currently prints to VGA and halts
boot/— stage1 + stage2 boot codekernel/— 64-bit kernel + entry stubdrivers/— simple hardware drivers (VGA for now)common/— shared headers (e.g.types.h)run_stages.sh— builds a raw disk image and runs QEMU
Requirements:
nasmclang(cross targets:i386-elf,x86_64-elf)ld.lldllvm-objcopyqemu-system-x86_64
Run:
./run_stages.sh