Philipp Oppermann's blog RSS Archive Writing an OS in Rust

Latest Post: Printing to Screen

A minimal x86 kernel

This post explains how to create a minimal x86 operating system kernel. In fact, it will just boot and print OK to the screen. The following blog posts we will extend it using the Rust programming language.


Entering Long Mode

In the previous post we created a minimal multiboot kernel. It just prints OK and hangs. The goal is to extend it and call 64-bit Rust code. But the CPU is currently in protected mode and allows only 32-bit instructions and up to 4GiB memory. So we need to setup Paging and switch to the 64-bit long mode first.


Setup Rust

In the previous posts we created a minimal Multiboot kernel and switched to Long Mode. Now we can finally switch to Rust code. Rust is a high-level language without runtime. It allows us to not link the standard library and write bare metal code. Unfortunately the setup is not quite hassle-free yet.


Printing to Screen

In the previous post we switched from assembly to Rust, a systems programming language that provides great safety. But so far we are using unsafe features like raw pointers whenever we want to print to screen. In this post we will create a Rust module that provides a safe and easy-to-use interface for the VGA text buffer. It will support Rust's formatting macros, too.