[edk2-devel][edk2-platforms][PATCH V1 1/2] WhitleySiliconPkg/FspWrapperPlatformLib: Update for large variables

Chiu, Chasel chasel.chiu at intel.com
Fri Sep 17 00:14:50 UTC 2021


Reviewed-by: Chasel Chiu <chasel.chiu at intel.com>

> -----Original Message-----
> From: Oram, Isaac W <isaac.w.oram at intel.com>
> Sent: Thursday, September 16, 2021 3:05 AM
> To: devel at edk2.groups.io
> Cc: Desimone, Nathaniel L <nathaniel.l.desimone at intel.com>; Chiu, Chasel
> <chasel.chiu at intel.com>
> Subject: [edk2-devel][edk2-platforms][PATCH V1 1/2]
> WhitleySiliconPkg/FspWrapperPlatformLib: Update for large variables
> 
> Update to utilize the larger variables.
> 
> Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
> Cc: Chasel Chiu <chasel.chiu at intel.com>
> Signed-off-by: Isaac Oram <isaac.w.oram at intel.com>
> ---
> 
> Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlat
> formLib.c   | 83 +++++++-------------
> 
> Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlat
> formLib.inf | 12 +--
>  2 files changed, 35 insertions(+), 60 deletions(-)
> 
> diff --git
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl
> atformLib.c
> b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl
> atformLib.c
> index 453e409523..a6196a78b0 100644
> ---
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl
> atformLib.c
> +++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspW
> +++ rapperPlatformLib.c
> @@ -10,76 +10,52 @@
>  #include <PiPei.h>
>  #include <Library/PeiServicesLib.h>
>  #include <Library/DebugLib.h>
> -#include <FspmUpd.h>
> -#include <Ppi/UpiPolicyPpi.h>
> -#include <Guid/PlatformInfo.h>
>  #include <Library/HobLib.h>
> -#include <Ppi/ReadOnlyVariable2.h>
>  #include <Library/MemoryAllocationLib.h>
> +#include <Library/LargeVariableReadLib.h>
> +
> +#include <FspmUpd.h>
> +#include <Guid/PlatformInfo.h>
> +#include <Ppi/UpiPolicyPpi.h>
> 
>  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/FspWrapperPl
> atformLib.inf
> b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl
> atformLib.inf
> index 625337c453..3e80ea670c 100644
> ---
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl
> atformLib.inf
> +++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspW
> +++ rapperPlatformLib.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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80834): https://edk2.groups.io/g/devel/message/80834
Mute This Topic: https://groups.io/mt/85635751/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list