MdeModulePkg/UiApp: Add warning if no bootable options found

This commit is contained in:
Tim Crawford
2020-02-11 10:01:45 -07:00
parent b1bed529dc
commit 40b9ce83bf
3 changed files with 46 additions and 0 deletions

View File

@ -524,6 +524,46 @@ SMBIOS_STRUCTURE_POINTER GetSmbiosTableFromType (
return SmbiosTableN;
}
STATIC
VOID
WarnNoBootableMedia (
VOID
)
{
CHAR16 *String;
EFI_STRING_ID Token;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
UINTN BootOptionCount;
UINTN Index;
UINTN Count = 0;
String = AllocateZeroPool (0x60);
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOptionCount; Index++) {
//
// Don't count the hidden/inactive boot option
//
if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {
continue;
}
Count++;
}
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
if (Count == 0) {
StrCatS (String, 0x60 / sizeof (CHAR16), L"Warning: No bootable media found");
} else {
StrCatS (String, 0x60 / sizeof (CHAR16), L"");
}
Token = STRING_TOKEN (STR_NO_BOOTABLE_MEDIA);
HiiSetString (gFrontPagePrivate.HiiHandle, Token, String, NULL);
FreePool(String);
}
/**
Update the information for the Front Page based on Smbios information.
@ -545,6 +585,8 @@ UpdateFrontPageStrings (
SMBIOS_TABLE_ENTRY_POINT *EntryPoint;
SMBIOS_STRUCTURE_POINTER SmbiosTable;
WarnNoBootableMedia ();
Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &Table);
if (EFI_ERROR (Status) || Table == NULL) {
return;