]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Pei Core Main Entry Point\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | 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 | PeiFfsFindNextVolume,\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 | &gPeiDefaultCpuIoPpi,\r | |
59 | &gPeiDefaultPciCfg2Ppi,\r | |
60 | \r | |
61 | PeiFfsFindFileByName,\r | |
62 | PeiFfsGetFileInfo,\r | |
63 | PeiFfsGetVolumeInfo,\r | |
64 | PeiRegisterForShadow,\r | |
65 | PeiFfsFindSectionData3,\r | |
66 | PeiFfsGetFileInfo2,\r | |
67 | PeiResetSystem2\r | |
68 | };\r | |
69 | \r | |
70 | /**\r | |
71 | Shadow PeiCore module from flash to installed memory.\r | |
72 | \r | |
73 | @param PrivateData PeiCore's private data structure\r | |
74 | \r | |
75 | @return PeiCore function address after shadowing.\r | |
76 | **/\r | |
77 | PEICORE_FUNCTION_POINTER\r | |
78 | ShadowPeiCore (\r | |
79 | IN PEI_CORE_INSTANCE *PrivateData\r | |
80 | )\r | |
81 | {\r | |
82 | EFI_PEI_FILE_HANDLE PeiCoreFileHandle;\r | |
83 | EFI_PHYSICAL_ADDRESS EntryPoint;\r | |
84 | EFI_STATUS Status;\r | |
85 | UINT32 AuthenticationState;\r | |
86 | \r | |
87 | PeiCoreFileHandle = NULL;\r | |
88 | \r | |
89 | //\r | |
90 | // Find the PEI Core in the BFV\r | |
91 | //\r | |
92 | Status = PrivateData->Fv[0].FvPpi->FindFileByType (\r | |
93 | PrivateData->Fv[0].FvPpi,\r | |
94 | EFI_FV_FILETYPE_PEI_CORE,\r | |
95 | PrivateData->Fv[0].FvHandle,\r | |
96 | &PeiCoreFileHandle\r | |
97 | );\r | |
98 | ASSERT_EFI_ERROR (Status);\r | |
99 | \r | |
100 | //\r | |
101 | // Shadow PEI Core into memory so it will run faster\r | |
102 | //\r | |
103 | Status = PeiLoadImage (\r | |
104 | GetPeiServicesTablePointer (),\r | |
105 | *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle),\r | |
106 | PEIM_STATE_REGISITER_FOR_SHADOW,\r | |
107 | &EntryPoint,\r | |
108 | &AuthenticationState\r | |
109 | );\r | |
110 | ASSERT_EFI_ERROR (Status);\r | |
111 | \r | |
112 | //\r | |
113 | // Compute the PeiCore's function address after shaowed PeiCore.\r | |
114 | // _ModuleEntryPoint is PeiCore main function entry\r | |
115 | //\r | |
116 | return (PEICORE_FUNCTION_POINTER)((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r | |
117 | }\r | |
118 | \r | |
119 | /**\r | |
120 | This routine is invoked by main entry of PeiMain module during transition\r | |
121 | from SEC to PEI. After switching stack in the PEI core, it will restart\r | |
122 | with the old core data.\r | |
123 | \r | |
124 | @param SecCoreDataPtr Points to a data structure containing information about the PEI core's operating\r | |
125 | environment, such as the size and location of temporary RAM, the stack location and\r | |
126 | the BFV location.\r | |
127 | @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r | |
128 | An empty PPI list consists of a single descriptor with the end-tag\r | |
129 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r | |
130 | phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r | |
131 | that both the PEI Foundation and any modules can leverage the associated service\r | |
132 | calls and/or code in these early PPIs\r | |
133 | @param Data Pointer to old core data that is used to initialize the\r | |
134 | core's data areas.\r | |
135 | If NULL, it is first PeiCore entering.\r | |
136 | \r | |
137 | **/\r | |
138 | VOID\r | |
139 | NORETURN\r | |
140 | EFIAPI\r | |
141 | PeiCore (\r | |
142 | IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreDataPtr,\r | |
143 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r | |
144 | IN VOID *Data\r | |
145 | )\r | |
146 | {\r | |
147 | PEI_CORE_INSTANCE PrivateData;\r | |
148 | EFI_SEC_PEI_HAND_OFF *SecCoreData;\r | |
149 | EFI_SEC_PEI_HAND_OFF NewSecCoreData;\r | |
150 | EFI_STATUS Status;\r | |
151 | PEI_CORE_TEMP_POINTERS TempPtr;\r | |
152 | PEI_CORE_INSTANCE *OldCoreData;\r | |
153 | EFI_PEI_CPU_IO_PPI *CpuIo;\r | |
154 | EFI_PEI_PCI_CFG2_PPI *PciCfg;\r | |
155 | EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;\r | |
156 | EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi;\r | |
157 | UINTN Index;\r | |
158 | \r | |
159 | //\r | |
160 | // Retrieve context passed into PEI Core\r | |
161 | //\r | |
162 | OldCoreData = (PEI_CORE_INSTANCE *) Data;\r | |
163 | SecCoreData = (EFI_SEC_PEI_HAND_OFF *) SecCoreDataPtr;\r | |
164 | \r | |
165 | //\r | |
166 | // Perform PEI Core phase specific actions.\r | |
167 | //\r | |
168 | if (OldCoreData == NULL) {\r | |
169 | //\r | |
170 | // If OldCoreData is NULL, means current is the first entry into the PEI Core before memory is available.\r | |
171 | //\r | |
172 | ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r | |
173 | PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r | |
174 | CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r | |
175 | } else {\r | |
176 | //\r | |
177 | // Memory is available to the PEI Core. See if the PEI Core has been shadowed to memory yet.\r | |
178 | //\r | |
179 | if (OldCoreData->ShadowedPeiCore == NULL) {\r | |
180 | //\r | |
181 | // Fixup the PeiCore's private data\r | |
182 | //\r | |
183 | OldCoreData->Ps = &OldCoreData->ServiceTableShadow;\r | |
184 | OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;\r | |
185 | if (OldCoreData->HeapOffsetPositive) {\r | |
186 | OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);\r | |
187 | OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);\r | |
188 | OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);\r | |
189 | OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset);\r | |
190 | OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);\r | |
191 | for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r | |
192 | OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;\r | |
193 | OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);\r | |
194 | }\r | |
195 | OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid + OldCoreData->HeapOffset);\r | |
196 | OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles + OldCoreData->HeapOffset);\r | |
197 | } else {\r | |
198 | OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);\r | |
199 | OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);\r | |
200 | OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);\r | |
201 | OldCoreData->PpiData.PpiListPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset);\r | |
202 | OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);\r | |
203 | for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r | |
204 | OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;\r | |
205 | OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);\r | |
206 | }\r | |
207 | OldCoreData->FileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->FileGuid - OldCoreData->HeapOffset);\r | |
208 | OldCoreData->FileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->FileHandles - OldCoreData->HeapOffset);\r | |
209 | }\r | |
210 | \r | |
211 | //\r | |
212 | // Initialize libraries that the PEI Core is linked against\r | |
213 | //\r | |
214 | ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r | |
215 | \r | |
216 | //\r | |
217 | // Fixup for PeiService's address\r | |
218 | //\r | |
219 | SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r | |
220 | \r | |
221 | //\r | |
222 | // Update HandOffHob for new installed permenent memory\r | |
223 | //\r | |
224 | HandoffInformationTable = OldCoreData->HobList.HandoffInformationTable;\r | |
225 | if (OldCoreData->HeapOffsetPositive) {\r | |
226 | HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList + OldCoreData->HeapOffset;\r | |
227 | } else {\r | |
228 | HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList - OldCoreData->HeapOffset;\r | |
229 | }\r | |
230 | HandoffInformationTable->EfiMemoryTop = OldCoreData->PhysicalMemoryBegin + OldCoreData->PhysicalMemoryLength;\r | |
231 | HandoffInformationTable->EfiMemoryBottom = OldCoreData->PhysicalMemoryBegin;\r | |
232 | HandoffInformationTable->EfiFreeMemoryTop = OldCoreData->FreePhysicalMemoryTop;\r | |
233 | HandoffInformationTable->EfiFreeMemoryBottom = HandoffInformationTable->EfiEndOfHobList + sizeof (EFI_HOB_GENERIC_HEADER);\r | |
234 | \r | |
235 | //\r | |
236 | // We need convert the PPI descriptor's pointer\r | |
237 | //\r | |
238 | ConvertPpiPointers (SecCoreData, OldCoreData);\r | |
239 | \r | |
240 | //\r | |
241 | // After the whole temporary memory is migrated, then we can allocate page in\r | |
242 | // permenent memory.\r | |
243 | //\r | |
244 | OldCoreData->PeiMemoryInstalled = TRUE;\r | |
245 | \r | |
246 | //\r | |
247 | // Indicate that PeiCore reenter\r | |
248 | //\r | |
249 | OldCoreData->PeimDispatcherReenter = TRUE;\r | |
250 | \r | |
251 | if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (OldCoreData->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r | |
252 | //\r | |
253 | // if Loading Module at Fixed Address is enabled, allocate the PEI code memory range usage bit map array.\r | |
254 | // Every bit in the array indicate the status of the corresponding memory page available or not\r | |
255 | //\r | |
256 | OldCoreData->PeiCodeMemoryRangeUsageBitMap = AllocateZeroPool (((PcdGet32(PcdLoadFixAddressPeiCodePageNumber)>>6) + 1)*sizeof(UINT64));\r | |
257 | }\r | |
258 | \r | |
259 | //\r | |
260 | // Shadow PEI Core. When permanent memory is avaiable, shadow\r | |
261 | // PEI Core and PEIMs to get high performance.\r | |
262 | //\r | |
263 | OldCoreData->ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) PeiCore;\r | |
264 | if ((HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnS3Boot))\r | |
265 | || (HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnBoot))) {\r | |
266 | OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);\r | |
267 | }\r | |
268 | \r | |
269 | //\r | |
270 | // PEI Core has now been shadowed to memory. Restart PEI Core in memory.\r | |
271 | //\r | |
272 | OldCoreData->ShadowedPeiCore (SecCoreData, PpiList, OldCoreData);\r | |
273 | \r | |
274 | //\r | |
275 | // Should never reach here.\r | |
276 | //\r | |
277 | ASSERT (FALSE);\r | |
278 | CpuDeadLoop();\r | |
279 | \r | |
280 | UNREACHABLE ();\r | |
281 | }\r | |
282 | \r | |
283 | //\r | |
284 | // Memory is available to the PEI Core and the PEI Core has been shadowed to memory.\r | |
285 | //\r | |
286 | CopyMem (&NewSecCoreData, SecCoreDataPtr, sizeof (NewSecCoreData));\r | |
287 | SecCoreData = &NewSecCoreData;\r | |
288 | \r | |
289 | CopyMem (&PrivateData, OldCoreData, sizeof (PrivateData));\r | |
290 | \r | |
291 | CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;\r | |
292 | PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;\r | |
293 | \r | |
294 | CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r | |
295 | \r | |
296 | PrivateData.ServiceTableShadow.CpuIo = CpuIo;\r | |
297 | PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r | |
298 | }\r | |
299 | \r | |
300 | //\r | |
301 | // Cache a pointer to the PEI Services Table that is either in temporary memory or permanent memory\r | |
302 | //\r | |
303 | PrivateData.Ps = &PrivateData.ServiceTableShadow;\r | |
304 | \r | |
305 | //\r | |
306 | // Initialize libraries that the PEI Core is linked against\r | |
307 | //\r | |
308 | ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r | |
309 | \r | |
310 | //\r | |
311 | // Save PeiServicePointer so that it can be retrieved anywhere.\r | |
312 | //\r | |
313 | SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r | |
314 | \r | |
315 | //\r | |
316 | // Initialize PEI Core Services\r | |
317 | //\r | |
318 | InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r | |
319 | if (OldCoreData == NULL) {\r | |
320 | //\r | |
321 | // Initialize PEI Core Private Data Buffer\r | |
322 | //\r | |
323 | PrivateData.PpiData.PpiListPtrs = AllocateZeroPool (sizeof (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported));\r | |
324 | ASSERT (PrivateData.PpiData.PpiListPtrs != NULL);\r | |
325 | PrivateData.Fv = AllocateZeroPool (sizeof (PEI_CORE_FV_HANDLE) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r | |
326 | ASSERT (PrivateData.Fv != NULL);\r | |
327 | PrivateData.Fv[0].PeimState = AllocateZeroPool (sizeof (UINT8) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r | |
328 | ASSERT (PrivateData.Fv[0].PeimState != NULL);\r | |
329 | PrivateData.Fv[0].FvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r | |
330 | ASSERT (PrivateData.Fv[0].FvFileHandles != NULL);\r | |
331 | for (Index = 1; Index < PcdGet32 (PcdPeiCoreMaxFvSupported); Index ++) {\r | |
332 | PrivateData.Fv[Index].PeimState = PrivateData.Fv[Index - 1].PeimState + PcdGet32 (PcdPeiCoreMaxPeimPerFv);\r | |
333 | PrivateData.Fv[Index].FvFileHandles = PrivateData.Fv[Index - 1].FvFileHandles + PcdGet32 (PcdPeiCoreMaxPeimPerFv);\r | |
334 | }\r | |
335 | PrivateData.UnknownFvInfo = AllocateZeroPool (sizeof (PEI_CORE_UNKNOW_FORMAT_FV_INFO) * PcdGet32 (PcdPeiCoreMaxFvSupported));\r | |
336 | ASSERT (PrivateData.UnknownFvInfo != NULL);\r | |
337 | PrivateData.CurrentFvFileHandles = AllocateZeroPool (sizeof (EFI_PEI_FILE_HANDLE) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));\r | |
338 | ASSERT (PrivateData.CurrentFvFileHandles != NULL);\r | |
339 | PrivateData.FileGuid = AllocatePool (sizeof (EFI_GUID) * PcdGet32 (PcdPeiCoreMaxPeimPerFv));\r | |
340 | ASSERT (PrivateData.FileGuid != NULL);\r | |
341 | PrivateData.FileHandles = AllocatePool (sizeof (EFI_PEI_FILE_HANDLE) * (PcdGet32 (PcdPeiCoreMaxPeimPerFv) + 1));\r | |
342 | ASSERT (PrivateData.FileHandles != NULL);\r | |
343 | }\r | |
344 | InitializePpiServices (&PrivateData, OldCoreData);\r | |
345 | \r | |
346 | //\r | |
347 | // Update performance measurements \r | |
348 | //\r | |
349 | if (OldCoreData == NULL) {\r | |
350 | PERF_START (NULL, "SEC", NULL, 1);\r | |
351 | PERF_END (NULL, "SEC", NULL, 0);\r | |
352 | \r | |
353 | //\r | |
354 | // If first pass, start performance measurement.\r | |
355 | //\r | |
356 | PERF_START (NULL,"PEI", NULL, 0);\r | |
357 | PERF_START (NULL,"PreMem", NULL, 0);\r | |
358 | \r | |
359 | } else {\r | |
360 | PERF_END (NULL,"PreMem", NULL, 0);\r | |
361 | PERF_START (NULL,"PostMem", NULL, 0);\r | |
362 | }\r | |
363 | \r | |
364 | //\r | |
365 | // Complete PEI Core Service initialization\r | |
366 | // \r | |
367 | InitializeSecurityServices (&PrivateData.Ps, OldCoreData);\r | |
368 | InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);\r | |
369 | InitializeImageServices (&PrivateData, OldCoreData);\r | |
370 | \r | |
371 | //\r | |
372 | // Perform PEI Core Phase specific actions\r | |
373 | // \r | |
374 | if (OldCoreData == NULL) {\r | |
375 | //\r | |
376 | // Report Status Code EFI_SW_PC_INIT\r | |
377 | //\r | |
378 | REPORT_STATUS_CODE (\r | |
379 | EFI_PROGRESS_CODE,\r | |
380 | (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)\r | |
381 | );\r | |
382 | \r | |
383 | //\r | |
384 | // If SEC provided any PPI services to PEI, install them.\r | |
385 | //\r | |
386 | if (PpiList != NULL) {\r | |
387 | Status = PeiServicesInstallPpi (PpiList);\r | |
388 | ASSERT_EFI_ERROR (Status);\r | |
389 | }\r | |
390 | } else {\r | |
391 | //\r | |
392 | // Try to locate Temporary RAM Done Ppi.\r | |
393 | //\r | |
394 | Status = PeiServicesLocatePpi (\r | |
395 | &gEfiTemporaryRamDonePpiGuid,\r | |
396 | 0,\r | |
397 | NULL,\r | |
398 | (VOID**)&TemporaryRamDonePpi\r | |
399 | );\r | |
400 | if (!EFI_ERROR (Status)) {\r | |
401 | //\r | |
402 | // Disable the use of Temporary RAM after the transition from Temporary RAM to Permanent RAM is complete.\r | |
403 | //\r | |
404 | TemporaryRamDonePpi->TemporaryRamDone ();\r | |
405 | }\r | |
406 | \r | |
407 | //\r | |
408 | // Alert any listeners that there is permanent memory available\r | |
409 | //\r | |
410 | PERF_START (NULL,"DisMem", NULL, 0);\r | |
411 | Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);\r | |
412 | \r | |
413 | //\r | |
414 | // Process the Notify list and dispatch any notifies for the Memory Discovered PPI\r | |
415 | //\r | |
416 | ProcessNotifyList (&PrivateData);\r | |
417 | \r | |
418 | PERF_END (NULL,"DisMem", NULL, 0);\r | |
419 | }\r | |
420 | \r | |
421 | //\r | |
422 | // Call PEIM dispatcher\r | |
423 | //\r | |
424 | PeiDispatcher (SecCoreData, &PrivateData);\r | |
425 | \r | |
426 | if (PrivateData.HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) {\r | |
427 | //\r | |
428 | // Check if InstallPeiMemory service was called on non-S3 resume boot path.\r | |
429 | //\r | |
430 | ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r | |
431 | }\r | |
432 | \r | |
433 | //\r | |
434 | // Measure PEI Core execution time.\r | |
435 | //\r | |
436 | PERF_END (NULL, "PostMem", NULL, 0);\r | |
437 | \r | |
438 | //\r | |
439 | // Lookup DXE IPL PPI\r | |
440 | //\r | |
441 | Status = PeiServicesLocatePpi (\r | |
442 | &gEfiDxeIplPpiGuid,\r | |
443 | 0,\r | |
444 | NULL,\r | |
445 | (VOID **)&TempPtr.DxeIpl\r | |
446 | );\r | |
447 | ASSERT_EFI_ERROR (Status);\r | |
448 | \r | |
449 | if (EFI_ERROR (Status)) {\r | |
450 | //\r | |
451 | // Report status code to indicate DXE IPL PPI could not be found.\r | |
452 | //\r | |
453 | REPORT_STATUS_CODE (\r | |
454 | EFI_ERROR_CODE | EFI_ERROR_MAJOR,\r | |
455 | (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_EC_DXEIPL_NOT_FOUND)\r | |
456 | );\r | |
457 | CpuDeadLoop ();\r | |
458 | }\r | |
459 | \r | |
460 | //\r | |
461 | // Enter DxeIpl to load Dxe core.\r | |
462 | //\r | |
463 | DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r | |
464 | Status = TempPtr.DxeIpl->Entry (\r | |
465 | TempPtr.DxeIpl,\r | |
466 | &PrivateData.Ps,\r | |
467 | PrivateData.HobList\r | |
468 | );\r | |
469 | //\r | |
470 | // Should never reach here.\r | |
471 | //\r | |
472 | ASSERT_EFI_ERROR (Status);\r | |
473 | CpuDeadLoop();\r | |
474 | \r | |
475 | UNREACHABLE ();\r | |
476 | }\r |