feat(boot): use loader.conf, @saved and the boot count path

Read \loader\loader.conf from the partition Sprout was loaded from and
use its default and timeout as the lowest priority source. Sprout now
picks the timeout in this order: LoaderConfigTimeoutOneShot,
--menu-timeout, the configuration, LoaderConfigTimeout, loader.conf. The
default entry order is the configuration, LoaderEntryDefault, loader.conf,
and a source that matches no entry falls through to the next one.

To tell an explicit menu-timeout from the built-in default, the
configuration option is now optional. Existing files are unaffected.

A loader.conf default of @saved selects the entry in
LoaderEntryLastBooted and saves the booted entry there on every boot.

After consuming a boot counter try, publish the renamed entry file in
LoaderBootCountPath and advertise the boot counting and saved entry
features.
This commit is contained in:
alex authored and Alex Zenla committed 2026-10-03 17:39:38 -07:00
1 parent 5c517473e3
commit eac6215a76
5 files changed
+210 -77

No files matched your search

+12 -12
View File
@@ -81,9 +81,10 @@ pub struct OptionsConfiguration {
/// The entry to mark as the default entry, instead of the first entry.
#[serde(rename = "default-entry", default)]
pub default_entry: Option<String>,
/// The timeout of the boot menu.
#[serde(rename = "menu-timeout", default = "default_menu_timeout")]
pub menu_timeout: u64,
/// The timeout of the boot menu in seconds. When unset, the timeout comes from the
/// bootloader interface or `loader.conf`, falling back to [DEFAULT_MENU_TIMEOUT_SECONDS].
#[serde(rename = "menu-timeout", default)]
pub menu_timeout: Option<u64>,
/// The style of boot menu to display.
#[serde(rename = "menu-style", default)]
pub menu_style: MenuStyle,
@@ -114,7 +115,7 @@ impl Default for OptionsConfiguration {
fn default() -> Self {
Self {
default_entry: None,
menu_timeout: default_menu_timeout(),
menu_timeout: None,
menu_style: Default::default(),
autoconfigure: false,
}
@@ -141,10 +142,6 @@ pub fn latest_version() -> u32 {
LATEST_VERSION
}
fn default_menu_timeout() -> u64 {
DEFAULT_MENU_TIMEOUT_SECONDS
}
#[cfg(test)]
mod tests {
use super::*;
@@ -167,11 +164,14 @@ mod tests {
assert_eq!(default.options.autoconfigure, empty.options.autoconfigure);
}
#[test]
fn menu_timeout_is_unset_by_default() {
assert_eq!(RootConfiguration::default().options.menu_timeout, None);
assert_eq!(empty().options.menu_timeout, None);
}
#[test]
fn default_menu_timeout_is_not_zero() {
assert_eq!(
RootConfiguration::default().options.menu_timeout,
DEFAULT_MENU_TIMEOUT_SECONDS
);
assert_ne!(DEFAULT_MENU_TIMEOUT_SECONDS, 0);
}
}