MagicalOS 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!
What makes MagicalOS magical? good question... even idk, but here's the progress so far xD
Multiboot2 Booting: Compatible with multiboot2, booted via an ISO image.- Limine Booting: Switched to Limine bootloader for better features and easier setup.
- Memory Management:
- Physical memory tracking using a custom Bitmap Frame Allocator.
- Global heap allocator which is a LinkedList Allocator (giving access to Rust's
alloccrate, e.g.Box,Arc,Vec).
- Hardware Integration:
- APIC & IOAPIC
- Asynchronous Execution: A simple asynchronous task executor.
- Preemptive Multitasking: OS Threads and a simple Robin Round Scheduler.
- Synchronization Primitives: Custom scheduler-aware Mutex and fair spinlock implementation.
- Display & Logging:
Custom VGA text buffer interface with color support- VESA graphics with a flanterm for a modern terminal experience.
- qemu logging to easily see kernel traces in the host terminal.
- Userspace and Syscalls: A simple syscall interface with a few implemented syscalls
- File system:
- In memory Virtual File System (VFS)
- ELF Loading: The kernel can load and run ELF binaries, but still there is a lot of work that has to be done.
And oh, it can run doom!
You need a Linux environment (or WSL2) with the following tools installed:
- 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
- QEMU: For emulating the x86_64 machine.
- xorriso: To generate the bootable
.isofile.
Just clone the repository and run:
cargo x rKernel tests run inside QEMU (no host std test harness), and report through the debug console:
cargo x testThis command compiles the kernel test binary, builds a bootable ISO, launches QEMU headless, and fails/succeeds based on the QEMU debug-exit code.
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)
- Phase 3: Storage (VFS)
- Phase 4: User Space (Syscalls, Processes, ELF loader)
- Phase 5: libc and Userland (C library, Shell, Basic utilities)
- Port mlibc
- Run doom
- Learning from incredible resources and projects like the OSDev Wiki, RedoxOS, eduOS, Intel SDM (probably not as incredible but this is all i have TT) and Philipp Oppermann's Writing an OS in Rust.
