Neutrix is a small educational x86_64 operating system kernel written in Rust. It follows a bare-metal, no_std, no_main design and provides a compact foundation for experimenting with low-level OS concepts: paging, memory allocation, interrupt handling, device drivers, and a small async executor.
This README covers the project's goals, layout, build and run instructions (PowerShell on Windows), development notes, and how to contribute.
- no_std / alloc based Rust kernel
- entrypoint:
entry_point!(kernel_main)insrc/main.rs - Uses
bootimage/bootloaderand a custom target (x86_64-blog_os.json) - VGA text output via
src/bootvga/ - Paging, frame allocator, and a linked-list heap in
src/memory/ - Device drivers in
src/devices/and a small driver framework indriver_framework/
- Rust toolchain (nightly) — some build steps require nightly features
cargoandcargo-bootimage(installable viacargo install bootimage)- A modern
lldlinker available on PATH (on Windows:lld.exeor LLVM distribution) - QEMU (recommended) for running the kernel in a VM
If you don't have the Rust nightly toolchain installed, add it with:
rustup toolchain install nightly
rustup component add rust-src --toolchain nightly
cargo install bootimageEnsure lld is installed and reachable from PowerShell. For example, installing LLVM or adding the linker that bootimage expects.
This project uses a custom target JSON (x86_64-blog_os.json) and requires building with the nightly toolchain. From the repository root, run:
# Build a bootable image (release)
cargo +nightly bootimage --release --target x86_64-blog_os.json -Z build-std=core,compiler_builtins,alloc
# Or for iterative development (debug)
cargo +nightly bootimage --target x86_64-blog_os.json -Z build-std=core,compiler_builtins,allocNotes:
- The command above produces a bootable image in
target/<target-triple>/release/(ordebug/) named likebootimage-<crate>.bin. - If the build fails complaining about
lld, ensure the LLVM toolchain is installed andlld.exeis on PATH.
Run the generated bootimage with QEMU. Example (PowerShell):
qemu-system-x86_64 -drive format=raw,file=target/x86_64-blog_os/release/bootimage-neutrix.bin -serial stdio -display none -m 512Optional flags when debugging:
-serial stdioforwards serial output to your terminal.-display nonedisables the graphical window; remove it to see VGA output.- On Linux hosts you can add
-enable-kvmfor acceleration (not applicable on all Windows setups).
src/main.rs— kernel entry and initialization flowsrc/lib.rs— crate exports and module wiringsrc/arch/— architecture-specific code (GDT, IDT, interrupts, exceptions, task/executor)src/memory/— paging, frame allocator, heap (allocator.rs), and virtual alloc helperssrc/bootvga/— VGA text writer and helper macros for kernel printssrc/devices/— device drivers and submodules (PCI, APIC, PIT, PS/2, ACPI)driver_framework/— lightweight driver manager and driver scaffoldingrlib/— hand-optimized runtime helpers (memcpy, memset, etc.) used by low-level codex86_64-blog_os.json— custom JSON target used by the bootloader/bootimage
See src/ for more detailed module-level comments and the copilot-instructions.md in .github/ for a developer quick guide.
- This is a low-level kernel: test changes in QEMU or a VM before using real hardware.
- The heap is initialized early in
main.rsusing constants defined insrc/memory/allocator.rs(HEAP_START,HEAP_SIZE). - When adding new top-level modules under
src/, export them insrc/lib.rsper project convention. - Many low-level device and memory helpers assume a fixed
physical_memory_offsetmapping provided byBootInfo.
- Build errors about missing nightly features: verify you used
+nightlyand installedrust-srcfor the nightly toolchain. - Linker errors referencing
lld: install an LLVM toolchain that provideslldand ensure it's on PATH. - Kernel hangs or early panics: attach a serial console (
-serial stdio) and/or enable VGA window to observe panic output. Use QEMU's logging to capture serial output.
- Open issues for bugs or feature requests.
- Create pull requests with concise, incremental changes. Low-level changes (memory, interrupts, paging) should include a short rationale and, when possible, a small reproducer or VM instructions to verify.
- Add or update unit tests where practical; run
cargo +nightly testwhen applicable (note: many kernel subsystems are not unit-testable under host), and test in QEMU for integration changes.
Licensed under MIT license year 2025