}
}
+static EFI_STATUS reboot_into_firmware(void) {
+ UINT64 osind = 0;
+ EFI_STATUS err;
+
+ if (!(get_os_indications_supported() & EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
+ return log_error_status_stall(EFI_UNSUPPORTED, L"Reboot to firmware interface not supported.");
+
+ (void) efivar_get_uint64_le(EFI_GLOBAL_GUID, L"OsIndications", &osind);
+ osind |= EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+
+ err = efivar_set_uint64_le(EFI_GLOBAL_GUID, L"OsIndications", osind, EFI_VARIABLE_NON_VOLATILE);
+ if (EFI_ERROR(err))
+ return log_error_status_stall(err, L"Error setting OsIndications: %r", err);
+
+ err = RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ return log_error_status_stall(err, L"Error calling ResetSystem: %r", err);
+}
+
static BOOLEAN menu_run(
Config *config,
ConfigEntry **chosen_entry,
UINT32 timeout_efivar_saved = config->timeout_sec_efivar;
UINT32 timeout_remain = config->timeout_sec == TIMEOUT_MENU_FORCE ? 0 : config->timeout_sec;
INT16 idx;
- BOOLEAN exit = FALSE, run = TRUE;
+ BOOLEAN exit = FALSE, run = TRUE, firmware_setup = FALSE;
INT64 console_mode_initial = ST->ConOut->Mode->Mode, console_mode_efivar_saved = config->console_mode_efivar;
graphics_mode(FALSE);
idx_highlight_prev = idx_highlight;
+ if (firmware_setup) {
+ firmware_setup = FALSE;
+ if (key == KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN))
+ reboot_into_firmware();
+ continue;
+ }
+
switch (key) {
case KEYPRESS(0, SCAN_UP, 0):
case KEYPRESS(0, 0, 'k'):
case KEYPRESS(0, 0, 'h'):
case KEYPRESS(0, 0, 'H'):
case KEYPRESS(0, 0, '?'):
- /* This must stay below 80 characters! Q/v/Ctrl+l deliberately not advertised. */
+ /* This must stay below 80 characters! Q/v/Ctrl+l/f deliberately not advertised. */
status = StrDuplicate(L"(d)efault (t/T)timeout (e)dit (r/R)resolution (p)rint (h)elp");
break;
new_mode = TRUE;
break;
+ case KEYPRESS(0, 0, 'f'):
+ case KEYPRESS(0, 0, 'F'):
+ case KEYPRESS(0, SCAN_F2, 0): /* Most vendors. */
+ case KEYPRESS(0, SCAN_F10, 0): /* HP and Lenovo. */
+ case KEYPRESS(0, SCAN_DELETE, 0): /* Same as F2. */
+ case KEYPRESS(0, SCAN_ESC, 0): /* HP. */
+ if (get_os_indications_supported() & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) {
+ firmware_setup = TRUE;
+ /* Let's make sure the user really wants to do this. */
+ status = PoolPrint(L"Press Enter to reboot into firmware interface.");
+ } else
+ status = PoolPrint(L"Reboot into firmware interface not supported.");
+ break;
+
default:
/* jump with a hotkey directly to a matching entry */
idx = entry_lookup_key(config, idx_highlight+1, KEYCHAR(key));
return err;
}
-static EFI_STATUS reboot_into_firmware(void) {
- UINT64 old, new;
- EFI_STATUS err;
-
- new = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
-
- err = efivar_get_uint64_le(EFI_GLOBAL_GUID, L"OsIndications", &old);
- if (!EFI_ERROR(err))
- new |= old;
-
- err = efivar_set_uint64_le(EFI_GLOBAL_GUID, L"OsIndications", new, EFI_VARIABLE_NON_VOLATILE);
- if (EFI_ERROR(err))
- return err;
-
- err = RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
- return log_error_status_stall(err, L"Error calling ResetSystem: %r", err);
-}
-
static void config_free(Config *config) {
assert(config);
for (UINTN i = 0; i < config->entry_count; i++)