boot: add get_os_indications_supported() helper

We inquire the EFI var for this at two places, let's add a helper that
queries it and gracefully handles it if we can't get it, by returning a
zero mask, i.e. no features supported.
This commit is contained in:
Lennart Poettering
2021-09-23 17:24:28 +02:00
parent 0d43ce5266
commit 3a6249127e
3 changed files with 23 additions and 12 deletions
+7 -12
View File
@@ -367,7 +367,7 @@ static UINTN entry_lookup_key(Config *config, UINTN start, CHAR16 key) {
}
static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
UINT64 key, indvar;
UINT64 key;
UINTN timeout;
BOOLEAN modevar;
_cleanup_freepool_ CHAR16 *partstr = NULL, *defaultstr = NULL;
@@ -395,8 +395,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
if (shim_loaded())
Print(L"Shim: present\n");
if (efivar_get_uint64_le(EFI_GLOBAL_GUID, L"OsIndicationsSupported", &indvar) == EFI_SUCCESS)
Print(L"OsIndicationsSupported: %d\n", indvar);
Print(L"OsIndicationsSupported: %d\n", get_os_indications_supported());
Print(L"\n--- press key ---\n\n");
console_key_read(&key, 0);
@@ -2427,8 +2426,6 @@ static VOID config_load_all_entries(
const CHAR16 *loaded_image_path,
EFI_FILE *root_dir) {
UINT64 osind = 0;
assert(config);
assert(loaded_image);
assert(loaded_image_path);
@@ -2456,13 +2453,11 @@ static VOID config_load_all_entries(
config_entry_add_loader_auto(config, loaded_image->DeviceHandle, root_dir, loaded_image_path,
L"auto-efi-default", '\0', L"EFI Default Loader", NULL);
if (config->auto_firmware && efivar_get_uint64_le(EFI_GLOBAL_GUID, L"OsIndicationsSupported", &osind) == EFI_SUCCESS) {
if (osind & EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
config_entry_add_call(config,
L"auto-reboot-to-firmware-setup",
L"Reboot Into Firmware Interface",
reboot_into_firmware);
}
if (config->auto_firmware && (get_os_indications_supported() & EFI_OS_INDICATIONS_BOOT_TO_FW_UI))
config_entry_add_call(config,
L"auto-reboot-to-firmware-setup",
L"Reboot Into Firmware Interface",
reboot_into_firmware);
}
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
+14
View File
@@ -743,3 +743,17 @@ EFI_STATUS open_directory(
*ret = TAKE_PTR(dir);
return EFI_SUCCESS;
}
UINT64 get_os_indications_supported(VOID) {
UINT64 osind;
EFI_STATUS err;
/* Returns the supported OS indications. If we can't acquire it, returns a zeroed out mask, i.e. no
* supported features. */
err = efivar_get_uint64_le(EFI_GLOBAL_GUID, L"OsIndicationsSupported", &osind);
if (EFI_ERROR(err))
return 0;
return osind;
}
+2
View File
@@ -144,3 +144,5 @@ static inline void *PHYSICAL_ADDRESS_TO_POINTER(EFI_PHYSICAL_ADDRESS addr) {
return (void*) (UINTN) addr;
}
UINT64 get_os_indications_supported(VOID);