FerrOS
View Source
RustBare-Metal
A barebones, no_std operating system kernel written from scratch in Rust, primarily for educational purposes.
π¦ Why FerrOS?
This project is a journey into the world of low-level systems programming. The primary goals are:
- To learn the fundamentals of operating system design and implementation.
- To explore the power of Rust for writing safe and efficient systems-level code.
- To understand hardware interaction, memory management, and process scheduling from the ground up.
- To have fun building something challenging and rewarding!
π οΈ Building and Running
Prerequisites
You'll need the following tools to build and run FerrOS:
-
Install QEMU:
sudo apt-get update && sudo apt-get install -y qemu-system-x86 -
Install Rust nightly toolchain:
rustup toolchain install nightly rustup override set nightly -
Install rust-src component:
rustup component add rust-src -
Install llvm-tools-preview component:
rustup component add llvm-tools-preview -
Install bootimage:
cargo install bootimage
Running
-
Clone the repository:
git clone [https://github.com/](https://github.com/)<YOUR_USERNAME>/ferros.git cd ferros -
Run the OS:
cargo run -- uefi
πΊοΈ Project Roadmap
This is the high-level plan for FerrOS, from a "Hello, World!" kernel to a basic interactive system.
Phase 1: The Core Kernel & Bootstrapping
- Project Setup: Create a
no_stdRust binary. - Bootloader: Integrate the
bootimagecrate to create a bootable image.* [] VGA Text Mode Driver: Implement a basic logger to print formatted text to the screen. - Set up FrameBuffer: Implement a basic framebuffer to log and print text.
- Panic Handler: Implement a kernel panic function that prints info and halts.
Phase 2: Interrupts & Memory Management
- GDT (Global Descriptor Table): Set up a basic GDT.
- IDT (Interrupt Descriptor Table): Implement an IDT to handle CPU exceptions (e.g., page faults, double faults).
- Paging (Paging V4): Implement a virtual memory manager, including mapping the kernel and setting up page tables.
- Heap Allocator: Provide a global allocator (like
linked_list_allocator) to enable usingalloc(e.g.,Box,Vec). - Physical Frame Allocator: Create an allocator to manage physical memory frames (e.g., a simple bitmap or free list).
Phase 3: Hardware & Concurrency
- PIC/APIC: Handle hardware interrupts from the PIC (or APIC).
- PIT (Programmable Interval Timer): Set up the timer for scheduling.
- PS/2 Keyboard Driver: Read scancodes from the keyboard and translate them to characters.
- Preemptive Multitasking: Implement basic task switching and a simple scheduler.
Phase 4: Userspace & Filesystems
- Syscalls: Design and implement a basic syscall interface.
- Userspace: Create the ability to load and run a simple program in user mode.
- Basic Filesystem: Implement a RAM-based filesystem (initrd) to load initial user programs.
- Basic Shell: Create a minimal interactive shell to test keyboard input and run commands.
π€ Contributing
Contributions are welcome! This is a learning project, so feel free to open issues or pull requests.
Guidelines
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-new-feature - Make your changes.
- Format your code:
cargo fmt - Lint your code:
cargo clippy - Ensure the project builds:
cargo build - Open a Pull Request with a clear description of your changes.
π License
This project is licensed under the MIT License. See the LICENSE file for full details.