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
;
173 FspMemoryInitParams
.HobListPtr
= &FspHobList
;
175 DEBUG ((DEBUG_INFO
, "FspMemoryInitParams - 0x%x\n", &FspMemoryInitParams
));
176 DEBUG ((DEBUG_INFO
, " NvsBufferPtr - 0x%x\n", FspMemoryInitParams
.NvsBufferPtr
));
177 DEBUG ((DEBUG_INFO
, " RtBufferPtr - 0x%x\n", FspMemoryInitParams
.RtBufferPtr
));
178 DEBUG ((DEBUG_INFO
, " StackTop - 0x%x\n", FspRtBuffer
.StackTop
));
179 DEBUG ((DEBUG_INFO
, " BootMode - 0x%x\n", FspRtBuffer
.BootMode
));
180 DEBUG ((DEBUG_INFO
, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer
.UpdDataRgnPtr
));
181 DEBUG ((DEBUG_INFO
, " HobListPtr - 0x%x\n", FspMemoryInitParams
.HobListPtr
));
183 Status
= CallFspMemoryInit (FspHeader
, &FspMemoryInitParams
);
184 DEBUG((DEBUG_INFO
, "FspMemoryInit status: 0x%x\n", Status
));
185 ASSERT_EFI_ERROR (Status
);
187 DEBUG ((DEBUG_INFO
, " HobListPtr (returned) - 0x%x\n", FspHobList
));
188 ASSERT (FspHobList
!= NULL
);
190 FspHobProcessForMemoryResource (FspHobList
);
193 // FspHobList is not complete at this moment.
194 // Save FspHobList pointer to hob, so that it can be got later
196 HobData
= BuildGuidHob (
197 &gFspInitDonePpiGuid
,
200 ASSERT (HobData
!= NULL
);
201 CopyMem (HobData
, &FspHobList
, sizeof (FspHobList
));
207 TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
208 by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
210 @retval EFI_SUCCESS Use of Temporary RAM was disabled.
211 @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
216 PeiTemporaryRamDone (
221 VOID
*TempRamExitParam
;
222 FSP_INFO_HEADER
*FspHeader
;
224 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
225 if (FspHeader
== NULL
) {
226 return EFI_DEVICE_ERROR
;
229 DEBUG ((DEBUG_INFO
, "PeiTemporaryRamDone enter\n"));
231 TempRamExitParam
= GetTempRamExitParam ();
232 Status
= CallTempRamExit (FspHeader
, TempRamExitParam
);
233 DEBUG((DEBUG_INFO
, "TempRamExit status: 0x%x\n", Status
));
234 ASSERT_EFI_ERROR (Status
);
240 This function is called after PEI core discover memory and finish migration.
242 @param[in] PeiServices Pointer to PEI Services Table.
243 @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
244 caused this function to execute.
245 @param[in] Ppi Pointer to the PPI data associated with this function.
247 @retval EFI_STATUS Always return EFI_SUCCESS
251 PeiMemoryDiscoveredNotify (
252 IN EFI_PEI_SERVICES
**PeiServices
,
253 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDesc
,
258 VOID
*FspSiliconInitParam
;
259 FSP_INFO_HEADER
*FspHeader
;
261 EFI_HOB_GUID_TYPE
*GuidHob
;
263 FspHeader
= FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase
));
264 if (FspHeader
== NULL
) {
265 return EFI_DEVICE_ERROR
;
268 DEBUG ((DEBUG_INFO
, "PeiMemoryDiscoveredNotify enter\n"));
270 FspSiliconInitParam
= GetFspSiliconInitParam ();
271 Status
= CallFspSiliconInit (FspHeader
, FspSiliconInitParam
);
272 DEBUG((DEBUG_ERROR
, "FspSiliconInit status: 0x%x\n", Status
));
273 ASSERT_EFI_ERROR (Status
);
276 // Now FspHobList complete, process it
278 GuidHob
= GetFirstGuidHob (&gFspInitDonePpiGuid
);
279 ASSERT (GuidHob
!= NULL
);
280 FspHobList
= *(VOID
**)GET_GUID_HOB_DATA (GuidHob
);
281 DEBUG ((DEBUG_INFO
, "FspHobList - 0x%x\n", FspHobList
));
282 FspHobProcessForOtherData (FspHobList
);
285 // Install FspInitDonePpi so that any other driver can consume this info.
287 Status
= PeiServicesInstallPpi (&mPeiFspInitDonePpiV2
);
288 ASSERT_EFI_ERROR(Status
);
294 Do FSP initialization based on FspApi version 2.
296 @param[in] FspHeader FSP header pointer.
298 @return FSP initialization status.
302 IN FSP_INFO_HEADER
*FspHeader
306 EFI_BOOT_MODE BootMode
;
308 Status
= PeiFspMemoryInit (FspHeader
);
309 ASSERT_EFI_ERROR (Status
);
312 // Install TempramDonePpi to run TempRamExit
314 Status
= PeiServicesInstallPpi (&mPeiTemporaryRamDoneDesc
);
315 ASSERT_EFI_ERROR(Status
);
318 // Register MemoryDiscovered Nofity to run FspSiliconInit
320 Status
= PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc
);
321 ASSERT_EFI_ERROR (Status
);
324 // Register EndOfPei Notify for S3 to run FspNotifyPhase
326 PeiServicesGetBootMode (&BootMode
);
327 if (BootMode
== BOOT_ON_S3_RESUME
) {
328 Status
= PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc
);
329 ASSERT_EFI_ERROR (Status
);