From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.3341.1634333146761283299 for ; Fri, 15 Oct 2021 14:25:47 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: isaac.w.oram@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="314187536" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="314187536" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 14:25:47 -0700 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="492709807" Received: from iworam-desk.amr.corp.intel.com ([10.7.150.79]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 14:25:44 -0700 From: "Oram, Isaac W" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Liming Gao , Eric Dong Subject: [edk2-devel][edk2-platforms][PATCH V1 09/11] MinPlatformPkg/SpifvbService: Publish FV based on board request Date: Fri, 15 Oct 2021 14:25:32 -0700 Message-Id: X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Change MM reporting to use ReportFvLib API ReportMmFv (); This removed the hardcoded table of FV to publish. Also removed the unused "default" table. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Isaac Oram --- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c | 16 -------- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h | 7 ---- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c | 41 ++++++++++++-------- Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf | 1 + Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf | 1 + 5 files changed, 27 insertions(+), 39 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c index 113c749d04..b8a255dbf4 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c @@ -15,22 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // FVB_GLOBAL mFvbModuleGlobal; -// -// This platform driver knows there are multiple FVs on FD. -// Now we only provide FVs on Variable region and MicorCode region for performance issue. -// -FV_INFO mPlatformFvBaseAddress[] = { - {0, 0}, // {FixedPcdGet32(PcdFlashNvStorageVariableBase), FixedPcdGet32(PcdFlashNvStorageVariableSize)}, - {0, 0}, // {FixedPcdGet32(PcdFlashFvMicrocodeBase), FixedPcdGet32(PcdFlashFvMicrocodeSize)}, - {0, 0} -}; - -FV_INFO mPlatformDefaultBaseAddress[] = { - {0, 0}, // {FixedPcdGet32(PcdFlashNvStorageVariableBase), FixedPcdGet32(PcdFlashNvStorageVariableSize)}, - {0, 0}, // {FixedPcdGet32(PcdFlashFvMicrocodeBase), FixedPcdGet32(PcdFlashFvMicrocodeSize)}, - {0, 0} -}; - FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = { { { diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h index e9d69e9858..d1d61b124f 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h @@ -71,11 +71,6 @@ typedef struct { EFI_DEVICE_PATH_PROTOCOL EndDevPath; } FV_MEMMAP_DEVICE_PATH; -typedef struct { - UINT32 FvBase; - UINT32 FvSize; -} FV_INFO; - // // Protocol APIs // @@ -152,7 +147,5 @@ extern FVB_GLOBAL mFvbModuleGlobal; extern FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate; extern FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate; extern EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL mFvbProtocolTemplate; -extern FV_INFO mPlatformFvBaseAddress[]; -extern FV_INFO mPlatformDefaultBaseAddress[]; #endif diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c index 016f19587c..1d8d55b8f2 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c @@ -11,6 +11,7 @@ #include "SpiFvbServiceCommon.h" #include #include +#include #include /** @@ -97,8 +98,12 @@ InstallFvbProtocol ( The function does the necessary initialization work for Firmware Volume Block Driver. + @param VOID + + @retval EFI_SUCCESS The driver initialized successfully. + @retval EFI_UNSUPPORTED The driver failed to initialize properly. **/ -VOID +EFI_STATUS FvbInitialize ( VOID ) @@ -113,15 +118,17 @@ FvbInitialize ( UINT32 MaxLbaSize; UINT32 BytesWritten; UINTN BytesErased; + FV_INFO *BoardFvInfoTablePtr; - mPlatformFvBaseAddress[0].FvBase = PcdGet32(PcdFlashNvStorageVariableBase); - mPlatformFvBaseAddress[0].FvSize = PcdGet32(PcdFlashNvStorageVariableSize); - mPlatformFvBaseAddress[1].FvBase = PcdGet32(PcdFlashFvMicrocodeBase); - mPlatformFvBaseAddress[1].FvSize = PcdGet32(PcdFlashFvMicrocodeSize); - mPlatformDefaultBaseAddress[0].FvBase = PcdGet32(PcdFlashNvStorageVariableBase); - mPlatformDefaultBaseAddress[0].FvSize = PcdGet32(PcdFlashNvStorageVariableSize); - mPlatformDefaultBaseAddress[1].FvBase = PcdGet32(PcdFlashFvMicrocodeBase); - mPlatformDefaultBaseAddress[1].FvSize = PcdGet32(PcdFlashFvMicrocodeSize); + // + // Retrieve the FV Info from the board library + // + BoardFvInfoTablePtr = NULL; + ReportMmFv (&BoardFvInfoTablePtr); + if (!BoardFvInfoTablePtr) { + ASSERT (BoardFvInfoTablePtr != NULL); + return EFI_UNSUPPORTED; + } // // We will only continue with FVB installation if the @@ -132,11 +139,11 @@ FvbInitialize ( // Make sure all FVB are valid and/or fix if possible // for (Idx = 0;; Idx++) { - if (mPlatformFvBaseAddress[Idx].FvSize == 0 && mPlatformFvBaseAddress[Idx].FvBase == 0) { + if (BoardFvInfoTablePtr[Idx].FvSize == 0 && BoardFvInfoTablePtr[Idx].FvBase == 0) { break; } - BaseAddress = mPlatformFvBaseAddress[Idx].FvBase; + BaseAddress = BoardFvInfoTablePtr[Idx].FvBase; FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; if (!IsFvHeaderValid (BaseAddress, FvHeader)) { @@ -192,10 +199,10 @@ FvbInitialize ( // BufferSize = 0; for (Idx = 0; ; Idx++) { - if (mPlatformFvBaseAddress[Idx].FvSize == 0 && mPlatformFvBaseAddress[Idx].FvBase == 0) { + if (BoardFvInfoTablePtr[Idx].FvSize == 0 && BoardFvInfoTablePtr[Idx].FvBase == 0) { break; } - BaseAddress = mPlatformFvBaseAddress[Idx].FvBase; + BaseAddress = BoardFvInfoTablePtr[Idx].FvBase; FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; if (!IsFvHeaderValid (BaseAddress, FvHeader)) { @@ -212,7 +219,7 @@ FvbInitialize ( mFvbModuleGlobal.FvbInstance = (EFI_FVB_INSTANCE *) AllocateRuntimeZeroPool (BufferSize); if (mFvbModuleGlobal.FvbInstance == NULL) { ASSERT (FALSE); - return; + return EFI_SUCCESS; } MaxLbaSize = 0; @@ -220,10 +227,10 @@ FvbInitialize ( mFvbModuleGlobal.NumFv = 0; for (Idx = 0; ; Idx++) { - if (mPlatformFvBaseAddress[Idx].FvSize == 0 && mPlatformFvBaseAddress[Idx].FvBase == 0) { + if (BoardFvInfoTablePtr[Idx].FvSize == 0 && BoardFvInfoTablePtr[Idx].FvBase == 0) { break; } - BaseAddress = mPlatformFvBaseAddress[Idx].FvBase; + BaseAddress = BoardFvInfoTablePtr[Idx].FvBase; FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress; if (!IsFvHeaderValid (BaseAddress, FvHeader)) { @@ -268,4 +275,6 @@ FvbInitialize ( } } + + return EFI_SUCCESS; } diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf index 10e51e1175..7b69bedcdc 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf @@ -34,6 +34,7 @@ UefiDriverEntryPoint SpiFlashCommonLib MmServicesTableLib + ReportFvLib [Packages] MdePkg/MdePkg.dec diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf index 9f08d3673f..1dfb2520e7 100644 --- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf +++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf @@ -33,6 +33,7 @@ MmServicesTableLib SpiFlashCommonLib StandaloneMmDriverEntryPoint + ReportFvLib [Packages] MdePkg/MdePkg.dec -- 2.27.0.windows.1