]>
Commit | Line | Data |
---|---|---|
615c6dd0 | 1 | /** @file\r |
b1f6a7c6 | 2 | Pei Core Main Entry Point\r |
3 | \r | |
192f6d4c | 4 | Copyright (c) 2006, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
615c6dd0 | 13 | **/\r |
192f6d4c | 14 | \r |
192f6d4c | 15 | #include <PeiMain.h>\r |
16 | \r | |
b1f6a7c6 | 17 | STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {\r |
192f6d4c | 18 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r |
19 | &gEfiPeiMemoryDiscoveredPpiGuid,\r | |
20 | NULL\r | |
21 | };\r | |
22 | \r | |
40f26b8f | 23 | ///\r |
24 | /// Pei Core Module Variables\r | |
25 | ///\r | |
26 | ///\r | |
b1f6a7c6 | 27 | STATIC EFI_PEI_SERVICES gPs = {\r |
192f6d4c | 28 | {\r |
29 | PEI_SERVICES_SIGNATURE,\r | |
30 | PEI_SERVICES_REVISION,\r | |
31 | sizeof (EFI_PEI_SERVICES),\r | |
32 | 0,\r | |
33 | 0\r | |
34 | },\r | |
35 | PeiInstallPpi,\r | |
36 | PeiReInstallPpi,\r | |
37 | PeiLocatePpi,\r | |
38 | PeiNotifyPpi,\r | |
39 | \r | |
40 | PeiGetBootMode,\r | |
41 | PeiSetBootMode,\r | |
42 | \r | |
43 | PeiGetHobList,\r | |
44 | PeiCreateHob,\r | |
45 | \r | |
46 | PeiFvFindNextVolume,\r | |
47 | PeiFfsFindNextFile,\r | |
48 | PeiFfsFindSectionData,\r | |
49 | \r | |
b0d803fe | 50 | PeiInstallPeiMemory, \r |
192f6d4c | 51 | PeiAllocatePages,\r |
52 | PeiAllocatePool,\r | |
53 | (EFI_PEI_COPY_MEM)CopyMem,\r | |
54 | (EFI_PEI_SET_MEM)SetMem,\r | |
55 | \r | |
56 | PeiReportStatusCode,\r | |
14e8823a | 57 | PeiResetSystem,\r |
b0d803fe | 58 | \r |
14e8823a | 59 | NULL,\r |
60 | NULL,\r | |
b0d803fe | 61 | \r |
62 | PeiFfsFindFileByName,\r | |
63 | PeiFfsGetFileInfo,\r | |
64 | PeiFfsGetVolumeInfo,\r | |
14e8823a | 65 | PeiRegisterForShadow\r |
192f6d4c | 66 | };\r |
67 | \r | |
b1f6a7c6 | 68 | /**\r |
192f6d4c | 69 | \r |
70 | The entry routine to Pei Core, invoked by PeiMain during transition\r | |
71 | from SEC to PEI. After switching stack in the PEI core, it will restart\r | |
72 | with the old core data.\r | |
73 | \r | |
192f6d4c | 74 | \r |
b1f6a7c6 | 75 | @param SecCoreData Points to a data structure containing information about the PEI core's operating\r |
5aae0aa7 | 76 | environment, such as the size and location of temporary RAM, the stack location and\r |
77 | the BFV location.\r | |
b1f6a7c6 | 78 | @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r |
5aae0aa7 | 79 | An empty PPI list consists of a single descriptor with the end-tag\r |
80 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r | |
81 | phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r | |
82 | that both the PEI Foundation and any modules can leverage the associated service\r | |
83 | calls and/or code in these early PPIs\r | |
b1f6a7c6 | 84 | @param Data Pointer to old core data that is used to initialize the\r |
192f6d4c | 85 | core's data areas.\r |
86 | \r | |
b1f6a7c6 | 87 | @retval EFI_NOT_FOUND Never reach\r |
192f6d4c | 88 | \r |
b1f6a7c6 | 89 | **/\r |
90 | EFI_STATUS\r | |
91 | EFIAPI\r | |
92 | PeiCore (\r | |
93 | IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r | |
94 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r | |
95 | IN VOID *Data\r | |
96 | )\r | |
192f6d4c | 97 | {\r |
98 | PEI_CORE_INSTANCE PrivateData;\r | |
99 | EFI_STATUS Status;\r | |
100 | PEI_CORE_TEMP_POINTERS TempPtr;\r | |
192f6d4c | 101 | UINT64 mTick;\r |
102 | PEI_CORE_INSTANCE *OldCoreData;\r | |
b0d803fe | 103 | EFI_PEI_CPU_IO_PPI *CpuIo;\r |
104 | EFI_PEI_PCI_CFG2_PPI *PciCfg;\r | |
15273993 | 105 | PEICORE_FUNCTION_POINTER ShadowedPeiCore;\r |
192f6d4c | 106 | \r |
107 | mTick = 0;\r | |
108 | OldCoreData = (PEI_CORE_INSTANCE *) Data;\r | |
109 | \r | |
40f26b8f | 110 | //\r |
111 | // Record the system tick for first entering PeiCore.\r | |
112 | // This tick is duration of executing platform seccore module.\r | |
113 | // \r | |
192f6d4c | 114 | if (PerformanceMeasurementEnabled()) {\r |
115 | if (OldCoreData == NULL) {\r | |
116 | mTick = GetPerformanceCounter ();\r | |
117 | }\r | |
118 | }\r | |
119 | \r | |
40f26b8f | 120 | //\r |
121 | // PeiCore has been shadowed to memory for first entering, so\r | |
122 | // just jump to PeiCore in memory here.\r | |
123 | //\r | |
192f6d4c | 124 | if (OldCoreData != NULL) {\r |
15273993 | 125 | ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) OldCoreData->ShadowedPeiCore;\r |
58dcdada | 126 | if (ShadowedPeiCore != NULL) {\r |
127 | OldCoreData->ShadowedPeiCore = NULL;\r | |
128 | ShadowedPeiCore (\r | |
129 | SecCoreData,\r | |
130 | PpiList,\r | |
131 | OldCoreData\r | |
132 | );\r | |
133 | }\r | |
134 | \r | |
192f6d4c | 135 | CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));\r |
b0d803fe | 136 | \r |
137 | CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;\r | |
138 | PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;\r | |
139 | \r | |
b1f6a7c6 | 140 | CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r |
b0d803fe | 141 | \r |
142 | PrivateData.ServiceTableShadow.CpuIo = CpuIo;\r | |
143 | PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r | |
192f6d4c | 144 | } else {\r |
145 | ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r | |
b0d803fe | 146 | PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r |
b1f6a7c6 | 147 | CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r |
192f6d4c | 148 | }\r |
149 | \r | |
b0d803fe | 150 | PrivateData.PS = &PrivateData.ServiceTableShadow;\r |
192f6d4c | 151 | \r |
152 | //\r | |
153 | // Initialize libraries that the PeiCore is linked against\r | |
192f6d4c | 154 | //\r |
155 | ProcessLibraryConstructorList (NULL, &PrivateData.PS);\r | |
156 | \r | |
b0d803fe | 157 | InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r |
192f6d4c | 158 | \r |
b0d803fe | 159 | InitializePpiServices (&PrivateData, OldCoreData);\r |
192f6d4c | 160 | \r |
81c7803c | 161 | //\r |
162 | // Save PeiServicePointer so that it can be retrieved anywhere.\r | |
163 | //\r | |
164 | SetPeiServicesTablePointer(&PrivateData.PS);\r | |
165 | \r | |
192f6d4c | 166 | if (OldCoreData != NULL) {\r |
167 | \r | |
168 | PERF_END (NULL,"PreMem", NULL, 0);\r | |
169 | PERF_START (NULL,"PostMem", NULL, 0);\r | |
170 | \r | |
192f6d4c | 171 | //\r |
172 | // Alert any listeners that there is permanent memory available\r | |
173 | //\r | |
174 | \r | |
175 | PERF_START (NULL,"DisMem", NULL, 0);\r | |
176 | Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);\r | |
177 | PERF_END (NULL,"DisMem", NULL, 0);\r | |
178 | \r | |
179 | } else {\r | |
180 | \r | |
181 | //\r | |
182 | // Report Status Code EFI_SW_PC_INIT\r | |
183 | //\r | |
184 | REPORT_STATUS_CODE (\r | |
185 | EFI_PROGRESS_CODE,\r | |
797a9d67 | 186 | FixedPcdGet32 (PcdStatusCodeValuePeiCoreEntry)\r |
192f6d4c | 187 | );\r |
188 | \r | |
189 | PERF_START (NULL,"PEI", NULL, mTick);\r | |
190 | //\r | |
191 | // If first pass, start performance measurement.\r | |
192 | //\r | |
193 | PERF_START (NULL,"PreMem", NULL, mTick);\r | |
194 | \r | |
195 | //\r | |
196 | // If SEC provided any PPI services to PEI, install them.\r | |
197 | //\r | |
5088e385 | 198 | if (PpiList != NULL) {\r |
199 | Status = PeiServicesInstallPpi (PpiList);\r | |
192f6d4c | 200 | ASSERT_EFI_ERROR (Status);\r |
201 | }\r | |
202 | }\r | |
203 | \r | |
b0d803fe | 204 | InitializeSecurityServices (&PrivateData.PS, OldCoreData);\r |
205 | \r | |
206 | InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);\r | |
207 | \r | |
208 | //\r | |
209 | // Install Pei Load File PPI. \r | |
210 | //\r | |
211 | InitializeImageServices (&PrivateData, OldCoreData);\r | |
192f6d4c | 212 | \r |
213 | //\r | |
214 | // Call PEIM dispatcher\r | |
215 | //\r | |
b0d803fe | 216 | PeiDispatcher (SecCoreData, &PrivateData);\r |
192f6d4c | 217 | \r |
218 | //\r | |
219 | // Check if InstallPeiMemory service was called.\r | |
220 | //\r | |
221 | ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r | |
222 | \r | |
40f26b8f | 223 | //\r |
224 | // Till now, PEI phase will be finished, get performace count\r | |
225 | // for computing duration of PEI phase\r | |
226 | //\r | |
192f6d4c | 227 | PERF_END (NULL, "PostMem", NULL, 0);\r |
228 | \r | |
229 | Status = PeiServicesLocatePpi (\r | |
230 | &gEfiDxeIplPpiGuid,\r | |
231 | 0,\r | |
232 | NULL,\r | |
233 | (VOID **)&TempPtr.DxeIpl\r | |
234 | );\r | |
235 | ASSERT_EFI_ERROR (Status);\r | |
236 | \r | |
40f26b8f | 237 | //\r |
238 | // Enter DxeIpl to load Dxe core.\r | |
239 | //\r | |
192f6d4c | 240 | DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r |
241 | Status = TempPtr.DxeIpl->Entry (\r | |
242 | TempPtr.DxeIpl,\r | |
243 | &PrivateData.PS,\r | |
244 | PrivateData.HobList\r | |
245 | );\r | |
246 | \r | |
247 | ASSERT_EFI_ERROR (Status);\r | |
248 | \r | |
249 | return EFI_NOT_FOUND;\r | |
250 | }\r | |
251 | \r | |
a3a15d21 | 252 | \r |