diff options
author | Guo Dong <guo.dong@intel.com> | 2023-05-09 20:53:55 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-05-15 21:26:04 +0000 |
commit | cafb4f3f36e2101cab2ed6db3ea246a5a3e4708e (patch) | |
tree | 5701604ff5434ef2d015a977405aee7e745f8112 /UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c | |
parent | 80bc13db83ddbd5bbe757a20abcdd34daf4871f8 (diff) | |
download | edk2-cafb4f3f36e2101cab2ed6db3ea246a5a3e4708e.zip edk2-cafb4f3f36e2101cab2ed6db3ea246a5a3e4708e.tar.gz edk2-cafb4f3f36e2101cab2ed6db3ea246a5a3e4708e.tar.bz2 |
UefiPayloadPkg: Fix boot shell issue for universal UEFI payload
After moving BDS driver to a new FV for universal UEFI payload,
the shell boot option path is not correct since it used the BDS
FV instead of DXE FV in its device path.
This patch would find the correct FV by reading shell file.
It also removed PcdShellFile by using gUefiShellFileGuid.
Signed-off-by: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Diffstat (limited to 'UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c')
-rw-r--r-- | UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c | 82 |
1 files changed, 75 insertions, 7 deletions
diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index 62637ae..4a02196 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -2,7 +2,7 @@ This file include all platform action which can be customized
by IBV/OEM.
-Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PlatformConsole.h"
#include <Guid/BootManagerMenu.h>
#include <Library/HobLib.h>
+#include <Protocol/FirmwareVolume2.h>
/**
Signal EndOfDxe event and install SMM Ready to lock protocol.
@@ -90,6 +91,77 @@ PlatformFindLoadOption ( }
/**
+ Get the FV device path for the shell file.
+
+ @return A pointer to device path structure.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+BdsGetShellFvDevicePath (
+ VOID
+ )
+{
+ UINTN FvHandleCount;
+ EFI_HANDLE *FvHandleBuffer;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+ UINTN Size;
+ UINT32 AuthenticationStatus;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_FV_FILETYPE FoundType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+
+ Status = EFI_SUCCESS;
+ gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &FvHandleCount,
+ &FvHandleBuffer
+ );
+
+ for (Index = 0; Index < FvHandleCount; Index++) {
+ Size = 0;
+ gBS->HandleProtocol (
+ FvHandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **)&Fv
+ );
+ Status = Fv->ReadFile (
+ Fv,
+ &gUefiShellFileGuid,
+ NULL,
+ &Size,
+ &FoundType,
+ &FileAttributes,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Found the shell file
+ //
+ break;
+ }
+ }
+
+ if (EFI_ERROR (Status)) {
+ if (FvHandleCount) {
+ FreePool (FvHandleBuffer);
+ }
+
+ return NULL;
+ }
+
+ DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
+
+ if (FvHandleCount) {
+ FreePool (FvHandleBuffer);
+ }
+
+ return DevicePath;
+}
+
+/**
Register a boot option using a file GUID in the FV.
@param FileGuid The file GUID name in FV.
@@ -109,15 +181,11 @@ PlatformRegisterFvBootOption ( 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 = AppendDevicePathNode (
- DevicePathFromHandle (LoadedImage->DeviceHandle),
+ BdsGetShellFvDevicePath (),
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
);
@@ -248,7 +316,7 @@ PlatformBootManagerAfterConsole ( //
// Register UEFI Shell
//
- PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE);
+ PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_OPTION_ACTIVE);
if (FixedPcdGetBool (PcdBootManagerEscape)) {
Print (
|