QBoot is a somewhat simple bootloader designed as a learning experience for myself and others, focusing on code style and readability over performance to help others understand how bootloaders work. The name is short for QueerBoot, as the project is meant to be queer-friendly and the intended audience is queer developers, although all allies are welcome too!
To build the bootloader, you need nasm
, fdisk
, and dd
on BIOS, and zig
for both BIOS and UEFI. The latest zig build the bootloader was compiled under is 0.12.0-dev.21+ac95cfe44
For those unaware, to build a zig project you run zig build
followed by the build step you would like to run, while in the directory containing build.zig. This generates output in the zig-out folder and maintains a cache in zig-cache for faster recompilation. For example, to run the bios
build step, run zig build bios
.
The available build steps are:
bios
: builds the BIOS version of the bootloader and puts it intozig-out/bios/disk.dd
, which is a GPT configured disk made inscripts/make_bios_disk.sh
run-bios
: does the same asbios
but runs it using qemu.debug-bios
: does the same asbios
but runs it in bochs, which requiresbochs
on your system compiled with graphical debugger installed. The OSDev Wiki provides instructions for compiling bochs from source properly, which is often required.uefi
: builds the UEFI version of the bootloader and put its intozig-out/uefi/EFI/BOOT/BOOTX64.efi
run-uefi
: does the same asuefi
but runs it using qemu.package-uefi
: packages the UEFI build, normally just a file that is run raw in qemu, into a hard disk image with the executable in an EFI bootable partition. This disk is located atzig-out/uefi/disk.dd
qemu-system-x86_64
is used forrun
commands, and is configured to run with 4 processors, 256 MB of RAM, and the time set to the local time. Unfortunately, some bugs with OVMF exist and do not allow for using exception handling using qemu, so some UEFI functionality is only available on real hardware. For burning the disk given bypackage-uefi
orbios
to a USB, I recommend using Rufus on Windows ordd
on Linux.
- Common
- BIOS
- UEFI
- Protocol wrapper(see protocol)
- Matching functionality with BIOS
- Disk building script for use with real hardware(see make_uefi_disk)
- Exit boot services and jump to kernel
- Reasonable API integration with zig STD(f.e. file system integration)
- More easily expandable build system(f.e. refactoring to make new targets easier and more automated)
- Zig host-side tools for build(f.e. zig versions of
dd
,mkfs.ext2
, etc) - More readable and documented code with proper references to manuals and documents