]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
IntelFsp2WrapperPkg : Remove EFIAPI from local functions.
[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
f862a3b6
JY
99 CallFspWrapperResetSystem ((UINT32)Status);\r
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
f862a3b6
JY
111 CallFspWrapperResetSystem ((UINT32)Status);\r
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
f862a3b6
JY
123 CallFspWrapperResetSystem ((UINT32)Status);\r
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
189\r
190UINTN\r
de9e5b7d
AA
191GetFspsUpdDataAddress (\r
192 VOID\r
193 )\r
194{\r
195 if (PcdGet64 (PcdFspsUpdDataAddress64) != 0) {\r
196 return (UINTN) PcdGet64 (PcdFspsUpdDataAddress64);\r
197 } else {\r
198 return (UINTN) PcdGet32 (PcdFspsUpdDataAddress);\r
199 }\r
200}\r
201\r
68d47eea
CC
202/**\r
203 This function is for FSP dispatch mode to perform post FSP-S process.\r
204\r
205 @param[in] PeiServices Pointer to PEI Services Table.\r
206 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
207 caused this function to execute.\r
208 @param[in] Ppi Pointer to the PPI data associated with this function.\r
209\r
210 @retval EFI_STATUS Status returned by PeiServicesInstallPpi ()\r
211**/\r
212EFI_STATUS\r
213EFIAPI\r
214FspsWrapperEndOfPeiNotify (\r
7c7184e2
MK
215 IN EFI_PEI_SERVICES **PeiServices,\r
216 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
217 IN VOID *Ppi\r
68d47eea
CC
218 )\r
219{\r
220 EFI_STATUS Status;\r
221\r
222 //\r
223 // This step may include platform specific process in some boot loaders so\r
224 // aligning the same behavior between API and Dispatch modes.\r
225 // Note: In Dispatch mode no FspHobList so passing NULL to function and\r
226 // expecting function will handle it.\r
227 //\r
228 PostFspsHobProcess (NULL);\r
229\r
230 //\r
231 // Install FspSiliconInitDonePpi so that any other driver can consume this info.\r
232 //\r
233 Status = PeiServicesInstallPpi (&mPeiFspSiliconInitDonePpi);\r
7c7184e2 234 ASSERT_EFI_ERROR (Status);\r
68d47eea
CC
235\r
236 return Status;\r
237}\r
238\r
7c7184e2 239EFI_PEI_NOTIFY_DESCRIPTOR mFspsWrapperEndOfPeiNotifyDesc = {\r
68d47eea
CC
240 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
241 &gEfiEndOfPeiSignalPpiGuid,\r
242 FspsWrapperEndOfPeiNotify\r
243};\r
244\r
cf1d4549
JY
245/**\r
246 This function is called after PEI core discover memory and finish migration.\r
247\r
248 @param[in] PeiServices Pointer to PEI Services Table.\r
249 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
250 caused this function to execute.\r
251 @param[in] Ppi Pointer to the PPI data associated with this function.\r
252\r
253 @retval EFI_STATUS Always return EFI_SUCCESS\r
254**/\r
255EFI_STATUS\r
256EFIAPI\r
257PeiMemoryDiscoveredNotify (\r
7c7184e2
MK
258 IN EFI_PEI_SERVICES **PeiServices,\r
259 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
260 IN VOID *Ppi\r
cf1d4549
JY
261 );\r
262\r
7c7184e2 263EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc = {\r
cf1d4549
JY
264 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
265 &gEfiPeiMemoryDiscoveredPpiGuid,\r
266 PeiMemoryDiscoveredNotify\r
267};\r
268\r
269/**\r
e69dcef5 270 This function is called after PEI core discover memory and finish migration.\r
cf1d4549 271\r
e69dcef5
CC
272 @param[in] PeiServices Pointer to PEI Services Table.\r
273 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
274 caused this function to execute.\r
275 @param[in] Ppi Pointer to the PPI data associated with this function.\r
cf1d4549 276\r
e69dcef5 277 @retval EFI_STATUS Always return EFI_SUCCESS\r
cf1d4549
JY
278**/\r
279EFI_STATUS\r
280EFIAPI\r
281PeiMemoryDiscoveredNotify (\r
7c7184e2
MK
282 IN EFI_PEI_SERVICES **PeiServices,\r
283 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
284 IN VOID *Ppi\r
cf1d4549
JY
285 )\r
286{\r
7c7184e2
MK
287 FSP_INFO_HEADER *FspsHeaderPtr;\r
288 UINT64 TimeStampCounterStart;\r
289 EFI_STATUS Status;\r
290 VOID *FspHobListPtr;\r
291 EFI_HOB_GUID_TYPE *GuidHob;\r
292 FSPS_UPD_COMMON *FspsUpdDataPtr;\r
293 UINTN *SourceData;\r
cf1d4549 294\r
cf1d4549 295 DEBUG ((DEBUG_INFO, "PeiMemoryDiscoveredNotify enter\n"));\r
e69dcef5
CC
296 FspsUpdDataPtr = NULL;\r
297\r
cf1d4549 298 FspsHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));\r
599c45ff
HW
299 DEBUG ((DEBUG_INFO, "FspsHeaderPtr - 0x%x\n", FspsHeaderPtr));\r
300 if (FspsHeaderPtr == NULL) {\r
301 return EFI_DEVICE_ERROR;\r
302 }\r
303\r
de9e5b7d 304 if ((GetFspsUpdDataAddress () == 0) && (FspsHeaderPtr->CfgRegionSize != 0) && (FspsHeaderPtr->CfgRegionOffset != 0)) {\r
e69dcef5
CC
305 //\r
306 // Copy default FSP-S UPD data from Flash\r
307 //\r
308 FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize);\r
309 ASSERT (FspsUpdDataPtr != NULL);\r
310 SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset);\r
311 CopyMem (FspsUpdDataPtr, SourceData, (UINTN)FspsHeaderPtr->CfgRegionSize);\r
312 } else {\r
de9e5b7d 313 FspsUpdDataPtr = (FSPS_UPD_COMMON *) GetFspsUpdDataAddress();\r
e69dcef5
CC
314 ASSERT (FspsUpdDataPtr != NULL);\r
315 }\r
cf1d4549
JY
316\r
317 UpdateFspsUpdData ((VOID *)FspsUpdDataPtr);\r
318\r
319 TimeStampCounterStart = AsmReadTsc ();\r
7c7184e2 320 PERF_START_EX (&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_ENTRY);\r
cf1d4549 321 Status = CallFspSiliconInit ((VOID *)FspsUpdDataPtr);\r
7c7184e2 322 PERF_END_EX (&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
cf1d4549 323 DEBUG ((DEBUG_INFO, "Total time spent executing FspSiliconInitApi: %d millisecond\n", DivU64x32 (GetTimeInNanoSecond (AsmReadTsc () - TimeStampCounterStart), 1000000)));\r
f862a3b6
JY
324\r
325 //\r
326 // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
327 //\r
328 if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
7c7184e2 329 DEBUG ((DEBUG_INFO, "FspSiliconInitApi requested reset 0x%x\n", Status));\r
f862a3b6
JY
330 CallFspWrapperResetSystem ((UINT32)Status);\r
331 }\r
332\r
7c7184e2 333 if (EFI_ERROR (Status)) {\r
cf1d4549
JY
334 DEBUG ((DEBUG_ERROR, "ERROR - Failed to execute FspSiliconInitApi(), Status = %r\n", Status));\r
335 }\r
7c7184e2
MK
336\r
337 DEBUG ((DEBUG_INFO, "FspSiliconInit status: 0x%x\n", Status));\r
cf1d4549
JY
338 ASSERT_EFI_ERROR (Status);\r
339\r
340 Status = TestFspSiliconInitApiOutput ((VOID *)NULL);\r
341 if (RETURN_ERROR (Status)) {\r
342 DEBUG ((DEBUG_ERROR, "ERROR - TestFspSiliconInitApiOutput () fail, Status = %r\n", Status));\r
343 }\r
344\r
345 //\r
346 // Now FspHobList complete, process it\r
347 //\r
348 GuidHob = GetFirstGuidHob (&gFspHobGuid);\r
349 ASSERT (GuidHob != NULL);\r
350 FspHobListPtr = *(VOID **)GET_GUID_HOB_DATA (GuidHob);\r
351 DEBUG ((DEBUG_INFO, "FspHobListPtr - 0x%x\n", FspHobListPtr));\r
352 PostFspsHobProcess (FspHobListPtr);\r
353\r
354 //\r
355 // Install FspSiliconInitDonePpi so that any other driver can consume this info.\r
356 //\r
357 Status = PeiServicesInstallPpi (&mPeiFspSiliconInitDonePpi);\r
7c7184e2 358 ASSERT_EFI_ERROR (Status);\r
cf1d4549
JY
359\r
360 return Status;\r
361}\r
362\r
363/**\r
00e3e480 364 Do FSP initialization in API mode.\r
cf1d4549 365\r
68d47eea 366 @retval EFI_STATUS Always return EFI_SUCCESS\r
cf1d4549
JY
367**/\r
368EFI_STATUS\r
68d47eea 369FspsWrapperInitApiMode (\r
cf1d4549
JY
370 VOID\r
371 )\r
372{\r
7c7184e2
MK
373 EFI_STATUS Status;\r
374 EFI_BOOT_MODE BootMode;\r
cf1d4549
JY
375\r
376 //\r
97eedf5d 377 // Register MemoryDiscovered Notify to run FspSiliconInit\r
cf1d4549
JY
378 //\r
379 Status = PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc);\r
380 ASSERT_EFI_ERROR (Status);\r
e69dcef5 381\r
cf1d4549
JY
382 //\r
383 // Register EndOfPei Notify for S3 to run FSP NotifyPhase\r
384 //\r
385 PeiServicesGetBootMode (&BootMode);\r
386 if (BootMode == BOOT_ON_S3_RESUME) {\r
387 Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);\r
388 ASSERT_EFI_ERROR (Status);\r
389 }\r
390\r
391 return EFI_SUCCESS;\r
392}\r
393\r
68d47eea 394/**\r
00e3e480 395 Do FSP initialization in Dispatch mode.\r
68d47eea
CC
396\r
397 @retval FSP initialization status.\r
398**/\r
399EFI_STATUS\r
400FspsWrapperInitDispatchMode (\r
401 VOID\r
402 )\r
403{\r
7c7184e2
MK
404 EFI_STATUS Status;\r
405 EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;\r
406 EFI_PEI_PPI_DESCRIPTOR *MeasurementExcludedPpiList;\r
407\r
408 MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));\r
409 ASSERT (MeasurementExcludedFvPpi != NULL);\r
410 MeasurementExcludedFvPpi->Count = 1;\r
411 MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspsBaseAddress);\r
412 MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength;\r
413\r
414 MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));\r
415 ASSERT (MeasurementExcludedPpiList != NULL);\r
53ea57fe
JY
416 MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
417 MeasurementExcludedPpiList->Guid = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;\r
418 MeasurementExcludedPpiList->Ppi = MeasurementExcludedFvPpi;\r
419\r
420 Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);\r
421 ASSERT_EFI_ERROR (Status);\r
422\r
68d47eea
CC
423 //\r
424 // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI dispatcher.\r
425 //\r
426 PeiServicesInstallFvInfoPpi (\r
427 NULL,\r
7c7184e2
MK
428 (VOID *)(UINTN)PcdGet32 (PcdFspsBaseAddress),\r
429 (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength,\r
68d47eea
CC
430 NULL,\r
431 NULL\r
432 );\r
433 //\r
434 // Register EndOfPei Nofity to run post FSP-S process.\r
435 //\r
436 Status = PeiServicesNotifyPpi (&mFspsWrapperEndOfPeiNotifyDesc);\r
437 ASSERT_EFI_ERROR (Status);\r
438 return Status;\r
439}\r
440\r
53ea57fe
JY
441/**\r
442 This function is called after TCG installed PPI.\r
443\r
444 @param[in] PeiServices Pointer to PEI Services Table.\r
445 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
446 caused this function to execute.\r
447 @param[in] Ppi Pointer to the PPI data associated with this function.\r
448\r
449 @retval EFI_STATUS Always return EFI_SUCCESS\r
450**/\r
451EFI_STATUS\r
452EFIAPI\r
453TcgPpiNotify (\r
7c7184e2
MK
454 IN EFI_PEI_SERVICES **PeiServices,\r
455 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
456 IN VOID *Ppi\r
53ea57fe
JY
457 );\r
458\r
7c7184e2 459EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {\r
53ea57fe
JY
460 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
461 &gEdkiiTcgPpiGuid,\r
462 TcgPpiNotify\r
463};\r
464\r
465/**\r
466 This function is called after TCG installed PPI.\r
467\r
468 @param[in] PeiServices Pointer to PEI Services Table.\r
469 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
470 caused this function to execute.\r
471 @param[in] Ppi Pointer to the PPI data associated with this function.\r
472\r
473 @retval EFI_STATUS Always return EFI_SUCCESS\r
474**/\r
475EFI_STATUS\r
476EFIAPI\r
477TcgPpiNotify (\r
7c7184e2
MK
478 IN EFI_PEI_SERVICES **PeiServices,\r
479 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
480 IN VOID *Ppi\r
53ea57fe
JY
481 )\r
482{\r
7c7184e2 483 UINT32 FspMeasureMask;\r
53ea57fe
JY
484\r
485 DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPS\n"));\r
486\r
487 FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);\r
488\r
489 if ((FspMeasureMask & FSP_MEASURE_FSPS) != 0) {\r
7c7184e2
MK
490 MeasureFspFirmwareBlob (\r
491 0,\r
492 "FSPS",\r
493 PcdGet32 (PcdFspsBaseAddress),\r
494 (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength\r
495 );\r
53ea57fe
JY
496 }\r
497\r
498 return EFI_SUCCESS;\r
499}\r
500\r
cf1d4549 501/**\r
00e3e480 502 This is the entrypoint of PEIM.\r
cf1d4549
JY
503\r
504 @param[in] FileHandle Handle of the file being invoked.\r
505 @param[in] PeiServices Describes the list of possible PEI Services.\r
506\r
507 @retval EFI_SUCCESS if it completed successfully.\r
508**/\r
509EFI_STATUS\r
510EFIAPI\r
511FspsWrapperPeimEntryPoint (\r
512 IN EFI_PEI_FILE_HANDLE FileHandle,\r
513 IN CONST EFI_PEI_SERVICES **PeiServices\r
514 )\r
515{\r
53ea57fe
JY
516 EFI_STATUS Status;\r
517\r
cf1d4549
JY
518 DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));\r
519\r
53ea57fe
JY
520 Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);\r
521 ASSERT_EFI_ERROR (Status);\r
522\r
e8f40b77 523 if (PcdGet8 (PcdFspModeSelection) == 1) {\r
68d47eea 524 FspsWrapperInitApiMode ();\r
2098de62 525 } else {\r
68d47eea 526 FspsWrapperInitDispatchMode ();\r
2098de62 527 }\r
cf1d4549
JY
528\r
529 return EFI_SUCCESS;\r
530}\r