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