From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web09.4072.1633660763018722729 for ; Thu, 07 Oct 2021 19:39:33 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: chasel.chiu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10130"; a="287301114" X-IronPort-AV: E=Sophos;i="5.85,356,1624345200"; d="scan'208";a="287301114" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2021 19:39:33 -0700 X-IronPort-AV: E=Sophos;i="5.85,356,1624345200"; d="scan'208";a="657644521" Received: from cchiu4-mobl.gar.corp.intel.com ([10.252.188.53]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2021 19:39:32 -0700 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: Chasel Chiu , Isaac Oram , Nate DeSimone Subject: [edk2-platforms: PATCH 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2. Date: Fri, 8 Oct 2021 10:39:01 +0800 Message-Id: <20211008023902.1066-9-chasel.chiu@intel.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20211008023902.1066-1-chasel.chiu@intel.com> References: <20211008023902.1066-1-chasel.chiu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3678 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 Cc: Nate DeSimone Signed-off-by: Chasel Chiu --- Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c = | 29 +++++++++++++++++++++++------ Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.in= f | 4 +++- Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc = | 1 + 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3= NvramSave.c b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S= 3NvramSave.c index 709c7ad479..ddca492a5a 100644 --- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa= ve.c +++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa= ve.c @@ -7,6 +7,7 @@ **/=0D =0D #include "S3NvramSave.h"=0D +#include =0D #include =0D #include =0D #include =0D @@ -80,21 +81,37 @@ SaveFspNonVolatileStorageHob ( Status =3D EFI_SUCCESS;=0D =0D DEBUG ((DEBUG_INFO, "Saving FSP / MRC Training Data\n"));=0D - GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D + //=0D + // Firstly check version2 FspNvsHob.=0D + //=0D + GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHob2Guid);=0D if (GuidHob !=3D NULL) {=0D - HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D - DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D + HobData =3D (VOID *) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHo= b)->NvsDataPtr;=0D + DataSize =3D ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsD= ataLength;=0D + } else {=0D + //=0D + // Fall back to version1 FspNvsHob=0D + //=0D + GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D + if (GuidHob !=3D NULL) {=0D + HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D + DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D + }=0D + }=0D + if (HobData !=3D NULL) {=0D + DEBUG ((DEBUG_INFO, "FspNvsHob.Size: %d\n", DataSize));=0D + DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr: 0x%x\n", HobData));=0D if (DataSize > 0) {=0D =0D //=0D // Check if the presently saved data is identical to the data given = by MRC/FSP=0D //=0D - Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorag= eHobGuid, &FspNvsBufferSize, NULL);=0D + Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariable= Guid, &FspNvsBufferSize, NULL);=0D if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D if (FspNvsBufferSize =3D=3D DataSize) {=0D VariableData =3D AllocatePool (FspNvsBufferSize);=0D if (VariableData !=3D NULL) {=0D - Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatile= StorageHobGuid, &FspNvsBufferSize, VariableData);=0D + Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVa= riableGuid, &FspNvsBufferSize, VariableData);=0D if (!EFI_ERROR (Status) && (FspNvsBufferSize =3D=3D DataSize) = && (0 =3D=3D CompareMem (HobData, VariableData, DataSize))) {=0D DataIsIdentical =3D TRUE;=0D }=0D @@ -105,7 +122,7 @@ SaveFspNonVolatileStorageHob ( Status =3D EFI_SUCCESS;=0D =0D if (!DataIsIdentical) {=0D - Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStor= ageHobGuid, TRUE, DataSize, HobData);=0D + Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariab= leGuid, TRUE, DataSize, HobData);=0D ASSERT_EFI_ERROR (Status);=0D DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n= ", DataSize));=0D } else {=0D diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3= NvramSave.inf b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave= /S3NvramSave.inf index e62baa24c4..a77125cf44 100644 --- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa= ve.inf +++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa= ve.inf @@ -43,7 +43,9 @@ LargeVariableWriteLib=0D =0D [Guids]=0D - gFspNonVolatileStorageHobGuid # CONSUMES=0D + gFspNonVolatileStorageHobGuid # CONSUMES=0D + gFspNonVolatileStorageHob2Guid # CONSUMES=0D + gFspNvsBufferVariableGuid # PRODUCES=0D =0D [Pcd]=0D gEfiCpRcPkgTokenSpaceGuid.PcdPeiSyshostMemorySize=0D 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 @@ =0D [LibraryClasses.Common]=0D DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in= f=0D + PeiLib|MinPlatformPkg/Library/PeiLib/PeiLib.inf=0D =0D [Components.IA32]=0D UefiCpuPkg/SecCore/SecCore.inf=0D --=20 2.28.0.windows.1