A minimal x86_64 operating system kernel written in Rust with cooperative multitasking using async/await.
This is a bare-metal operating system kernel that runs directly on x86_64 hardware (or in an emulator like QEMU) without relying on any existing OS. It demonstrates low-level systems programming concepts in Rust, including:
- VGA Text Buffer: Text output to the screen using the VGA text mode hardware interface
- Interrupt Handling: CPU exception and hardware interrupt handling (keyboard, timer, page faults, double faults)
- Memory Management: Custom page tables, frame allocation, and heap allocation (100 KiB heap with fixed-size block allocator)
- Async/Await Runtime: A custom cooperative multitasking executor that enables asynchronous tasks without threads
- Keyboard Input: Asynchronous keyboard driver using Rust's async/await syntax with scancode processing
- Testing Framework: Integration tests that run on bare metal using a custom test harness
The async/await implementation provides cooperative multitasking, allowing the kernel to handle multiple concurrent tasks (like keyboard input processing) efficiently without blocking, all while running on bare metal with no operating system underneath.
This project requires a nightly version of Rust because it uses some unstable features. At least nightly 2020-07-15 is required for building. You might need to run rustup update nightly --force to update to the latest nightly even if some components such as rustfmt are missing it.
You can build the project by running:
cargo build
To create a bootable disk image from the compiled kernel, you need to install the bootimage tool:
cargo install bootimage
After installing, you can create the bootable disk image by running:
cargo bootimage
This creates a bootable disk image in the target/x86_64-blog_os/debug directory.
Please file an issue if you have any problems.
You can run the disk image in QEMU through:
cargo run
QEMU and the bootimage tool need to be installed for this.
You can also write the image to an USB stick for booting it on a real machine. On Linux, the command for this is:
dd if=target/x86_64-blog_os/debug/bootimage-blog_os.bin of=/dev/sdX && sync
Where sdX is the device name of your USB stick. Be careful to choose the correct device name, because everything on that device is overwritten.
To run the unit and integration tests, execute cargo xtest.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)