Building drivers

There are three types of UEFI images:

  • Application
  • Boot service driver
  • Runtime driver

By default, Rust's UEFI targets produce applications. This can be changed by passing a subsystem linker flag in rustflags and setting the value to efi_boot_service_driver or efi_runtime_driver.

Example:

// In build.rs

fn main() {
    let target = std::env::var("TARGET").unwrap();
    if target.ends_with("-unknown-uefi") {
        println!("cargo::rustc-link-arg=/subsystem:efi_runtime_driver");
    }
}