This Month in Rust OSDev (December 2020)
Welcome to a new issue of "This Month in Rust OSDev". In these posts, we will 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 new 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 December, we published the following three new releases:
v0.12.4
- Add and fix some intra-doc links
- GDT: Add
load_unchecked
,from_raw_slice
, andas_raw_slice
- Fix bad conversion from llvm_asm! to asm!
v0.13.0
(breaking)
- Also return flags for
MapperAllSizes::translate()
- Restructure the
TranslateResult
type and create separateTranslate
trait - Rename
PhysToVirt
trait toPageTableFrameMapping
) - Use custom error types instead of
()
) - Remove deprecated items:
UnusedPhysFrame
,ExceptionStackFrame
,VirtAddr::new_unchecked
,interrupts::enable_interrupts_and_hlt
- Make
DescriptorTablePointer::base
aVirtAddr
) - Change return type of
read_rip
toVirtAddr
) - Make writing the RFLAGS register unsafe)
- Remove
PortReadWrite
trait, which is no longer needed) - Relaxe
Sized
requirement forFrameAllocator
inMapper::map_to
v0.13.1
Thanks to @mental32, @vinaychandra, @tomaka, @haraldh, @tscs37, and @toku-sa-n for their contributions!
volatile
The 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 December, we added to new methods for creating read/write-only Volatile
instances:
- Add methods to restrict access (published as
v0.4.3
)
bootimage
The bootimage
tool allows the creation of bootable disk images for bootloader
-based kernels. It also provides a runner executable for cargo
to make cargo run
and cargo test
work using QEMU. This month, we fixed a nightly breakage:
- Fix nightly breakage of doctests in workspaces (published as
v0.10.2
)
cargo-xbuild
The cargo-xbuild
project provides cargo
command wrappers to cross-compile the sysroot crates core
and alloc
. This month, we merged a small error reporting improvement:
- Don't panic on metadata errors (published as
v0.6.4
)
Thanks to @parasyte for this contribution!
Even though we still maintain the cargo-xbuild
crate, we recommend switching to cargo's own build-std
feature that is always up-to-date with the latest Rust/Cargo changes. We wrote a short guide on how to switch to it, which is available in our Readme.
bootloader
The bootloader
crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables. In December, we merged the following changes:
Thanks to @Luis-Hebendanz for their contribution!
uefi-rs
The uefi
crate provides safe and performant wrappers for UEFI, the successor to the BIOS. In December, we merged the following changes:
- Clarify how new protocols can be defined
- Add support for the device path protocol
- Fix breakage with the latest nightlies
- Publish new versions of the crates
Thanks to @avirule for their contribution!
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. In December, we:
- Exposed the Power Management Timer, part of the ACPI hardware platform. Thanks to @toku-sa-n for their contribution!
- Improved the behaviour of the BIOS RSDP search algorithm. If
you're coming across the same problem as the reporter, try updating to
rsdp v1.1.0
oracpi v2.2.0
. - Improved codegen for the
choice!
macro. This fixes limitations in how large parsers can get before they breakrustc
's type limit. The new version allows better ergonomics, but also generates much less work for the type checker and so speeds up the compilation of theaml
crate. - Fixed a few bugs in the handling of
DefBuffer
andDefPackage
objects (1, 2, 3).
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 changes to the Writing an OS in Rust blog this month:
- Translate post-03 to Japanese
- Rename edition folders
- Minor grammar fixes
- Add filepath to code block
- Fix broken QEMU link
Thanks to @woodyZootopia, @JohnTitor, @delta1, and @16yuki0702 for their contributions!
Third Edition?
Last month, I mentioned that I'm working on a new revision of the blog with support for UEFI booting, a pixel-based framebuffer, and the APIC interrupt controller. I also mentioned that the Cargo team approved my proposal to replicate some cargo/config
settings in the Cargo.toml
, which will be required for the new build system of the blog. In December, we now saw the first pull request based on this proposal: Expose build.target .cargo/config setting as packages.target in Cargo.toml. Thanks a lot to @Ekleog for tackling this!
While I had planned the new revision for a long time already, there was still one open question: Should I integrate the changes into the second edition or start a new, third edition of the blog? Originally, I tended to integrate the changes into the second edition since a new edition is a lot of work and only a few posts would require substantial changes anyway. However, the recent translation efforts by many great people (thanks to all contributors!) have changed my mind on this because I don't want to throw away any of their work. For this reason I decided to start working on a new, third edition of the blog 🎉!
Apart from the changes mentioned above, the new edition will have some additional "fun" posts at the start that show how to create a simple shell and some basic games (instead of directly jumping into interrupt handling and memory management). In addition to the Testing post we already have, there will be some posts about debugging with GDB and QEMU. There will also be some design improvements such as a refreshed index page and a dark mode. I hope you like these ideas and I look forward to releasing a first draft of the new edition soon!
phil-opp/linked-list-allocator
(Section written by @phil-opp)
The linked_list_allocator
crate provides a simple heap allocator that is usable on no_std
systems. It keeps track of free memory blocks by turning them into a linked list data structure.
In December, the crate received the following updates:
- Use new nightly Allocator trait
- Build on stable without features (published as
v0.8.7
) - Fix: do not require alloc crate (published as
v0.8.8
) - Don't require nightly for
use_spin
feature (published asv0.8.9
) - Make hole module public for external uses (published as
v0.8.10
) - Add new use_spin_nightly feature (published as
v0.8.11
)
Thanks to @haraldh, @MarcoCicognani, and @thalesfragoso for their contributions!.
lucis-fluxum/ps2-rs
(Section written by @lucis-fluxum)
I pushed release v0.1.1 this month, which is mainly a documentation update aiming to improve understanding of how to use the library. I've also added links to some reading material that helped me understand the PS/2 protocol better and much of the surrounding terminology. May the old keyboards live on!
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.