public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
@ 2021-10-08  5:14 Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 1/9] " Chiu, Chasel
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Isaac Oram, Nate DeSimone, Heng Luo, Jeremy Soller,
	Benjamin Doron, Rangasai V Chaganty, Deepika Kethi Reddy,
	Kathappan Esakkithevar, Liming Gao, Eric Dong

V2:
Fix GCC build failures.

V1:
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@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Heng Luo <heng.luo@intel.com>
Cc: Jeremy Soller <jeremy@system76.com>
Cc: Benjamin Doron <benjamin.doron00@gmail.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Cc: Deepika Kethi Reddy <deepika.kethi.reddy@intel.com>
Cc: Kathappan Esakkithevar <kathappan.esakkithevar@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>

Chasel Chiu (9):
  MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
  CometlakeOpenBoardPkg: Use same variable name for FspNvsHob.
  KabylakeOpenBoardPkg/AspireVn7Dash572G:Use same variable name for
    FspNvsHob
  KabylakeOpenBoardPkg/GalagoPro3: Use same variable name for FspNvsHob.
  KabylakeOpenBoardPkg/KabylakeRvp3: Use same variable name for
    FspNvsHob.
  TigerlakeOpenBoardPkg: Use same variable name for FspNvsHob.
  WhiskeylakeOpenBoardPkg: Use same variable name for FspNvsHob.
  WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
  WhitleySiliconPkg: Use same variable name for FspNvsHob.

 Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c                          | 63 ++++++++++++++-------------------------------------------------
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c         | 24 ++++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c             | 23 +++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c                | 24 ++++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c              | 25 ++++++++++---------------
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c                  | 23 +++++++++--------------
 Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c                                                           | 39 ++++++++++++++++++++++++++++-----------
 Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c                                                                                  | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c                                      | 21 ++++++++++++++++++---
 Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c                        | 63 ++++++++++++---------------------------------------------------
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c               | 63 ++++++++++++---------------------------------------------------
 Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c                                                              | 29 +++++++++++++++++++++++------
 Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c                                                  | 35 +++++++++--------------------------
 Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc                                                                    |  3 +++
 Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf                  |  5 ++---
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf |  7 ++++---
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf           |  2 +-
 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf        |  5 ++---
 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc                                                                        |  3 +++
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf      |  5 ++---
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf                |  2 +-
 Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf                                                         |  5 ++++-
 Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h                                                                                 | 33 ++++++++++++++++++++++++++++++++-
 Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf                                                                                |  4 +++-
 Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec                                                                                       |  1 +
 Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf                                    |  1 +
 Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc                                                                    |  3 +++
 Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf                |  5 ++---
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf       |  4 ++--
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf                                                        | 18 +++++++++---------
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc                                                                       |  3 +++
 Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc                                                                |  3 +++
 Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf                                                            |  4 +++-
 Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc                                                                                     |  1 +
 Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf                                                |  3 ++-
 35 files changed, 319 insertions(+), 302 deletions(-)

