sd-boot: introduce a one-time override for the boot menu timeout
This is useful to allow userspace to request a "boot into boot menu" feature.
This commit is contained in:
parent
2366d92345
commit
fe2579dd9c
|
@ -256,8 +256,12 @@
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>LoaderConfigTimeout</varname></term>
|
<term><varname>LoaderConfigTimeout</varname></term>
|
||||||
<listitem><para>The menu time-out. Read by the boot loader. (Also, modified by it when the
|
<term><varname>LoaderConfigTimeoutOneShot</varname></term>
|
||||||
<keycap>t</keycap>/<keycap>T</keycap> keys are used, see above.)</para></listitem>
|
<listitem><para>The menu time-out in seconds. Read by the boot loader. <varname>LoaderConfigTimeout</varname>
|
||||||
|
is maintained persistently, while <varname>LoaderConfigTimeoutOneShot</varname> is a one-time override which is
|
||||||
|
read once (in which case it takes precedence over <varname>LoaderConfigTimeout</varname>) and then
|
||||||
|
removed. <varname>LoaderConfigTimeout</varname> may be manipulated with the
|
||||||
|
<keycap>t</keycap>/<keycap>T</keycap> keys, see above.)</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -62,6 +62,7 @@ typedef struct {
|
||||||
BOOLEAN editor;
|
BOOLEAN editor;
|
||||||
BOOLEAN auto_entries;
|
BOOLEAN auto_entries;
|
||||||
BOOLEAN auto_firmware;
|
BOOLEAN auto_firmware;
|
||||||
|
BOOLEAN force_menu;
|
||||||
UINTN console_mode;
|
UINTN console_mode;
|
||||||
enum console_mode_change_type console_mode_change;
|
enum console_mode_change_type console_mode_change;
|
||||||
} Config;
|
} Config;
|
||||||
|
@ -1417,6 +1418,15 @@ static VOID config_load_defaults(Config *config, EFI_FILE *root_dir) {
|
||||||
config->timeout_sec = sec;
|
config->timeout_sec = sec;
|
||||||
} else
|
} else
|
||||||
config->timeout_sec_efivar = -1;
|
config->timeout_sec_efivar = -1;
|
||||||
|
|
||||||
|
err = efivar_get_int(L"LoaderConfigTimeoutOneShot", &sec);
|
||||||
|
if (!EFI_ERROR(err)) {
|
||||||
|
/* Unset variable now, after all it's "one shot". */
|
||||||
|
(void) efivar_set(L"LoaderConfigTimeoutOneShot", NULL, TRUE);
|
||||||
|
|
||||||
|
config->timeout_sec = sec;
|
||||||
|
config->force_menu = TRUE; /* force the menu when this is set */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID config_load_entries(
|
static VOID config_load_entries(
|
||||||
|
@ -2167,7 +2177,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* select entry or show menu when key is pressed or timeout is set */
|
/* select entry or show menu when key is pressed or timeout is set */
|
||||||
if (config.timeout_sec == 0) {
|
if (config.force_menu || config.timeout_sec > 0)
|
||||||
|
menu = TRUE;
|
||||||
|
else {
|
||||||
UINT64 key;
|
UINT64 key;
|
||||||
|
|
||||||
err = console_key_read(&key, FALSE);
|
err = console_key_read(&key, FALSE);
|
||||||
|
@ -2181,8 +2193,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
|
||||||
else
|
else
|
||||||
menu = TRUE;
|
menu = TRUE;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
menu = TRUE;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ConfigEntry *entry;
|
ConfigEntry *entry;
|
||||||
|
|
Loading…
Reference in a new issue