[edk2-devel] [edk2-platforms: PATCH v3 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob.

Chiu, Chasel posted 9 patches 4 years, 4 months ago
There is a newer version of this series
[edk2-devel] [edk2-platforms: PATCH v3 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob.
Posted by Chiu, Chasel 4 years, 4 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3678

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c   | 35 +++++++++--------------------------
 Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf |  3 ++-
 2 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c
index a6196a78b0..95a1f2a33c 100644
--- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c
+++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c
@@ -13,7 +13,7 @@
 #include <Library/HobLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/LargeVariableReadLib.h>
-
+#include <Library/PeiLib.h>
 #include <FspmUpd.h>
 #include <Guid/PlatformInfo.h>
 #include <Ppi/UpiPolicyPpi.h>
@@ -24,39 +24,22 @@ GetFspNvsBuffer (
 )
 {
   EFI_STATUS          Status;
-  UINTN                     FspNvsBufferSize;
-  VOID                      *FspNvsBufferPtr;
+  UINTN               FspNvsBufferSize;
+  VOID                *FspNvsBufferPtr;
 
   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;
-  }
-    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;
-  }
-
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+  if (Status == EFI_SUCCESS) {
     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);
-  }
-
+    DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does not exist (this is likely a first boot)\n"));
     return NULL;
   }
 
+
+}
+
 VOID
 EFIAPI
 UpdateFspmUpdData (
diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf
index 3e80ea670c..6ee15ea55f 100644
--- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf
+++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf
@@ -58,11 +58,12 @@
 
 [Guids]
   gEfiPlatformInfoGuid
-  gFspNonVolatileStorageHobGuid
+  gFspNvsBufferVariableGuid      # CONSUMES
 
 [LibraryClasses]
   PeiServicesLib
   LargeVariableReadLib
+  PeiLib
 
 [Pcd]
   gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase         ## CONSUMES
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81666): https://edk2.groups.io/g/devel/message/81666
Mute This Topic: https://groups.io/mt/86164713/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [edk2-platforms: PATCH v3 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob.
Posted by Nate DeSimone 4 years, 4 months ago
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

> -----Original Message-----
> From: Chiu, Chasel <chasel.chiu@intel.com>
> Sent: Thursday, October 7, 2021 11:43 PM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Oram, Isaac W
> <isaac.w.oram@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>
> Subject: [edk2-platforms: PATCH v3 9/9] WhitleySiliconPkg: Use same
> variable name for FspNvsHob.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3678
> 
> To simplify the implementation the variable Name/GUID has been changed
> to "FspNvsBuffer" and gFspNvsBufferVariableGuid regardless it stores the
> data from FSP_NON_VOLATILE_STORAGE_HOB2 or
> FSP_NON_VOLATILE_STORAGE_HOB.
> 
> Cc: Isaac Oram <isaac.w.oram@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
> 
> Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapper
> PlatformLib.c   | 35 +++++++++--------------------------
> 
> Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapper
> PlatformLib.inf |  3 ++-
>  2 files changed, 11 insertions(+), 27 deletions(-)
> 
> diff --git
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapp
> erPlatformLib.c
> b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapp
> erPlatformLib.c
> index a6196a78b0..95a1f2a33c 100644
> ---
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapp
> erPlatformLib.c
> +++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspW
> +++ rapperPlatformLib.c
> @@ -13,7 +13,7 @@
>  #include <Library/HobLib.h> #include <Library/MemoryAllocationLib.h>
> #include <Library/LargeVariableReadLib.h>-+#include <Library/PeiLib.h>
> #include <FspmUpd.h> #include <Guid/PlatformInfo.h> #include
> <Ppi/UpiPolicyPpi.h>@@ -24,39 +24,22 @@ GetFspNvsBuffer (
>  ) {   EFI_STATUS          Status;-  UINTN                     FspNvsBufferSize;-  VOID
> *FspNvsBufferPtr;+  UINTN               FspNvsBufferSize;+  VOID
> *FspNvsBufferPtr;    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;-  }-    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;-  }-+  Status =
> PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid,
> &FspNvsBufferPtr, &FspNvsBufferSize);+  if (Status == EFI_SUCCESS) {
> 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);-  }-+    DEBUG ((DEBUG_INFO, "Cannot create
> FSP NVS Buffer, UEFI variable does not exist (this is likely a first boot)\n"));
> return NULL;   } ++}+ VOID EFIAPI UpdateFspmUpdData (diff --git
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapp
> erPlatformLib.inf
> b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapp
> erPlatformLib.inf
> index 3e80ea670c..6ee15ea55f 100644
> ---
> a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapp
> erPlatformLib.inf
> +++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspW
> +++ rapperPlatformLib.inf
> @@ -58,11 +58,12 @@
>   [Guids]   gEfiPlatformInfoGuid-  gFspNonVolatileStorageHobGuid+
> gFspNvsBufferVariableGuid      # CONSUMES  [LibraryClasses]   PeiServicesLib
> LargeVariableReadLib+  PeiLib  [Pcd]
> gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase         ## CONSUMES--
> 2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81776): https://edk2.groups.io/g/devel/message/81776
Mute This Topic: https://groups.io/mt/86164713/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-