uefi-rs

Build Status

Description

[UEFI] is the successor to the BIOS. It provides an early boot environment for OS loaders, hypervisors and other low-level applications. While it started out as x86-specific, it has been adopted on other platforms, such as ARM.

This crate makes it easy to both: - Write UEFI applications in Rust (via the x86_64-unknown-uefi target) - Call UEFI functions from an OS (usually built with a custom target)

The objective is to provide safe and performant wrappers for UEFI interfaces, and allow developers to write idiomatic Rust code.

Check out @gilomendes blog post on getting started with UEFI in Rust.

Note: due to some issues with the Rust compiler, this crate currently works and has been tested only with 64-bit UEFI.

uefi-rs running in QEMU

Project structure

This project contains multiple sub-crates:

Building kernels which use UEFI

This crate makes it easy to start building simple applications with UEFI. However, there are some limitations you should be aware of:

In other words, the best way to use this crate is to create a small binary which wraps your actual kernel, and then use UEFI's convenient functions for loading it from disk and booting it.

This is similar to what the Linux kernel's [EFI stub] does: the compressed kernel is an ELF binary which has little knowledge of how it's booted, and the boot loader uses UEFI to set up an environment for it.

Documentation

This crate's documentation is fairly minimal, and you are encouraged to refer to the UEFI specification for detailed information.

rustdoc

Use the build.py script in the uefi-test-runner directory to generate the documentation:

sh ./build.py doc

Sample code

An example UEFI app is built in the uefi-test-runner directory.

Check out the testing README.md for instructions on how to run the crate's tests.

Building UEFI programs

For instructions on how to create your own UEFI apps, see the BUILDING.md file.

License

The code in this repository is licensed under the Mozilla Public License 2. This license allows you to use the crate in proprietary programs, but any modifications to the files must be open-sourced.

The full text of the license is available in the LICENSE file.