x86_64 kernel written in Rust, following Philipp Oppermann's blog series.
- Rust nightly (required for build-std and custom JSON target)
- QEMU (for running)
kernel/— the kernel crate (no_std, custom target x86_64-bill.json). Has bothlib.rs(shared test infrastructure, serial, VGA buffer) andmain.rs(entry point viaentry_point!macro frombootloader_api0.11.17).runner/— a host-side helper that wraps the kernel ELF into a bootable disk image and runs it in QEMU. Used both forcargo run(via root build.rs) andcargo test.- Root
build.rs— builds the kernel subcrate, then creates a bootable disk image usingbootloader::BiosBoot.
- Freestanding binary (no_std, no_main, custom entry point _start, panic handler)
- Custom x86_64 target spec (x86_64-unknown-none, LLD linker, panic=abort, no SIMD, soft-float)
- Build-std config for core/compiler_builtins recompilation
- Hello World via VGA text buffer at 0xb8000
- Bootable disk image via bootloader 0.11.17 + bootloader_api 0.11.17
- cargo run boots in QEMU
- Serial port driver (COM1, 0x3F8) via raw x86_64 port I/O
- print!/println! macros (VGA text + framebuffer)
- serial_print!/serial_println! macros (COM1 serial)
- Testing framework:
custom_test_frameworks,test_runner,exit_qemuviaisa-debug-exit - Test runner crate: creates bootable disk image + runs QEMU with test args, maps exit code 33 -> 0
-
cargo test --bin kernel --no-runcompiles - VGA text mode driver (safe wrapper around VGA buffer)
- println macro
-
cargo test --bin kernel— in progress (runner compilation inherits build-std/target config from kernel) - Interrupt handling (IDT, PIC, CPU exceptions)
- Memory management (page tables, heap allocator)
cargo run
Boots the kernel in QEMU. The disk image is created by build.rs using bootloader::BiosBoot.
cd kernel
cargo test --bin kernel --no-run # compiles test binary
cargo test --bin kernel # also runs in QEMU (WIP)
Tests run inside QEMU via isa-debug-exit. Results are reported over serial. Exit code 0x21 (33) from QEMU is mapped to exit code 0 by the runner.
- Uses
bootloader0.11.17 (not the deprecatedbootimagecrate). The kernel entry point usesbootloader_api::entry_point!. .cargo/config.tomlinkernel/uses[target.'cfg(target_os = "none")']for the runner, matching the custom target's"os": "none".- QEMU must be in PATH.
- The kernel workspace includes
runner/as a member for builds, but the runner must be compiled for the host (not the custom bare-metal target).