]>
Commit | Line | Data |
---|---|---|
d8043ce9 JY |
1 | /** @file\r |
2 | In FSP API V1 mode, it will be invoked twice by pei core. In 1st entry, it will\r | |
3 | call FspInit API. In 2nd entry, it will parse the hoblist from fsp and report\r | |
4 | them into pei core.\r | |
5 | \r | |
6 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r | |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php.\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | \r | |
18 | #include "FspInitPei.h"\r | |
19 | \r | |
20 | /**\r | |
21 | FSP Init continuation function.\r | |
22 | Control will be returned to this callback function after FspInit API call.\r | |
23 | \r | |
24 | @param[in] Status Status of the FSP INIT API\r | |
25 | @param[in] HobListPtr Pointer to the HOB data structure defined in the PI specification.\r | |
26 | \r | |
27 | **/\r | |
28 | VOID\r | |
29 | ContinuationFunc (\r | |
30 | IN EFI_STATUS Status,\r | |
31 | IN VOID *HobListPtr\r | |
32 | )\r | |
33 | {\r | |
34 | EFI_BOOT_MODE BootMode;\r | |
35 | UINT64 StackSize;\r | |
36 | EFI_PHYSICAL_ADDRESS StackBase;\r | |
37 | \r | |
38 | DEBUG ((DEBUG_INFO, "ContinuationFunc - %r\n", Status));\r | |
39 | DEBUG ((DEBUG_INFO, "HobListPtr - 0x%x\n", HobListPtr));\r | |
40 | \r | |
41 | if (Status != EFI_SUCCESS) {\r | |
42 | CpuDeadLoop ();\r | |
43 | }\r | |
44 | \r | |
45 | //\r | |
46 | // Can not call any PeiServices\r | |
47 | //\r | |
48 | BootMode = GetBootMode ();\r | |
49 | \r | |
50 | GetStackInfo (BootMode, TRUE, &StackBase, &StackSize);\r | |
51 | DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));\r | |
52 | DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));\r | |
53 | CallPeiCoreEntryPoint (\r | |
54 | HobListPtr,\r | |
55 | (VOID *)(UINTN)StackBase,\r | |
56 | (VOID *)(UINTN)(StackBase + StackSize)\r | |
57 | );\r | |
58 | }\r | |
59 | \r | |
60 | /**\r | |
61 | Call FspInit API.\r | |
62 | \r | |
63 | @param[in] FspHeader FSP header pointer.\r | |
64 | **/\r | |
65 | VOID\r | |
66 | PeiFspInit (\r | |
67 | IN FSP_INFO_HEADER *FspHeader\r | |
68 | )\r | |
69 | {\r | |
70 | FSP_INIT_PARAMS FspInitParams;\r | |
71 | FSP_INIT_RT_COMMON_BUFFER FspRtBuffer;\r | |
72 | UINT8 FspUpdRgn[FixedPcdGet32 (PcdMaxUpdRegionSize)];\r | |
73 | UINT32 UpdRegionSize;\r | |
74 | EFI_BOOT_MODE BootMode;\r | |
75 | UINT64 StackSize;\r | |
76 | EFI_PHYSICAL_ADDRESS StackBase;\r | |
77 | EFI_STATUS Status;\r | |
78 | \r | |
79 | DEBUG ((DEBUG_INFO, "PeiFspInit enter\n"));\r | |
80 | \r | |
81 | PeiServicesGetBootMode (&BootMode);\r | |
82 | DEBUG ((DEBUG_INFO, "BootMode - 0x%x\n", BootMode));\r | |
83 | \r | |
84 | GetStackInfo (BootMode, FALSE, &StackBase, &StackSize);\r | |
85 | DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));\r | |
86 | DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));\r | |
87 | \r | |
88 | ZeroMem (&FspRtBuffer, sizeof(FspRtBuffer));\r | |
89 | FspRtBuffer.StackTop = (UINT32 *)(UINTN)(StackBase + StackSize);\r | |
90 | \r | |
91 | FspRtBuffer.BootMode = BootMode;\r | |
92 | \r | |
93 | /* Platform override any UPD configs */\r | |
94 | UpdRegionSize = GetUpdRegionSize();\r | |
95 | DEBUG ((DEBUG_INFO, "UpdRegionSize - 0x%x\n", UpdRegionSize));\r | |
96 | DEBUG ((DEBUG_INFO, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn)));\r | |
97 | ASSERT(sizeof(FspUpdRgn) >= UpdRegionSize);\r | |
98 | ZeroMem (FspUpdRgn, UpdRegionSize);\r | |
99 | FspRtBuffer.UpdDataRgnPtr = UpdateFspUpdConfigs (FspUpdRgn);\r | |
88a539ca | 100 | FspRtBuffer.BootLoaderTolumSize = 0;\r |
d8043ce9 JY |
101 | \r |
102 | ZeroMem (&FspInitParams, sizeof(FspInitParams));\r | |
103 | FspInitParams.NvsBufferPtr = GetNvsBuffer ();\r | |
104 | DEBUG ((DEBUG_INFO, "NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));\r | |
105 | FspInitParams.RtBufferPtr = (VOID *)&FspRtBuffer;\r | |
106 | FspInitParams.ContinuationFunc = (CONTINUATION_PROC)ContinuationFunc;\r | |
107 | \r | |
108 | SaveSecContext (GetPeiServicesTablePointer ());\r | |
109 | \r | |
110 | DEBUG ((DEBUG_INFO, "FspInitParams - 0x%x\n", &FspInitParams));\r | |
111 | DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));\r | |
112 | DEBUG ((DEBUG_INFO, " RtBufferPtr - 0x%x\n", FspInitParams.RtBufferPtr));\r | |
113 | DEBUG ((DEBUG_INFO, " StackTop - 0x%x\n", FspRtBuffer.StackTop));\r | |
114 | DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspRtBuffer.BootMode));\r | |
115 | DEBUG ((DEBUG_INFO, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer.UpdDataRgnPtr));\r | |
116 | DEBUG ((DEBUG_INFO, " ContinuationFunc - 0x%x\n", FspInitParams.ContinuationFunc));\r | |
117 | \r | |
118 | Status = CallFspInit (FspHeader, &FspInitParams);\r | |
119 | //\r | |
120 | // Should never return\r | |
121 | //\r | |
122 | DEBUG((DEBUG_ERROR, "FSP Init failed, status: 0x%x\n", Status));\r | |
123 | CpuDeadLoop ();\r | |
124 | }\r | |
125 | \r | |
126 | /**\r | |
127 | Do FSP initialization based on FspApi version 1.\r | |
128 | \r | |
129 | @param[in] FspHeader FSP header pointer.\r | |
130 | \r | |
131 | @return FSP initialization status.\r | |
132 | **/\r | |
133 | EFI_STATUS\r | |
134 | PeiFspInitV1 (\r | |
135 | IN FSP_INFO_HEADER *FspHeader\r | |
136 | )\r | |
137 | {\r | |
138 | EFI_STATUS Status;\r | |
139 | FSP_INIT_DONE_PPI *FspInitDone;\r | |
140 | VOID *FspHobList;\r | |
141 | EFI_BOOT_MODE BootMode;\r | |
142 | \r | |
143 | Status = PeiServicesLocatePpi (\r | |
144 | &gFspInitDonePpiGuid,\r | |
145 | 0,\r | |
146 | NULL,\r | |
147 | (VOID **) &FspInitDone\r | |
148 | );\r | |
149 | if (EFI_ERROR (Status)) {\r | |
150 | //\r | |
151 | // 1st entry\r | |
152 | //\r | |
153 | DEBUG ((DEBUG_INFO, "1st entry\n"));\r | |
154 | \r | |
155 | PeiFspInit (FspHeader);\r | |
156 | //\r | |
157 | // Never return here, for FspApi version 1.\r | |
158 | //\r | |
159 | CpuDeadLoop ();\r | |
160 | } else {\r | |
161 | //\r | |
162 | // 2nd entry for FspApi version 1 only.\r | |
163 | //\r | |
164 | DEBUG ((DEBUG_INFO, "2nd entry\n"));\r | |
165 | \r | |
166 | Status = FspInitDone->GetFspHobList (GetPeiServicesTablePointer (), FspInitDone, &FspHobList);\r | |
167 | ASSERT_EFI_ERROR (Status);\r | |
168 | DEBUG ((DEBUG_INFO, "FspHobList - 0x%x\n", FspHobList));\r | |
169 | FspHobProcess (FspHobList);\r | |
170 | \r | |
171 | //\r | |
172 | // Register EndOfPei Notify for S3 to run FspNotifyPhase\r | |
173 | //\r | |
174 | PeiServicesGetBootMode (&BootMode);\r | |
175 | if (BootMode == BOOT_ON_S3_RESUME) {\r | |
176 | Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);\r | |
177 | ASSERT_EFI_ERROR (Status);\r | |
178 | }\r | |
179 | }\r | |
180 | \r | |
181 | return EFI_SUCCESS;\r | |
182 | } |