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