2 In FSP API V2 mode, it 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.
6 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include "FspInitPei.h"
15 Return Hob list produced by FSP.
17 @param[in] PeiServices The pointer to the PEI Services Table.
18 @param[in] This The pointer to this instance of this PPI.
19 @param[out] FspHobList The pointer to Hob list produced by FSP.
21 @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
25 FspInitDoneGetFspHobListV2 (
26 IN CONST EFI_PEI_SERVICES
**PeiServices
,
27 IN FSP_INIT_DONE_PPI
*This
,
31 FSP_INIT_DONE_PPI mFspInitDonePpiV2
= {
32 FspInitDoneGetFspHobListV2
35 EFI_PEI_PPI_DESCRIPTOR mPeiFspInitDonePpiV2
= {
36 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
42 This function is called after PEI core discover memory and finish migration.
44 @param[in] PeiServices Pointer to PEI Services Table.
45 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
46 caused this function to execute.
47 @param[in] Ppi Pointer to the PPI data associated with this function.
49 @retval EFI_STATUS Always return EFI_SUCCESS
53 PeiMemoryDiscoveredNotify (
54 IN EFI_PEI_SERVICES
**PeiServices
,
55 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDesc
,
59 EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc
= {
60 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
61 &gEfiPeiMemoryDiscoveredPpiGuid
,
62 PeiMemoryDiscoveredNotify
66 TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
67 by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
69 @retval EFI_SUCCESS Use of Temporary RAM was disabled.
70 @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
79 EFI_PEI_TEMPORARY_RAM_DONE_PPI mPeiTemporaryRamDonePpi
= {
83 EFI_PEI_PPI_DESCRIPTOR mPeiTemporaryRamDoneDesc
= {
84 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
85 &gEfiTemporaryRamDonePpiGuid
,
86 &mPeiTemporaryRamDonePpi
90 Return Hob list produced by FSP.
92 @param[in] PeiServices The pointer to the PEI Services Table.
93 @param[in] This The pointer to this instance of this PPI.
94 @param[out] FspHobList The pointer to Hob list produced by FSP.
96 @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
100 FspInitDoneGetFspHobListV2 (
101 IN CONST EFI_PEI_SERVICES
**PeiServices
,
102 IN FSP_INIT_DONE_PPI
*This
,
103 OUT VOID
**FspHobList
106 EFI_HOB_GUID_TYPE
*GuidHob
;
108 GuidHob
= GetFirstGuidHob (&gFspInitDonePpiGuid
);
109 if (GuidHob
!= NULL
) {
110 *FspHobList
= *(VOID
**)GET_GUID_HOB_DATA (GuidHob
);
113 return EFI_NOT_FOUND
;
118 Call FspMemoryInit API.
120 @param[in] FspHeader FSP header pointer.
122 @return Status returned by FspMemoryInit API.
126 IN FSP_INFO_HEADER
*FspHeader
129 FSP_MEMORY_INIT_PARAMS FspMemoryInitParams
;
130 FSP_INIT_RT_COMMON_BUFFER FspRtBuffer
;
131 UINT8 FspUpdRgn
[FixedPcdGet32 (PcdMaxUpdRegionSize
)];
132 UINT32 UpdRegionSize
;
133 EFI_BOOT_MODE BootMode
;
135 EFI_PHYSICAL_ADDRESS StackBase
;
140 DEBUG ((DEBUG_INFO
, "PeiFspMemoryInit enter\n"));
142 PeiServicesGetBootMode (&BootMode
);
143 DEBUG ((DEBUG_INFO
, "BootMode - 0x%x\n", BootMode
));
145 GetStackInfo (BootMode
, FALSE
, &StackSize
, &StackBase
);
146 DEBUG ((DEBUG_INFO
, "StackBase - 0x%x\n", StackBase
));
147 DEBUG ((DEBUG_INFO
, "StackSize - 0x%x\n", StackSize
));
149 ZeroMem (&FspRtBuffer
, sizeof(FspRtBuffer
));
150 FspRtBuffer
.StackTop
= (UINT32
*)(UINTN
)(StackBase
+ StackSize
);
152 FspRtBuffer
.BootMode
= BootMode
;
154 /* Platform override any UPD configs */
155 UpdRegionSize
= GetUpdRegionSize();
156 DEBUG ((DEBUG_INFO
, "UpdRegionSize - 0x%x\n", UpdRegionSize
));
157 DEBUG ((DEBUG_INFO
, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn
)));
158 ASSERT(sizeof(FspUpdRgn
) >= UpdRegionSize
);
159 ZeroMem (FspUpdRgn
, UpdRegionSize
);
160 FspRtBuffer
.UpdDataRgnPtr
= UpdateFspUpdConfigs (FspUpdRgn
);
161 FspRtBuffer
.BootLoaderTolumSize
= GetBootLoaderTolumSize ();
163 ZeroMem (&FspMemoryInitParams
, sizeof(FspMemoryInitParams
));
164 FspMemoryInitParams
.NvsBufferPtr
= GetNvsBuffer ();
165 DEBUG ((DEBUG_INFO
, "NvsBufferPtr - 0x%x\n", FspMemoryInitParams
.NvsBufferPtr
));
166 FspMemoryInitParams
.RtBufferPtr
= (VOID
*)&FspRtBuffer
;
168 FspMemoryInitParams
.HobListPtr
= &FspHobList
;
170 DEBUG ((DEBUG_INFO
, "FspMemoryInitParams - 0x%x\n", &FspMemoryInitParams
));
171 DEBUG ((DEBUG_INFO
, " NvsBufferPtr - 0x%x\n", FspMemoryInitParams
.NvsBufferPtr
));
172 DEBUG ((DEBUG_INFO
, " RtBufferPtr - 0x%x\n", FspMemoryInitParams
.RtBufferPtr
));
173 DEBUG ((DEBUG_INFO
, " StackTop - 0x%x\n", FspRtBuffer
.StackTop
));
174 DEBUG ((DEBUG_INFO
, " BootMode - 0x%x\n", FspRtBuffer
.BootMode
));
175 DEBUG ((DEBUG_INFO
, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer
.UpdDataRgnPtr
));
176 DEBUG ((DEBUG_INFO
, " HobListPtr - 0x%x\n", FspMemoryInitParams
.HobListPtr
));
178 Status
= CallFspMemoryInit (FspHeader
, &FspMemoryInitParams
);
179 DEBUG((DEBUG_INFO
, "FspMemoryInit status: 0x%x\n", Status
));
180 ASSERT_EFI_ERROR (Status
);
182 DEBUG ((DEBUG_INFO
, " HobListPtr (returned) - 0x%x\n", FspHobList
));
183 ASSERT (FspHobList
!= NULL
);
185 FspHobProcessForMemoryResource (FspHobList
);
188 // FspHobList is not complete at this moment.
189 // Save FspHobList pointer to hob, so that it can be got later
191 HobData
= BuildGuidHob (
192 &gFspInitDonePpiGuid
,
195 ASSERT (HobData
!= NULL
);
196 CopyMem (HobData
, &FspHobList
, sizeof (FspHobList
));
202 TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
203 by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
205 @retval EFI_SUCCESS Use of Temporary RAM was disabled.
206 @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
211 PeiTemporaryRamDone (
216 VOID
*TempRamExitParam
;
217 FSP_INFO_HEADER
*FspHeader
;
219 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
220 if (FspHeader
== NULL
) {
221 return EFI_DEVICE_ERROR
;
224 DEBUG ((DEBUG_INFO
, "PeiTemporaryRamDone enter\n"));
226 TempRamExitParam
= GetTempRamExitParam ();
227 Status
= CallTempRamExit (FspHeader
, TempRamExitParam
);
228 DEBUG((DEBUG_INFO
, "TempRamExit status: 0x%x\n", Status
));
229 ASSERT_EFI_ERROR (Status
);
235 This function is called after PEI core discover memory and finish migration.
237 @param[in] PeiServices Pointer to PEI Services Table.
238 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
239 caused this function to execute.
240 @param[in] Ppi Pointer to the PPI data associated with this function.
242 @retval EFI_STATUS Always return EFI_SUCCESS
246 PeiMemoryDiscoveredNotify (
247 IN EFI_PEI_SERVICES
**PeiServices
,
248 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDesc
,
253 VOID
*FspSiliconInitParam
;
254 FSP_INFO_HEADER
*FspHeader
;
256 EFI_HOB_GUID_TYPE
*GuidHob
;
258 if (PcdGet32 (PcdFlashFvSecondFspBase
) == 0) {
259 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
261 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvSecondFspBase
));
263 if (FspHeader
== NULL
) {
264 return EFI_DEVICE_ERROR
;
267 DEBUG ((DEBUG_INFO
, "PeiMemoryDiscoveredNotify enter\n"));
269 FspSiliconInitParam
= GetFspSiliconInitParam ();
270 Status
= CallFspSiliconInit (FspHeader
, FspSiliconInitParam
);
271 DEBUG((DEBUG_ERROR
, "FspSiliconInit status: 0x%x\n", Status
));
272 ASSERT_EFI_ERROR (Status
);
275 // Now FspHobList complete, process it
277 GuidHob
= GetFirstGuidHob (&gFspInitDonePpiGuid
);
278 ASSERT (GuidHob
!= NULL
);
279 FspHobList
= *(VOID
**)GET_GUID_HOB_DATA (GuidHob
);
280 DEBUG ((DEBUG_INFO
, "FspHobList - 0x%x\n", FspHobList
));
281 FspHobProcessForOtherData (FspHobList
);
284 // Install FspInitDonePpi so that any other driver can consume this info.
286 Status
= PeiServicesInstallPpi (&mPeiFspInitDonePpiV2
);
287 ASSERT_EFI_ERROR(Status
);
293 Do FSP initialization based on FspApi version 2.
295 @param[in] FspHeader FSP header pointer.
297 @return FSP initialization status.
301 IN FSP_INFO_HEADER
*FspHeader
305 EFI_BOOT_MODE BootMode
;
307 Status
= PeiFspMemoryInit (FspHeader
);
308 ASSERT_EFI_ERROR (Status
);
311 // Install TempramDonePpi to run TempRamExit
313 Status
= PeiServicesInstallPpi (&mPeiTemporaryRamDoneDesc
);
314 ASSERT_EFI_ERROR(Status
);
317 // Register MemoryDiscovered Nofity to run FspSiliconInit
319 Status
= PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc
);
320 ASSERT_EFI_ERROR (Status
);
323 // Register EndOfPei Notify for S3 to run FspNotifyPhase
325 PeiServicesGetBootMode (&BootMode
);
326 if (BootMode
== BOOT_ON_S3_RESUME
) {
327 Status
= PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc
);
328 ASSERT_EFI_ERROR (Status
);