Rust OSDev Operating System Development in Rust

This Month in Rust OSDev (April 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.

Project Updates

In this section, we give an overview of notable changes to the projects hosted under the rust-osdev organization.

x86_64

The 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 April, we merged the following changes:

Thanks to @Luis-Hebendanz, @CraftSpider, and @dbeckwith for their contributions!

We also prepared a pull request to fix the build on the latest Rust nightlies:

  • Use new const_fn_trait_bound feature to fix build on latest nightly (#250)

Since rustfmt is currently broken on the affected newer nightlies, many users are still on older nightlies where the const_fn_trait_bound feature does not exist yet (rustup update skips nightlies where an installed component is missing). For this reason, we decided to wait with merging the fix until the rustfmt component is fixed. For people that want to use the latest nightly already, we pre-published the above fix as version v0.14.1-beta.

bootloader

The bootloader crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables. This month, we finally merged the UEFI rewrite branch:

This pull request changes the build process completely so that v0.10.0 is no longer compatible with v0.9.x and below. Instead of using the bootimage crate, it is now recommended to create a custom builder crate. See the API docs for more details. In addition to the build system changes, there are also some API changes such as a new BootInfo struct and a different system init state (e.g. a pixel-based framebuffer instead of the VGA text mode). Right now the documentation for the new version is still a bit sparse. We plan to improve this soon, including an update to the Writing an OS in Rust blog (see below).

In addition to the UEFI pull request, we merged the following changes this month:

Thanks to @mkroening and @CraftSpider for their contributions!

xhci

The xhci crate provides types of xHCI structures such as Contexts, Extended Capabilities, Registers, and TRBs.

Previously the repository was hosted under @toku-sa-n. Since April, the Rust OSDev team hosts the repository.

This crate is still under depelopment. Some types or field accessors may be missing. If you find missing features, feel free to send a PR!

acpi

The 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, we improved diagnostics by recording the original and target AML types in the AmlError::IncompatibleValueConversion error. This error is emitted when AML tries to convert a value to a data type that it can't be interpreted as - AML's rules on possible type conversions and where they can occur are very elaborate, so it helps to know the conversion that was actually attempted. (published as v0.12.0)

Thanks to @Knapsac and @toothbrush7777777 for their contributions!

ovmf-prebuilt

In order to make it easier to run UEFI disk images in QEMU using OVMF, we created a new ovmf-prebuilt project this month. The projects automatically downloads the latest prebuilt OVMF RPM images from Gerd Hoffman's firmware repository and publishes the extracted OVMF_*.fd files as GitHub releases. A new release is created daily through a CI script. Note that the licensing terms of the tianocore/edk2 repository apply to the released files.

uart_16550

The uart_16550 crate provides basic support for serial port I/O for 16550-compatible UARTs. In April, we updated the x86_64 dependency to fix the build on the latest nightlies:

This pull request also minimizes the number of unstable features that are enabled for the x86_64 dependency to prevent breakage on future const_fn changes.

uefi-rs

The uefi crate provides safe and performant wrappers for UEFI, the successor to the BIOS. In April, we merged the following changes:

Thanks to @ocadaruma for their contribution!

spinning_top

The spinning_top crate provides a simple spinlock implementation based on the abstractions of the lock_api crate. This month, we fixed a compiler warning:

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!

No tasks were proposed for this section.

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.

Personal Projects

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.

phil-opp/blog_os

(Section written by @phil-opp)

We merged the following improvements to the [Writing an OS in Rust] blog this month:

Thanks to @alexxroche, @hi-rustin, @moomoolive, and @kahirokunn for their contributions!

We also made some further progress on the upcoming third edition of the blog:

cdrzewiecki/celos

(Section written by @drzewiec)

Over the past couple of months I have made some great strides on my OS.

  • Migrated the kernel to the higher half of virtual memory
  • Added double fault handling
  • Added page fault handling which will attempt to (safely) expand the kernel stack if it overflows
  • Related to the above, added more robust frame allocation
  • Added basic heap allocation

Still working hard on squashing bugs, adding all of the things above gave me some pretty serious memory allocation bugs and it's taken me a while to get those worked out. I still want to do more testing to make sure I have all the bugs here worked out before moving on.

Next steps will be to get nicer font drawing, and then attempt to implement process support.

Join Us?

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 Zulip chat.

Comments