-- 
2.28.0.windows.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 1/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
@ 2021-10-08  5:14 ` Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 2/9] CometlakeOpenBoardPkg: Use same variable name for FspNvsHob Chiu, Chasel
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone, Liming Gao, Eric Dong

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: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c   | 39 ++++++++++++++++++++++++++++-----------
 Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c                          | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf |  5 ++++-
 Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h                         | 33 ++++++++++++++++++++++++++++++++-
 Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf                        |  4 +++-
 Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec                               |  1 +
 6 files changed, 136 insertions(+), 15 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c
index 41ed2550bd..497c2cffb8 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c
@@ -2,7 +2,7 @@
   This is the driver that locates the MemoryConfigurationData HOB, if it
   exists, and saves the data to nvRAM.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/MemoryAllocationLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Protocol/VariableLock.h>
+#include <Guid/FspNonVolatileStorageHob2.h>
 
 /**
   This is the standard EFI driver point that detects whether there is a
@@ -50,11 +51,27 @@ SaveMemoryConfigEntryPoint (
   //
   // Search for the Memory Configuration GUID HOB.  If it is not present, then
   // there's nothing we can do. It may not exist on the update path.
+  // Firstly check version2 FspNvsHob.
   //
-  GuidHob = GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);
+  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 = ((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.NvsDataLength:%d\n", DataSize));
+    DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr   : 0x%x\n", HobData));
+
     if (DataSize > 0) {
       //
       // Use the HOB to save Memory Configuration Data
@@ -65,8 +82,8 @@ SaveMemoryConfigEntryPoint (
         return EFI_UNSUPPORTED;
       }
       Status = gRT->GetVariable (
-                      L"MemoryConfig",
-                      &gFspNonVolatileStorageHobGuid,
+                      L"FspNvsBuffer",
+                      &gFspNvsBufferVariableGuid,
                       NULL,
                       &BufferSize,
                       VariableData
@@ -80,8 +97,8 @@ SaveMemoryConfigEntryPoint (
         }
 
         Status = gRT->GetVariable (
-                        L"MemoryConfig",
-                        &gFspNonVolatileStorageHobGuid,
+                        L"FspNvsBuffer",
+                        &gFspNvsBufferVariableGuid,
                         NULL,
                         &BufferSize,
                         VariableData
@@ -90,8 +107,8 @@ SaveMemoryConfigEntryPoint (
 
       if ( (EFI_ERROR(Status)) || BufferSize != DataSize || 0 != CompareMem (HobData, VariableData, DataSize)) {
         Status = gRT->SetVariable (
-                        L"MemoryConfig",
-                        &gFspNonVolatileStorageHobGuid,
+                        L"FspNvsBuffer",
+                        &gFspNvsBufferVariableGuid,
                         (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),
                         DataSize,
                         HobData
@@ -106,7 +123,7 @@ SaveMemoryConfigEntryPoint (
       //
       Status = gBS->LocateProtocol(&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLock);
       if (!EFI_ERROR(Status)) {
-        Status = VariableLock->RequestToLock(VariableLock, L"MemoryConfig", &gFspNonVolatileStorageHobGuid);
+        Status = VariableLock->RequestToLock(VariableLock, L"FspNvsBuffer", &gFspNvsBufferVariableGuid);
         ASSERT_EFI_ERROR(Status);
       }
 
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
index 96dfd588dc..9e92387761 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/PeiServicesLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/LargeVariableReadLib.h>
 #include <Ppi/ReadOnlyVariable2.h>
 
 /**
@@ -108,6 +109,72 @@ PeiGetVariable (
   return Status;
 }
 
+/**
+  Returns the status whether get the large variable success. When variable size
+  is bigger than single UEFI variable size limit, The variable will be saved in
+  multiple UEFI variables. This function retrieves such large variable through the
+  ReadOnlyVariable2 PPI GetVariable().
+  The returned buffer is allocated using AllocatePage() to support > 64KB and this
+  buffer cannot be Free().
+
+  If Name  is NULL, then ASSERT().
+  If Guid  is NULL, then ASSERT().
+  If Value is NULL, then ASSERT().
+
+  @param[in]  Name  The pointer to a Null-terminated Unicode string.
+  @param[in]  Guid  The pointer to an EFI_GUID structure
+  @param[out] Value The buffer point saved the variable info.
+  @param[out] Size  The buffer size of the variable.
+
+  @return EFI_OUT_OF_RESOURCES      Allocate buffer failed.
+  @return EFI_SUCCESS               Find the specified variable.
+  @return Others Errors             Return errors from call to gRT->GetVariable.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiGetLargeVariable (
+  IN  CHAR16    *Name,
+  IN  EFI_GUID  *Guid,
+  OUT VOID      **Value,
+  OUT UINTN     *Size  OPTIONAL
+  )
+{
+  EFI_STATUS                        Status;
+  UINTN                             VariableSize;
+  VOID                              *VariableData;
+
+  ASSERT (Name != NULL);
+  ASSERT (Guid != NULL);
+  ASSERT (Value != NULL);
+
+  VariableSize = 0;
+  VariableData = NULL;
+  Status = GetLargeVariable (Name, Guid, &VariableSize, NULL);
+  if (Status == EFI_BUFFER_TOO_SMALL) {
+    VariableData = AllocatePages (EFI_SIZE_TO_PAGES (VariableSize));
+    if (VariableData == NULL) {
+      DEBUG ((DEBUG_ERROR, "Error: Cannot create VariableData, out of memory!\n"));
+      ASSERT (FALSE);
+      return EFI_OUT_OF_RESOURCES;
+    }
+    Status = GetLargeVariable (Name, Guid, &VariableSize, VariableData);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Error: Unable to read UEFI variable Status: %r\n", Status));
+      ASSERT_EFI_ERROR (Status);
+      return Status;
+    }
+    if (Value != NULL) {
+      *Value = VariableData;
+    }
+    if (Size != NULL) {
+      *Size = VariableSize;
+    }
+    return EFI_SUCCESS;
+  }
+  return Status;
+}
+
 EFI_PEI_FILE_HANDLE
 InternalGetFfsHandleFromAnyFv (
   IN CONST  EFI_GUID           *NameGuid
diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
index 0c8689a6f6..eac0880504 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
@@ -1,7 +1,7 @@
 ### @file
 # Component information file for SaveMemoryConfig module
 #
-# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -28,6 +28,7 @@
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   IntelFsp2Pkg/IntelFsp2Pkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
 
 [Sources]
   SaveMemoryConfig.c
@@ -39,6 +40,8 @@
 
 [Guids]
   gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNonVolatileStorageHob2Guid                ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## PRODUCES
 
 [Depex]
   gEfiVariableArchProtocolGuid        AND
diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
index d8b1a47c58..86ffb378ec 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -38,6 +38,37 @@ PeiGetVariable (
   OUT UINTN          *Size
   );
 
+/**
+  Returns the status whether get the large variable success. When variable size
+  is bigger than single UEFI variable size limit, The variable will be saved in
+  multiple UEFI variables. This function retrieves such large variable through the
+  ReadOnlyVariable2 PPI GetVariable().
+  The returned buffer is allocated using AllocatePage() to support > 64KB and this
+  buffer cannot be Free().
+
+  If Name  is NULL, then ASSERT().
+  If Guid  is NULL, then ASSERT().
+  If Value is NULL, then ASSERT().
+
+  @param[in]  Name  The pointer to a Null-terminated Unicode string.
+  @param[in]  Guid  The pointer to an EFI_GUID structure
+  @param[out] Value The buffer point saved the variable info.
+  @param[out] Size  The buffer size of the variable.
+
+  @return EFI_OUT_OF_RESOURCES      Allocate buffer failed.
+  @return EFI_SUCCESS               Find the specified variable.
+  @return Others Errors             Return errors from call to gRT->GetVariable.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiGetLargeVariable (
+  IN  CHAR16    *Name,
+  IN  EFI_GUID  *Guid,
+  OUT VOID      **Value,
+  OUT UINTN     *Size  OPTIONAL
+  );
+
 /**
   Finds the file in any FV and gets file Address and Size
   
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
index 7e740172a0..bd57cf7870 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
@@ -1,7 +1,7 @@
 ## @file
 # Component information file for Board Init Test Library
 #
-# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -20,9 +20,11 @@
   PeiServicesLib
   MemoryAllocationLib
   DebugLib
+  LargeVariableReadLib
 
 [Packages]
   MdePkg/MdePkg.dec
+  MinPlatformPkg/MinPlatformPkg.dec
 
 [Sources]
   PeiLib.c
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
index bcb42f0ef9..d6e80a66ce 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -50,6 +50,7 @@
   gBdsEventBeforeConsoleAfterTrustedConsoleGuid  = {0x51e49ff5, 0x28a9, 0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}
   gBdsEventBeforeConsoleBeforeEndOfDxeGuid       = {0xfcf26e41, 0xbda6, 0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}
   gBdsEventAfterConsoleReadyBeforeBootOptionGuid = {0x8eb3d5dc, 0xf4e7, 0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}
+  gFspNvsBufferVariableGuid                      = {0x9c7715cd, 0x8d66, 0x4d2a, { 0x90, 0x0d, 0x01, 0x45, 0x9a, 0x57, 0x59, 0x6b}}
 
 [LibraryClasses]
 
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 2/9] CometlakeOpenBoardPkg: Use same variable name for FspNvsHob.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 1/9] " Chiu, Chasel
@ 2021-10-08  5:14 ` Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 3/9] KabylakeOpenBoardPkg/AspireVn7Dash572G:Use " Chiu, Chasel
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel
  Cc: Chasel Chiu, Nate DeSimone, Rangasai V Chaganty,
	Deepika Kethi Reddy, Kathappan Esakkithevar

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: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Cc: Deepika Kethi Reddy <deepika.kethi.reddy@intel.com>
Cc: Kathappan Esakkithevar <kathappan.esakkithevar@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c         | 63 ++++++++++++++-------------------------------------------------
 Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc                                                   |  3 +++
 Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf |  5 ++---
 3 files changed, 19 insertions(+), 52 deletions(-)

