2 In FSP API V1 mode, it will be invoked twice by pei core. In 1st entry, it will
3 call FspInit API. In 2nd entry, it will parse the hoblist from fsp and report
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 FSP Init continuation function.
22 Control will be returned to this callback function after FspInit API call.
24 @param[in] Status Status of the FSP INIT API
25 @param[in] HobListPtr Pointer to the HOB data structure defined in the PI specification.
34 EFI_BOOT_MODE BootMode
;
36 EFI_PHYSICAL_ADDRESS StackBase
;
38 DEBUG ((DEBUG_INFO
, "ContinuationFunc - %r\n", Status
));
39 DEBUG ((DEBUG_INFO
, "HobListPtr - 0x%x\n", HobListPtr
));
41 if (Status
!= EFI_SUCCESS
) {
46 // Can not call any PeiServices
48 BootMode
= GetBootMode ();
50 GetStackInfo (BootMode
, TRUE
, &StackBase
, &StackSize
);
51 DEBUG ((DEBUG_INFO
, "StackBase - 0x%x\n", StackBase
));
52 DEBUG ((DEBUG_INFO
, "StackSize - 0x%x\n", StackSize
));
53 CallPeiCoreEntryPoint (
55 (VOID
*)(UINTN
)StackBase
,
56 (VOID
*)(UINTN
)(StackBase
+ StackSize
)
63 @param[in] FspHeader FSP header pointer.
67 IN FSP_INFO_HEADER
*FspHeader
70 FSP_INIT_PARAMS FspInitParams
;
71 FSP_INIT_RT_COMMON_BUFFER FspRtBuffer
;
72 UINT8 FspUpdRgn
[FixedPcdGet32 (PcdMaxUpdRegionSize
)];
74 EFI_BOOT_MODE BootMode
;
76 EFI_PHYSICAL_ADDRESS StackBase
;
79 DEBUG ((DEBUG_INFO
, "PeiFspInit enter\n"));
81 PeiServicesGetBootMode (&BootMode
);
82 DEBUG ((DEBUG_INFO
, "BootMode - 0x%x\n", BootMode
));
84 GetStackInfo (BootMode
, FALSE
, &StackBase
, &StackSize
);
85 DEBUG ((DEBUG_INFO
, "StackBase - 0x%x\n", StackBase
));
86 DEBUG ((DEBUG_INFO
, "StackSize - 0x%x\n", StackSize
));
88 ZeroMem (&FspRtBuffer
, sizeof(FspRtBuffer
));
89 FspRtBuffer
.StackTop
= (UINT32
*)(UINTN
)(StackBase
+ StackSize
);
91 FspRtBuffer
.BootMode
= BootMode
;
93 /* Platform override any UPD configs */
94 UpdRegionSize
= GetUpdRegionSize();
95 DEBUG ((DEBUG_INFO
, "UpdRegionSize - 0x%x\n", UpdRegionSize
));
96 DEBUG ((DEBUG_INFO
, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn
)));
97 ASSERT(sizeof(FspUpdRgn
) >= UpdRegionSize
);
98 ZeroMem (FspUpdRgn
, UpdRegionSize
);
99 FspRtBuffer
.UpdDataRgnPtr
= UpdateFspUpdConfigs (FspUpdRgn
);
101 ZeroMem (&FspInitParams
, sizeof(FspInitParams
));
102 FspInitParams
.NvsBufferPtr
= GetNvsBuffer ();
103 DEBUG ((DEBUG_INFO
, "NvsBufferPtr - 0x%x\n", FspInitParams
.NvsBufferPtr
));
104 FspInitParams
.RtBufferPtr
= (VOID
*)&FspRtBuffer
;
105 FspInitParams
.ContinuationFunc
= (CONTINUATION_PROC
)ContinuationFunc
;
107 SaveSecContext (GetPeiServicesTablePointer ());
109 DEBUG ((DEBUG_INFO
, "FspInitParams - 0x%x\n", &FspInitParams
));
110 DEBUG ((DEBUG_INFO
, " NvsBufferPtr - 0x%x\n", FspInitParams
.NvsBufferPtr
));
111 DEBUG ((DEBUG_INFO
, " RtBufferPtr - 0x%x\n", FspInitParams
.RtBufferPtr
));
112 DEBUG ((DEBUG_INFO
, " StackTop - 0x%x\n", FspRtBuffer
.StackTop
));
113 DEBUG ((DEBUG_INFO
, " BootMode - 0x%x\n", FspRtBuffer
.BootMode
));
114 DEBUG ((DEBUG_INFO
, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer
.UpdDataRgnPtr
));
115 DEBUG ((DEBUG_INFO
, " ContinuationFunc - 0x%x\n", FspInitParams
.ContinuationFunc
));
117 Status
= CallFspInit (FspHeader
, &FspInitParams
);
119 // Should never return
121 DEBUG((DEBUG_ERROR
, "FSP Init failed, status: 0x%x\n", Status
));
126 Do FSP initialization based on FspApi version 1.
128 @param[in] FspHeader FSP header pointer.
130 @return FSP initialization status.
134 IN FSP_INFO_HEADER
*FspHeader
138 FSP_INIT_DONE_PPI
*FspInitDone
;
140 EFI_BOOT_MODE BootMode
;
142 Status
= PeiServicesLocatePpi (
143 &gFspInitDonePpiGuid
,
146 (VOID
**) &FspInitDone
148 if (EFI_ERROR (Status
)) {
152 DEBUG ((DEBUG_INFO
, "1st entry\n"));
154 PeiFspInit (FspHeader
);
156 // Never return here, for FspApi version 1.
161 // 2nd entry for FspApi version 1 only.
163 DEBUG ((DEBUG_INFO
, "2nd entry\n"));
165 Status
= FspInitDone
->GetFspHobList (GetPeiServicesTablePointer (), FspInitDone
, &FspHobList
);
166 ASSERT_EFI_ERROR (Status
);
167 DEBUG ((DEBUG_INFO
, "FspHobList - 0x%x\n", FspHobList
));
168 FspHobProcess (FspHobList
);
171 // Register EndOfPei Notify for S3 to run FspNotifyPhase
173 PeiServicesGetBootMode (&BootMode
);
174 if (BootMode
== BOOT_ON_S3_RESUME
) {
175 Status
= PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc
);
176 ASSERT_EFI_ERROR (Status
);