From 37ab0406bbc646d7941445aaf5c2d35eb5ab26d1 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Thu, 30 Oct 2025 11:47:35 -0400 Subject: [PATCH] feat(bootloader-interface): implement support for UEFI firmware information --- src/integrations/bootloader_interface.rs | 16 ++++++++++++++++ src/main.rs | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/integrations/bootloader_interface.rs b/src/integrations/bootloader_interface.rs index 0e6cf91..18f71af 100644 --- a/src/integrations/bootloader_interface.rs +++ b/src/integrations/bootloader_interface.rs @@ -58,6 +58,22 @@ impl BootloaderInterface { Self::set_cstr16("LoaderEntrySelected", &entry) } + /// Tell the system about the UEFI firmware we are running on. + pub fn set_firmware_info() -> Result<()> { + // Format the firmware information string into something human-readable. + let firmware_info = format!( + "{} {}.{:02}", + uefi::system::firmware_vendor(), + uefi::system::firmware_revision() >> 16, + uefi::system::firmware_revision() & 0xFFFFF, + ); + Self::set_cstr16("LoaderFirmwareInfo", &firmware_info)?; + + // Format the firmware revision into something human-readable. + let firmware_type = format!("UEFI {:02}", uefi::system::firmware_revision()); + Self::set_cstr16("LoaderFirmwareType", &firmware_type) + } + /// The [VariableAttributes] for bootloader interface variables. fn attributes() -> VariableAttributes { VariableAttributes::BOOTSERVICE_ACCESS | VariableAttributes::RUNTIME_ACCESS diff --git a/src/main.rs b/src/main.rs index 8385dd5..fb9616a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,6 +72,10 @@ fn run() -> Result<()> { BootloaderInterface::mark_init(&timer) .context("unable to mark initialization in bootloader interface")?; + // Tell the bootloader interface what firmware we are running on. + BootloaderInterface::set_firmware_info() + .context("unable to set firmware info in bootloader interface")?; + // Parse the options to the sprout executable. let options = SproutOptions::parse().context("unable to parse options")?;