X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FLibrary%2FPlatformBootManagerLib%2FBdsPlatform.c;h=cf774a16a78bde5e1a8e77f495d6bca13a9a18f1;hb=e64a2ebe7d46a68e57404ab7bbd6ab9710ce26f1;hp=cae2192f9a318be65c1b08823fc8d5be90e18120;hpb=e9e9ad644fab65b8dd66772df1bb139e3a1d2854;p=mirror_edk2.git diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index cae2192f9a..cf774a16a7 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -14,7 +14,6 @@ #include "BdsPlatform.h" #include -#include // @@ -88,6 +87,111 @@ InstallDevicePathCallback ( VOID ); +VOID +PlatformRegisterFvBootOption ( + EFI_GUID *FileGuid, + CHAR16 *Description, + UINT32 Attributes + ) +{ + EFI_STATUS Status; + INTN OptionIndex; + EFI_BOOT_MANAGER_LOAD_OPTION NewOption; + EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions; + UINTN BootOptionCount; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode; + EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + + Status = gBS->HandleProtocol ( + gImageHandle, + &gEfiLoadedImageProtocolGuid, + (VOID **) &LoadedImage + ); + ASSERT_EFI_ERROR (Status); + + EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid); + DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle); + ASSERT (DevicePath != NULL); + DevicePath = AppendDevicePathNode ( + DevicePath, + (EFI_DEVICE_PATH_PROTOCOL *) &FileNode + ); + ASSERT (DevicePath != NULL); + + Status = EfiBootManagerInitializeLoadOption ( + &NewOption, + LoadOptionNumberUnassigned, + LoadOptionTypeBoot, + Attributes, + Description, + DevicePath, + NULL, + 0 + ); + ASSERT_EFI_ERROR (Status); + FreePool (DevicePath); + + BootOptions = EfiBootManagerGetLoadOptions ( + &BootOptionCount, LoadOptionTypeBoot + ); + + OptionIndex = EfiBootManagerFindLoadOption ( + &NewOption, BootOptions, BootOptionCount + ); + + if (OptionIndex == -1) { + Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN); + ASSERT_EFI_ERROR (Status); + } + EfiBootManagerFreeLoadOption (&NewOption); + EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); +} + +VOID +PlatformRegisterOptionsAndKeys ( + VOID + ) +{ + EFI_STATUS Status; + EFI_INPUT_KEY Enter; + EFI_INPUT_KEY F2; + EFI_INPUT_KEY Esc; + EFI_BOOT_MANAGER_LOAD_OPTION BootOption; + + // + // Register ENTER as CONTINUE key + // + Enter.ScanCode = SCAN_NULL; + Enter.UnicodeChar = CHAR_CARRIAGE_RETURN; + Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL); + ASSERT_EFI_ERROR (Status); + + // + // Map F2 to Boot Manager Menu + // + F2.ScanCode = SCAN_F2; + F2.UnicodeChar = CHAR_NULL; + Esc.ScanCode = SCAN_ESC; + Esc.UnicodeChar = CHAR_NULL; + Status = EfiBootManagerGetBootManagerMenu (&BootOption); + ASSERT_EFI_ERROR (Status); + Status = EfiBootManagerAddKeyOptionVariable ( + NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL + ); + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED); + Status = EfiBootManagerAddKeyOptionVariable ( + NULL, (UINT16) BootOption.OptionNumber, 0, &Esc, NULL + ); + ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED); + // + // Register UEFI Shell + // + PlatformRegisterFvBootOption ( + PcdGetPtr (PcdShellFile), L"EFI Internal Shell", LOAD_OPTION_ACTIVE + ); +} + EFI_STATUS EFIAPI ConnectRootBridge ( @@ -166,6 +270,9 @@ Returns: ASSERT_EFI_ERROR (Status); PlatformInitializeConsole (gPlatformConsole); + PcdSet16 (PcdPlatformBootTimeOut, GetFrontPageTimeoutFromQemu ()); + + PlatformRegisterOptionsAndKeys (); } @@ -1052,7 +1159,6 @@ PlatformBdsRestoreNvVarsFromHardDisk ( } - VOID PlatformBdsConnectSequence ( VOID @@ -1089,14 +1195,15 @@ Returns: // // Build the platform boot option // - BdsLibConnectDevicePath (gPlatformConnectSequence[Index]); + EfiBootManagerConnectDevicePath (gPlatformConnectSequence[Index], NULL); Index++; } // // Just use the simple policy to connect all devices // - BdsLibConnectAll (); + DEBUG ((EFI_D_INFO, "EfiBootManagerConnectAll\n")); + EfiBootManagerConnectAll (); PciAcpiInitialization (); @@ -1106,87 +1213,6 @@ Returns: gST->ConOut->ClearScreen (gST->ConOut); } -VOID -PlatformBdsGetDriverOption ( - IN OUT LIST_ENTRY *BdsDriverLists - ) -/*++ - -Routine Description: - - Load the predefined driver option, OEM/IBV can customize this - to load their own drivers - -Arguments: - - BdsDriverLists - The header of the driver option link list. - -Returns: - - None. - ---*/ -{ - DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n")); - return; -} - -VOID -PlatformBdsDiagnostics ( - IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel, - IN BOOLEAN QuietBoot, - IN BASEM_MEMORY_TEST BaseMemoryTest - ) -/*++ - -Routine Description: - - Perform the platform diagnostic, such like test memory. OEM/IBV also - can customize this fuction to support specific platform diagnostic. - -Arguments: - - MemoryTestLevel - The memory test intensive level - - QuietBoot - Indicate if need to enable the quiet boot - - BaseMemoryTest - A pointer to BaseMemoryTest() - -Returns: - - None. - ---*/ -{ - EFI_STATUS Status; - - DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n")); - - // - // Here we can decide if we need to show - // the diagnostics screen - // Notes: this quiet boot code should be remove - // from the graphic lib - // - if (QuietBoot) { - EnableQuietBoot (PcdGetPtr(PcdLogoFile)); - // - // Perform system diagnostic - // - Status = BaseMemoryTest (MemoryTestLevel); - if (EFI_ERROR (Status)) { - DisableQuietBoot (); - } - - return ; - } - // - // Perform system diagnostic - // - Status = BaseMemoryTest (MemoryTestLevel); -} - - /** Save the S3 boot script. @@ -1234,7 +1260,6 @@ Routine Description: --*/ { - EFI_STATUS Status; EFI_BOOT_MODE BootMode; DEBUG ((EFI_D_INFO, "PlatformBootManagerAfterConsole\n")); @@ -1250,15 +1275,10 @@ Routine Description: PlatformBdsRestoreNvVarsFromHardDisk (); } - // - // Load the driver option as the driver option list - // - PlatformBdsGetDriverOption (DriverOptionList); - // // Get current Boot Mode // - Status = BdsLibGetBootMode (&BootMode); + BootMode = GetBootModeHob (); DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode)); // @@ -1268,9 +1288,9 @@ Routine Description: ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION); // - // Memory test and Logo show + // Logo show // - PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest); + EnableQuietBoot (PcdGetPtr (PcdLogoFile)); // // Perform some platform specific connect sequence @@ -1282,114 +1302,11 @@ Routine Description: // TryRunningQemuKernel (); - DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n")); - BdsLibConnectAll (); - BdsLibEnumerateAllBootOption (BootOptionList); - - SetBootOrderFromQemu (BootOptionList); - // - // The BootOrder variable may have changed, reload the in-memory list with - // it. - // - BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder"); - - PlatformBdsEnterFrontPage (GetFrontPageTimeoutFromQemu(), TRUE); -} - -VOID -EFIAPI -PlatformBdsBootSuccess ( - IN BDS_COMMON_OPTION *Option - ) -/*++ - -Routine Description: - - Hook point after a boot attempt succeeds. We don't expect a boot option to - return, so the EFI 1.0 specification defines that you will default to an - interactive mode and stop processing the BootOrder list in this case. This - is alos a platform implementation and can be customized by IBV/OEM. - -Arguments: - - Option - Pointer to Boot Option that succeeded to boot. - -Returns: - - None. - ---*/ -{ - CHAR16 *TmpStr; - - DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n")); - // - // If Boot returned with EFI_SUCCESS and there is not in the boot device - // select loop then we need to pop up a UI and wait for user input. - // - TmpStr = Option->StatusString; - if (TmpStr != NULL) { - BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL); - FreePool (TmpStr); - } -} - -VOID -EFIAPI -PlatformBdsBootFail ( - IN BDS_COMMON_OPTION *Option, - IN EFI_STATUS Status, - IN CHAR16 *ExitData, - IN UINTN ExitDataSize - ) -/*++ - -Routine Description: - - Hook point after a boot attempt fails. - -Arguments: - - Option - Pointer to Boot Option that failed to boot. - - Status - Status returned from failed boot. - - ExitData - Exit data returned from failed boot. - - ExitDataSize - Exit data size returned from failed boot. - -Returns: - - None. - ---*/ -{ - CHAR16 *TmpStr; - - DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n")); + EfiBootManagerRefreshAllBootOption (); - // - // If Boot returned with failed status then we need to pop up a UI and wait - // for user input. - // - TmpStr = Option->StatusString; - if (TmpStr != NULL) { - BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL); - FreePool (TmpStr); - } + SetBootOrderFromQemu (NULL); } -VOID -EFIAPI -PlatformBdsLockNonUpdatableFlash ( - VOID - ) -{ - DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n")); - return; -} - - /** This notification function is invoked when an instance of the EFI_DEVICE_PATH_PROTOCOL is produced.