[edk2-devel] [edk2-platforms: PATCH v5 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel chasel.chiu at intel.com
Thu Oct 14 09:16:21 UTC 2021


REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3678

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit.

Cc: Isaac Oram <isaac.w.oram at intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu at intel.com>
Reviewed-by: Nate DeSimone <nathaniel.l.desimone at intel.com>
---
 Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c   | 29 +++++++++++++++++++++++------
 Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf |  4 +++-
 Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc                          |  1 +
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c
index 709c7ad479..01e36cda27 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c
+++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c
@@ -7,6 +7,7 @@
 **/
 
 #include "S3NvramSave.h"
+#include <Guid/FspNonVolatileStorageHob2.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/LargeVariableReadLib.h>
 #include <Library/LargeVariableWriteLib.h>
@@ -80,21 +81,37 @@ SaveFspNonVolatileStorageHob (
   Status            = EFI_SUCCESS;
 
   DEBUG ((DEBUG_INFO, "Saving FSP / MRC Training Data\n"));
-  GuidHob = GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);
+  //
+  // Firstly check version2 FspNvsHob.
+  //
+  GuidHob = GetFirstGuidHob (&gFspNonVolatileStorageHob2Guid);
   if (GuidHob != NULL) {
-    HobData  = GET_GUID_HOB_DATA (GuidHob);
-    DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
+    HobData = (VOID *) (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsDataPtr;
+    DataSize = (UINTN) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsDataLength;
+  } else {
+    //
+    // Fall back to version1 FspNvsHob
+    //
+    GuidHob = GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);
+    if (GuidHob != NULL) {
+      HobData  = GET_GUID_HOB_DATA (GuidHob);
+      DataSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
+    }
+  }
+  if (HobData != NULL) {
+    DEBUG ((DEBUG_INFO, "FspNvsHob.Size:       %d\n",   DataSize));
+    DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr: 0x%x\n", HobData));
     if (DataSize > 0) {
 
       //
       // Check if the presently saved data is identical to the data given by MRC/FSP
       //
-      Status = GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, &FspNvsBufferSize, NULL);
+      Status = GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferSize, NULL);
       if (Status == EFI_BUFFER_TOO_SMALL) {
         if (FspNvsBufferSize == DataSize) {
           VariableData = AllocatePool (FspNvsBufferSize);
           if (VariableData != NULL) {
-            Status = GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, &FspNvsBufferSize, VariableData);
+            Status = GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferSize, VariableData);
             if (!EFI_ERROR (Status) && (FspNvsBufferSize == DataSize) && (0 == CompareMem (HobData, VariableData, DataSize))) {
               DataIsIdentical = TRUE;
             }
@@ -105,7 +122,7 @@ SaveFspNonVolatileStorageHob (
       Status = EFI_SUCCESS;
 
       if (!DataIsIdentical) {
-        Status = SetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHobGuid, TRUE, DataSize, HobData);
+        Status = SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, TRUE, DataSize, HobData);
         ASSERT_EFI_ERROR (Status);
         DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n", DataSize));
       } else {
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf
index e62baa24c4..a77125cf44 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf
+++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf
@@ -43,7 +43,9 @@
   LargeVariableWriteLib
 
 [Guids]
-  gFspNonVolatileStorageHobGuid # CONSUMES
+  gFspNonVolatileStorageHobGuid  # CONSUMES
+  gFspNonVolatileStorageHob2Guid # CONSUMES
+  gFspNvsBufferVariableGuid      # PRODUCES
 
 [Pcd]
   gEfiCpRcPkgTokenSpaceGuid.PcdPeiSyshostMemorySize
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
index dc3dd0e026..87165103bf 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
+++ b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
@@ -637,6 +637,7 @@
 
 [LibraryClasses.Common]
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+  PeiLib|MinPlatformPkg/Library/PeiLib/PeiLib.inf
 
 [Components.IA32]
   UefiCpuPkg/SecCore/SecCore.inf
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82019): https://edk2.groups.io/g/devel/message/82019
Mute This Topic: https://groups.io/mt/86308180/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