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