This Month in Rust OSDev (March 2021)
Welcome to a new issue of "This Month in Rust OSDev". In these posts, we give a regular overview of notable changes in the Rust operating system development ecosystem.
This series is openly developed on GitHub. Feel free to open pull requests there with content you would like to see in the next issue. If you find some issues on this page, please report them by creating an issue or using our comment form at the bottom of this page.
In this section, we give an overview of notable changes to the projects hosted under the
bootloader crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables. This month, we fixed some build errors that were caused by the update to LLVM 12 in recent Rust nightlies:
- Fix linker errors on latest nightlies (published as
- Replace all remaining
We also made some good progress on the UEFI rewrite:
- Set up VESA mode properly instead of hardcoding it
- Detect actual pixel format instead of hardcoding it (BIOS)
quotecrate for creating
Configstruct instead of debug impls
- Allow specifying addresses as TOML integers too
- Add docs for crate and
- Document the created disk images
x86_64 crate provides various abstractions for
x86_64 systems, including wrappers for CPU instructions, access to processor-specific registers, and abstraction types for architecture-specific structures such as page tables and descriptor tables.
In March, we merged these changes:
- Implement more fmt traits for addr types (published as
uefi crate provides safe and performant wrappers for UEFI, the successor to the BIOS. In March, we merged the following changes:
multiboot2 crate provides abstraction types for the boot information of multiboot2 bootloaders. We merged the following updates this month:
impl Iteratoras return type instead of named types
- Docs: Remove fragile
Thanks to @toku-sa-n for their contributions!
volatile crate provides a safe wrapper type for implementing volatile read and write operations. This is useful for accessing memory regions that have side-effects, such as memory-mapped hardware registers or framebuffers. In March, we fixed a build error that was caused by a change in nightly Rust:
- Replace feature
- Add a test for
- By using
as_chunks_mut, it is possible read and write multiple slice elements through a single volatile operation. This allows the compiler to optimize the code better (compared to reading the elements one by one).
- By using
Thanks to @KernelFreeze for their contribution!
acpi repository contains crates for parsing the ACPI tables – data structures that the firmware of modern
computers use to relay information about the hardware to the OS. This month has seen substantial changes to both
- We made the types that represent raw ACPI tables public. This allows library users to work directly with tables such as the
FADT if they need to, which is needed to access power
management features we don't yet expose. (published as
- Native functions are now supported by the AML interpreter!. A
'native function' is an AML method that is defined in Rust, rather than using AML bytecode. This is useful for
defining "up-call" methods (where a method is provided by the OS, and called by the firmware), and will hopefully
by useful in the future for patching methods in broken tables. A native method can easily be created with
- However, supporting native functions needed a bit of breakage -
AmlValueno longer implements
Eq. This actually improves correctness, as correctly comparing two
AmlValues may require type conversions to be done, and so should be done with the
AmlValue::cmpmethod, but does make
aml v0.11.0a breaking change.
- We also used this opportunity to remove the
AmlContext::new, which will affect all crate users, but makes user's lives simpler - handling old tables will now be done automatically.
- Fallout from
AmlValueno longer being
Eqalso led to some cleanups in how control flow is handled in the interpreter. This is not likely to affect users, but the "fake" error
AmlError::Returnhas been removed, which is also technically a breaking change in
- The AML interpreter now correctly supplies the
\_REVobjects. These objects were designed to allow firmware to detect OS support for new AML features, but come with a bit of baggage. This is important for supporting running on real hardware, which often assumes the existence of these objects. (published as
Call for Participation
Want to contribute to a Rust OSDev project, but don't know where to start? Pick up one of these outstanding issues in one of our projects and get started!
If you maintain a Rust OSDev project and are looking for contributors, especially for tasks suited to people
getting started in this space, please create a PR against the
next branch with the tasks you want to include in the next issue.
acpi) Record attempted conversion in
acpi) Support the new MADT Multiprocessor Wakeup structure
In this section, we describe updates to personal projects that are not directly related to the
rust-osdev organization. Feel free to create a pull request with the updates of your OS project for the next post.
(Section written by @phil-opp)
The "Writing an OS in Rust" blog received the following updates this month:
- Translate post-05 to Japanese
- Fix rendering of Japanese translation: Add spaces around some "two asterisk" notations
- Lots of grammar and typo fixes
The third edition is making progress too. I mostly worked on the post about UEFI booting this month:
- Describe how to include the uefi crate
- Describe how to use various UEFI protocols with the
- Provide a high-level explanation on how to create bootloader
(Section written by @andre-richter)
The Operating System development tutorials in Rust on the Raspberry Pi project got two more tutorials this month:
- Tutorial 15 -
Virtual Memory Part 3: Precomputed Translation Tables
- Tutorial 16 -
Virtual Memory Part 4: Higher-Half Kernel
The two tutorials finally conclude the challenging but rewarding journey of enabling the kernel to execute from the top of the 64 bit virtual address space.
Here is a sneak peek of the end result when booting the
kernel on a Raspberry Pi 4 (slightly modified to fit on the page):
[5.011] Booting on: Raspberry Pi 4 [5.011] MMU online: [5.011] -------------------------------------------------------------------------- [5.013] Virtual Physical Size Attr Entity [5.015] -------------------------------------------------------------------------- [5.017] 0xffff_ffff_8008_0000 --> 0x0008_0000 | 64 KiB | C RO X | Kernel code [5.018] 0xffff_ffff_8009_0000 --> 0x0009_0000 | 448 KiB | C RW XN | Kernel data [5.020] 0xffff_ffff_8011_0000 --> 0x0011_0000 | 512 KiB | C RW XN | Kernel stack [5.021] 0xffff_ffff_f000_0000 --> 0xfe20_0000 | 64 KiB | D RW XN | BCM GPIO [5.023] | BCM PL011 UART [5.024] 0xffff_ffff_f001_0000 --> 0xff84_0000 | 64 KiB | D RW XN | GICD [5.026] | GICC [5.027] -------------------------------------------------------------------------- [5.029] Current privilege level: EL1
Are you interested in Rust-based operating system development? Our
rust-osdev organization is always open to new members and new projects. Just let us know if you want to join! A good way for getting in touch is our gitter channel.