From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.8685.1683691114797196238 for ; Tue, 09 May 2023 20:58:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=a1+9rVHC; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: guo.dong@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683691114; x=1715227114; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fP9LpWOvWO4bxP1oCcsoB3GefORC9KQlKcwKLGkDH14=; b=a1+9rVHC5aR6QMTfyTgqYuvmU/in7uctMgk86B1HEgC1GAQwH9XBOAkt gaaYC8fELJ7VRs9gGedOCFZK3oTi8OHh5w9/YnYAY3f3kdwquttsAPD2t Vd0X9KA3qCFWjvuE09DTeH92jQaacj/1vstVqt23MgOLmLJRaq4HqwHu4 hBcVefvuAX4nGIcYANNpMTLuIkbi6VsbM3y6M0YC0HZSVlIYdyPW6Uh3k zujglzZiLjdseJLBfKiaAPuoiA+wDQsSwSkp5OBBljzjIdr5FNeadq3r9 5Ple5dxSnYU3yF6puqyz56osJszALvDoD3EZTW+8YyVBwMrhrgdURqMLH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="352307275" X-IronPort-AV: E=Sophos;i="5.99,263,1677571200"; d="scan'208";a="352307275" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 20:58:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10705"; a="945549206" X-IronPort-AV: E=Sophos;i="5.99,263,1677571200"; d="scan'208";a="945549206" Received: from gdong1-mobl.amr.corp.intel.com ([10.212.24.100]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2023 20:58:33 -0700 From: "Guo Dong" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: [edk2-devel][PATCH] UefiPayloadPkg: Fix boot shell issue for universal UEFI payload Date: Tue, 9 May 2023 20:58:17 -0700 Message-Id: <20230510035817.1023-1-guo.dong@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Guo Dong 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 Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo --- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c |= 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-= ----- UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |= 5 +++-- UefiPayloadPkg/UefiPayloadPkg.dec |= 3 --- 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= ger.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index 62637ae6aa..cf72783af1 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=0D by IBV/OEM.=0D =0D -Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PlatformConsole.h"=0D #include =0D #include =0D +#include =0D =0D /**=0D Signal EndOfDxe event and install SMM Ready to lock protocol.=0D @@ -89,6 +90,72 @@ PlatformFindLoadOption ( return -1;=0D }=0D =0D +=0D +EFI_DEVICE_PATH_PROTOCOL *=0D +BdsGetShellFvDevicePath (=0D + VOID=0D + )=0D +{=0D + UINTN FvHandleCount;=0D + EFI_HANDLE *FvHandleBuffer;=0D + UINTN Index;=0D + EFI_STATUS Status;=0D + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;=0D + UINTN Size;=0D + UINT32 AuthenticationStatus;=0D + EFI_DEVICE_PATH_PROTOCOL *DevicePath;=0D + VOID *Buffer;=0D +=0D + Status =3D EFI_SUCCESS;=0D + gBS->LocateHandleBuffer (=0D + ByProtocol,=0D + &gEfiFirmwareVolume2ProtocolGuid,=0D + NULL,=0D + &FvHandleCount,=0D + &FvHandleBuffer=0D + );=0D +=0D + for (Index =3D 0; Index < FvHandleCount; Index++) {=0D + Buffer =3D NULL;=0D + Size =3D 0;=0D + gBS->HandleProtocol (=0D + FvHandleBuffer[Index],=0D + &gEfiFirmwareVolume2ProtocolGuid,=0D + (VOID **) &Fv=0D + );=0D + Status =3D Fv->ReadSection (=0D + Fv,=0D + &gUefiShellFileGuid,=0D + EFI_SECTION_PE32,=0D + 0,=0D + &Buffer,=0D + &Size,=0D + &AuthenticationStatus=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + //=0D + // Found the shell file=0D + //=0D + break;=0D + }=0D + }=0D +=0D + if (EFI_ERROR (Status)) {=0D + if (FvHandleCount) {=0D + FreePool (FvHandleBuffer);=0D + }=0D + return NULL;=0D + }=0D +=0D + DevicePath =3D DevicePathFromHandle (FvHandleBuffer[Index]);=0D +=0D + if (FvHandleCount) {=0D + FreePool (FvHandleBuffer);=0D + }=0D +=0D + return DevicePath;=0D +}=0D +=0D /**=0D Register a boot option using a file GUID in the FV.=0D =0D @@ -109,15 +176,12 @@ PlatformRegisterFvBootOption ( EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;=0D UINTN BootOptionCount;=0D MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;=0D - EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;=0D EFI_DEVICE_PATH_PROTOCOL *DevicePath;=0D =0D - Status =3D gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGu= id, (VOID **)&LoadedImage);=0D - ASSERT_EFI_ERROR (Status);=0D =0D EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);=0D DevicePath =3D AppendDevicePathNode (=0D - DevicePathFromHandle (LoadedImage->DeviceHandle),=0D + BdsGetShellFvDevicePath(),=0D (EFI_DEVICE_PATH_PROTOCOL *)&FileNode=0D );=0D =0D @@ -248,7 +312,7 @@ PlatformBootManagerAfterConsole ( //=0D // Register UEFI Shell=0D //=0D - PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", L= OAD_OPTION_ACTIVE);=0D + PlatformRegisterFvBootOption (&gUefiShellFileGuid, L"UEFI Shell", LOAD_O= PTION_ACTIVE);=0D =0D if (FixedPcdGetBool (PcdBootManagerEscape)) {=0D Print (=0D diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana= gerLib.inf index f9626175e2..a3951b7a7e 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf @@ -1,7 +1,7 @@ ## @file=0D # Include all platform action which can be customized by IBV/OEM.=0D #=0D -# Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.
= =0D +# Copyright (c) 2012 - 2023, Intel Corporation. All rights reserved.
= =0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -32,6 +32,7 @@ MdePkg/MdePkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D UefiPayloadPkg/UefiPayloadPkg.dec=0D + ShellPkg/ShellPkg.dec=0D =0D [LibraryClasses]=0D BaseLib=0D @@ -52,6 +53,7 @@ [Guids]=0D gEfiEndOfDxeEventGroupGuid=0D gEdkiiBootManagerMenuFileGuid=0D + gUefiShellFileGuid=0D =0D [Protocols]=0D gEfiGenericMemTestProtocolGuid ## CONSUMES=0D @@ -69,7 +71,6 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow=0D gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn=0D gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand=0D - gUefiPayloadPkgTokenSpaceGuid.PcdShellFile=0D gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate=0D gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits=0D gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index a23a7b5a78..8d111f3a90 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -67,9 +67,6 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize|0|UINT3= 2|0x10000002 ## Save bootloader parameter=0D gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004=0D =0D -## FFS filename to find the shell application.=0D -gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E,= 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }|VOID*|0= x10000005=0D -=0D ## Used to help reduce fragmentation in the EFI memory map=0D gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0x19|UINT3= 2|0x10000012=0D gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0x04|UINT32|0x= 10000013=0D --=20 2.39.1.windows.1