]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
96f3efbd 24#include <Library/FspWrapperMultiPhaseProcessLib.h>\r
cf1d4549
JY
25#include <Library/TimerLib.h>\r
26#include <Library/PerformanceLib.h>\r
27#include <Library/FspWrapperApiLib.h>\r
53ea57fe 28#include <Library/FspMeasurementLib.h>\r
cf1d4549
JY
29\r
30#include <Ppi/FspSiliconInitDone.h>\r
31#include <Ppi/EndOfPeiPhase.h>\r
32#include <Ppi/MemoryDiscovered.h>\r
33#include <Ppi/TemporaryRamDone.h>\r
34#include <Ppi/SecPlatformInformation.h>\r
53ea57fe
JY
35#include <Ppi/Tcg.h>\r
36#include <Ppi/FirmwareVolumeInfoMeasurementExcluded.h>\r
cf1d4549
JY
37#include <Library/FspWrapperApiTestLib.h>\r
38#include <FspEas.h>\r
19d29d35 39#include <FspStatusCode.h>\r
96f3efbd 40#include <FspGlobalData.h>\r
cf1d4549 41\r
7c7184e2
MK
42extern EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc;\r
43extern EFI_GUID gFspHobGuid;\r
cf1d4549
JY
44\r
45/**\r
00e3e480 46 This function handles S3 resume task at the end of PEI.\r
cf1d4549 47\r
e69dcef5
CC
48 @param[in] PeiServices Pointer to PEI Services Table.\r
49 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
50 caused this function to execute.\r
51 @param[in] Ppi Pointer to the PPI data associated with this function.\r
cf1d4549 52\r
e69dcef5 53 @retval EFI_STATUS Always return EFI_SUCCESS\r
cf1d4549
JY
54**/\r
55EFI_STATUS\r
56EFIAPI\r
7c7184e2
MK
57S3EndOfPeiNotify (\r
58 IN EFI_PEI_SERVICES **PeiServices,\r
59 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
60 IN VOID *Ppi\r
cf1d4549
JY
61 );\r
62\r
7c7184e2 63EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc = {\r
cf1d4549
JY
64 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
65 &gEfiEndOfPeiSignalPpiGuid,\r
66 S3EndOfPeiNotify\r
67};\r
68\r
69/**\r
00e3e480 70 This function handles S3 resume task at the end of PEI.\r
cf1d4549 71\r
e69dcef5
CC
72 @param[in] PeiServices Pointer to PEI Services Table.\r
73 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
74 caused this function to execute.\r
75 @param[in] Ppi Pointer to the PPI data associated with this function.\r
cf1d4549 76\r
e69dcef5 77 @retval EFI_STATUS Always return EFI_SUCCESS\r
cf1d4549
JY
78**/\r
79EFI_STATUS\r
80EFIAPI\r
7c7184e2
MK
81S3EndOfPeiNotify (\r
82 IN EFI_PEI_SERVICES **PeiServices,\r
83 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
84 IN VOID *Ppi\r
cf1d4549
JY
85 )\r
86{\r
7c7184e2
MK
87 NOTIFY_PHASE_PARAMS NotifyPhaseParams;\r
88 EFI_STATUS Status;\r
cf1d4549 89\r
7c7184e2 90 DEBUG ((DEBUG_INFO, "S3EndOfPeiNotify enter\n"));\r
cf1d4549
JY
91\r
92 NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration;\r
7c7184e2
MK
93 Status = CallFspNotifyPhase (&NotifyPhaseParams);\r
94 DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration status: 0x%x\n", Status));\r
cf1d4549 95\r
f862a3b6
JY
96 //\r
97 // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
98 //\r
99 if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
7c7184e2 100 DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration requested reset 0x%x\n", Status));\r
24eac4ca 101 CallFspWrapperResetSystem (Status);\r
f862a3b6
JY
102 }\r
103\r
cf1d4549 104 NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot;\r
7c7184e2
MK
105 Status = CallFspNotifyPhase (&NotifyPhaseParams);\r
106 DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot status: 0x%x\n", Status));\r
cf1d4549 107\r
f862a3b6
JY
108 //\r
109 // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
110 //\r
111 if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
7c7184e2 112 DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot requested reset 0x%x\n", Status));\r
24eac4ca 113 CallFspWrapperResetSystem (Status);\r
f862a3b6
JY
114 }\r
115\r
cf1d4549 116 NotifyPhaseParams.Phase = EnumInitPhaseEndOfFirmware;\r
7c7184e2
MK
117 Status = CallFspNotifyPhase (&NotifyPhaseParams);\r
118 DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase EndOfFirmware status: 0x%x\n", Status));\r
cf1d4549 119\r
f862a3b6
JY
120 //\r
121 // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
122 //\r
123 if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
7c7184e2 124 DEBUG ((DEBUG_INFO, "FSP S3NotifyPhase EndOfFirmware requested reset 0x%x\n", Status));\r
24eac4ca 125 CallFspWrapperResetSystem (Status);\r
f862a3b6
JY
126 }\r
127\r
cf1d4549
JY
128 return EFI_SUCCESS;\r
129}\r
130\r
131/**\r
e69dcef5 132 Return Hob list produced by FSP.\r
cf1d4549 133\r
e69dcef5
CC
134 @param[in] PeiServices The pointer to the PEI Services Table.\r
135 @param[in] This The pointer to this instance of this PPI.\r
136 @param[out] FspHobList The pointer to Hob list produced by FSP.\r
cf1d4549 137\r
68d47eea 138 @return EFI_SUCCESS Return Hob list produced by FSP successfully.\r
cf1d4549
JY
139**/\r
140EFI_STATUS\r
141EFIAPI\r
142FspSiliconInitDoneGetFspHobList (\r
7c7184e2
MK
143 IN CONST EFI_PEI_SERVICES **PeiServices,\r
144 IN FSP_SILICON_INIT_DONE_PPI *This,\r
145 OUT VOID **FspHobList\r
cf1d4549
JY
146 );\r
147\r
7c7184e2 148FSP_SILICON_INIT_DONE_PPI mFspSiliconInitDonePpi = {\r
cf1d4549
JY
149 FspSiliconInitDoneGetFspHobList\r
150};\r
151\r
7c7184e2 152EFI_PEI_PPI_DESCRIPTOR mPeiFspSiliconInitDonePpi = {\r
cf1d4549
JY
153 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
154 &gFspSiliconInitDonePpiGuid,\r
155 &mFspSiliconInitDonePpi\r
156};\r
157\r
158/**\r
e69dcef5 159 Return Hob list produced by FSP.\r
cf1d4549 160\r
e69dcef5
CC
161 @param[in] PeiServices The pointer to the PEI Services Table.\r
162 @param[in] This The pointer to this instance of this PPI.\r
163 @param[out] FspHobList The pointer to Hob list produced by FSP.\r
cf1d4549 164\r
68d47eea 165 @return EFI_SUCCESS Return Hob list produced by FSP successfully.\r
cf1d4549
JY
166**/\r
167EFI_STATUS\r
168EFIAPI\r
169FspSiliconInitDoneGetFspHobList (\r
7c7184e2
MK
170 IN CONST EFI_PEI_SERVICES **PeiServices,\r
171 IN FSP_SILICON_INIT_DONE_PPI *This,\r
172 OUT VOID **FspHobList\r
cf1d4549
JY
173 )\r
174{\r
7c7184e2 175 EFI_HOB_GUID_TYPE *GuidHob;\r
cf1d4549
JY
176\r
177 GuidHob = GetFirstGuidHob (&gFspHobGuid);\r
178 if (GuidHob != NULL) {\r
7c7184e2 179 *FspHobList = *(VOID **)GET_GUID_HOB_DATA (GuidHob);\r
cf1d4549
JY
180 return EFI_SUCCESS;\r
181 } else {\r
182 return EFI_NOT_FOUND;\r
183 }\r
184}\r
185\r
de9e5b7d
AA
186/**\r
187 Get the FSP S UPD Data address\r
188\r
189 @return FSP-S UPD Data Address\r
190**/\r
de9e5b7d 191UINTN\r
de9e5b7d
AA
192GetFspsUpdDataAddress (\r
193 VOID\r
194 )\r
195{\r
196 if (PcdGet64 (PcdFspsUpdDataAddress64) != 0) {\r
24eac4ca 197 return (UINTN)PcdGet64 (PcdFspsUpdDataAddress64);\r
de9e5b7d 198 } else {\r
24eac4ca 199 return (UINTN)PcdGet32 (PcdFspsUpdDataAddress);\r
de9e5b7d
AA
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
24eac4ca 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
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
96f3efbd 328 DEBUG ((DEBUG_INFO, "FspSiliconInitApi requested reset %r\n", Status));\r
24eac4ca 329 CallFspWrapperResetSystem (Status);\r
f862a3b6
JY
330 }\r
331\r
96f3efbd 332 if ((Status != FSP_STATUS_VARIABLE_REQUEST) && EFI_ERROR (Status)) {\r
cf1d4549 333 DEBUG ((DEBUG_ERROR, "ERROR - Failed to execute FspSiliconInitApi(), Status = %r\n", Status));\r
96f3efbd 334 ASSERT_EFI_ERROR (Status);\r
cf1d4549 335 }\r
7c7184e2 336\r
96f3efbd
CC
337 DEBUG ((DEBUG_INFO, "FspSiliconInit status: %r\n", Status));\r
338\r
339 if (Status == FSP_STATUS_VARIABLE_REQUEST) {\r
340 //\r
341 // call to Variable request handler\r
342 //\r
343 FspWrapperVariableRequestHandler (&FspHobListPtr, FspMultiPhaseSiInitApiIndex);\r
344 }\r
345\r
346 //\r
347 // See if MultiPhase process is required or not\r
348 //\r
349 FspWrapperMultiPhaseHandler (&FspHobListPtr, FspMultiPhaseSiInitApiIndex); // FspS MultiPhase\r
350\r
351 PERF_END_EX (&gFspApiPerformanceGuid, "EventRec", NULL, 0, FSP_STATUS_CODE_SILICON_INIT | FSP_STATUS_CODE_COMMON_CODE | FSP_STATUS_CODE_API_EXIT);\r
352 DEBUG ((DEBUG_INFO, "Total time spent executing FspSiliconInitApi: %d millisecond\n", DivU64x32 (GetTimeInNanoSecond (AsmReadTsc () - TimeStampCounterStart), 1000000)));\r
cf1d4549
JY
353\r
354 Status = TestFspSiliconInitApiOutput ((VOID *)NULL);\r
355 if (RETURN_ERROR (Status)) {\r
356 DEBUG ((DEBUG_ERROR, "ERROR - TestFspSiliconInitApiOutput () fail, Status = %r\n", Status));\r
357 }\r
358\r
359 //\r
360 // Now FspHobList complete, process it\r
361 //\r
362 GuidHob = GetFirstGuidHob (&gFspHobGuid);\r
363 ASSERT (GuidHob != NULL);\r
364 FspHobListPtr = *(VOID **)GET_GUID_HOB_DATA (GuidHob);\r
365 DEBUG ((DEBUG_INFO, "FspHobListPtr - 0x%x\n", FspHobListPtr));\r
366 PostFspsHobProcess (FspHobListPtr);\r
367\r
368 //\r
369 // Install FspSiliconInitDonePpi so that any other driver can consume this info.\r
370 //\r
371 Status = PeiServicesInstallPpi (&mPeiFspSiliconInitDonePpi);\r
7c7184e2 372 ASSERT_EFI_ERROR (Status);\r
cf1d4549
JY
373\r
374 return Status;\r
375}\r
376\r
377/**\r
00e3e480 378 Do FSP initialization in API mode.\r
cf1d4549 379\r
68d47eea 380 @retval EFI_STATUS Always return EFI_SUCCESS\r
cf1d4549
JY
381**/\r
382EFI_STATUS\r
68d47eea 383FspsWrapperInitApiMode (\r
cf1d4549
JY
384 VOID\r
385 )\r
386{\r
7c7184e2
MK
387 EFI_STATUS Status;\r
388 EFI_BOOT_MODE BootMode;\r
cf1d4549
JY
389\r
390 //\r
97eedf5d 391 // Register MemoryDiscovered Notify to run FspSiliconInit\r
cf1d4549
JY
392 //\r
393 Status = PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc);\r
394 ASSERT_EFI_ERROR (Status);\r
e69dcef5 395\r
cf1d4549
JY
396 //\r
397 // Register EndOfPei Notify for S3 to run FSP NotifyPhase\r
398 //\r
399 PeiServicesGetBootMode (&BootMode);\r
400 if (BootMode == BOOT_ON_S3_RESUME) {\r
401 Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);\r
402 ASSERT_EFI_ERROR (Status);\r
403 }\r
404\r
405 return EFI_SUCCESS;\r
406}\r
407\r
68d47eea 408/**\r
00e3e480 409 Do FSP initialization in Dispatch mode.\r
68d47eea
CC
410\r
411 @retval FSP initialization status.\r
412**/\r
413EFI_STATUS\r
414FspsWrapperInitDispatchMode (\r
415 VOID\r
416 )\r
417{\r
7c7184e2
MK
418 EFI_STATUS Status;\r
419 EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI *MeasurementExcludedFvPpi;\r
420 EFI_PEI_PPI_DESCRIPTOR *MeasurementExcludedPpiList;\r
421\r
422 MeasurementExcludedFvPpi = AllocatePool (sizeof (*MeasurementExcludedFvPpi));\r
423 ASSERT (MeasurementExcludedFvPpi != NULL);\r
424 MeasurementExcludedFvPpi->Count = 1;\r
425 MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspsBaseAddress);\r
426 MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength;\r
427\r
428 MeasurementExcludedPpiList = AllocatePool (sizeof (*MeasurementExcludedPpiList));\r
429 ASSERT (MeasurementExcludedPpiList != NULL);\r
53ea57fe
JY
430 MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
431 MeasurementExcludedPpiList->Guid = &gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid;\r
432 MeasurementExcludedPpiList->Ppi = MeasurementExcludedFvPpi;\r
433\r
434 Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);\r
435 ASSERT_EFI_ERROR (Status);\r
436\r
68d47eea
CC
437 //\r
438 // FSP-S Wrapper running in Dispatch mode and reports FSP-S FV to PEI dispatcher.\r
439 //\r
440 PeiServicesInstallFvInfoPpi (\r
441 NULL,\r
7c7184e2
MK
442 (VOID *)(UINTN)PcdGet32 (PcdFspsBaseAddress),\r
443 (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength,\r
68d47eea
CC
444 NULL,\r
445 NULL\r
446 );\r
447 //\r
448 // Register EndOfPei Nofity to run post FSP-S process.\r
449 //\r
450 Status = PeiServicesNotifyPpi (&mFspsWrapperEndOfPeiNotifyDesc);\r
451 ASSERT_EFI_ERROR (Status);\r
452 return Status;\r
453}\r
454\r
53ea57fe
JY
455/**\r
456 This function is called after TCG installed PPI.\r
457\r
458 @param[in] PeiServices Pointer to PEI Services Table.\r
459 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
460 caused this function to execute.\r
461 @param[in] Ppi Pointer to the PPI data associated with this function.\r
462\r
463 @retval EFI_STATUS Always return EFI_SUCCESS\r
464**/\r
465EFI_STATUS\r
466EFIAPI\r
467TcgPpiNotify (\r
7c7184e2
MK
468 IN EFI_PEI_SERVICES **PeiServices,\r
469 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
470 IN VOID *Ppi\r
53ea57fe
JY
471 );\r
472\r
7c7184e2 473EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {\r
53ea57fe
JY
474 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
475 &gEdkiiTcgPpiGuid,\r
476 TcgPpiNotify\r
477};\r
478\r
479/**\r
480 This function is called after TCG installed PPI.\r
481\r
482 @param[in] PeiServices Pointer to PEI Services Table.\r
483 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that\r
484 caused this function to execute.\r
485 @param[in] Ppi Pointer to the PPI data associated with this function.\r
486\r
487 @retval EFI_STATUS Always return EFI_SUCCESS\r
488**/\r
489EFI_STATUS\r
490EFIAPI\r
491TcgPpiNotify (\r
7c7184e2
MK
492 IN EFI_PEI_SERVICES **PeiServices,\r
493 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,\r
494 IN VOID *Ppi\r
53ea57fe
JY
495 )\r
496{\r
7c7184e2 497 UINT32 FspMeasureMask;\r
53ea57fe
JY
498\r
499 DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPS\n"));\r
500\r
501 FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);\r
502\r
503 if ((FspMeasureMask & FSP_MEASURE_FSPS) != 0) {\r
7c7184e2
MK
504 MeasureFspFirmwareBlob (\r
505 0,\r
506 "FSPS",\r
507 PcdGet32 (PcdFspsBaseAddress),\r
508 (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PcdGet32 (PcdFspsBaseAddress))->FvLength\r
509 );\r
53ea57fe
JY
510 }\r
511\r
512 return EFI_SUCCESS;\r
513}\r
514\r
cf1d4549 515/**\r
00e3e480 516 This is the entrypoint of PEIM.\r
cf1d4549
JY
517\r
518 @param[in] FileHandle Handle of the file being invoked.\r
519 @param[in] PeiServices Describes the list of possible PEI Services.\r
520\r
521 @retval EFI_SUCCESS if it completed successfully.\r
522**/\r
523EFI_STATUS\r
524EFIAPI\r
525FspsWrapperPeimEntryPoint (\r
526 IN EFI_PEI_FILE_HANDLE FileHandle,\r
527 IN CONST EFI_PEI_SERVICES **PeiServices\r
528 )\r
529{\r
53ea57fe
JY
530 EFI_STATUS Status;\r
531\r
cf1d4549
JY
532 DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));\r
533\r
53ea57fe
JY
534 Status = PeiServicesNotifyPpi (&mTcgPpiNotifyDesc);\r
535 ASSERT_EFI_ERROR (Status);\r
536\r
e8f40b77 537 if (PcdGet8 (PcdFspModeSelection) == 1) {\r
68d47eea 538 FspsWrapperInitApiMode ();\r
2098de62 539 } else {\r
68d47eea 540 FspsWrapperInitDispatchMode ();\r
2098de62 541 }\r
cf1d4549
JY
542\r
543 return EFI_SUCCESS;\r
544}\r