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 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include "FspInitPei.h"
21 Return Hob list produced by FSP.
23 @param[in] PeiServices The pointer to the PEI Services Table.
24 @param[in] This The pointer to this instance of this PPI.
25 @param[out] FspHobList The pointer to Hob list produced by FSP.
27 @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
31 FspInitDoneGetFspHobListV2 (
32 IN CONST EFI_PEI_SERVICES
**PeiServices
,
33 IN FSP_INIT_DONE_PPI
*This
,
37 FSP_INIT_DONE_PPI mFspInitDonePpiV2
= {
38 FspInitDoneGetFspHobListV2
41 EFI_PEI_PPI_DESCRIPTOR mPeiFspInitDonePpiV2
= {
42 EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
,
48 This function is called after PEI core discover memory and finish migration.
50 @param[in] PeiServices Pointer to PEI Services Table.
51 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
52 caused this function to execute.
53 @param[in] Ppi Pointer to the PPI data associated with this function.
55 @retval EFI_STATUS Always return EFI_SUCCESS
59 PeiMemoryDiscoveredNotify (
60 IN EFI_PEI_SERVICES
**PeiServices
,
61 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDesc
,
65 EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc
= {
66 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
67 &gEfiPeiMemoryDiscoveredPpiGuid
,
68 PeiMemoryDiscoveredNotify
72 TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
73 by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
75 @retval EFI_SUCCESS Use of Temporary RAM was disabled.
76 @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
85 EFI_PEI_TEMPORARY_RAM_DONE_PPI mPeiTemporaryRamDonePpi
= {
89 EFI_PEI_PPI_DESCRIPTOR mPeiTemporaryRamDoneDesc
= {
90 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
91 &gEfiTemporaryRamDonePpiGuid
,
92 &mPeiTemporaryRamDonePpi
96 Return Hob list produced by FSP.
98 @param[in] PeiServices The pointer to the PEI Services Table.
99 @param[in] This The pointer to this instance of this PPI.
100 @param[out] FspHobList The pointer to Hob list produced by FSP.
102 @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
106 FspInitDoneGetFspHobListV2 (
107 IN CONST EFI_PEI_SERVICES
**PeiServices
,
108 IN FSP_INIT_DONE_PPI
*This
,
109 OUT VOID
**FspHobList
112 EFI_HOB_GUID_TYPE
*GuidHob
;
114 GuidHob
= GetFirstGuidHob (&gFspInitDonePpiGuid
);
115 if (GuidHob
!= NULL
) {
116 *FspHobList
= *(VOID
**)GET_GUID_HOB_DATA (GuidHob
);
119 return EFI_NOT_FOUND
;
124 Call FspMemoryInit API.
126 @param[in] FspHeader FSP header pointer.
128 @return Status returned by FspMemoryInit API.
132 IN FSP_INFO_HEADER
*FspHeader
135 FSP_MEMORY_INIT_PARAMS FspMemoryInitParams
;
136 FSP_INIT_RT_COMMON_BUFFER FspRtBuffer
;
137 UINT8 FspUpdRgn
[FixedPcdGet32 (PcdMaxUpdRegionSize
)];
138 UINT32 UpdRegionSize
;
139 EFI_BOOT_MODE BootMode
;
141 EFI_PHYSICAL_ADDRESS StackBase
;
146 DEBUG ((DEBUG_INFO
, "PeiFspMemoryInit enter\n"));
148 PeiServicesGetBootMode (&BootMode
);
149 DEBUG ((DEBUG_INFO
, "BootMode - 0x%x\n", BootMode
));
151 GetStackInfo (BootMode
, FALSE
, &StackBase
, &StackSize
);
152 DEBUG ((DEBUG_INFO
, "StackBase - 0x%x\n", StackBase
));
153 DEBUG ((DEBUG_INFO
, "StackSize - 0x%x\n", StackSize
));
155 ZeroMem (&FspRtBuffer
, sizeof(FspRtBuffer
));
156 FspRtBuffer
.StackTop
= (UINT32
*)(UINTN
)(StackBase
+ StackSize
);
158 FspRtBuffer
.BootMode
= BootMode
;
160 /* Platform override any UPD configs */
161 UpdRegionSize
= GetUpdRegionSize();
162 DEBUG ((DEBUG_INFO
, "UpdRegionSize - 0x%x\n", UpdRegionSize
));
163 DEBUG ((DEBUG_INFO
, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn
)));
164 ASSERT(sizeof(FspUpdRgn
) >= UpdRegionSize
);
165 ZeroMem (FspUpdRgn
, UpdRegionSize
);
166 FspRtBuffer
.UpdDataRgnPtr
= UpdateFspUpdConfigs (FspUpdRgn
);
168 ZeroMem (&FspMemoryInitParams
, sizeof(FspMemoryInitParams
));
169 FspMemoryInitParams
.NvsBufferPtr
= GetNvsBuffer ();
170 DEBUG ((DEBUG_INFO
, "NvsBufferPtr - 0x%x\n", FspMemoryInitParams
.NvsBufferPtr
));
171 FspMemoryInitParams
.RtBufferPtr
= (VOID
*)&FspRtBuffer
;
172 FspMemoryInitParams
.HobListPtr
= &FspHobList
;
174 DEBUG ((DEBUG_INFO
, "FspMemoryInitParams - 0x%x\n", &FspMemoryInitParams
));
175 DEBUG ((DEBUG_INFO
, " NvsBufferPtr - 0x%x\n", FspMemoryInitParams
.NvsBufferPtr
));
176 DEBUG ((DEBUG_INFO
, " RtBufferPtr - 0x%x\n", FspMemoryInitParams
.RtBufferPtr
));
177 DEBUG ((DEBUG_INFO
, " StackTop - 0x%x\n", FspRtBuffer
.StackTop
));
178 DEBUG ((DEBUG_INFO
, " BootMode - 0x%x\n", FspRtBuffer
.BootMode
));
179 DEBUG ((DEBUG_INFO
, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer
.UpdDataRgnPtr
));
180 DEBUG ((DEBUG_INFO
, " HobListPtr - 0x%x\n", FspMemoryInitParams
.HobListPtr
));
182 Status
= CallFspMemoryInit (FspHeader
, &FspMemoryInitParams
);
183 DEBUG((DEBUG_INFO
, "FspMemoryInit status: 0x%x\n", Status
));
184 ASSERT_EFI_ERROR (Status
);
186 DEBUG ((DEBUG_INFO
, " HobListPtr (returned) - 0x%x\n", FspHobList
));
188 FspHobProcessForMemoryResource (FspHobList
);
191 // FspHobList is not complete at this moment.
192 // Save FspHobList pointer to hob, so that it can be got later
194 HobData
= BuildGuidHob (
195 &gFspInitDonePpiGuid
,
198 ASSERT (HobData
!= NULL
);
199 CopyMem (HobData
, &FspHobList
, sizeof (FspHobList
));
205 TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
206 by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
208 @retval EFI_SUCCESS Use of Temporary RAM was disabled.
209 @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
214 PeiTemporaryRamDone (
219 VOID
*TempRamExitParam
;
220 FSP_INFO_HEADER
*FspHeader
;
222 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
223 if (FspHeader
== NULL
) {
224 return EFI_DEVICE_ERROR
;
227 DEBUG ((DEBUG_INFO
, "PeiTemporaryRamDone enter\n"));
229 TempRamExitParam
= GetTempRamExitParam ();
230 Status
= CallTempRamExit (FspHeader
, TempRamExitParam
);
231 DEBUG((DEBUG_INFO
, "TempRamExit status: 0x%x\n", Status
));
232 ASSERT_EFI_ERROR (Status
);
238 This function is called after PEI core discover memory and finish migration.
240 @param[in] PeiServices Pointer to PEI Services Table.
241 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
242 caused this function to execute.
243 @param[in] Ppi Pointer to the PPI data associated with this function.
245 @retval EFI_STATUS Always return EFI_SUCCESS
249 PeiMemoryDiscoveredNotify (
250 IN EFI_PEI_SERVICES
**PeiServices
,
251 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDesc
,
256 VOID
*FspSiliconInitParam
;
257 FSP_INFO_HEADER
*FspHeader
;
259 EFI_HOB_GUID_TYPE
*GuidHob
;
261 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
262 if (FspHeader
== NULL
) {
263 return EFI_DEVICE_ERROR
;
266 DEBUG ((DEBUG_INFO
, "PeiMemoryDiscoveredNotify enter\n"));
268 FspSiliconInitParam
= GetFspSiliconInitParam ();
269 Status
= CallFspSiliconInit (FspHeader
, FspSiliconInitParam
);
270 DEBUG((DEBUG_ERROR
, "FspSiliconInit status: 0x%x\n", Status
));
271 ASSERT_EFI_ERROR (Status
);
274 // Now FspHobList complete, process it
276 GuidHob
= GetFirstGuidHob (&gFspInitDonePpiGuid
);
277 ASSERT (GuidHob
!= NULL
);
278 FspHobList
= *(VOID
**)GET_GUID_HOB_DATA (GuidHob
);
279 DEBUG ((DEBUG_INFO
, "FspHobList - 0x%x\n", FspHobList
));
280 FspHobProcessForOtherData (FspHobList
);
283 // Install FspInitDonePpi so that any other driver can consume this info.
285 Status
= PeiServicesInstallPpi (&mPeiFspInitDonePpiV2
);
286 ASSERT_EFI_ERROR(Status
);
292 Do FSP initialization based on FspApi version 2.
294 @param[in] FspHeader FSP header pointer.
296 @return FSP initialization status.
300 IN FSP_INFO_HEADER
*FspHeader
304 EFI_BOOT_MODE BootMode
;
306 Status
= PeiFspMemoryInit (FspHeader
);
307 ASSERT_EFI_ERROR (Status
);
310 // Install TempramDonePpi to run TempRamExit
312 Status
= PeiServicesInstallPpi (&mPeiTemporaryRamDoneDesc
);
313 ASSERT_EFI_ERROR(Status
);
316 // Register MemoryDiscovered Nofity to run FspSiliconInit
318 Status
= PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc
);
319 ASSERT_EFI_ERROR (Status
);
322 // Register EndOfPei Notify for S3 to run FspNotifyPhase
324 PeiServicesGetBootMode (&BootMode
);
325 if (BootMode
== BOOT_ON_S3_RESUME
) {
326 Status
= PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc
);
327 ASSERT_EFI_ERROR (Status
);