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
, &StackSize
, &StackBase
);
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
, &StackSize
, &StackBase
);
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
);
100 FspRtBuffer
.BootLoaderTolumSize
= 0;
102 ZeroMem (&FspInitParams
, sizeof(FspInitParams
));
103 FspInitParams
.NvsBufferPtr
= GetNvsBuffer ();
104 DEBUG ((DEBUG_INFO
, "NvsBufferPtr - 0x%x\n", FspInitParams
.NvsBufferPtr
));
105 FspInitParams
.RtBufferPtr
= (VOID
*)&FspRtBuffer
;
106 FspInitParams
.ContinuationFunc
= (CONTINUATION_PROC
)ContinuationFunc
;
108 SaveSecContext (GetPeiServicesTablePointer ());
110 DEBUG ((DEBUG_INFO
, "FspInitParams - 0x%x\n", &FspInitParams
));
111 DEBUG ((DEBUG_INFO
, " NvsBufferPtr - 0x%x\n", FspInitParams
.NvsBufferPtr
));
112 DEBUG ((DEBUG_INFO
, " RtBufferPtr - 0x%x\n", FspInitParams
.RtBufferPtr
));
113 DEBUG ((DEBUG_INFO
, " StackTop - 0x%x\n", FspRtBuffer
.StackTop
));
114 DEBUG ((DEBUG_INFO
, " BootMode - 0x%x\n", FspRtBuffer
.BootMode
));
115 DEBUG ((DEBUG_INFO
, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer
.UpdDataRgnPtr
));
116 DEBUG ((DEBUG_INFO
, " ContinuationFunc - 0x%x\n", FspInitParams
.ContinuationFunc
));
118 Status
= CallFspInit (FspHeader
, &FspInitParams
);
120 // Should never return
122 DEBUG((DEBUG_ERROR
, "FSP Init failed, status: 0x%x\n", Status
));
127 Do FSP initialization based on FspApi version 1.
129 @param[in] FspHeader FSP header pointer.
131 @return FSP initialization status.
135 IN FSP_INFO_HEADER
*FspHeader
139 FSP_INIT_DONE_PPI
*FspInitDone
;
141 EFI_BOOT_MODE BootMode
;
143 Status
= PeiServicesLocatePpi (
144 &gFspInitDonePpiGuid
,
147 (VOID
**) &FspInitDone
149 if (EFI_ERROR (Status
)) {
153 DEBUG ((DEBUG_INFO
, "1st entry\n"));
155 PeiFspInit (FspHeader
);
157 // Never return here, for FspApi version 1.
162 // 2nd entry for FspApi version 1 only.
164 DEBUG ((DEBUG_INFO
, "2nd entry\n"));
166 Status
= FspInitDone
->GetFspHobList (GetPeiServicesTablePointer (), FspInitDone
, &FspHobList
);
167 ASSERT_EFI_ERROR (Status
);
168 DEBUG ((DEBUG_INFO
, "FspHobList - 0x%x\n", FspHobList
));
169 FspHobProcess (FspHobList
);
172 // Register EndOfPei Notify for S3 to run FspNotifyPhase
174 PeiServicesGetBootMode (&BootMode
);
175 if (BootMode
== BOOT_ON_S3_RESUME
) {
176 Status
= PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc
);
177 ASSERT_EFI_ERROR (Status
);