This file include all platform action which can be customized\r
by IBV/OEM.\r
\r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include "PlatformBootManager.h"\r
\r
+EFI_GUID mBootMenuFile = {\r
+ 0xEEC25BDC, 0x67F2, 0x4D95, { 0xB1, 0xD5, 0xF8, 0x1B, 0x20, 0x39, 0xD1, 0x1D }\r
+};\r
+\r
/**\r
Perform the platform diagnostic, such like test memory. OEM/IBV also\r
can customize this function to support specific platform diagnostic.\r
// from the graphic lib\r
//\r
if (QuietBoot) {\r
- PlatformBootManagerEnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
+ BootLogoEnableLogo ();\r
\r
//\r
// Perform system diagnostic\r
//\r
Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
if (EFI_ERROR (Status)) {\r
- PlatformBootManagerDisableQuietBoot ();\r
+ BootLogoDisableLogo ();\r
}\r
\r
return;\r
Status = PlatformBootManagerMemoryTest (MemoryTestLevel);\r
}\r
\r
-/**\r
- Return the index of the load option in the load option array.\r
-\r
- The function consider two load options are equal when the \r
- OptionType, Attributes, Description, FilePath and OptionalData are equal.\r
-\r
- @param Key Pointer to the load option to be found.\r
- @param Array Pointer to the array of load options to be found.\r
- @param Count Number of entries in the Array.\r
-\r
- @retval -1 Key wasn't found in the Array.\r
- @retval 0 ~ Count-1 The index of the Key in the Array.\r
-**/\r
-INTN\r
-PlatformFindLoadOption (\r
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,\r
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,\r
- IN UINTN Count\r
- )\r
-{\r
- UINTN Index;\r
-\r
- for (Index = 0; Index < Count; Index++) {\r
- if ((Key->OptionType == Array[Index].OptionType) &&\r
- (Key->Attributes == Array[Index].Attributes) &&\r
- (StrCmp (Key->Description, Array[Index].Description) == 0) &&\r
- (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&\r
- (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&\r
- (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {\r
- return (INTN) Index;\r
- }\r
- }\r
-\r
- return -1;\r
-}\r
-\r
-VOID\r
-PlatformRegisterFvBootOption (\r
- EFI_GUID *FileGuid,\r
- CHAR16 *Description,\r
- UINT32 Attributes\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN OptionIndex;\r
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;\r
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
- UINTN BootOptionCount;\r
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;\r
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-\r
- Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);\r
- DevicePath = AppendDevicePathNode (\r
- DevicePathFromHandle (LoadedImage->DeviceHandle),\r
- (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
- );\r
-\r
- Status = EfiBootManagerInitializeLoadOption (\r
- &NewOption,\r
- LoadOptionNumberUnassigned,\r
- LoadOptionTypeBoot,\r
- Attributes,\r
- Description,\r
- DevicePath,\r
- NULL,\r
- 0\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
-\r
- OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);\r
-\r
- if (OptionIndex == -1) {\r
- Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);\r
- ASSERT_EFI_ERROR (Status);\r
- }\r
- EfiBootManagerFreeLoadOption (&NewOption);\r
- EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
- }\r
-}\r
-\r
/**\r
Do the platform specific action before the console is connected.\r
\r
UINTN Index;\r
EFI_STATUS Status;\r
WIN_NT_SYSTEM_CONFIGURATION *Configuration;\r
- EFI_INPUT_KEY Enter;\r
- EFI_INPUT_KEY F2;\r
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
\r
GetVariable2 (L"Setup", &gEfiWinNtSystemConfigGuid, (VOID **) &Configuration, NULL);\r
if (Configuration != NULL) {\r
}\r
\r
//\r
- // Register ENTER as CONTINUE key\r
+ // From PI spec vol2:\r
+ // Prior to invoking any UEFI drivers, applications, or connecting consoles, \r
+ // the platform should signal the event EFI_END_OF_DXE_EVENT_GUID\r
//\r
- Enter.ScanCode = SCAN_NULL;\r
- Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;\r
- EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);\r
+ EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);\r
+\r
//\r
- // Map F2 to Boot Manager Menu\r
+ // Dispatch deferred images after EndOfDxe event.\r
//\r
- F2.ScanCode = SCAN_F2;\r
- F2.UnicodeChar = CHAR_NULL;\r
- EfiBootManagerGetBootManagerMenu (&BootOption);\r
- EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
+ EfiBootManagerDispatchDeferredImages ();\r
+}\r
+\r
+/**\r
+ Returns the priority number.\r
+\r
+ @param BootOption\r
+**/\r
+UINTN\r
+BootOptionPriority (\r
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption\r
+ )\r
+{\r
//\r
- // Register UEFI Shell\r
+ // Make sure Shell is first\r
//\r
- PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE);\r
+ if (StrCmp (BootOption->Description, L"UEFI Shell") == 0) {\r
+ return 0;\r
+ }\r
+ return 100;\r
+}\r
+\r
+INTN\r
+EFIAPI\r
+CompareBootOption (\r
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *Left,\r
+ CONST EFI_BOOT_MANAGER_LOAD_OPTION *Right\r
+ )\r
+{\r
+ return BootOptionPriority (Left) - BootOptionPriority (Right);\r
+}\r
+\r
+/**\r
+ Generate device path include the input file guid info.\r
+\r
+ @param FileGuid Input file guid for the BootManagerMenuApp.\r
+\r
+ @retval DevicePath for BootManagerMenuApp.\r
+**/\r
+EFI_DEVICE_PATH *\r
+FvFilePath (\r
+ EFI_GUID *FileGuid\r
+ )\r
+{\r
+\r
+ EFI_STATUS Status;\r
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;\r
+\r
+ EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);\r
+\r
+ Status = gBS->HandleProtocol (\r
+ gImageHandle,\r
+ &gEfiLoadedImageProtocolGuid,\r
+ (VOID **) &LoadedImage\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return AppendDevicePathNode (\r
+ DevicePathFromHandle (LoadedImage->DeviceHandle),\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &FileNode\r
+ );\r
+}\r
+\r
+/**\r
+ Create one boot option for BootManagerMenuApp.\r
+\r
+ @param FileGuid Input file guid for the BootManagerMenuApp.\r
+ @param Description Description of the BootManagerMenuApp boot option.\r
+ @param Position Position of the new load option to put in the ****Order variable.\r
+ @param IsBootCategory Whether this is a boot category.\r
+\r
+\r
+ @retval OptionNumber Return the option number info.\r
+\r
+**/\r
+UINTN\r
+RegisterBootManagerMenuAppBootOption (\r
+ EFI_GUID *FileGuid,\r
+ CHAR16 *Description,\r
+ UINTN Position,\r
+ BOOLEAN IsBootCategory\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ UINTN OptionNumber;\r
+\r
+ DevicePath = FvFilePath (FileGuid);\r
+ Status = EfiBootManagerInitializeLoadOption (\r
+ &NewOption,\r
+ LoadOptionNumberUnassigned,\r
+ LoadOptionTypeBoot,\r
+ IsBootCategory ? LOAD_OPTION_ACTIVE : LOAD_OPTION_CATEGORY_APP,\r
+ Description,\r
+ DevicePath,\r
+ NULL,\r
+ 0\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ FreePool (DevicePath);\r
+\r
+ Status = EfiBootManagerAddLoadOptionVariable (&NewOption, Position);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ OptionNumber = NewOption.OptionNumber;\r
+\r
+ EfiBootManagerFreeLoadOption (&NewOption);\r
+\r
+ return OptionNumber;\r
+}\r
+\r
+/**\r
+ Check if it's a Device Path pointing to BootManagerMenuApp.\r
+\r
+ @param DevicePath Input device path.\r
+\r
+ @retval TRUE The device path is BootManagerMenuApp File Device Path.\r
+ @retval FALSE The device path is NOT BootManagerMenuApp File Device Path.\r
+**/\r
+BOOLEAN\r
+IsBootManagerMenuAppFilePath (\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+)\r
+{\r
+ EFI_HANDLE FvHandle;\r
+ VOID *NameGuid;\r
+ EFI_STATUS Status;\r
+\r
+ Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);\r
+ if (!EFI_ERROR (Status)) {\r
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);\r
+ if (NameGuid != NULL) {\r
+ return CompareGuid (NameGuid, &mBootMenuFile);\r
+ }\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+/**\r
+ Return the boot option number to the BootManagerMenuApp.\r
+\r
+ If not found it in the current boot option, create a new one.\r
+\r
+ @retval OptionNumber Return the boot option number to the BootManagerMenuApp.\r
+\r
+**/\r
+UINTN\r
+GetBootManagerMenuAppOption (\r
+ VOID\r
+ )\r
+{\r
+ UINTN BootOptionCount;\r
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;\r
+ UINTN Index;\r
+ UINTN OptionNumber;\r
+\r
+ OptionNumber = 0;\r
+\r
+ BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);\r
+\r
+ for (Index = 0; Index < BootOptionCount; Index++) {\r
+ if (IsBootManagerMenuAppFilePath (BootOptions[Index].FilePath)) {\r
+ OptionNumber = BootOptions[Index].OptionNumber;\r
+ break;\r
+ }\r
+ }\r
+\r
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);\r
+\r
+ if (Index >= BootOptionCount) {\r
+ //\r
+ // If not found the BootManagerMenuApp, create it.\r
+ //\r
+ OptionNumber = (UINT16) RegisterBootManagerMenuAppBootOption (&mBootMenuFile, L"UEFI BootManagerMenuApp", (UINTN) -1, FALSE);\r
+ }\r
+\r
+ return OptionNumber;\r
}\r
\r
/**\r
{\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;\r
+ EFI_INPUT_KEY Enter;\r
+ EFI_INPUT_KEY F2;\r
+ EFI_INPUT_KEY F7;\r
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
+ UINTN OptionNumber;\r
\r
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
EfiBootManagerConnectAll ();\r
EfiBootManagerRefreshAllBootOption ();\r
\r
+ //\r
+ // Register ENTER as CONTINUE key\r
+ //\r
+ Enter.ScanCode = SCAN_NULL;\r
+ Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;\r
+ EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);\r
+ //\r
+ // Map F2 to Boot Manager Menu\r
+ //\r
+ F2.ScanCode = SCAN_F2;\r
+ F2.UnicodeChar = CHAR_NULL;\r
+ EfiBootManagerGetBootManagerMenu (&BootOption);\r
+ EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);\r
+\r
+ //\r
+ // 3. Boot Device List menu\r
+ //\r
+ F7.ScanCode = SCAN_F7;\r
+ F7.UnicodeChar = CHAR_NULL;\r
+ OptionNumber = GetBootManagerMenuAppOption ();\r
+ EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL);\r
+\r
+ //\r
+ // Make Shell as the first boot option\r
+ //\r
+ EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption);\r
+\r
PlatformBootManagerDiagnostics (QUICK, TRUE);\r
- \r
- PrintXY (10, 10, &White, &Black, L"F2 to enter Boot Manager Menu. ");\r
- PrintXY (10, 30, &White, &Black, L"Enter to boot directly.");\r
+\r
+ PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. ");\r
+ PrintXY (10, 30, &White, &Black, L"F7 to enter Boot Manager Menu.");\r
+ PrintXY (10, 50, &White, &Black, L"Enter to boot directly.");\r
}\r
\r
/**\r
UINT16 TimeoutRemain\r
)\r
{\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;\r
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;\r
- UINT16 Timeout;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;\r
+ UINT16 Timeout;\r
\r
Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
\r
- Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;\r
- White.Blue = White.Green = White.Red = White.Reserved = 0xFF;\r
+ Black.Raw = 0x00000000;\r
+ White.Raw = 0x00FFFFFF;\r
\r
- PlatformBootManagerShowProgress (\r
- White,\r
- Black,\r
+ BootLogoUpdateProgress (\r
+ White.Pixel,\r
+ Black.Pixel,\r
L"Start boot option",\r
- White,\r
+ White.Pixel,\r
(Timeout - TimeoutRemain) * 100 / Timeout,\r
0\r
);\r
}\r
+\r
+/**\r
+ The function is called when no boot option could be launched,\r
+ including platform recovery options and options pointing to applications\r
+ built into firmware volumes.\r
+\r
+ If this function returns, BDS attempts to enter an infinite loop.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBootManagerUnableToBoot (\r
+ VOID\r
+ )\r
+{\r
+ return;\r
+}\r
+\r