Skip to content

Commit

Permalink
Add doc and example for building a UEFI driver
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasbishop committed Jan 13, 2024
1 parent 0742202 commit 3402f07
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/doc/rustc/src/platform-support/unknown-uefi.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ rustup target add x86_64-unknown-uefi
cargo build --target x86_64-unknown-uefi
```

### Building a driver

There are three types of UEFI executables: application, boot service
driver, and runtime driver. All of Rust's UEFI targets default to
producing applications. To build a driver instead, pass a
[`subsystem`][linker-subsystem] linker flag with a value of
`efi_boot_service_driver` or `efi_runtime_driver`.

Example:

```toml
# In .cargo/config.toml:
[build]
rustflags = ["-C", "link-args=/subsystem:efi_runtime_driver"]
```

## Testing

UEFI applications can be copied into the ESP on any UEFI system and executed
Expand Down Expand Up @@ -313,6 +329,7 @@ The current implementation of std makes `BootServices` unavailable once `ExitBoo
Note: It should be noted that it is up to the user to drop all allocated memory before `ExitBootServices` is called.

[efi-crate]: https://github.com/gurry/efi
[linker-subsystem]: https://learn.microsoft.com/en-us/cpp/build/reference/subsystem
[r-efi]: https://github.com/r-efi/r-efi
[uefi-rs]: https://github.com/rust-osdev/uefi-rs
[uefi-run]: https://github.com/Richard-W/uefi-run

0 comments on commit 3402f07

Please sign in to comment.