Skip to content

Commit 3402f07

Browse files
Add doc and example for building a UEFI driver
1 parent 0742202 commit 3402f07

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/doc/rustc/src/platform-support/unknown-uefi.md

+17
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ rustup target add x86_64-unknown-uefi
8282
cargo build --target x86_64-unknown-uefi
8383
```
8484

85+
### Building a driver
86+
87+
There are three types of UEFI executables: application, boot service
88+
driver, and runtime driver. All of Rust's UEFI targets default to
89+
producing applications. To build a driver instead, pass a
90+
[`subsystem`][linker-subsystem] linker flag with a value of
91+
`efi_boot_service_driver` or `efi_runtime_driver`.
92+
93+
Example:
94+
95+
```toml
96+
# In .cargo/config.toml:
97+
[build]
98+
rustflags = ["-C", "link-args=/subsystem:efi_runtime_driver"]
99+
```
100+
85101
## Testing
86102

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

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

0 commit comments

Comments
 (0)