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