From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.857.1631732689591917140 for ; Wed, 15 Sep 2021 12:04:51 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: isaac.w.oram@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="222068170" X-IronPort-AV: E=Sophos;i="5.85,296,1624345200"; d="scan'208";a="222068170" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2021 12:04:51 -0700 X-IronPort-AV: E=Sophos;i="5.85,296,1624345200"; d="scan'208";a="482456696" 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 Sep 2021 12:04:51 -0700 From: "Oram, Isaac W" To: devel@edk2.groups.io Cc: Nate DeSimone , Chasel Chiu Subject: [edk2-devel][edk2-platforms][PATCH V1 1/2] WhitleySiliconPkg/FspWrapperPlatformLib: Update for large variables Date: Wed, 15 Sep 2021 12:04:40 -0700 Message-Id: <00401ec51bcef4ff40a74c1a1c623ccf808328a9.1631730773.git.isaac.w.oram@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Update to utilize the larger variables. Cc: Nate DeSimone Cc: Chasel Chiu Signed-off-by: Isaac Oram --- Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c | 83 +++++++------------- Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf | 12 +-- 2 files changed, 35 insertions(+), 60 deletions(-) diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c index 453e409523..a6196a78b0 100644 --- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c +++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c @@ -10,76 +10,52 @@ #include #include #include -#include -#include -#include #include -#include #include +#include + +#include +#include +#include VOID * -GetPlatformNvs( +GetFspNvsBuffer ( + VOID ) { EFI_STATUS Status; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *PeiVariable; - VOID *DataBuffer; - UINT32 DataBufferSize; - UINTN VarAttrib; - CHAR16 EfiMemoryConfigVariable[] = L"MemoryConfig"; + UINTN FspNvsBufferSize; + VOID *FspNvsBufferPtr; - DEBUG ((EFI_D_INFO, "Start PlatformGetNvs\n")); - - Status = PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, - 0, - NULL, - (VOID **) &PeiVariable - ); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "PlatformGetNvs: PeiServicesLocatePpi not found\n")); + FspNvsBufferPtr = NULL; + FspNvsBufferSize = 0; + Status = GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, &FspNvsBufferSize, NULL); + if (Status == EFI_BUFFER_TOO_SMALL) { + DEBUG ((DEBUG_INFO, "FspNvsBuffer Size = %d\n", FspNvsBufferSize)); + FspNvsBufferPtr = AllocateZeroPool (FspNvsBufferSize); + if (FspNvsBufferPtr == NULL) { + DEBUG ((DEBUG_ERROR, "Error: Cannot create FspNvsBuffer, out of memory!\n")); ASSERT (FALSE); return NULL; } - - VarAttrib = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS; - DataBufferSize = 0; - DataBuffer = NULL; - - Status = PeiVariable->GetVariable ( - PeiVariable, - EfiMemoryConfigVariable, - &gFspNonVolatileStorageHobGuid, - (UINT32*)&VarAttrib, - &DataBufferSize, - NULL - ); - if (Status == EFI_NOT_FOUND) { - DEBUG ((EFI_D_ERROR, "PlatformGetNvs: gEfiMemoryConfigDataGuid Variable not found\n")); + Status = GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, &FspNvsBufferSize, FspNvsBufferPtr); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variable Status: %r\n", Status)); + ASSERT_EFI_ERROR (Status); return NULL; } - if (Status != EFI_BUFFER_TOO_SMALL) { - DEBUG ((EFI_D_ERROR, "PlatformGetNvs: gEfiMemoryConfigDataGuid Get Error %r\n", Status)); - ASSERT (FALSE); + return FspNvsBufferPtr; + + } else if (Status == EFI_NOT_FOUND) { + DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does not exist (this is likely a first boot)\n")); + } else { + DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variable Status: %r\n", Status)); + ASSERT_EFI_ERROR (Status); } - DataBuffer = AllocateZeroPool(DataBufferSize); - Status = PeiVariable->GetVariable ( - PeiVariable, - EfiMemoryConfigVariable, - &gFspNonVolatileStorageHobGuid, - (UINT32*)&VarAttrib, - &DataBufferSize, - DataBuffer - ); - if (EFI_ERROR(Status)) { - DEBUG ((EFI_D_ERROR, "PlatformGetNvs: gEfiMemoryConfigDataGuid Variable Error %r\n", Status)); return NULL; } - DEBUG ((EFI_D_INFO, "PlatformGetNvs: GetNVS %x %x\n", DataBuffer, DataBufferSize)); - return DataBuffer; -} VOID EFIAPI @@ -164,11 +140,10 @@ UpdateFspmUpdData ( FspmUpd->FspmConfig.AllLanesSizeOfTable = Upi->AllLanesSizeOfTable; FspmUpd->FspmConfig.PerLaneSizeOfTable = Upi->PerLaneSizeOfTable; FspmUpd->FspmConfig.WaitTimeForPSBP = Upi->WaitTimeForPSBP; - FspmUpd->FspmConfig.IsKtiNvramDataReady = Upi->IsKtiNvramDataReady; FspmUpd->FspmConfig.WaSerializationEn = Upi->WaSerializationEn; FspmUpd->FspmConfig.KtiInEnableMktme = Upi->KtiInEnableMktme; FspmUpd->FspmConfig.BoardId = PlatformInfo->BoardId; - FspmUpd->FspmArchUpd.NvsBufferPtr = GetPlatformNvs(); + FspmUpd->FspmArchUpd.NvsBufferPtr = GetFspNvsBuffer (); } /** diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf index 625337c453..3e80ea670c 100644 --- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf +++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf @@ -35,7 +35,6 @@ [Sources] FspWrapperPlatformLib.c - ################################################################################ # # Package Dependency Section - list of Package files that are required for @@ -47,11 +46,11 @@ MdePkg/MdePkg.dec IntelFsp2Pkg/IntelFsp2Pkg.dec IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec - WhitleySiliconPkg/WhitleySiliconPkg.dec + MinPlatformPkg/MinPlatformPkg.dec WhitleySiliconPkg/SiliconPkg.dec WhitleySiliconPkg/CpRcPkg.dec - WhitleyOpenBoardPkg/PlatformPkg.dec - CedarIslandFspBinPkg/CedarIslandFspBinPkg.dec + WhitleyOpenBoardPkg/PlatformPkg.dec # For LargeVariableReadLib + WhitleyFspBinPkg/WhitleyFspBinPkg.dec [Ppis] gUpiSiPolicyPpiGuid @@ -63,9 +62,10 @@ [LibraryClasses] PeiServicesLib + LargeVariableReadLib [Pcd] gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase ## CONSUMES - gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamSize - gIntelFsp2PkgTokenSpaceGuid.PcdFspTemporaryRamSize + gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamSize ## CONSUMES + gIntelFsp2PkgTokenSpaceGuid.PcdFspTemporaryRamSize ## CONSUMES gEfiCpRcPkgTokenSpaceGuid.PcdPeiTemporaryRamRcHeapSize ## CONSUMES -- 2.27.0.windows.1