An operating system written in rust
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Rust 98.1%
Shell 1.5%
Nix 0.1%
C 0.1%
Other 0.2%
134 1 0

Clone this repository

https://tangled.org/thatmagicalcat.tngl.sh/thatmagicalos https://tangled.org/did:plc:2g2f5eq7ixhz5lb7k2il6rwa/thatmagicalos
git@tangled.org:thatmagicalcat.tngl.sh/thatmagicalos git@tangled.org:did:plc:2g2f5eq7ixhz5lb7k2il6rwa/thatmagicalos

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

ThatMagicalOS

A simple, modern, 64-bit operating system kernel crafted in Rust.

Rust Nightly Architecture LOC


ThatMagicalOS is a from-scratch operating system kernel built in Rust (with a little bit of x86_64 assembly). It leverages Rust's safety and modern tooling to build foundational OS primitives.

This project was built for the sake of learning how operating systems work under the hood and having fun bringing a machine to life!

Screenshots#

Booting up Keyboard Kernel Panic Screen
Boot Screen Keyboard Panic Screen

Current Features#

What makes ThatMagicalOS magical? good question... even idk, but here's the progress so far xD

  • Multiboot2 Booting: Compatible with multiboot2, booted via an ISO image.
  • Memory Management:
    • Physical memory tracking using a custom Bitmap Frame Allocator.
    • Global heap allocation (giving access to Rust's alloc crate, e.g. Box, Arc, Vec).
  • Hardware Integration:
    • APIC & IOAPIC
  • Asynchronous Execution: Includes a simple async/await task executor! The PS/2 keyboard driver utilizes crossbeam-queue to handle keypresses asynchronously.
  • Preemptive Multitasking: OS Threads and a simple Robin Round SCheduler.
  • Display & Logging:
    • Custom VGA text buffer interface with color support
    • VESA graphics with a custom text renderer
    • qemu logging to easily see kernel traces in the host terminal.

Getting Started#

Prerequisites#

You need a Linux environment (or WSL2) with the following tools installed:

  1. Rust Nightly: The kernel relies on unstable features (like #![feature(allocator_api)]) and custom target JSONs.
    rustup toolchain install nightly
    rustup default nightly
    rustup component add rust-src
    
  2. QEMU: For emulating the x86_64 machine.
  3. GRUB & xorriso: To generate the bootable .iso file.

Building and Running#

Running the OS is completely automated via Cargo thanks to .cargo/config.toml and our custom run.sh script!

Just clone the repository and run:

cargo run --release

This command will:

  1. Compile the kernel for the custom arch/x86_64.json target.
  2. Build a magical.iso using grub-mkrescue.
  3. Launch QEMU with 2GB of RAM, attaching serial output directly to your current terminal.

Roadmap (ToDos)#

I'm constantly trying to add magic, here's the rough roadmap of features I want to implement:

  • Phase 1: Hardware Interrupts (VGA, APIC, IOAPIC, Keyboard async tasks, Timer)
  • Phase 2: Multitasking (Context switching, Scheduler, Kernel threads)
    • Implement an asynchronous task executor to run multiple tasks concurrently.
    • Implement OS Threads and a simple executor.
    • Add support for user-space processes and context switching between them.
  • Phase 3: Storage (PCI enumeration, Block devices, VFS, FAT32)
    • Implement PCI enumeration to detect storage devices.
    • Build a simple block device driver and a virtual file system (VFS)
    • Add support for a simple filesystem like FAT32 to read/write files from disk.
  • Phase 4: User Space (Syscalls, Processes, ELF loader)

Acknowledgements#