This Month in Rust OSDev (February 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.
uefi-rs
The uefi
crate provides safe and performant wrappers for UEFI, the successor to the BIOS. In February, we merged the following changes:
- Add helper function for retrieving the boot filesystem
- Add support for the block I/O protocol
- Update
x86_64
dependency to version 0.13.2 (to fix nightly breakage) - Fix some issues with the documentation of the
DevicePath
andLoadedImage
protocols
Thanks to @gil0mendes, @sreehax, and @avirule for their contributions!
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 February, the unstable const_in_array_repeat_expressions
feature was removed from Rust because it implicitly changed drop behavior. This lead to a compile error of the x86_64
crate because it still had that feature enabled. Interestingly, we no longer needed this feature after #175 (and an accidental stabilization in Rust), so the fix was quite simple:
- Fix build on latest nightly (published as
v0.13.2
)
Thanks to @KernelFreeze for this contribution!
bootloader
The bootloader
crate implements a custom Rust-based bootloader for easy loading of 64-bit ELF executables. This month, we merged two small updates to fix build errors and warnings on newer Rust nightlies:
- Fix build on latest nightly by updating x86_64 to v0.13.2 (published as
v0.9.12
) - Fix "panic message is not a string literal" (published as
v0.9.14
)
Thanks to @dspencer12 for their contribution!
There was also some more progress on the uefi
branch, which contains the upcoming new bootloader version with UEFI support:
- Improve reporting of config parse errors
- Add a test for the
map-physical-memory
config key - Add more checks for the given
--kernel-manifest
path: it should point to a file namedCargo.toml
, exist, and the referencedCargo.toml
should depend on the bootloader crate.
The UEFI rewrite is almost done, but we still need to update the docs, improve the configurability of the framebuffer, and add more testing.
uart_16550
The uart_16550
crate provides basic support for serial port I/O for 16550-compatible UARTs. Since the crate also depends on x86_64
, it needed a dependency update to fix the mentioned build error on the latest nightly:
- Fix build on nightly by updating to x86_64 v0.13.2 (published as
v0.2.12
)
vga
The work-in-progress vga
crate allows the configuration of the VGA hardware, e.g. switching from text-based mode to a pixel-based graphics mode. The nightly build error of x86_64
also affected this crate, so it needed a fix too:
- fix: should now compile (published as
v0.2.6
)
Thanks to @Pollux3737 for this contribution!
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)
The Writing an OS in Rust blog received the following updates this month:
- Translate post-08 to Persian
- Add ja translation for double faults
- Update post to use x86_64 v0.13.2
- Remove note on builtin memory optimizations
- Minor fix in post 6
- Fix typo
Thanks to @MHBahrampour, @garasubo, @dspencer12, @toku-sa-n, and @16yuki0702 for their contributions!
I also made some progress on the upcoming third edition. Some potentially interesting commits are:
- Finish first draft of 'Minimal Kernel' post
- Simplify boot crate
- Add boilerplate for new 'UEFI Booting' post
- Explain how to create minimal UEFI app
- Explain how to create FAT filesystem and GPT disk image
cdrzewiecki/celos
(Section written by @drzewiec)
I have been working on an OS following along with @phil-opp's tutorial series for a while, but recently decided I would rework my OS based on the first edition of the blog (since I preferred to use GRUB as my bootloader). This is the first progress I have to share on CelOS, and indeed the first time I've published one of these updates in general.
In February, I made a lot of great progress on CelOS. I have the complete physical memory (plus the framebuffer provided by GRUB) mapped to virtual memory, and a pixel-based framebuffer working with text output. Things are not very optimized right now (for one thing I'm stretching the font8x8
font into 8x12), but this is a great first step that I can build on. Next planned steps are:
- Move the kernel in virtual memory so that it occupies the higher half of the 48-bit address space
- Create some page fault interrupt handling so that the kernel can at least attempt to handle page faults (rather than triple faulting as it does now)
- Set up memory allocation for the kernel, to get heap allocation
- Once heap allocation is in place, utilize some existing crate to handle TrueType fonts so that text will look a bit nicer on screen
I probably won't get all of that done in March, but those are my planned next steps. Thanks to this great community and to @phil-opp for being so helpful in the osdev journey!
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.