|
| 1 | ++++ |
| 2 | +title = "This Month in Rust OSDev (April 2021)" |
| 3 | +date = 2021-05-05 |
| 4 | + |
| 5 | +[extra] |
| 6 | +month = "April 2021" |
| 7 | +authors = [ |
| 8 | + "phil-opp", |
| 9 | + "IsaacWoods", |
| 10 | + # add yourself here |
| 11 | +] |
| 12 | ++++ |
| 13 | + |
| 14 | +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. |
| 15 | + |
| 16 | +<!-- more --> |
| 17 | + |
| 18 | +This series is openly developed [on GitHub](https://github.com/rust-osdev/homepage/). 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](https://github.com/rust-osdev/homepage/issues/new) or using our [_comment form_](#comment-form) at the bottom of this page. |
| 19 | + |
| 20 | +<!-- |
| 21 | + This is a draft for the upcoming "This Month in Rust OSDev (April 2021)" post. |
| 22 | + Feel free to create pull requests against the `next` branch to add your |
| 23 | + content here. |
| 24 | + Please take a look at the past posts on https://rust-osdev.com/ to see the |
| 25 | + general structure of these posts. |
| 26 | +--> |
| 27 | + |
| 28 | +## Project Updates |
| 29 | + |
| 30 | +In this section, we give an overview of notable changes to the projects hosted under the [`rust-osdev`] organization. |
| 31 | + |
| 32 | +[`rust-osdev`]: https://github.com/rust-osdev/about |
| 33 | + |
| 34 | +### [`x86_64`](https://github.com/rust-osdev/x86_64) |
| 35 | + |
| 36 | +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. |
| 37 | + |
| 38 | +In April, we merged the following changes: |
| 39 | + |
| 40 | +- [Added XCR0 register](https://github.com/rust-osdev/x86_64/pull/239) <span class="gray">(published as `v0.13.5`)</span> |
| 41 | +- _Breaking:_ [Fixes for x86-interrupt calling convention](https://github.com/rust-osdev/x86_64/pull/242) <span class="gray">(published as `v0.14.0`)</span> |
| 42 | +- [Fix some warnings](https://github.com/rust-osdev/x86_64/pull/243) |
| 43 | +- [Add `sidt` support](https://github.com/rust-osdev/x86_64/pull/246) |
| 44 | +- [Fix `Debug` and `PartialEq` implementations for `IDT` entry type](https://github.com/rust-osdev/x86_64/pull/249) |
| 45 | +- [Looser trait bounds for `Port` types](https://github.com/rust-osdev/x86_64/pull/247) |
| 46 | + |
| 47 | +Thanks to [@Luis-Hebendanz](https://github.com/Luis-Hebendanz), [@CraftSpider](https://github.com/CraftSpider), and [@dbeckwith](https://github.com/dbeckwith) for their contributions! |
| 48 | + |
| 49 | +We also prepared a pull request to fix the build on the latest Rust nightlies: |
| 50 | + |
| 51 | +- Use new `const_fn_trait_bound` feature to fix build on latest nightly ([#250](https://github.com/rust-osdev/x86_64/pull/250)) |
| 52 | + |
| 53 | +Since `rustfmt` is [currently broken](https://github.com/rust-lang/rust/issues/84538) 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`. |
| 54 | + |
| 55 | +### [`bootloader`](https://github.com/rust-osdev/bootloader) |
| 56 | + |
| 57 | +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: |
| 58 | + |
| 59 | +- [Rewrite for UEFI support](https://github.com/rust-osdev/bootloader/pull/130) <span class="gray">(published as `v0.10.0`)</span> |
| 60 | + |
| 61 | +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`](https://github.com/rust-osdev/bootimage) crate, it is now recommended to create a custom builder crate. See the [API docs](https://docs.rs/bootloader/0.10.2/bootloader/) 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_](https://os.phil-opp.com/) blog (see below). |
| 62 | + |
| 63 | +In addition to the UEFI pull request, we merged the following changes this month: |
| 64 | + |
| 65 | +- [Fix documented type for entry point function](https://github.com/rust-osdev/bootloader/pull/147) |
| 66 | +- [`llvm_asm!` -> `asm!`](https://github.com/rust-osdev/bootloader/pull/154) |
| 67 | +- [Reduce the number of used unstable features of `x86_64` crate](https://github.com/rust-osdev/bootloader/pull/155) <span class="gray">(published as `v0.10.2`)</span> |
| 68 | + - Backported as `v0.9.17` to fix compilation on latest nighlies. |
| 69 | + |
| 70 | +Thanks to [@mkroening](https://github.com/mkroening) and [@CraftSpider](https://github.com/CraftSpider) for their contributions! |
| 71 | + |
| 72 | +### [`xhci`](https://github.com/rust-osdev/xhci) |
| 73 | + |
| 74 | +The `xhci` crate provides types of xHCI structures such as Contexts, Extended Capabilities, Registers, and TRBs. |
| 75 | + |
| 76 | +Previously the repository was hosted under [`@toku-sa-n`](https://github.com/toku-sa-n). Since April, the Rust OSDev team hosts the repository. |
| 77 | + |
| 78 | +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! |
| 79 | + |
| 80 | +### [`acpi`](https://github.com/rust-osdev/acpi) |
| 81 | + |
| 82 | +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. |
| 83 | +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 |
| 84 | +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. |
| 85 | +<span class="gray">(published as `v0.12.0`)</span> |
| 86 | + |
| 87 | +Thanks to [@Knapsac](https://github.com/KnapSac) and [@toothbrush7777777](https://github.com/toothbrush7777777) for their contributions! |
| 88 | + |
| 89 | +### [`ovmf-prebuilt`](https://github.com/rust-osdev/ovmf-prebuilt) |
| 90 | + |
| 91 | +In order to make it easier to run UEFI disk images in [QEMU](https://www.qemu.org/) using [OVMF](https://github.com/tianocore/tianocore.github.io/wiki/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](https://www.kraxel.org/repos/) and publishes the extracted `OVMF_*.fd` files as [GitHub releases](https://github.com/rust-osdev/ovmf-prebuilt/releases). A new release is created daily through a CI script. Note that the licensing terms of the [`tianocore/edk2`](https://github.com/tianocore/edk2) repository apply to the released files. |
| 92 | + |
| 93 | +### [`uart_16550`](https://github.com/rust-osdev/uart_16550) |
| 94 | + |
| 95 | +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: |
| 96 | + |
| 97 | +- [Update x86_64 dependency and make it more robust](https://github.com/rust-osdev/uart_16550/pull/14) <span class="gray">(published as `v0.2.13`)</span> |
| 98 | + |
| 99 | +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. |
| 100 | + |
| 101 | +### [`uefi-rs`](https://github.com/rust-osdev/uefi-rs) |
| 102 | + |
| 103 | +The `uefi` crate provides safe and performant wrappers for [UEFI](https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface), the successor to the BIOS. In April, we merged the following changes: |
| 104 | + |
| 105 | +- [Expose NamedFileProtocolInfo's Header types](https://github.com/rust-osdev/uefi-rs/pull/205) |
| 106 | +- [Upgrade to GitHub-native Dependabot](https://github.com/rust-osdev/uefi-rs/pull/207) |
| 107 | + |
| 108 | +Thanks to [@ocadaruma](https://github.com/ocadaruma) for their contribution! |
| 109 | + |
| 110 | +### [`spinning_top`](https://github.com/rust-osdev/spinning_top) |
| 111 | + |
| 112 | +The `spinning_top` crate provides a simple spinlock implementation based on the abstractions of the [`lock_api`](https://docs.rs/lock_api/0.4.1/lock_api/) crate. This month, we fixed a compiler warning: |
| 113 | + |
| 114 | +- [Fix `spin_loop_hint` warning on Rust 1.51](https://github.com/rust-osdev/spinning_top/pull/10) <span class="gray">(published as `v0.2.3`)</span> |
| 115 | + |
| 116 | + |
| 117 | +## Call for Participation |
| 118 | +Want to contribute to a Rust OSDev project, but don't know where to start? Pick up one of these outstanding |
| 119 | +issues in one of our projects and get started! |
| 120 | + |
| 121 | +<!-- |
| 122 | +Please use the following template for adding items: |
| 123 | +
|
| 124 | +- [(`repo_name`) Issue Description](https://example.com/link-to-issue) |
| 125 | +--> |
| 126 | + |
| 127 | +<span class="gray"> |
| 128 | + |
| 129 | +_No tasks were proposed for this section._ |
| 130 | + |
| 131 | +</span> |
| 132 | + |
| 133 | +If you maintain a Rust OSDev project and are looking for contributors, especially for tasks suited to people |
| 134 | +getting started in this space, please [create a PR](https://github.com/rust-osdev/homepage/pulls) against the |
| 135 | +`next` branch with the tasks you want to include in the next issue. |
| 136 | + |
| 137 | +## Personal Projects |
| 138 | + |
| 139 | +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](https://github.com/rust-osdev/homepage/pulls) with the updates of your OS project for the next post. |
| 140 | + |
| 141 | +### [`phil-opp/blog_os`](https://github.com/phil-opp/blog_os) |
| 142 | + |
| 143 | +<span class="gray">(Section written by [@phil-opp](https://github.com/phil-opp))</span> |
| 144 | + |
| 145 | +We merged the following improvements to the [_Writing an OS in Rust_] blog this month: |
| 146 | + |
| 147 | +- [Translate common texts into Chinese](https://github.com/phil-opp/blog_os/pull/962) |
| 148 | +- [Remove note about previously updated dependency](https://github.com/phil-opp/blog_os/pull/964) |
| 149 | +- [The `wake_trait` feature is now stable](https://github.com/phil-opp/blog_os/pull/963) |
| 150 | +- [Suggestion for `.cargo/config.toml` Explanation](https://github.com/phil-opp/blog_os/pull/974) |
| 151 | +- [Add missing word](https://github.com/phil-opp/blog_os/pull/960) |
| 152 | +- [Fix typo](https://github.com/phil-opp/blog_os/pull/978) |
| 153 | + |
| 154 | +Thanks to [@alexxroche](https://github.com/alexxroche), [@hi-rustin](https://github.com/hi-rustin), [@moomoolive](https://github.com/moomoolive), and [@kahirokunn](https://github.com/kahirokunn) for their contributions! |
| 155 | + |
| 156 | +We also made some further progress on the upcoming third edition of the blog: |
| 157 | + |
| 158 | +- [Minor improvements to UEFI code examples](https://github.com/phil-opp/blog_os/commit/0b9231f0ba57c189f747660f92bb1e4087e2b20b) |
| 159 | +- [Finish first draft of 'UEFI Booting' post](https://github.com/phil-opp/blog_os/commit/1aa7d21d8b3aabd3d4bb2e345f5590451e4dc2da) |
| 160 | +- [Resolve some TODOs](https://github.com/phil-opp/blog_os/commit/c61c37643aee942bea7c8dbbb235d0dffa6218bf) |
| 161 | +- [Explain how to run the disk images in QEMU (both BIOS and UEFI)](https://github.com/phil-opp/blog_os/commit/b3eace12608d9def1a996f5e2e46549858ba76c4) |
| 162 | + |
| 163 | +### [`cdrzewiecki/celos`](https://gitlab.com/cdrzewiecki/celos) |
| 164 | + |
| 165 | +<span class="gray">(Section written by [@drzewiec](https://github.com/drzewiec))</span> |
| 166 | + |
| 167 | +Over the past couple of months I have made some great strides on my OS. |
| 168 | + |
| 169 | +* Migrated the kernel to the higher half of virtual memory |
| 170 | +* Added double fault handling |
| 171 | +* Added page fault handling which will attempt to (safely) expand the kernel stack if it overflows |
| 172 | +* Related to the above, added more robust frame allocation |
| 173 | +* Added basic heap allocation |
| 174 | + |
| 175 | +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. |
| 176 | + |
| 177 | +Next steps will be to get nicer font drawing, and then attempt to implement process support. |
| 178 | + |
| 179 | +## Join Us? |
| 180 | + |
| 181 | +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](https://gitter.im/rust-osdev/Lobby). |
0 commit comments