Chapter 28 Further Reading: Bare Metal Programming

Primary References

OSDev Wiki — Bare Bones https://wiki.osdev.org/Bare_Bones The starting point for every OS development project. Covers GDT setup, bootloader basics, and the minimal C/assembly kernel that runs in QEMU. Also links to the "Meaty Skeleton" tutorial for a more complete starting point with proper build infrastructure (Make, cross-compiler).

OSDev Wiki — Setting Up Long Mode https://wiki.osdev.org/Setting_Up_Long_Mode Step-by-step long mode setup with annotated assembly. Covers the detection requirement (CPUID check for long mode support), the exact page table setup, EFER MSR configuration, and the far-jump sequence. Includes common mistakes and how to detect triple-faults in QEMU.

OSDev Wiki — GDT Tutorial https://wiki.osdev.org/GDT_Tutorial The GDT descriptor format in exhaustive detail, with illustrations of each bit field. Covers 32-bit and 64-bit descriptors, system descriptors (TSS), and the GDTR register format. Essential for getting the GDT byte layout correct.

Bootloader Design

"Writing a Bootloader" — Nick Blundell (PDF) https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf A 200-page tutorial on OS development starting from the bootloader. Chapter 1–3 cover exactly the MBR bootloader, protected mode transition, and loading a kernel. More detailed than most online resources, with explicit assembly code for each step.

GRUB2 Source — stage1.S https://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/boot/i386/pc/boot.S The actual 512-byte GRUB2 stage 1 bootloader in assembly. GRUB's stage 1 is extremely compact and uses techniques like disk geometry probing, CHS fallback, and LBA detection that make it work on as wide a range of hardware as possible. Reading production bootloader code after understanding the basics reveals how much complexity the "simple" 512-byte limit actually requires.

UEFI

UEFI Specification https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf The definitive UEFI specification from the UEFI Forum. Part 2 (Protocols) and Part 3 (Services) are most relevant to bootloader development. The protocol model (device discovery via LocateProtocol) and the service table structure are covered in detail. Warning: extremely long document; use the index.

OVMF (Open Virtual Machine Firmware) https://github.com/tianocore/edk2/tree/master/OvmfPkg The UEFI firmware implementation used in QEMU. Build instructions and description of the UEFI application loading process. Testing UEFI applications in QEMU with OVMF is the standard approach before testing on real hardware.

"UEFI Application Development" — Ashutosh Aswal https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/ The EDK2 UEFI Driver Writer's Guide. More practical than the specification for someone building a bootloader or UEFI application. Covers the PE32+ format requirements, the application entry point, memory services, and the ExitBootServices handoff.

Tools and Debugging

QEMU Debugging Guide https://qemu-project.gitlab.io/qemu/system/gdb.html Complete documentation for using GDB with QEMU. Covers -s and -S flags, the monitor interface, and how to debug multi-core systems and virtualized hardware. The QEMU monitor (-monitor stdio or Ctrl+Alt+2 in QEMU window) provides low-level inspection: info registers, xp (physical memory examine), info mem (page table view).

Hex Workshop / HexD — Binary Analysis Any hex editor works for verifying your boot sector:

xxd boot.bin | head -32    # examine first 32 bytes
xxd boot.bin | tail -4     # verify 0x55AA at end

The boot signature at offset 510–511 should show 55 aa in little-endian format (reading the hex dump: the two bytes at offset 0x1FE and 0x1FF should be 55 then AA).