FspsWrapperPeim.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /** @file
  2. This will be invoked only once. It will call FspMemoryInit API,
  3. register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
  4. notify to call FspSiliconInit API.
  5. Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #include <PiPei.h>
  9. #include <Library/PeimEntryPoint.h>
  10. #include <Library/PeiServicesLib.h>
  11. #include <Library/PeiServicesTablePointerLib.h>
  12. #include <Library/BaseLib.h>
  13. #include <Library/DebugLib.h>
  14. #include <Library/BaseMemoryLib.h>
  15. #include <Library/HobLib.h>
  16. #include <Library/PcdLib.h>
  17. #include <Library/MemoryAllocationLib.h>
  18. #include <Library/FspWrapperPlatformLib.h>
  19. #include <Library/FspWrapperHobProcessLib.h>
  20. #include <Library/FspWrapperMultiPhaseProcessLib.h>
  21. #include <Library/TimerLib.h>
  22. #include <Library/PerformanceLib.h>
  23. #include <Library/FspWrapperApiLib.h>
  24. #include <Library/FspMeasurementLib.h>
  25. #include <Ppi/FspSiliconInitDone.h>
  26. #include <Ppi/EndOfPeiPhase.h>
  27. #include <Ppi/MemoryDiscovered.h>
  28. #include <Ppi/TemporaryRamDone.h>
  29. #include <Ppi/SecPlatformInformation.h>
  30. #include <Ppi/Tcg.h>
  31. #include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>
  32. #include <Library/FspWrapperApiTestLib.h>
  33. #include <FspEas.h>
  34. #include <FspStatusCode.h>
  35. #include <FspGlobalData.h>
  36. extern EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc;
  37. extern EFI_GUID gFspHobGuid;
  38. /**
  39. This function handles S3 resume task at the end of PEI.
  40. @param[in] PeiServices Pointer to PEI Services Table.
  41. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  42. caused this function to execute.
  43. @param[in] Ppi Pointer to the PPI data associated with this function.
  44. @retval EFI_STATUS Always return EFI_SUCCESS
  45. **/
  46. EFI_STATUS
  47. EFIAPI
  48. S3EndOfPeiNotify (
  49. IN EFI_PEI_SERVICES **PeiServices,
  50. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  51. IN VOID *Ppi
  52. );
  53. EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc = {
  54. (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  55. &gEfiEndOfPeiSignalPpiGuid,
  56. S3EndOfPeiNotify
  57. };
  58. /**
  59. This function handles S3 resume task at the end of PEI.
  60. @param[in] PeiServices Pointer to PEI Services Table.
  61. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  62. caused this function to execute.
  63. @param[in] Ppi Pointer to the PPI data associated with this function.
  64. @retval EFI_STATUS Always return EFI_SUCCESS
  65. **/
  66. EFI_STATUS
  67. EFIAPI
  68. S3EndOfPeiNotify (
  69. IN EFI_PEI_SERVICES **PeiServices,
  70. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  71. IN VOID *Ppi
  72. )
  73. {
  74. NOTIFY_PHASE_PARAMS NotifyPhaseParams;
  75. EFI_STATUS Status;
  76. DEBUG ((DEBUG_INFO, "S3EndOfPeiNotify enter\n"));
  77. NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration;
  78. Status = CallFspNotifyPhase (&NotifyPhaseParams);
  79. DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration status: 0x%x\n", Status));
  80. //
  81. // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status
  82. //
  83. if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {
  84. DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration requested reset 0x%x\n", Status));
  85. CallFspWrapperResetSystem (Status);
  86. }
  87. NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot;
  88. Status = CallFspNotifyPhase (&NotifyPhaseParams);
  89. DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot status: 0x%x\n", Status));
  90. //
  91. // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status
  92. //
  93. if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {
  94. DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot requested reset 0x%x\n", Status));
  95. CallFspWrapperResetSystem (Status);
  96. }
  97. NotifyPhaseParams.Phase = EnumInitPhaseEndOfFirmware;
  98. Status = CallFspNotifyPhase (&NotifyPhaseParams);
  99. DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase EndOfFirmware status: 0x%x\n", Status));
  100. //
  101. // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status
  102. //
  103. if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {
  104. DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase EndOfFirmware requested reset 0x%x\n", Status));
  105. CallFspWrapperResetSystem (Status);
  106. }
  107. return EFI_SUCCESS;
  108. }
  109. /**
  110. Return Hob list produced by FSP.
  111. @param[in] PeiServices The pointer to the PEI Services Table.
  112. @param[in] This The pointer to this instance of this PPI.
  113. @param[out] FspHobList The pointer to Hob list produced by FSP.
  114. @return EFI_SUCCESS Return Hob list produced by FSP successfully.
  115. **/
  116. EFI_STATUS
  117. EFIAPI
  118. FspSiliconInitDoneGetFspHobList (
  119. IN CONST EFI_PEI_SERVICES **PeiServices,
  120. IN FSP_SILICON_INIT_DONE_PPI *This,
  121. OUT VOID **FspHobList
  122. );
  123. FSP_SILICON_INIT_DONE_PPI mFspSiliconInitDonePpi = {
  124. FspSiliconInitDoneGetFspHobList
  125. };
  126. EFI_PEI_PPI_DESCRIPTOR mPeiFspSiliconInitDonePpi = {
  127. EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  128. &gFspSiliconInitDonePpiGuid,
  129. &mFspSiliconInitDonePpi
  130. };
  131. /**
  132. Return Hob list produced by FSP.
  133. @param[in] PeiServices The pointer to the PEI Services Table.
  134. @param[in] This The pointer to this instance of this PPI.
  135. @param[out] FspHobList The pointer to Hob list produced by FSP.
  136. @return EFI_SUCCESS Return Hob list produced by FSP successfully.
  137. **/
  138. EFI_STATUS
  139. EFIAPI
  140. FspSiliconInitDoneGetFspHobList (
  141. IN CONST EFI_PEI_SERVICES **PeiServices,
  142. IN FSP_SILICON_INIT_DONE_PPI *This,
  143. OUT VOID **FspHobList
  144. )
  145. {
  146. EFI_HOB_GUID_TYPE *GuidHob;
  147. GuidHob = GetFirstGuidHob (&gFspHobGuid);
  148. if (GuidHob != NULL) {
  149. *FspHobList = *(VOID **)GET_GUID_HOB_DATA (GuidHob);
  150. return EFI_SUCCESS;
  151. } else {
  152. return EFI_NOT_FOUND;
  153. }
  154. }
  155. /**
  156. Get the FSP S UPD Data address
  157. @return FSP-S UPD Data Address
  158. **/
  159. UINTN
  160. GetFspsUpdDataAddress (
  161. VOID
  162. )
  163. {
  164. if (PcdGet64 (PcdFspsUpdDataAddress64) != 0) {
  165. return (UINTN)PcdGet64 (PcdFspsUpdDataAddress64);
  166. } else {
  167. return (UINTN)PcdGet32 (PcdFspsUpdDataAddress);
  168. }
  169. }
  170. /**
  171. This function is for FSP dispatch mode to perform post FSP-S process.
  172. @param[in] PeiServices Pointer to PEI Services Table.
  173. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  174. caused this function to execute.
  175. @param[in] Ppi Pointer to the PPI data associated with this function.
  176. @retval EFI_STATUS Status returned by PeiServicesInstallPpi ()
  177. **/
  178. EFI_STATUS
  179. EFIAPI
  180. FspsWrapperEndOfPeiNotify (
  181. IN EFI_PEI_SERVICES **PeiServices,
  182. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  183. IN VOID *Ppi
  184. )
  185. {
  186. EFI_STATUS Status;
  187. //
  188. // This step may include platform specific process in some boot loaders so
  189. // aligning the same behavior between API and Dispatch modes.
  190. // Note: In Dispatch mode no FspHobList so passing NULL to function and
  191. // expecting function will handle it.
  192. //
  193. PostFspsHobProcess (NULL);
  194. //
  195. // Install FspSiliconInitDonePpi so that any other driver can consume this info.
  196. //
  197. Status = PeiServicesInstallPpi (&mPeiFspSiliconInitDonePpi);
  198. ASSERT_EFI_ERROR (Status);
  199. return Status;
  200. }
  201. EFI_PEI_NOTIFY_DESCRIPTOR mFspsWrapperEndOfPeiNotifyDesc = {
  202. (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  203. &gEfiEndOfPeiSignalPpiGuid,
  204. FspsWrapperEndOfPeiNotify
  205. };
  206. /**
  207. This function is called after PEI core discover memory and finish migration.
  208. @param[in] PeiServices Pointer to PEI Services Table.
  209. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  210. caused this function to execute.
  211. @param[in] Ppi Pointer to the PPI data associated with this function.
  212. @retval EFI_STATUS Always return EFI_SUCCESS
  213. **/
  214. EFI_STATUS
  215. EFIAPI
  216. PeiMemoryDiscoveredNotify (
  217. IN EFI_PEI_SERVICES **PeiServices,
  218. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  219. IN VOID *Ppi
  220. );
  221. EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc = {
  222. (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  223. &gEfiPeiMemoryDiscoveredPpiGuid,
  224. PeiMemoryDiscoveredNotify
  225. };
  226. /**
  227. This function is called after PEI core discover memory and finish migration.
  228. @param[in] PeiServices Pointer to PEI Services Table.
  229. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  230. caused this function to execute.
  231. @param[in] Ppi Pointer to the PPI data associated with this function.
  232. @retval EFI_STATUS Always return EFI_SUCCESS
  233. **/
  234. EFI_STATUS
  235. EFIAPI
  236. PeiMemoryDiscoveredNotify (
  237. IN EFI_PEI_SERVICES **PeiServices,
  238. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  239. IN VOID *Ppi
  240. )
  241. {
  242. FSP_INFO_HEADER *FspsHeaderPtr;
  243. UINT64 TimeStampCounterStart;
  244. EFI_STATUS Status;
  245. VOID *FspHobListPtr;
  246. EFI_HOB_GUID_TYPE *GuidHob;
  247. FSPS_UPD_COMMON *FspsUpdDataPtr;
  248. UINTN *SourceData;
  249. DEBUG ((DEBUG_INFO, "PeiMemoryDiscoveredNotify enter\n"));
  250. FspsUpdDataPtr = NULL;
  251. FspsHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));
  252. DEBUG ((DEBUG_INFO, "FspsHeaderPtr - 0x%x\n", FspsHeaderPtr));
  253. if (FspsHeaderPtr == NULL) {
  254. return EFI_DEVICE_ERROR;
  255. }
  256. if ((GetFspsUpdDataAddress () == 0) && (FspsHeaderPtr->CfgRegionSize != 0) && (FspsHeaderPtr->CfgRegionOffset != 0)) {
  257. //
  258. // Copy default FSP-S UPD data from Flash
  259. //
  260. FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize);
  261. ASSERT (FspsUpdDataPtr != NULL);
  262. SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset);
  263. CopyMem (FspsUpdDataPtr, SourceData, (UINTN)FspsHeaderPtr->CfgRegionSize);
  264. } else {
  265. FspsUpdDataPtr = (FSPS_UPD_COMMON *)GetFspsUpdDataAddress ();
  266. ASSERT (FspsUpdDataPtr != NULL);
  267. }
  268. UpdateFspsUpdData ((VOID *)FspsUpdDataPtr);
  269. TimeStampCounterStart = AsmReadTsc ();
  270. PERF_START_EX (&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);
  271. Status = CallFspSiliconInit ((VOID *)FspsUpdDataPtr);
  272. //
  273. // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status
  274. //
  275. if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {
  276. DEBUG ((DEBUG_INFO, "FspSiliconInitApi requested reset %r\n", Status));
  277. CallFspWrapperResetSystem (Status);
  278. }
  279. if ((Status != FSP_STATUS_VARIABLE_REQUEST) && EFI_ERROR (Status)) {
  280. DEBUG ((DEBUG_ERROR, "ERROR - Failed to execute FspSiliconInitApi(), Status = %r\n", Status));
  281. ASSERT_EFI_ERROR (Status);
  282. }
  283. DEBUG ((DEBUG_INFO, "FspSiliconInit status: %r\n", Status));
  284. if (Status == FSP_STATUS_VARIABLE_REQUEST) {
  285. //
  286. // call to Variable request handler
  287. //
  288. FspWrapperVariableRequestHandler (&FspHobListPtr, FspMultiPhaseSiInitApiIndex);
  289. }
  290. //
  291. // See if MultiPhase process is required or not
  292. //
  293. FspWrapperMultiPhaseHandler (&FspHobListPtr, FspMultiPhaseSiInitApiIndex); // FspS MultiPhase
  294. PERF_END_EX (&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);
  295. DEBUG ((DEBUG_INFO, "Total time spent executing FspSiliconInitApi: %d millisecond\n", DivU64x32 (GetTimeInNanoSecond (AsmReadTsc () - TimeStampCounterStart), 1000000)));
  296. Status = TestFspSiliconInitApiOutput ((VOID *)NULL);
  297. if (RETURN_ERROR (Status)) {
  298. DEBUG ((DEBUG_ERROR, "ERROR - TestFspSiliconInitApiOutput () fail, Status = %r\n", Status));
  299. }
  300. //
  301. // Now FspHobList complete, process it
  302. //
  303. GuidHob = GetFirstGuidHob (&gFspHobGuid);
  304. ASSERT (GuidHob != NULL);
  305. FspHobListPtr = *(VOID **)GET_GUID_HOB_DATA (GuidHob);
  306. DEBUG ((DEBUG_INFO, "FspHobListPtr - 0x%x\n", FspHobListPtr));
  307. PostFspsHobProcess (FspHobListPtr);
  308. //
  309. // Install FspSiliconInitDonePpi so that any other driver can consume this info.
  310. //
  311. Status = PeiServicesInstallPpi (&mPeiFspSiliconInitDonePpi);
  312. ASSERT_EFI_ERROR (Status);
  313. return Status;
  314. }
  315. /**
  316. Do FSP initialization in API mode.
  317. @retval EFI_STATUS Always return EFI_SUCCESS
  318. **/
  319. EFI_STATUS
  320. FspsWrapperInitApiMode (
  321. VOID
  322. )
  323. {
  324. EFI_STATUS Status;
  325. EFI_BOOT_MODE BootMode;
  326. //
  327. // Register MemoryDiscovered Notify to run FspSiliconInit
  328. //
  329. Status = PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc);
  330. ASSERT_EFI_ERROR (Status);
  331. //
  332. // Register EndOfPei Notify for S3 to run FSP NotifyPhase
  333. //
  334. PeiServicesGetBootMode (&BootMode);
  335. if (BootMode == BOOT_ON_S3_RESUME) {
  336. Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);
  337. ASSERT_EFI_ERROR (Status);
  338. }
  339. return EFI_SUCCESS;
  340. }
  341. /**
  342. Do FSP initialization in Dispatch mode.
  343. @retval FSP initialization status.
  344. **/
  345. EFI_STATUS
  346. FspsWrapperInitDispatchMode (
  347. VOID
  348. )
  349. {
  350. EFI_STATUS Status;
  351. EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;
  352. EFI_PEI_PPI_DESCRIPTOR *MeasurementExcludedPpiList;
  353. MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));
  354. ASSERT (MeasurementExcludedFvPpi != NULL);
  355. MeasurementExcludedFvPpi->Count = 1;
  356. MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspsBaseAddress);
  357. MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength;
  358. MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));
  359. ASSERT (MeasurementExcludedPpiList != NULL);
  360. MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
  361. MeasurementExcludedPpiList->Guid = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;
  362. MeasurementExcludedPpiList->Ppi = MeasurementExcludedFvPpi;
  363. Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);
  364. ASSERT_EFI_ERROR (Status);
  365. //
  366. // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI dispatcher.
  367. //
  368. PeiServicesInstallFvInfoPpi (
  369. NULL,
  370. (VOID *)(UINTN)PcdGet32 (PcdFspsBaseAddress),
  371. (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength,
  372. NULL,
  373. NULL
  374. );
  375. //
  376. // Register EndOfPei Nofity to run post FSP-S process.
  377. //
  378. Status = PeiServicesNotifyPpi (&mFspsWrapperEndOfPeiNotifyDesc);
  379. ASSERT_EFI_ERROR (Status);
  380. return Status;
  381. }
  382. /**
  383. This function is called after TCG installed PPI.
  384. @param[in] PeiServices Pointer to PEI Services Table.
  385. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  386. caused this function to execute.
  387. @param[in] Ppi Pointer to the PPI data associated with this function.
  388. @retval EFI_STATUS Always return EFI_SUCCESS
  389. **/
  390. EFI_STATUS
  391. EFIAPI
  392. TcgPpiNotify (
  393. IN EFI_PEI_SERVICES **PeiServices,
  394. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  395. IN VOID *Ppi
  396. );
  397. EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {
  398. (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
  399. &gEdkiiTcgPpiGuid,
  400. TcgPpiNotify
  401. };
  402. /**
  403. This function is called after TCG installed PPI.
  404. @param[in] PeiServices Pointer to PEI Services Table.
  405. @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
  406. caused this function to execute.
  407. @param[in] Ppi Pointer to the PPI data associated with this function.
  408. @retval EFI_STATUS Always return EFI_SUCCESS
  409. **/
  410. EFI_STATUS
  411. EFIAPI
  412. TcgPpiNotify (
  413. IN EFI_PEI_SERVICES **PeiServices,
  414. IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
  415. IN VOID *Ppi
  416. )
  417. {
  418. UINT32 FspMeasureMask;
  419. DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPS\n"));
  420. FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);
  421. if ((FspMeasureMask & FSP_MEASURE_FSPS) != 0) {
  422. MeasureFspFirmwareBlob (
  423. 0,
  424. "FSPS",
  425. PcdGet32 (PcdFspsBaseAddress),
  426. (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength
  427. );
  428. }
  429. return EFI_SUCCESS;
  430. }
  431. /**
  432. This is the entrypoint of PEIM.
  433. @param[in] FileHandle Handle of the file being invoked.
  434. @param[in] PeiServices Describes the list of possible PEI Services.
  435. @retval EFI_SUCCESS if it completed successfully.
  436. **/
  437. EFI_STATUS
  438. EFIAPI
  439. FspsWrapperPeimEntryPoint (
  440. IN EFI_PEI_FILE_HANDLE FileHandle,
  441. IN CONST EFI_PEI_SERVICES **PeiServices
  442. )
  443. {
  444. EFI_STATUS Status;
  445. DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));
  446. Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);
  447. ASSERT_EFI_ERROR (Status);
  448. if (PcdGet8 (PcdFspModeSelection) == 1) {
  449. FspsWrapperInitApiMode ();
  450. } else {
  451. FspsWrapperInitDispatchMode ();
  452. }
  453. return EFI_SUCCESS;
  454. }