diff --git a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index 7dbdfa7c16..9e8606ada9 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
   Implementation of Fsp Misc UPD Initialization.
 
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -17,7 +17,6 @@
 #include <FspmUpd.h>
 #include <FspsUpd.h>
 
-#include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 #include <Library/PciLib.h>
@@ -44,55 +43,21 @@ PeiFspMiscUpdUpdatePreMem (
   )
 {
   EFI_STATUS                        Status;
-  EFI_PEI_READ_ONLY_VARIABLE2_PPI   *VariableServices;
-  UINTN                             VariableSize;
-  VOID                              *MemorySavedData;
-
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiReadOnlyVariable2PpiGuid,
-             0,
-             NULL,
-             (VOID **) &VariableServices
-             );
-  if (EFI_ERROR (Status)) {
-    ASSERT_EFI_ERROR (Status);
-    return Status;
+  UINTN                             FspNvsBufferSize;
+  VOID                              *FspNvsBufferPtr;
+
+  //
+  // Initialize S3 Data variable (S3DataPtr). It may be used for warm and fast boot paths.
+  //
+  FspNvsBufferPtr   = NULL;
+  FspNvsBufferSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+  if (Status == EFI_SUCCESS) {
+    DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+    DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));
+    FspmUpd->FspmArchUpd.NvsBufferPtr = FspNvsBufferPtr;
   }
 
-  VariableSize = 0;
-  MemorySavedData = NULL;
-  Status = VariableServices->GetVariable (
-                               VariableServices,
-                               L"MemoryConfig",
-                               &gFspNonVolatileStorageHobGuid,
-                               NULL,
-                               &VariableSize,
-                               MemorySavedData
-                               );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    MemorySavedData = AllocatePool (VariableSize);
-    if (MemorySavedData == NULL) {
-      ASSERT (MemorySavedData != NULL);
-      return EFI_OUT_OF_RESOURCES;
-    }
-
-    DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));
-    Status = VariableServices->GetVariable (
-                                 VariableServices,
-                                 L"MemoryConfig",
-                                 &gFspNonVolatileStorageHobGuid,
-                                 NULL,
-                                 &VariableSize,
-                                 MemorySavedData
-                                 );
-    if (Status == EFI_SUCCESS) {
-      FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
-    } else {
-      DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMemoryConfigVariableGuid, Status = %r\n", Status));
-      ASSERT_EFI_ERROR (Status);
-    }
-  }
-  FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
 
   return EFI_SUCCESS;
 }
diff --git a/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc b/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc
index 44a1bd54d6..d63ff263c1 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
   #######################################
   PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookLib.inf
 
+[LibraryClasses.Common.SEC]
+  VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
+
 [LibraryClasses.IA32.SEC]
   #######################################
   # Platform Package
diff --git a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index c842b7eef6..94776603c4 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
 #  Provide FSP wrapper platform related function.
 #
 #
-#  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -82,7 +82,6 @@
   PchInfoLib
   PchHsioLib
   PchPcieRpLib
-  MemoryAllocationLib
   DebugPrintErrorLevelLib
   SiPolicyLib
   PchGbeLib
