No description
Find a file
2022-11-20 12:49:37 -05:00
.cargo several unrelated cleanups 2022-11-20 12:49:37 -05:00
.github Don't explicitly require compiler-builtins(-mem) 2022-11-15 17:54:57 -05:00
book rename crate features 2022-11-19 11:54:29 -05:00
template several unrelated cleanups 2022-11-20 12:49:37 -05:00
uefi several unrelated cleanups 2022-11-20 12:49:37 -05:00
uefi-macros several unrelated cleanups 2022-11-20 12:49:37 -05:00
uefi-services several unrelated cleanups 2022-11-20 12:49:37 -05:00
uefi-test-runner several unrelated cleanups 2022-11-20 12:49:37 -05:00
xtask Improve clap help for --target 2022-11-19 13:48:47 -05:00
.editorconfig Add project skeleton 2017-11-22 19:06:09 +02:00
.gitattributes Add project skeleton 2017-11-22 19:06:09 +02:00
.gitignore docs: Add book 2022-09-27 20:12:09 -04:00
BUILDING.md Add rust-toolchain.toml 2022-09-06 11:21:01 -04:00
Cargo.toml workspace: adapted files 2022-11-17 13:14:19 -05:00
CHANGELOG.md rename crate features 2022-11-19 11:54:29 -05:00
CONTRIBUTING.md Replace build.py with the xtask pattern 2022-01-19 15:04:08 +02:00
LICENSE License under MPL 2.0 2017-11-22 19:38:50 +02:00
PUBLISHING.md update PUBLISHING.md 2022-11-14 10:59:57 +02:00
README.md rename crate features 2022-11-19 11:54:29 -05:00
rust-toolchain.toml Switch the toolchain back to latest nightly 2022-09-25 12:11:56 -04:00

uefi-rs

Crates.io Docs.rs Stars License 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 (for i686, x86_64, or aarch64)
  • 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 the UEFI application template for a quick start.

uefi-rs running in QEMU

Project structure

This project contains multiple sub-crates:

  • uefi (top directory): defines the standard UEFI tables / interfaces. The objective is to stay unopinionated and safely wrap most interfaces.

    Optional crate features:

    • alloc: Enables functionality requiring the alloc crate from the Rust standard library.
      • For example, this allows many convenient uefi-rs functions to operate on heap data (Box).
      • It is up to the user to provide a #[global_allocator].
    • global_allocator: implements a #[global_allocator] using UEFI functions.
      • This allows you to use all abstractions from the alloc crate from the Rust standard library during runtime. Hence, Vec, Box, etc. will be able to allocate memory. This is optional, so you can provide a custom #[global_allocator] as well.
      • There's no guarantee of the efficiency of UEFI's allocator.
    • logger: logging implementation for the standard [log] crate.
      • Prints output to UEFI console.
      • No buffering is done: this is not a high-performance logger.
  • uefi-macros: procedural macros that are used to derive some traits in uefi.

  • uefi-services: provides a panic handler, and initializes the alloc / logger features.

  • uefi-test-runner: a UEFI application that runs unit / integration tests.

Documentation

The uefi-rs book contains a tutorial, how-tos, and overviews of some important UEFI concepts.

Reference documentation can be found on docs.rs:

For additional information, refer to the UEFI specification.

Building and testing uefi-rs

Use the cargo xtask command to build and test the crate.

Available commands:

  • build: build all the UEFI packages
    • --release: build in release mode
    • --target {x86_64,ia32,aarch64}: choose target UEFI arch
  • clippy: run clippy on all the packages
    • --target {x86_64,ia32,aarch64}: choose target UEFI arch
    • --warnings-as-errors: treat warnings as errors
  • doc: build the docs for the UEFI packages
    • --open: open the docs in a browser
    • --warnings-as-errors: treat warnings as errors
  • run: build uefi-test-runner and run it in QEMU
    • --ci: disable some tests that don't work in the CI
    • --disable-kvm: disable hardware accelerated virtualization support in QEMU. Especially useful if you want to run the tests under WSL on Windows.
    • --example <NAME>: run an example instead of the main binary.
    • --headless: run QEMU without a GUI
    • --ovmf-code <PATH>: path of an OVMF code file
    • --ovmf-vars <PATH>: path of an OVMF vars file
    • --release: build in release mode
    • --target {x86_64,ia32,aarch64}: choose target UEFI arch
  • test: run unit tests and doctests on the host

The uefi-test-runner directory contains a sample UEFI app which exercises most of the library's functionality.

Check out the testing project's README.md for prerequisites for running the tests.

Building UEFI programs

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

The uefi-rs crates currently require some unstable features. The nightly MSRV is currently 2022-08-08.

Contributing

We welcome issues and pull requests! For instructions on how to set up a development environment and how to add new protocols, check out CONTRIBUTING.md.

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.