summaryrefslogtreecommitdiffstats
path: root/IntelFsp2WrapperPkg/FspiWrapperPeim
diff options
context:
space:
mode:
authorHongbin1 Zhang <hongbin1.zhang@intel.com>2024-10-07 21:15:08 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-12-20 06:29:58 +0000
commitdf1726a65ef2f7f9793bbad4d18596ac7dbf0749 (patch)
treeff276b2ae0f3eb149e914e7e38ea69fc0a0ecb6d /IntelFsp2WrapperPkg/FspiWrapperPeim
parent4ffa8810af6494eacab0898bfcd4cf0d8b49ad5c (diff)
downloadedk2-df1726a65ef2f7f9793bbad4d18596ac7dbf0749.tar.gz
IntelFsp2WrapperPkg/FspiWrapperPeim : Support API mode
Add fspsmm init interface for API mode. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com> Cc: Duggapu Chinni B <chinni.b.duggapu@intel.com> Cc: Chen Gang C <gang.c.chen@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Ted Kuo <ted.kuo@intel.com> Cc: Ashraf Ali S <ashraf.ali.s@intel.com> Cc: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'IntelFsp2WrapperPkg/FspiWrapperPeim')
-rw-r--r--IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.c114
-rw-r--r--IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.inf13
2 files changed, 126 insertions, 1 deletions
diff --git a/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.c b/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.c
index 3d1d66c314..f76f824938 100644
--- a/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.c
@@ -9,12 +9,120 @@
**/
#include <PiPei.h>
+#include <FspEas.h>
+#include <FspStatusCode.h>
+#include <FspGlobalData.h>
#include <Library/PeimEntryPoint.h>
#include <Library/PeiServicesLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/FspWrapperPlatformLib.h>
+#include <Library/TimerLib.h>
+#include <Library/PerformanceLib.h>
+#include <Library/FspWrapperApiLib.h>
+#include <Library/FspWrapperHobProcessLib.h>
+#include <Library/FspWrapperApiTestLib.h>
+
+/**
+ Call FspSmmInit API.
+
+ @return Status returned by FspSmmInit API.
+**/
+EFI_STATUS
+FspiWrapperInitApiMode (
+ VOID
+ )
+{
+ FSP_INFO_HEADER *FspiHeaderPtr;
+ EFI_STATUS Status;
+ UINT64 TimeStampCounterStart;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ VOID *FspHobListPtr;
+ VOID *FspiUpdDataPtr;
+ UINTN *SourceData;
+
+ DEBUG ((DEBUG_INFO, "PeiFspSmmInit enter\n"));
+
+ FspHobListPtr = NULL;
+ FspiUpdDataPtr = NULL;
+
+ FspiHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspiBaseAddress));
+ DEBUG ((DEBUG_INFO, "FspiHeaderPtr - 0x%x\n", FspiHeaderPtr));
+ if (FspiHeaderPtr == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ if ((PcdGet64 (PcdFspiUpdDataAddress) == 0) && (FspiHeaderPtr->CfgRegionSize != 0) && (FspiHeaderPtr->CfgRegionOffset != 0)) {
+ //
+ // Copy default FSP-I UPD data from Flash
+ //
+ FspiUpdDataPtr = AllocateZeroPool ((UINTN)FspiHeaderPtr->CfgRegionSize);
+ ASSERT (FspiUpdDataPtr != NULL);
+ SourceData = (UINTN *)((UINTN)FspiHeaderPtr->ImageBase + (UINTN)FspiHeaderPtr->CfgRegionOffset);
+ CopyMem (FspiUpdDataPtr, SourceData, (UINTN)FspiHeaderPtr->CfgRegionSize);
+ } else {
+ //
+ // External UPD is ready, get the buffer from PCD pointer.
+ //
+ FspiUpdDataPtr = (VOID *)(UINTN)PcdGet64 (PcdFspiUpdDataAddress);
+ ASSERT (FspiUpdDataPtr != NULL);
+ }
+
+ DEBUG ((DEBUG_INFO, "UpdateFspiUpdData enter\n"));
+ UpdateFspiUpdData (FspiUpdDataPtr);
+ DEBUG ((DEBUG_INFO, " BootloaderSmmFvBaseAddress - 0x%lx\n", ((FSPI_UPD_COMMON *)FspiUpdDataPtr)->FspiArchUpd.BootloaderSmmFvBaseAddress));
+ DEBUG ((DEBUG_INFO, " BootloaderSmmFvLength - 0x%lx\n", ((FSPI_UPD_COMMON *)FspiUpdDataPtr)->FspiArchUpd.BootloaderSmmFvLength));
+ DEBUG ((DEBUG_INFO, " BootloaderSmmFvContextData - 0x%lx\n", ((FSPI_UPD_COMMON *)FspiUpdDataPtr)->FspiArchUpd.BootloaderSmmFvContextData));
+ DEBUG ((DEBUG_INFO, " BootloaderSmmFvContextDataLength - 0x%lx\n", ((FSPI_UPD_COMMON *)FspiUpdDataPtr)->FspiArchUpd.BootloaderSmmFvContextDataLength));
+
+ //
+ // Get FspHobList
+ //
+ GuidHob = GetFirstGuidHob (&gFspHobGuid);
+ ASSERT (GuidHob != NULL);
+ FspHobListPtr = *(VOID **)GET_GUID_HOB_DATA (GuidHob);
+ DEBUG ((DEBUG_INFO, " HobListPtr - 0x%x\n", &FspHobListPtr));
+
+ TimeStampCounterStart = AsmReadTsc ();
+ Status = CallFspSmmInit (FspiUpdDataPtr);
+
+ //
+ // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status
+ //
+ if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {
+ DEBUG ((DEBUG_INFO, "FspSmmInitApi requested reset %r\n", Status));
+ CallFspWrapperResetSystem (Status);
+ }
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ERROR - Failed to execute FspSmmInitApi(), Status = %r\n", Status));
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ DEBUG ((DEBUG_INFO, "FspSmmInit status: %r\n", Status));
+ //
+ // Create hobs after FspSmmInit. Hence passing the recorded timestamp here
+ //
+ PERF_START_EX (&gFspApiPerformanceGuid, "EventRec", NULL, TimeStampCounterStart, FSP_STATUS_CODE_FSPSMM_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);
+ PERF_END_EX (&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_FSPSMM_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);
+ DEBUG ((DEBUG_INFO, "Total time spent executing FspSmmInitApi: %d millisecond\n", DivU64x32 (GetTimeInNanoSecond (AsmReadTsc () - TimeStampCounterStart), 1000000)));
+
+ Status = TestFspSmmInitApiOutput (FspiUpdDataPtr);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ERROR - TestFspSmmInitApiOutput () fail, Status = %r\n", Status));
+ }
+
+ DEBUG ((DEBUG_INFO, " FspHobListPtr (returned) - 0x%x\n", FspHobListPtr));
+ ASSERT (FspHobListPtr != NULL);
+
+ PostFspiHobProcess (FspHobListPtr);
+
+ return Status;
+}
/**
Do FSP SMM initialization in Dispatch mode.
@@ -61,7 +169,11 @@ FspiWrapperPeimEntryPoint (
DEBUG ((DEBUG_INFO, "FspiWrapperPeimEntryPoint\n"));
- Status = FspiWrapperInitDispatchMode ();
+ if (PcdGet8 (PcdFspModeSelection) == 1) {
+ Status = FspiWrapperInitApiMode ();
+ } else {
+ Status = FspiWrapperInitDispatchMode ();
+ }
return Status;
}
diff --git a/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.inf b/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.inf
index 07ab497333..346e500b64 100644
--- a/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspiWrapperPeim/FspiWrapperPeim.inf
@@ -30,20 +30,33 @@
PeimEntryPoint
PeiServicesLib
PeiServicesTablePointerLib
+ BaseMemoryLib
+ TimerLib
DebugLib
+ HobLib
MemoryAllocationLib
+ FspWrapperPlatformLib
+ FspWrapperHobProcessLib
+ PerformanceLib
+ FspWrapperApiLib
+ FspWrapperApiTestLib
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+ IntelFsp2Pkg/IntelFsp2Pkg.dec
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
[Ppis]
[Pcd]
gIntelFsp2WrapperTokenSpaceGuid.PcdFspiBaseAddress ## CONSUMES
+ gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection ## CONSUMES
+ gIntelFsp2WrapperTokenSpaceGuid.PcdFspiUpdDataAddress ## CONSUMES
[Guids]
+ gFspHobGuid ## CONSUMES ## HOB
+ gFspApiPerformanceGuid ## SOMETIMES_CONSUMES ## GUID
[Sources]
FspiWrapperPeim.c