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