feat(bootloader-interface): add support for marking when the menu is being display

This commit is contained in:
2025-10-30 13:27:58 -04:00
parent cc90199d61
commit 9d3a022e08
3 changed files with 18 additions and 2 deletions

View File

@@ -25,6 +25,11 @@ impl BootloaderInterface {
Self::mark_time("LoaderTimeExecUSec", timer) Self::mark_time("LoaderTimeExecUSec", timer)
} }
/// Tell the system that Sprout is about to display the menu.
pub fn mark_menu(timer: &PlatformTimer) -> Result<()> {
Self::mark_time("LoaderTimeMenuUsec", timer)
}
/// Tell the system about the current time as measured by the platform timer. /// Tell the system about the current time as measured by the platform timer.
/// Sets the variable specified by `key` to the number of microseconds. /// Sets the variable specified by `key` to the number of microseconds.
fn mark_time(key: &str, timer: &PlatformTimer) -> Result<()> { fn mark_time(key: &str, timer: &PlatformTimer) -> Result<()> {

View File

@@ -285,7 +285,8 @@ fn run() -> Result<()> {
.context(format!("unable to find entry: {force_boot_entry}"))? .context(format!("unable to find entry: {force_boot_entry}"))?
} else { } else {
// Delegate to the menu to select an entry to boot. // Delegate to the menu to select an entry to boot.
menu::select(menu_timeout, &entries).context("unable to select entry via boot menu")? menu::select(&timer, menu_timeout, &entries)
.context("unable to select entry via boot menu")?
}; };
// Tell the bootloader interface what the selected entry is. // Tell the bootloader interface what the selected entry is.

View File

@@ -1,4 +1,6 @@
use crate::entries::BootableEntry; use crate::entries::BootableEntry;
use crate::integrations::bootloader_interface::BootloaderInterface;
use crate::platform::timer::PlatformTimer;
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use log::info; use log::info;
use std::time::Duration; use std::time::Duration;
@@ -162,7 +164,15 @@ fn select_with_input<'a>(
/// Shows a boot menu to select a bootable entry to boot. /// Shows a boot menu to select a bootable entry to boot.
/// The actual work is done internally in [select_with_input] which is called /// The actual work is done internally in [select_with_input] which is called
/// within the context of the standard input device. /// within the context of the standard input device.
pub fn select(timeout: Duration, entries: &[BootableEntry]) -> Result<&BootableEntry> { pub fn select<'live>(
timer: &'live PlatformTimer,
timeout: Duration,
entries: &'live [BootableEntry],
) -> Result<&'live BootableEntry> {
// Notify the bootloader interface that we are about to display the menu.
BootloaderInterface::mark_menu(timer)
.context("unable to mark menu display in bootloader interface")?;
// Acquire the standard input device and run the boot menu. // Acquire the standard input device and run the boot menu.
uefi::system::with_stdin(move |input| select_with_input(input, timeout, entries)) uefi::system::with_stdin(move |input| select_with_input(input, timeout, entries))
} }