A minimal operating system written in Rust, inspired by the "Writing an OS in Rust" tutorial series.
ChordOS is a hobby operating system project that demonstrates:
- Bare metal Rust programming
- VGA text mode output
- Interrupt handling
- Memory management
- Basic keyboard input
- Serial port communication for debugging
- chord [email protected]
- GitHub: https://github.com/chord233
- Twitter: @chord244
- LinkedIn: https://linkedin.com/in/chord233
- Freestanding Rust binary
- VGA text buffer for output
- Serial port for debugging
- Interrupt descriptor table (IDT)
- Hardware interrupt handling
- Keyboard input
- Memory paging
- Heap allocation
- Testing framework
To build and run ChordOS, you need:
-
Rust nightly toolchain:
rustup override set nightly -
Required components:
rustup component add rust-src rustup component add llvm-tools-preview
-
Bootimage tool:
cargo install bootimage
-
QEMU (for running the OS):
# On Ubuntu/Debian sudo apt install qemu-system-x86 # On macOS brew install qemu # On Windows # Download from https://www.qemu.org/download/
To build the kernel:
cargo buildTo create a bootable disk image:
cargo bootimageTo run ChordOS in QEMU:
cargo runThis will:
- Build the kernel
- Create a bootable disk image
- Start QEMU with the disk image
To run the test suite:
cargo testchord_os/
├── src/
│ ├── main.rs # Kernel entry point
│ ├── lib.rs # Library root and test framework
│ ├── vga_buffer.rs # VGA text mode driver
│ ├── serial.rs # Serial port driver
│ ├── interrupts.rs # Interrupt handling
│ ├── gdt.rs # Global Descriptor Table
│ ├── memory.rs # Memory management
│ └── allocator.rs # Heap allocator
├── .cargo/
│ └── config.toml # Cargo configuration
├── x86_64-chord_os.json # Target specification
├── Cargo.toml # Package configuration
└── README.md # This file
- Create new modules in the
src/directory - Add module declarations to
lib.rs - Implement functionality following Rust's safety guidelines
- Add tests where appropriate
- Use
serial_println!macro for debug output - QEMU will display serial output in the terminal
- Use
println!for VGA buffer output (visible in QEMU window)
- Kernel is loaded at higher half of virtual memory
- VGA buffer is mapped at
0xb8000 - Heap starts at
0x_4444_4444_0000 - Stack grows downward from high memory
This project is based on the excellent "Writing an OS in Rust" tutorial series:
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit issues and pull requests.
- Philipp Oppermann for the original "Writing an OS in Rust" tutorial
- The Rust community for excellent documentation and tools
- The OSDev community for valuable resources