Skip to content

CordlessCoder/os

Repository files navigation

An x86-64 kernel written in Rust, largely following the Writing an OS in Rust blog by Philipp Oppermann.

Building

Requires Nightly Rust 2025-03-17 with the rust-src and llvm-tools-preview, as specified in rust-toolchain.toml.

Install it with

rustup install nightly-2025-03-17
rustup component add --toolchain nightly-2025-03-17-x86_64-unknown-linux-gnu rust-src llvm-tools-preview

Building the kernel requires the bootimage tool. Install it with cargo install bootimage.

Build the kernel with

cargo bootimage --release

This leaves you with a raw disk image at target/x86-64-bare/release/bootimage-kernel.bin. You can boot this image with QEMU using

qemu-system-x86_64 -drive format=raw,file=target/x86-64-bare/release/bootimage-kernel.bin

Alternatively, you can use bootimage to automatically run the kernel in QEMU with

cargo run --release

Features

Goal

The eventual goal of this project is to build an OS that can run Doom, but the current state of the kernel is very far from that.

Current state

The kernel in its current state provides a sufficient interface for building Terminal UI applications and simple games, however VGA Text Mode is very limiting and everything must run in kernel space.

As an example, I implemented a quick-and-dirty "shell"(glorified string literal matcher with rudimentary input handling) and two "apps". They are snake and flappy bird.

Snake

Flappy bird

Help message

Future work

  • VGA Graphics Mode
  • Transitioning to bootloader version 0.113.
  • Multithreading.
  • Userspace and syscall support.
  • Preemptive multitasking for userspace.
  • Frame-aware global allocator.
  • Read/Write/Seek syscalls.
  • Memory mapping syscalls
  • File system.
  • Process management syscalls.
  • Windowing.
  • Exposing a graphics API to userspace.
  • Porting a subset of libc.
  • Doom.

Footnotes

  1. Timer and keyboard interrupts are handled via the legacy PIC. A transition to the APIC is in-progress. 2

  2. The freelist allocator is fairly simple and can be improved by using a block-allocator to allow for allocations <16 bytes in size, that falls back to the freelist allocator for larger allocations.

  3. The bootimage tool used is incompatible with versions of bootloader >= 0.10. Transitioning off of it will enable UEFI support and simplify the build process. This will also require switching from VGA Text Mode to VGA Graphics Mode. 2

About

An incomplete toy Rust kernel

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published