mirror of https://github.com/acidanthera/audk.git
Nt32Pkg PlatformBootManagerLib: Enable BootManagerMenuApp.
Enable BootManagerMenuApp application for Nt32 platform. Also enable F7 hotkey to select this boot option. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
parent
37078045d7
commit
0b6dc68dc3
|
@ -15,6 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include "PlatformBootManager.h"
|
||||
|
||||
EFI_GUID mBootMenuFile = {
|
||||
0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }
|
||||
};
|
||||
|
||||
/**
|
||||
Perform the platform diagnostic, such like test memory. OEM/IBV also
|
||||
can customize this function to support specific platform diagnostic.
|
||||
|
@ -143,6 +147,154 @@ CompareBootOption (
|
|||
return BootOptionPriority (Left) - BootOptionPriority (Right);
|
||||
}
|
||||
|
||||
/**
|
||||
Generate device path include the input file guid info.
|
||||
|
||||
@param FileGuid Input file guid for the BootManagerMenuApp.
|
||||
|
||||
@retval DevicePath for BootManagerMenuApp.
|
||||
**/
|
||||
EFI_DEVICE_PATH *
|
||||
FvFilePath (
|
||||
EFI_GUID *FileGuid
|
||||
)
|
||||
{
|
||||
|
||||
EFI_STATUS Status;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
|
||||
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &LoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return AppendDevicePathNode (
|
||||
DevicePathFromHandle (LoadedImage->DeviceHandle),
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Create one boot option for BootManagerMenuApp.
|
||||
|
||||
@param FileGuid Input file guid for the BootManagerMenuApp.
|
||||
@param Description Description of the BootManagerMenuApp boot option.
|
||||
@param Position Position of the new load option to put in the ****Order variable.
|
||||
@param IsBootCategory Whether this is a boot category.
|
||||
|
||||
|
||||
@retval OptionNumber Return the option number info.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
RegisterBootManagerMenuAppBootOption (
|
||||
EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINTN Position,
|
||||
BOOLEAN IsBootCategory
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN OptionNumber;
|
||||
|
||||
DevicePath = FvFilePath (FileGuid);
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&NewOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypeBoot,
|
||||
IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,
|
||||
Description,
|
||||
DevicePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (DevicePath);
|
||||
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
OptionNumber = NewOption.OptionNumber;
|
||||
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
|
||||
return OptionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
Check if it's a Device Path pointing to BootManagerMenuApp.
|
||||
|
||||
@param DevicePath Input device path.
|
||||
|
||||
@retval TRUE The device path is BootManagerMenuApp File Device Path.
|
||||
@retval FALSE The device path is NOT BootManagerMenuApp File Device Path.
|
||||
**/
|
||||
BOOLEAN
|
||||
IsBootManagerMenuAppFilePath (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
EFI_HANDLE FvHandle;
|
||||
VOID *NameGuid;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
|
||||
if (NameGuid != NULL) {
|
||||
return CompareGuid (NameGuid, &mBootMenuFile);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
Return the boot option number to the BootManagerMenuApp.
|
||||
|
||||
If not found it in the current boot option, create a new one.
|
||||
|
||||
@retval OptionNumber Return the boot option number to the BootManagerMenuApp.
|
||||
|
||||
**/
|
||||
UINTN
|
||||
GetBootManagerMenuAppOption (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINTN BootOptionCount;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN Index;
|
||||
UINTN OptionNumber;
|
||||
|
||||
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
|
||||
|
||||
for (Index = 0; Index < BootOptionCount; Index++) {
|
||||
if (IsBootManagerMenuAppFilePath (BootOptions[Index].FilePath)) {
|
||||
OptionNumber = BootOptions[Index].OptionNumber;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||
|
||||
if (Index >= BootOptionCount) {
|
||||
//
|
||||
// If not found the BootManagerMenuApp, create it.
|
||||
//
|
||||
OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);
|
||||
}
|
||||
|
||||
return OptionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
Do the platform specific action after the console is connected.
|
||||
|
||||
|
@ -163,7 +315,9 @@ PlatformBootManagerAfterConsole (
|
|||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
|
||||
EFI_INPUT_KEY Enter;
|
||||
EFI_INPUT_KEY F2;
|
||||
EFI_INPUT_KEY F7;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
UINTN OptionNumber;
|
||||
|
||||
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;
|
||||
White.Blue = White.Green = White.Red = White.Reserved = 0xFF;
|
||||
|
@ -185,15 +339,24 @@ PlatformBootManagerAfterConsole (
|
|||
EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
|
||||
|
||||
//
|
||||
// 3. Boot Device List menu
|
||||
//
|
||||
F7.ScanCode = SCAN_F7;
|
||||
F7.UnicodeChar = CHAR_NULL;
|
||||
OptionNumber = GetBootManagerMenuAppOption ();
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);
|
||||
|
||||
//
|
||||
// Make Shell as the first boot option
|
||||
//
|
||||
EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption);
|
||||
|
||||
PlatformBootManagerDiagnostics (QUICK, TRUE);
|
||||
|
||||
PrintXY (10, 10, &White, &Black, L"F2 to enter Boot Manager Menu. ");
|
||||
PrintXY (10, 30, &White, &Black, L"Enter to boot directly.");
|
||||
|
||||
PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. ");
|
||||
PrintXY (10, 30, &White, &Black, L"F7 to enter Boot Manager Menu.");
|
||||
PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Protocol/WinNtThunk.h>
|
||||
#include <Protocol/WinNtIo.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
gEfiGraphicsOutputProtocolGuid ## CONSUMES
|
||||
gEfiUgaDrawProtocolGuid ## CONSUMES
|
||||
gEfiBootLogoProtocolGuid ## CONSUMES
|
||||
gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
|
||||
|
||||
[Pcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
||||
|
|
|
@ -470,6 +470,10 @@
|
|||
|
||||
MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf
|
||||
MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.inf
|
||||
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf {
|
||||
<LibraryClasses>
|
||||
NULL|IntelFrameworkModulePkg/Library/LegacyBootManagerLib/LegacyBootManagerLib.inf
|
||||
}
|
||||
|
||||
###################################################################################################
|
||||
#
|
||||
|
|
|
@ -262,6 +262,7 @@ INF NetworkPkg/HttpBootDxe/HttpBootDxe.inf
|
|||
INF NetworkPkg/DnsDxe/DnsDxe.inf
|
||||
INF NetworkPkg/HttpDxe/HttpDxe.inf
|
||||
INF NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
|
||||
INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
|
||||
################################################################################
|
||||
#
|
||||
# FILE statements are provided so that a platform integrator can include
|
||||
|
|
Loading…
Reference in New Issue