X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=OvmfPkg%2FLibrary%2FPlatformBootManagerLib%2FBdsPlatform.c;h=722776b2b538e750c53ae5eb5aabefe2872035c5;hb=fed691a6f9138c3c22d075a9597435be43e660d0;hp=3432e02715d6ab162e7f16bf7f559749103d2ea7;hpb=8dc0f0a6aab090af015d65f92eb1386f8db7f0c0;p=mirror_edk2.git diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index 3432e02715..722776b2b5 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -88,6 +88,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 ( @@ -167,6 +272,8 @@ Returns: PlatformInitializeConsole (gPlatformConsole); PcdSet16 (PcdPlatformBootTimeOut, GetFrontPageTimeoutFromQemu ()); + + PlatformRegisterOptionsAndKeys (); } @@ -1053,7 +1160,6 @@ PlatformBdsRestoreNvVarsFromHardDisk ( } - VOID PlatformBdsConnectSequence ( VOID @@ -1090,14 +1196,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 (); @@ -1282,9 +1389,6 @@ Routine Description: // Process QEMU's -kernel command line option // TryRunningQemuKernel (); - - DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n")); - BdsLibConnectAll (); BdsLibEnumerateAllBootOption (BootOptionList); SetBootOrderFromQemu (BootOptionList); @@ -1295,100 +1399,6 @@ Routine Description: BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder"); } -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")); - - // - // 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); - } -} - -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.