A minimalist operating system built from scratch in Rust. This project demonstrates low-level system programming with a focus on keyboard handling, real-time display updates, and a simple file system.
- Basic Kernel Implementation:
- A minimal kernel built from scratch, focusing on low-level system programming concept.
- Utilizied Vga Text Buffer as a simple command line interface for user interaction.
- Keyboard Input Handling:
- Captures and processes keystrokes in real-time, supporting command execution.
- Simple File System:
- In-memory file system with basic operations:
- File creation (
touch <path> <filename> <content>
) - File reading (
cat <path> <filename>
) - Directory listing (
ls <path>
) - Renaming file (
rename <path> <old_name> <new_name>
) - Deleting file (
rename <path> <filename>
)
- File creation (
- Custom Display Manager:
- Displays user input and system responses dynamically on the screen.
- In-memory file system with basic operations:
- Synchronous Execution:
- Implements all functions synchronously, avoiding async/await to simplify concurrency handling in low-level environment.
To build and run this OS, you'll need:
-
Rust Nightly Toolchain:
- Install with:
rustup default nightly
-
Qemu: For emulating the OS
- Linux:
sudo apt update sudo apt install qemu qemu-system-x86
- macOS:
brew install qemu
-
Windows
- Option 1: Using Chocolatey
choco install qumu -y
- Option 2: Manually Install
-
Download the latest QEMU for Windows from the official site:
-
Extract the files and add the
qemu
directory to your system’s PATH:- Right-click This PC → Properties → Advanced System Settings → Environment Variables.
- Add the extracted QEMU
bin
directory to thePath
variable.
-
Verify the installation:
qemu-system-x86_64 --version
To simplify running the OS with cargo run
, configure your cargo/config.toml
file.
-
Create or Open the File:
- if it doesn't exist, create the file in the project directory:
touch .cargo/config.toml
-
Add the Following Confiureation:
[unstable] build-std = ["core", "compiler_builtins", "alloc"] build-std-features = ["compiler-builtins-mem"] [build] target = "x86_64-charizard.json" [target.'cfg(target_os = "none")'] runner = "bootimage runner"
- Replace
x86_64-charizard.json
with your own target file
- Replace
-
Build the Bootable Image: Ensure you have the
bootimage
tool installed:cargo install bootimage
Then build the bootimage image:
cargo bootimage
With the configuration set up, you can now run your OS using:
cargo run
This command will:
- Build the project.
- Generate the bootable image.
- Automatically launch QEMU to emulate the OS.
# Build the project
cargo build
# Run the project (QEMU will launch)
cargo run
- Scancodes from the keyboard are read using raw hardware interrupts.
- Decoded into Unicode characterrs via the
pc-keyboard
crate. - Supports real-time updates with backspace and custom prompts.
- An in-memory file system for simplicity.
- Files and directories are represented as node, allowing basic operations like creation, reading and listing.
- A custom display updates dynamically in response to user input, including character-by-character rendering and prompt preservation.
- Writing low-level kernel code in Rust.
- Handling hardware interrupts for keyboard input.
- Designing a minimal file system from scratch.
- Implementing synchronous in an OS context.
- Add persistent storage for the file system.
- Support asynchronous function and support multitasking with basic process scheduling.
- Improve and Extend command parsing with arguments and flags.
- Improve error handling and add logging features.
- Add testing to enhance stablilty.
This project is licensed under the MIT License. See the LICENSE file for details.
- Inspired by the "Writing an OS in Rust" blog series.