@@ -132,7 +131,7 @@
   gCometlakeOpenBoardPkgTokenSpaceGuid.PcdMrcSpdAddressTable3
 
 [Guids]
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gTianoLogoGuid                                ## CONSUMES
   gEfiMemoryOverwriteControlDataGuid
 
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 3/9] KabylakeOpenBoardPkg/AspireVn7Dash572G:Use same variable name for FspNvsHob
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 1/9] " Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 2/9] CometlakeOpenBoardPkg: Use same variable name for FspNvsHob Chiu, Chasel
@ 2021-10-08  5:14 ` Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 4/9] KabylakeOpenBoardPkg/GalagoPro3: Use " Chiu, Chasel
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone, Benjamin Doron

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: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Benjamin Doron <benjamin.doron00@gmail.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c         | 24 ++++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c             | 23 +++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf |  7 ++++---
 Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf           |  2 +-
 4 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index d8413d284e..a9b7e446c8 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of Fsp Misc UPD Initialization.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/DebugLib.h>
 #include <Library/PciLib.h>
 #include <Library/PeiLib.h>
-
 #include <FspEas.h>
 #include <FspmUpd.h>
 #include <FspsUpd.h>
@@ -34,24 +33,21 @@ PeiFspMiscUpdUpdatePreMem (
 {
   EFI_STATUS                        Status;
   UINTN                             VariableSize;
-  VOID                              *MemorySavedData;
+  VOID                              *FspNvsBufferPtr;
   UINT8                             MorControl;
   VOID                              *MorControlPtr;
 
   //
   // Initialize S3 Data variable (S3DataPtr). It may be used for warm and fast boot paths.
   //
-  VariableSize = 0;
-  MemorySavedData = NULL;
-  Status = PeiGetVariable (
-             L"MemoryConfig",
-             &gFspNonVolatileStorageHobGuid,
-             &MemorySavedData,
-             &VariableSize
-             );
-  DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid - %r\n", Status));
-  DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));
-  FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
+  FspNvsBufferPtr   = NULL;
+  VariableSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &VariableSize);
+  if (Status == EFI_SUCCESS) {
+    DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+    DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));
+    FspmUpd->FspmArchUpd.NvsBufferPtr = FspNvsBufferPtr;
+  }
 
   if (FspmUpd->FspmArchUpd.NvsBufferPtr != NULL) {
     //
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
index c9dfb17e0a..3764f7c3ac 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
@@ -431,8 +431,8 @@ SiliconPolicyUpdatePreMem (
   SA_MISC_PEI_PREMEM_CONFIG     *MiscPeiPreMemConfig;
   MEMORY_CONFIG_NO_CRC          *MemConfigNoCrc;
   VOID                          *Buffer;
-  UINTN                         VariableSize;
-  VOID                          *MemorySavedData;
+  UINTN                         FspNvsBufferSize;
+  VOID                          *FspNvsBufferPtr;
   UINT8                         SpdAddressTable[4];
 
   DEBUG((DEBUG_INFO, "\nUpdating Policy in Pre-Mem\n"));
@@ -463,18 +463,13 @@ SiliconPolicyUpdatePreMem (
       // Note: AmberLake FSP does not implement the FSPM_ARCH_CONFIG_PPI added in FSP 2.1, hence
       // the platform specific S3DataPtr must be used instead.
       //
-      VariableSize = 0;
-      MemorySavedData = NULL;
-      Status = PeiGetVariable (
-                L"MemoryConfig",
-                &gFspNonVolatileStorageHobGuid,
-                &MemorySavedData,
-                &VariableSize
-                );
-      DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid - %r\n", Status));
-      DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));
-      if (!EFI_ERROR (Status)) {
-        MiscPeiPreMemConfig->S3DataPtr = MemorySavedData;
+      FspNvsBufferPtr   = NULL;
+      FspNvsBufferSize  = 0;
+      Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+      if (Status == EFI_SUCCESS) {
+        DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+        DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));
+        MiscPeiPreMemConfig->S3DataPtr = FspNvsBufferPtr;
       }
 
       //
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index e4a657c5f1..eac9344b0a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Provide FSP wrapper platform related function.
 #
-# Copyright (c) 2017 - 2020 Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2021 Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -74,7 +74,6 @@
   PchInfoLib
   PchHsioLib
   PchPcieRpLib
-  MemoryAllocationLib
   SiPolicyLib
   PeiLib
 
@@ -134,9 +133,11 @@
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAudioConnector
 
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress
+  gKabylakeOpenBoardPkgTokenSpaceGuid.PcdRootPort4ClkInfo
 
 [Guids]
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gTianoLogoGuid                                ## CONSUMES
   gEfiMemoryOverwriteControlDataGuid
 
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
index 0a8cf91b07..4dcc000186 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
@@ -52,7 +52,7 @@
   gHsioPciePreMemConfigGuid                     ## CONSUMES
   gHsioSataPreMemConfigGuid                     ## CONSUMES
   gSaMiscPeiPreMemConfigGuid                    ## CONSUMES
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gIoApicConfigGuid                             ## CONSUMES
   gHpetPreMemConfigGuid                         ## CONSUMES
   gLockDownConfigGuid
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 4/9] KabylakeOpenBoardPkg/GalagoPro3: Use same variable name for FspNvsHob.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
                   ` (2 preceding siblings ...)
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 3/9] KabylakeOpenBoardPkg/AspireVn7Dash572G:Use " Chiu, Chasel
@ 2021-10-08  5:14 ` Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 5/9] KabylakeOpenBoardPkg/KabylakeRvp3: " Chiu, Chasel
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone, Jeremy Soller

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: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c         | 24 ++++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf |  5 ++---
 Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc                                                                 |  3 +++
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index 9d6c0176f6..2158eb299f 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of Fsp Misc UPD Initialization.
 
-Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <FspmUpd.h>
 #include <FspsUpd.h>
 
-#include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 #include <Library/PciLib.h>
@@ -38,24 +37,21 @@ PeiFspMiscUpdUpdatePreMem (
 {
   EFI_STATUS                        Status;
   UINTN                             VariableSize;
-  VOID                              *MemorySavedData;
+  VOID                              *FspNvsBufferPtr;
   UINT8                             MorControl;
   VOID                              *MorControlPtr;
 
   //
   // Initialize S3 Data variable (S3DataPtr). It may be used for warm and fast boot paths.
   //
-  VariableSize = 0;
-  MemorySavedData = NULL;
-  Status = PeiGetVariable (
-             L"MemoryConfig",
-             &gFspNonVolatileStorageHobGuid,
-             &MemorySavedData,
-             &VariableSize
-             );
-  DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid - %r\n", Status));
-  DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));
-  FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
+  FspNvsBufferPtr   = NULL;
+  VariableSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &VariableSize);
+  if (Status == EFI_SUCCESS) {
+    DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+    DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));
+    FspmUpd->FspmArchUpd.NvsBufferPtr = FspNvsBufferPtr;
+  }
 
   if (FspmUpd->FspmArchUpd.NvsBufferPtr != NULL) {
     //
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 463455c90b..ceefe7639e 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
 ## @file
 #  FSP wrapper silicon policy update library.
 #
-# Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019 - 2021 Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -81,7 +81,6 @@
   PchInfoLib
   PchHsioLib
   PchPcieRpLib
-  MemoryAllocationLib
   CpuMailboxLib
   DebugPrintErrorLevelLib
   SiPolicyLib
@@ -138,7 +137,7 @@
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid
 
 [Guids]
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gTianoLogoGuid                                ## CONSUMES
   gEfiMemoryOverwriteControlDataGuid
 
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 7f276d3512..299c7f18cd 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -141,6 +141,9 @@
   PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookLib.inf
   SiliconPolicyUpdateLib|$(PROJECT)/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
 
+[LibraryClasses.Common.SEC]
+  VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
+
 [LibraryClasses.IA32.SEC]
   #######################################
   # Edk2 Packages
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 5/9] KabylakeOpenBoardPkg/KabylakeRvp3: Use same variable name for FspNvsHob.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
                   ` (3 preceding siblings ...)
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 4/9] KabylakeOpenBoardPkg/GalagoPro3: Use " Chiu, Chasel
@ 2021-10-08  5:14 ` Chiu, Chasel
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 6/9] TigerlakeOpenBoardPkg: " Chiu, Chasel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone

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: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c         | 25 ++++++++++---------------
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c             | 23 +++++++++--------------
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf |  5 ++---
 Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf           |  2 +-
 4 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index d8aff1960f..699f4297fa 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
 /** @file
   Implementation of Fsp Misc UPD Initialization.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <FspmUpd.h>
 #include <FspsUpd.h>
 
-#include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 #include <Library/PciLib.h>
@@ -38,25 +37,21 @@ PeiFspMiscUpdUpdatePreMem (
 {
   EFI_STATUS                        Status;
   UINTN                             VariableSize;
-  VOID                              *MemorySavedData;
+  VOID                              *FspNvsBufferPtr;
   UINT8                             MorControl;
   VOID                              *MorControlPtr;
 
   //
   // Initialize S3 Data variable (S3DataPtr). It may be used for warm and fast boot paths.
   //
-  VariableSize = 0;
-  MemorySavedData = NULL;
-  Status = PeiGetVariable (
-             L"MemoryConfig",
-             &gFspNonVolatileStorageHobGuid,
-             &MemorySavedData,
-             &VariableSize
-             );
-  DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid - %r\n", Status));
-  DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));
-  FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
-
+  FspNvsBufferPtr   = NULL;
+  VariableSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &VariableSize);
+  if (Status == EFI_SUCCESS) {
+    DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+    DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));
+    FspmUpd->FspmArchUpd.NvsBufferPtr = FspNvsBufferPtr;
+  }
   if (FspmUpd->FspmArchUpd.NvsBufferPtr != NULL) {
     //
     // Set the DISB bit in PCH (DRAM Initialization Scratchpad Bit - GEN_PMCON_A[23]),
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
index 2dce9be63c..22aadc0221 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
@@ -398,8 +398,8 @@ SiliconPolicyUpdatePreMem (
   SA_MISC_PEI_PREMEM_CONFIG     *MiscPeiPreMemConfig;
   MEMORY_CONFIG_NO_CRC          *MemConfigNoCrc;
   VOID                          *Buffer;
-  UINTN                         VariableSize;
-  VOID                          *MemorySavedData;
+  UINTN                         FspNvsBufferSize;
+  VOID                          *FspNvsBufferPtr;
   UINT8                         SpdAddressTable[4];
 
   DEBUG((DEBUG_INFO, "\nUpdating Policy in Pre-Mem\n"));
@@ -430,18 +430,13 @@ SiliconPolicyUpdatePreMem (
       // Note: AmberLake FSP does not implement the FSPM_ARCH_CONFIG_PPI added in FSP 2.1, hence
       // the platform specific S3DataPtr must be used instead.
       //
-      VariableSize = 0;
-      MemorySavedData = NULL;
-      Status = PeiGetVariable (
-                L"MemoryConfig",
-                &gFspNonVolatileStorageHobGuid,
-                &MemorySavedData,
-                &VariableSize
-                );
-      DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid - %r\n", Status));
-      DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));
-      if (!EFI_ERROR (Status)) {
-        MiscPeiPreMemConfig->S3DataPtr = MemorySavedData;
+      FspNvsBufferPtr   = NULL;
+      FspNvsBufferSize  = 0;
+      Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+      if (Status == EFI_SUCCESS) {
+        DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+        DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));
+        MiscPeiPreMemConfig->S3DataPtr = FspNvsBufferPtr;
       }
 
       //
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index f8bec0c852..dacec18cd9 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Provide FSP wrapper platform related function.
 #
-# Copyright (c) 2017 - 2020 Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2017 - 2021 Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -80,7 +80,6 @@
   PchInfoLib
   PchHsioLib
   PchPcieRpLib
-  MemoryAllocationLib
   CpuMailboxLib
   DebugPrintErrorLevelLib
   SiPolicyLib
@@ -141,7 +140,7 @@
   gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid
 
 [Guids]
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gTianoLogoGuid                                ## CONSUMES
   gEfiMemoryOverwriteControlDataGuid
 
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
index 5c2da68bf9..4b30ba02ea 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
@@ -50,7 +50,7 @@
   gHsioPciePreMemConfigGuid                     ## CONSUMES
   gHsioSataPreMemConfigGuid                     ## CONSUMES
   gSaMiscPeiPreMemConfigGuid                    ## CONSUMES
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
 
 [Pcd]
   gSiPkgTokenSpaceGuid.PcdPeiMinMemorySize
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 6/9] TigerlakeOpenBoardPkg: Use same variable name for FspNvsHob.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
                   ` (4 preceding siblings ...)
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 5/9] KabylakeOpenBoardPkg/KabylakeRvp3: " Chiu, Chasel
@ 2021-10-08  5:14 ` Chiu, Chasel
  2021-10-08  5:15 ` [edk2-platforms: PATCH v2 7/9] WhiskeylakeOpenBoardPkg: " Chiu, Chasel
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:14 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Sai Chaganty, Nate DeSimone, Heng Luo

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: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Heng Luo <heng.luo@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c   | 21 ++++++++++++++++++---
 Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf |  1 +
 Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc                                 |  3 +++
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c
index fc523e93d1..938b74e5d8 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c
@@ -9,7 +9,9 @@
 #include <Library/FspWrapperApiLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/PeiLib.h>
 #include <Ppi/FspmArchConfigPpi.h>
