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