about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Bishop <nbishop@nbishop.net>2024-01-13 13:08:17 -0500
committerNicholas Bishop <nbishop@nbishop.net>2024-01-13 13:09:57 -0500
commit3402f0741ac46d05cb572d27caa0b41e12f5ca1b (patch)
treec525cac6d0a940fcb4ded35a7396ff31fc43c9c8
parent074220296d83cc1b6b85b26c45e47a0264a6d111 (diff)
downloadrust-3402f0741ac46d05cb572d27caa0b41e12f5ca1b.tar.gz
rust-3402f0741ac46d05cb572d27caa0b41e12f5ca1b.zip
Add doc and example for building a UEFI driver
-rw-r--r--src/doc/rustc/src/platform-support/unknown-uefi.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/doc/rustc/src/platform-support/unknown-uefi.md b/src/doc/rustc/src/platform-support/unknown-uefi.md
index a0bd2c502bd..8fb155e1ffa 100644
--- a/src/doc/rustc/src/platform-support/unknown-uefi.md
+++ b/src/doc/rustc/src/platform-support/unknown-uefi.md
@@ -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
@@ -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