+#include <PolicyUpdateMacro.h>
 
 VOID
 EFIAPI
@@ -70,9 +72,11 @@ SiliconPolicyDonePreMem(
 )
 {
   EFI_STATUS                   Status;
+  UINTN                        FspNvsBufferSize;
+  VOID                         *FspNvsBufferPtr;
 #if FixedPcdGet8(PcdFspModeSelection) == 0
-  FSPM_ARCH_CONFIG_PPI                  *FspmArchConfigPpi;
-  EFI_PEI_PPI_DESCRIPTOR                *FspmArchConfigPpiDesc;
+  FSPM_ARCH_CONFIG_PPI         *FspmArchConfigPpi;
+  EFI_PEI_PPI_DESCRIPTOR       *FspmArchConfigPpiDesc;
 
   FspmArchConfigPpi = (FSPM_ARCH_CONFIG_PPI *) AllocateZeroPool (sizeof (FSPM_ARCH_CONFIG_PPI));
   if (FspmArchConfigPpi == NULL) {
@@ -80,7 +84,6 @@ SiliconPolicyDonePreMem(
     return EFI_OUT_OF_RESOURCES;
   }
   FspmArchConfigPpi->Revision            = 1;
-  FspmArchConfigPpi->NvsBufferPtr        = NULL;
   FspmArchConfigPpi->BootLoaderTolumSize = 0;
 
   FspmArchConfigPpiDesc = (EFI_PEI_PPI_DESCRIPTOR *) AllocateZeroPool (sizeof (EFI_PEI_PPI_DESCRIPTOR));
@@ -98,6 +101,18 @@ SiliconPolicyDonePreMem(
   ASSERT_EFI_ERROR (Status);
 #endif
 
+  //
+  // Initialize S3 Data variable (S3DataPtr). It may be used for warm and fast boot paths.
+  //
+  FspNvsBufferPtr   = NULL;
+  FspNvsBufferSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+  if (Status == EFI_SUCCESS) {
+    DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid - %r\n", Status));
+    DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));
+    UPDATE_POLICY (((FSPM_UPD *) FspmUpd)->FspmArchUpd.NvsBufferPtr, FspmArchConfigPpi->NvsBufferPtr, FspNvsBufferPtr);
+  }
+
   //
   // Install Policy Ready PPI
   // While installed, RC assumes the Policy is ready and finalized. So please
diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf
index 708fbac08f..0236ae45ae 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf
@@ -181,3 +181,4 @@
   gTianoLogoGuid                          ## CONSUMES
   gCnviConfigGuid                         ## CONSUMES
   gHdAudioPreMemConfigGuid                ## CONSUMES
+  gFspNvsBufferVariableGuid               ## CONSUMES
diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc b/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc
index 1adf634034..451492f984 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
   GpioCheckConflictLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Gpio/Library/BaseGpioCheckConflictLibNull/BaseGpioCheckConflictLibNull.inf
 !endif
 
+[LibraryClasses.Common.SEC]
+  VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
+
 [LibraryClasses.IA32.SEC]
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/SecTestPointCheckLib.inf
   TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.inf
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 7/9] WhiskeylakeOpenBoardPkg: Use same variable name for FspNvsHob.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
                   ` (5 preceding siblings ...)
  2021-10-08  5:14 ` [edk2-platforms: PATCH v2 6/9] TigerlakeOpenBoardPkg: " Chiu, Chasel
