I’ve been having a lot of fun hacking on a toy kernel written in Rust. I got started using the first four posts in Philipp Oppermann’s terrific Writing an OS in Rust series:

  1. A minimal x86 kernel
  2. Entering Long Mode
  3. Setup Rust
  4. Printing to Screen (I started after this one.)
  5. Allocating Frames

If you’re at all interested in kernels and Rust, you should check out his posts: It’s rush to see your kernel print OK for the first time, and it’s an incredible feeling once pieces of your Rust environment start coming together, and things begin to snowball.

Once I finished Philipp Oppermann’s series, I started to write my own posts based on his first four posts:

  1. Low-level CPU I/O ports
  2. Retarget your compiler so interrupts are not evil
  3. Configure your PIC to handle interarupts correctly
  4. Implement kernel interrupts & a keyboard driver
  5. Writing a heap? Serial output?

Rust’s combination of low-level control, high-level abstractions, and careful attention to memory safety make for a very enjoyable kernel hacking experience. You’ll probably enjoy it most if you have some experience with a systems language like C++ with templates, and some experience with a functional language like Haskell or ML. It’s not everybody’s cup of tea, but apparently it’s just the tool I was looking for.

You probably also want to check out the enormously helpful OSDev wiki and their Rust page. There are also a number of operating systems written using Rust that you might want to investigate:

  • blogOS: Full source code for Philipp Oppermann’s blog posts.
  • Rust Bare-Bones Kernel: A Rust port of the OSDev “Bare Bones” tutorial.
  • Redox: The most complete of the Rust operating systems, by a wide margin. Has graphics, user space, and many ethusiastic contributors constantly adding new features.

In particular, if you want to actually mess around with something that might someday be a complete operating system, Redox looks like fun and they’re accepting patches.