@ 2021-10-08  5:15 ` Chiu, Chasel
  2021-10-08  5:15 ` [edk2-platforms: PATCH v2 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
  2021-10-08  5:15 ` [edk2-platforms: PATCH v2 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob Chiu, Chasel
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:15 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Nate DeSimone

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: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c                  | 63 ++++++++++++---------------------------------------------------
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c         | 63 ++++++++++++---------------------------------------------------
 Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf          |  5 ++---
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf |  4 ++--
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf                                                  | 18 +++++++++---------
 Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc                                                                 |  3 +++
 Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc                                                          |  3 +++
 7 files changed, 43 insertions(+), 116 deletions(-)

diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index a341a58930..ab35bc3f8f 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
   Implementation of Fsp Misc UPD Initialization.
 
 
-  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -17,11 +17,9 @@
 #include <FspmUpd.h>
 #include <FspsUpd.h>
 
-#include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 #include <Library/PciLib.h>
-#include <Ppi/ReadOnlyVariable2.h>
 #include <Guid/MemoryOverwriteControl.h>
 #include <PchAccess.h>
 
@@ -44,55 +42,18 @@ PeiFspMiscUpdUpdatePreMem (
   )
 {
   EFI_STATUS                        Status;
-  EFI_PEI_READ_ONLY_VARIABLE2_PPI   *VariableServices;
-  UINTN                             VariableSize;
-  VOID                              *MemorySavedData;
-
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiReadOnlyVariable2PpiGuid,
-             0,
-             NULL,
-             (VOID **) &VariableServices
-             );
-  if (EFI_ERROR (Status)) {
-    ASSERT_EFI_ERROR (Status);
-    return Status;
-  }
-
-  VariableSize = 0;
-  MemorySavedData = NULL;
-  Status = VariableServices->GetVariable (
-                               VariableServices,
-                               L"MemoryConfig",
-                               &gFspNonVolatileStorageHobGuid,
-                               NULL,
-                               &VariableSize,
-                               MemorySavedData
-                               );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    MemorySavedData = AllocatePool (VariableSize);
-    if (MemorySavedData == NULL) {
-      ASSERT (MemorySavedData != NULL);
-      return EFI_OUT_OF_RESOURCES;
-    }
-
-    DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));
-    Status = VariableServices->GetVariable (
-                                 VariableServices,
-                                 L"MemoryConfig",
-                                 &gFspNonVolatileStorageHobGuid,
-                                 NULL,
-                                 &VariableSize,
-                                 MemorySavedData
-                                 );
-    if (Status == EFI_SUCCESS) {
-      FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
-    } else {
-      DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMemoryConfigVariableGuid, Status = %r\n", Status));
-      ASSERT_EFI_ERROR (Status);
-    }
+  UINTN                             FspNvsBufferSize;
+  VOID                              *FspNvsBufferPtr;
+
+  FspNvsBufferPtr   = NULL;
+  FspNvsBufferSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+  if (Status == EFI_SUCCESS) {
+    FspmUpd->FspmArchUpd.NvsBufferPtr = FspNvsBufferPtr;
+  } else {
+    DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does not exist (this is likely a first boot)\n"));
+    FspmUpd->FspmArchUpd.NvsBufferPtr = NULL;
   }
-  FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
 
   return EFI_SUCCESS;
 }
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index 145deb5de3..381ef232ea 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
   Implementation of Fsp Misc UPD Initialization.
 
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
@@ -18,11 +18,9 @@
 #include <FspmUpd.h>
 #include <FspsUpd.h>
 
-#include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
 #include <Library/DebugPrintErrorLevelLib.h>
 #include <Library/PciLib.h>
-#include <Ppi/ReadOnlyVariable2.h>
 #include <Guid/MemoryOverwriteControl.h>
 #include <PchAccess.h>
 #include <Platform.h>
@@ -46,54 +44,17 @@ PeiFspMiscUpdUpdatePreMem (
   )
 {
   EFI_STATUS                        Status;
-  EFI_PEI_READ_ONLY_VARIABLE2_PPI   *VariableServices;
-  UINTN                             VariableSize;
-  VOID                              *MemorySavedData;
-
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiReadOnlyVariable2PpiGuid,
-             0,
-             NULL,
-             (VOID **) &VariableServices
-             );
-  if (EFI_ERROR (Status)) {
-    ASSERT_EFI_ERROR (Status);
-    return Status;
-  }
-
-  VariableSize = 0;
-  MemorySavedData = NULL;
-  Status = VariableServices->GetVariable (
-                               VariableServices,
-                               L"MemoryConfig",
-                               &gFspNonVolatileStorageHobGuid,
-                               NULL,
-                               &VariableSize,
-                               MemorySavedData
-                               );
-  if (Status == EFI_BUFFER_TOO_SMALL) {
-    MemorySavedData = AllocatePool (VariableSize);
-    if (MemorySavedData == NULL) {
-      ASSERT (MemorySavedData != NULL);
-      return EFI_OUT_OF_RESOURCES;
-    }
-
-    DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));
-    Status = VariableServices->GetVariable (
-                                 VariableServices,
-                                 L"MemoryConfig",
-                                 &gFspNonVolatileStorageHobGuid,
-                                 NULL,
-                                 &VariableSize,
-                                 MemorySavedData
-                                 );
-    if (Status == EFI_SUCCESS) {
-      FspmUpd->FspmArchUpd.NvsBufferPtr = MemorySavedData;
-    } else {
-      FspmUpd->FspmArchUpd.NvsBufferPtr = NULL;
-      DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMemoryConfigVariableGuid, Status = %r\n", Status));
-      ASSERT_EFI_ERROR (Status);
-    }
+  UINTN                             FspNvsBufferSize;
+  VOID                              *FspNvsBufferPtr;
+
+  FspNvsBufferPtr   = NULL;
+  FspNvsBufferSize  = 0;
+  Status = PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableGuid, &FspNvsBufferPtr, &FspNvsBufferSize);
+  if (Status == EFI_SUCCESS) {
+    FspmUpd->FspmArchUpd.NvsBufferPtr = FspNvsBufferPtr;
+  } else {
+    DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does not exist (this is likely a first boot)\n"));
+    FspmUpd->FspmArchUpd.NvsBufferPtr = NULL;
   }
 
   FspmUpd->FspmConfig.TsegSize              = FixedPcdGet32 (PcdTsegSize);
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 2c90d0cb94..362dc2c995 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
 #  Provide FSP wrapper platform related function.
 #
 #
-#  Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2019 - 2021 Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -82,7 +82,6 @@
   PchInfoLib
   PchHsioLib
   PchPcieRpLib
-  MemoryAllocationLib
   DebugPrintErrorLevelLib
   SiPolicyLib
   PchGbeLib
@@ -132,7 +131,7 @@
   gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdMrcSpdAddressTable3
 
 [Guids]
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gTianoLogoGuid                                ## CONSUMES
   gEfiMemoryOverwriteControlDataGuid
 
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 529c2f1253..1a664b1327 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
 #  FSP silicon policy updates for the Up Xtreme board.
 #
 #
-#  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -136,7 +136,7 @@
   gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdBoardBomId
 
 [Guids]
-  gFspNonVolatileStorageHobGuid                 ## CONSUMES
+  gFspNvsBufferVariableGuid                     ## CONSUMES
   gTianoLogoGuid                                ## CONSUMES
   gEfiMemoryOverwriteControlDataGuid
 
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf
index f7aa730ae7..698efce248 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/Include/Fdf/FlashMapInclude.fdf
@@ -2,7 +2,7 @@
 #  Flash map for the UpXtreme Board.
 #
 #
-#  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -35,16 +35,16 @@ SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvOsBootSize              = 0x00090000
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootOffset          = 0x00190000  # Flash addr (0xFFAE0000)
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvUefiBootSize            = 0x00190000  #
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemoryOffset        = 0x00320000  # Flash addr (0xFFC70000)
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize          = 0x00170000  #
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset              = 0x00490000  # Flash addr (0xFFDE0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPostMemorySize          = 0x00160000  #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSOffset              = 0x00480000  # Flash addr (0xFFDD0000)
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspSSize                = 0x00070000  #
-SET gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvOffset                  = 0x00500000  # Flash addr (0xFFE50000)
+SET gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvOffset                  = 0x004F0000  # Flash addr (0xFFE40000)
 SET gSiPkgTokenSpaceGuid.PcdFlashMicrocodeFvSize                    = 0x00050000  #
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset              = 0x00550000  # Flash addr (0xFFEA0000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMOffset              = 0x00540000  # Flash addr (0xFFE90000)
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspMSize                = 0x000EA000  #
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset              = 0x0063A000  # Flash addr (0xFFF8A000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTOffset              = 0x0062A000  # Flash addr (0xFFF7A000)
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspTSize                = 0x00006000  #
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemoryOffset = 0x00640000  # Flash addr (0xFFF90000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemoryOffset = 0x00630000  # Flash addr (0xFFF80000)
 SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvAdvancedPreMemorySize   = 0x00010000  #
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryOffset         = 0x00650000  # Flash addr (0xFFFA0000)
-SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize           = 0x00060000  #
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemoryOffset         = 0x00640000  # Flash addr (0xFFF90000)
+SET gMinPlatformPkgTokenSpaceGuid.PcdFlashFvPreMemorySize           = 0x00070000  #
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc
index ee2aedd978..9d08dc3fe4 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
   #######################################
   PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookLib.inf
 
+[LibraryClasses.Common.SEC]
+  VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
+
 [LibraryClasses.IA32.SEC]
   #######################################
   # Platform Package
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
index b69cc8deb0..8d25b818ee 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
   #######################################
   PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookLib.inf
 
+[LibraryClasses.Common.SEC]
+  VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
+
 [LibraryClasses.IA32.SEC]
   #######################################
   # Platform Package
-- 
2.28.0.windows.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
                   ` (6 preceding siblings ...)
  2021-10-08  5:15 ` [edk2-platforms: PATCH v2 7/9] WhiskeylakeOpenBoardPkg: " Chiu, Chasel
@ 2021-10-08  5:15 ` Chiu, Chasel
  2021-10-08  5:15 ` [edk2-platforms: PATCH v2 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob Chiu, Chasel
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:15 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Isaac Oram, Nate DeSimone

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@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@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..f86615591c 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 = ((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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [edk2-platforms: PATCH v2 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob.
  2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
                   ` (7 preceding siblings ...)
  2021-10-08  5:15 ` [edk2-platforms: PATCH v2 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
@ 2021-10-08  5:15 ` Chiu, Chasel
  8 siblings, 0 replies; 10+ messages in thread
From: Chiu, Chasel @ 2021-10-08  5:15 UTC (permalink / raw)
  To: devel; +Cc: Chasel Chiu, Isaac Oram, Nate DeSimone

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-08  5:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-08  5:14 [edk2-platforms: PATCH v2 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
2021-10-08  5:14 ` [edk2-platforms: PATCH v2 1/9] " Chiu, Chasel
2021-10-08  5:14 ` [edk2-platforms: PATCH v2 2/9] CometlakeOpenBoardPkg: Use same variable name for FspNvsHob Chiu, Chasel
2021-10-08  5:14 ` [edk2-platforms: PATCH v2 3/9] KabylakeOpenBoardPkg/AspireVn7Dash572G:Use " Chiu, Chasel
2021-10-08  5:14 ` [edk2-platforms: PATCH v2 4/9] KabylakeOpenBoardPkg/GalagoPro3: Use " Chiu, Chasel
2021-10-08  5:14 ` [edk2-platforms: PATCH v2 5/9] KabylakeOpenBoardPkg/KabylakeRvp3: " Chiu, Chasel
2021-10-08  5:14 ` [edk2-platforms: PATCH v2 6/9] TigerlakeOpenBoardPkg: " Chiu, Chasel
2021-10-08  5:15 ` [edk2-platforms: PATCH v2 7/9] WhiskeylakeOpenBoardPkg: " Chiu, Chasel
2021-10-08  5:15 ` [edk2-platforms: PATCH v2 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2 Chiu, Chasel
2021-10-08  5:15 ` [edk2-platforms: PATCH v2 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob Chiu, Chasel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox