]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
IntelSiliconPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain / PeiMain.c
CommitLineData
615c6dd0 1/** @file\r
b1f6a7c6 2 Pei Core Main Entry Point\r
d1102dba 3\r
9b23c7ba 4Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
192f6d4c 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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 17EFI_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 26EFI_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
d1102dba 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
c7935105
SZ
64 PeiRegisterForShadow,\r
65 PeiFfsFindSectionData3,\r
672473ea 66 PeiFfsGetFileInfo2,\r
b2374cec
SZ
67 PeiResetSystem2,\r
68 PeiFreePages,\r
192f6d4c 69};\r
70\r
ef05e063 71/**\r
72 Shadow PeiCore module from flash to installed memory.\r
d1102dba 73\r
ef05e063 74 @param PrivateData PeiCore's private data structure\r
75\r
76 @return PeiCore function address after shadowing.\r
77**/\r
78PEICORE_FUNCTION_POINTER\r
79ShadowPeiCore (\r
80 IN PEI_CORE_INSTANCE *PrivateData\r
81 )\r
82{\r
9b23c7ba
CC
83 EFI_PEI_FILE_HANDLE PeiCoreFileHandle;\r
84 EFI_PHYSICAL_ADDRESS EntryPoint;\r
85 EFI_STATUS Status;\r
86 UINT32 AuthenticationState;\r
87 UINTN Index;\r
88 EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;\r
89 UINTN PeiCoreFvIndex;\r
ef05e063 90\r
91 PeiCoreFileHandle = NULL;\r
ef05e063 92 //\r
9b23c7ba
CC
93 // Default PeiCore is in BFV\r
94 //\r
95 PeiCoreFvIndex = 0;\r
96 //\r
97 // Find the PEI Core either from EFI_PEI_CORE_FV_LOCATION_PPI indicated FV or BFV\r
98 //\r
99 Status = PeiServicesLocatePpi (\r
100 &gEfiPeiCoreFvLocationPpiGuid,\r
101 0,\r
102 NULL,\r
103 (VOID **) &PeiCoreFvLocationPpi\r
104 );\r
105 if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != NULL)) {\r
106 //\r
107 // If PeiCoreFvLocation present, the PEI Core should be found from indicated FV\r
108 //\r
109 for (Index = 0; Index < PrivateData->FvCount; Index ++) {\r
110 if (PrivateData->Fv[Index].FvHandle == PeiCoreFvLocationPpi->PeiCoreFvLocation) {\r
111 PeiCoreFvIndex = Index;\r
112 break;\r
113 }\r
114 }\r
115 ASSERT (Index < PrivateData->FvCount);\r
116 }\r
117 //\r
118 // Find PEI Core from the given FV index\r
ef05e063 119 //\r
9b23c7ba
CC
120 Status = PrivateData->Fv[PeiCoreFvIndex].FvPpi->FindFileByType (\r
121 PrivateData->Fv[PeiCoreFvIndex].FvPpi,\r
122 EFI_FV_FILETYPE_PEI_CORE,\r
123 PrivateData->Fv[PeiCoreFvIndex].FvHandle,\r
124 &PeiCoreFileHandle\r
125 );\r
ef05e063 126 ASSERT_EFI_ERROR (Status);\r
127\r
128 //\r
129 // Shadow PEI Core into memory so it will run faster\r
130 //\r
131 Status = PeiLoadImage (\r
132 GetPeiServicesTablePointer (),\r
133 *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle),\r
c2c4199b 134 PEIM_STATE_REGISTER_FOR_SHADOW,\r
ef05e063 135 &EntryPoint,\r
136 &AuthenticationState\r
137 );\r
138 ASSERT_EFI_ERROR (Status);\r
139\r
140 //\r
141 // Compute the PeiCore's function address after shaowed PeiCore.\r
142 // _ModuleEntryPoint is PeiCore main function entry\r
143 //\r
144 return (PEICORE_FUNCTION_POINTER)((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r
145}\r
146\r
b1f6a7c6 147/**\r
82b8c8df 148 This routine is invoked by main entry of PeiMain module during transition\r
192f6d4c 149 from SEC to PEI. After switching stack in the PEI core, it will restart\r
150 with the old core data.\r
151\r
0f9ebb32 152 @param SecCoreDataPtr Points to a data structure containing information about the PEI core's operating\r
5aae0aa7 153 environment, such as the size and location of temporary RAM, the stack location and\r
154 the BFV location.\r
b1f6a7c6 155 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
5aae0aa7 156 An empty PPI list consists of a single descriptor with the end-tag\r
157 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
158 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
159 that both the PEI Foundation and any modules can leverage the associated service\r
160 calls and/or code in these early PPIs\r
b1f6a7c6 161 @param Data Pointer to old core data that is used to initialize the\r
192f6d4c 162 core's data areas.\r
82b8c8df 163 If NULL, it is first PeiCore entering.\r
192f6d4c 164\r
b1f6a7c6 165**/\r
0308e20d 166VOID\r
b1f6a7c6 167EFIAPI\r
168PeiCore (\r
0f9ebb32 169 IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreDataPtr,\r
b1f6a7c6 170 IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
171 IN VOID *Data\r
172 )\r
192f6d4c 173{\r
ef05e063 174 PEI_CORE_INSTANCE PrivateData;\r
0f9ebb32
LG
175 EFI_SEC_PEI_HAND_OFF *SecCoreData;\r
176 EFI_SEC_PEI_HAND_OFF NewSecCoreData;\r
ef05e063 177 EFI_STATUS Status;\r
178 PEI_CORE_TEMP_POINTERS TempPtr;\r
ef05e063 179 PEI_CORE_INSTANCE *OldCoreData;\r
180 EFI_PEI_CPU_IO_PPI *CpuIo;\r
181 EFI_PEI_PCI_CFG2_PPI *PciCfg;\r
182 EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;\r
0f9ebb32 183 EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi;\r
fe781940 184 UINTN Index;\r
d1102dba 185\r
6b22483f 186 //\r
187 // Retrieve context passed into PEI Core\r
188 //\r
0f9ebb32
LG
189 OldCoreData = (PEI_CORE_INSTANCE *) Data;\r
190 SecCoreData = (EFI_SEC_PEI_HAND_OFF *) SecCoreDataPtr;\r
192f6d4c 191\r
40f26b8f 192 //\r
6b22483f 193 // Perform PEI Core phase specific actions.\r
194 //\r
195 if (OldCoreData == NULL) {\r
196 //\r
197 // If OldCoreData is NULL, means current is the first entry into the PEI Core before memory is available.\r
198 //\r
199 ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE));\r
200 PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;\r
201 CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
202 } else {\r
203 //\r
204 // Memory is available to the PEI Core. See if the PEI Core has been shadowed to memory yet.\r
205 //\r
ef05e063 206 if (OldCoreData->ShadowedPeiCore == NULL) {\r
ef05e063 207 //\r
208 // Fixup the PeiCore's private data\r
209 //\r
6b22483f 210 OldCoreData->Ps = &OldCoreData->ServiceTableShadow;\r
211 OldCoreData->CpuIo = &OldCoreData->ServiceTableShadow.CpuIo;\r
ef05e063 212 if (OldCoreData->HeapOffsetPositive) {\r
213 OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);\r
111e6c92
SZ
214 if (OldCoreData->UnknownFvInfo != NULL) {\r
215 OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);\r
216 }\r
b62fe570
SZ
217 if (OldCoreData->CurrentFvFileHandles != NULL) {\r
218 OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);\r
219 }\r
f2bc359c
SZ
220 if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {\r
221 OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);\r
222 }\r
223 if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {\r
224 OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);\r
225 }\r
226 if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {\r
227 OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);\r
228 }\r
fe781940 229 OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);\r
111e6c92 230 for (Index = 0; Index < OldCoreData->FvCount; Index ++) {\r
b62fe570
SZ
231 if (OldCoreData->Fv[Index].PeimState != NULL) {\r
232 OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;\r
233 }\r
234 if (OldCoreData->Fv[Index].FvFileHandles != NULL) {\r
235 OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);\r
236 }\r
fe781940 237 }\r
b62fe570
SZ
238 OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid + OldCoreData->HeapOffset);\r
239 OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);\r
ef05e063 240 } else {\r
241 OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);\r
111e6c92
SZ
242 if (OldCoreData->UnknownFvInfo != NULL) {\r
243 OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);\r
244 }\r
b62fe570
SZ
245 if (OldCoreData->CurrentFvFileHandles != NULL) {\r
246 OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);\r
247 }\r
f2bc359c
SZ
248 if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {\r
249 OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);\r
250 }\r
251 if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {\r
252 OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);\r
253 }\r
254 if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {\r
255 OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);\r
256 }\r
fe781940 257 OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);\r
111e6c92 258 for (Index = 0; Index < OldCoreData->FvCount; Index ++) {\r
b62fe570
SZ
259 if (OldCoreData->Fv[Index].PeimState != NULL) {\r
260 OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;\r
261 }\r
262 if (OldCoreData->Fv[Index].FvFileHandles != NULL) {\r
263 OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);\r
264 }\r
fe781940 265 }\r
b62fe570
SZ
266 OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid - OldCoreData->HeapOffset);\r
267 OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles - OldCoreData->HeapOffset);\r
ef05e063 268 }\r
269\r
270 //\r
271 // Fixup for PeiService's address\r
272 //\r
273 SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r
274\r
75fe0a78
LG
275 //\r
276 // Initialize libraries that the PEI Core is linked against\r
277 //\r
278 ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&OldCoreData->Ps);\r
279\r
ef05e063 280 //\r
6393d9c8 281 // Update HandOffHob for new installed permanent memory\r
ef05e063 282 //\r
283 HandoffInformationTable = OldCoreData->HobList.HandoffInformationTable;\r
284 if (OldCoreData->HeapOffsetPositive) {\r
285 HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList + OldCoreData->HeapOffset;\r
286 } else {\r
287 HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList - OldCoreData->HeapOffset;\r
288 }\r
289 HandoffInformationTable->EfiMemoryTop = OldCoreData->PhysicalMemoryBegin + OldCoreData->PhysicalMemoryLength;\r
290 HandoffInformationTable->EfiMemoryBottom = OldCoreData->PhysicalMemoryBegin;\r
291 HandoffInformationTable->EfiFreeMemoryTop = OldCoreData->FreePhysicalMemoryTop;\r
292 HandoffInformationTable->EfiFreeMemoryBottom = HandoffInformationTable->EfiEndOfHobList + sizeof (EFI_HOB_GENERIC_HEADER);\r
293\r
b2374cec
SZ
294 //\r
295 // We need convert MemoryBaseAddress in memory allocation HOBs\r
296 //\r
297 ConvertMemoryAllocationHobs (OldCoreData);\r
298\r
ef05e063 299 //\r
424b7c9f 300 // We need convert the PPI descriptor's pointer\r
ef05e063 301 //\r
424b7c9f 302 ConvertPpiPointers (SecCoreData, OldCoreData);\r
ef05e063 303\r
304 //\r
305 // After the whole temporary memory is migrated, then we can allocate page in\r
6393d9c8 306 // permanent memory.\r
ef05e063 307 //\r
308 OldCoreData->PeiMemoryInstalled = TRUE;\r
309\r
310 //\r
311 // Indicate that PeiCore reenter\r
312 //\r
313 OldCoreData->PeimDispatcherReenter = TRUE;\r
d1102dba 314\r
ef05e063 315 if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (OldCoreData->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r
316 //\r
317 // if Loading Module at Fixed Address is enabled, allocate the PEI code memory range usage bit map array.\r
318 // Every bit in the array indicate the status of the corresponding memory page available or not\r
319 //\r
320 OldCoreData->PeiCodeMemoryRangeUsageBitMap = AllocateZeroPool (((PcdGet32(PcdLoadFixAddressPeiCodePageNumber)>>6) + 1)*sizeof(UINT64));\r
321 }\r
322\r
ef05e063 323 //\r
324 // Shadow PEI Core. When permanent memory is avaiable, shadow\r
325 // PEI Core and PEIMs to get high performance.\r
326 //\r
3d44658c
LG
327 OldCoreData->ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) PeiCore;\r
328 if ((HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnS3Boot))\r
329 || (HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnBoot))) {\r
330 OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);\r
331 }\r
d1102dba 332\r
ef05e063 333 //\r
6b22483f 334 // PEI Core has now been shadowed to memory. Restart PEI Core in memory.\r
ef05e063 335 //\r
336 OldCoreData->ShadowedPeiCore (SecCoreData, PpiList, OldCoreData);\r
d1102dba 337\r
6b22483f 338 //\r
339 // Should never reach here.\r
340 //\r
341 ASSERT (FALSE);\r
342 CpuDeadLoop();\r
3a7daf9e
MH
343\r
344 UNREACHABLE ();\r
58dcdada 345 }\r
346\r
6b22483f 347 //\r
348 // Memory is available to the PEI Core and the PEI Core has been shadowed to memory.\r
349 //\r
0f9ebb32
LG
350 CopyMem (&NewSecCoreData, SecCoreDataPtr, sizeof (NewSecCoreData));\r
351 SecCoreData = &NewSecCoreData;\r
352\r
ef05e063 353 CopyMem (&PrivateData, OldCoreData, sizeof (PrivateData));\r
0f9ebb32 354\r
b0d803fe 355 CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;\r
356 PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;\r
d1102dba 357\r
b1f6a7c6 358 CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));\r
d1102dba 359\r
b0d803fe 360 PrivateData.ServiceTableShadow.CpuIo = CpuIo;\r
361 PrivateData.ServiceTableShadow.PciCfg = PciCfg;\r
192f6d4c 362 }\r
d1102dba 363\r
6b22483f 364 //\r
365 // Cache a pointer to the PEI Services Table that is either in temporary memory or permanent memory\r
366 //\r
4140a663 367 PrivateData.Ps = &PrivateData.ServiceTableShadow;\r
192f6d4c 368\r
369 //\r
75fe0a78 370 // Save PeiServicePointer so that it can be retrieved anywhere.\r
192f6d4c 371 //\r
75fe0a78 372 SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
192f6d4c 373\r
81c7803c 374 //\r
75fe0a78 375 // Initialize libraries that the PEI Core is linked against\r
81c7803c 376 //\r
75fe0a78 377 ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);\r
192f6d4c 378\r
6b22483f 379 //\r
380 // Initialize PEI Core Services\r
fe781940 381 //\r
b62fe570 382 InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);\r
d1102dba 383\r
6b22483f 384 //\r
d1102dba 385 // Update performance measurements\r
6b22483f 386 //\r
387 if (OldCoreData == NULL) {\r
67e9ab84 388 PERF_EVENT ("SEC"); // Means the end of SEC phase.\r
192f6d4c 389\r
192f6d4c 390 //\r
6b22483f 391 // If first pass, start performance measurement.\r
192f6d4c 392 //\r
67e9ab84
BD
393 PERF_CROSSMODULE_BEGIN ("PEI");\r
394 PERF_INMODULE_BEGIN ("PreMem");\r
192f6d4c 395\r
396 } else {\r
67e9ab84
BD
397 PERF_INMODULE_END ("PreMem");\r
398 PERF_INMODULE_BEGIN ("PostMem");\r
6b22483f 399 }\r
400\r
401 //\r
402 // Complete PEI Core Service initialization\r
d1102dba 403 //\r
6b22483f 404 InitializeSecurityServices (&PrivateData.Ps, OldCoreData);\r
405 InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);\r
406 InitializeImageServices (&PrivateData, OldCoreData);\r
192f6d4c 407\r
6b22483f 408 //\r
409 // Perform PEI Core Phase specific actions\r
d1102dba 410 //\r
6b22483f 411 if (OldCoreData == NULL) {\r
192f6d4c 412 //\r
413 // Report Status Code EFI_SW_PC_INIT\r
414 //\r
415 REPORT_STATUS_CODE (\r
416 EFI_PROGRESS_CODE,\r
f9876ecf 417 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)\r
192f6d4c 418 );\r
d1102dba 419\r
192f6d4c 420 //\r
884200f9 421 // If SEC provided the PpiList, process it.\r
192f6d4c 422 //\r
5088e385 423 if (PpiList != NULL) {\r
884200f9 424 ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);\r
192f6d4c 425 }\r
6b22483f 426 } else {\r
0f9ebb32
LG
427 //\r
428 // Try to locate Temporary RAM Done Ppi.\r
429 //\r
430 Status = PeiServicesLocatePpi (\r
431 &gEfiTemporaryRamDonePpiGuid,\r
432 0,\r
433 NULL,\r
434 (VOID**)&TemporaryRamDonePpi\r
435 );\r
436 if (!EFI_ERROR (Status)) {\r
437 //\r
438 // Disable the use of Temporary RAM after the transition from Temporary RAM to Permanent RAM is complete.\r
439 //\r
440 TemporaryRamDonePpi->TemporaryRamDone ();\r
441 }\r
442\r
6b22483f 443 //\r
444 // Alert any listeners that there is permanent memory available\r
445 //\r
67e9ab84 446 PERF_INMODULE_BEGIN ("DisMem");\r
6b22483f 447 Status = PeiServicesInstallPpi (&mMemoryDiscoveredPpi);\r
b0d803fe 448\r
6b22483f 449 //\r
450 // Process the Notify list and dispatch any notifies for the Memory Discovered PPI\r
451 //\r
f2bc359c 452 ProcessDispatchNotifyList (&PrivateData);\r
b0d803fe 453\r
67e9ab84 454 PERF_INMODULE_END ("DisMem");\r
6b22483f 455 }\r
192f6d4c 456\r
457 //\r
458 // Call PEIM dispatcher\r
459 //\r
b0d803fe 460 PeiDispatcher (SecCoreData, &PrivateData);\r
192f6d4c 461\r
ebaafbe6
EC
462 if (PrivateData.HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) {\r
463 //\r
464 // Check if InstallPeiMemory service was called on non-S3 resume boot path.\r
465 //\r
466 ASSERT(PrivateData.PeiMemoryInstalled == TRUE);\r
467 }\r
192f6d4c 468\r
40f26b8f 469 //\r
6b22483f 470 // Measure PEI Core execution time.\r
40f26b8f 471 //\r
67e9ab84 472 PERF_INMODULE_END ("PostMem");\r
192f6d4c 473\r
6b22483f 474 //\r
475 // Lookup DXE IPL PPI\r
476 //\r
192f6d4c 477 Status = PeiServicesLocatePpi (\r
478 &gEfiDxeIplPpiGuid,\r
479 0,\r
480 NULL,\r
481 (VOID **)&TempPtr.DxeIpl\r
482 );\r
483 ASSERT_EFI_ERROR (Status);\r
484\r
206f4121
EL
485 if (EFI_ERROR (Status)) {\r
486 //\r
487 // Report status code to indicate DXE IPL PPI could not be found.\r
488 //\r
489 REPORT_STATUS_CODE (\r
490 EFI_ERROR_CODE | EFI_ERROR_MAJOR,\r
491 (EFI_SOFTWARE_PEI_CORE | EFI_SW_PEI_CORE_EC_DXEIPL_NOT_FOUND)\r
492 );\r
493 CpuDeadLoop ();\r
494 }\r
495\r
40f26b8f 496 //\r
497 // Enter DxeIpl to load Dxe core.\r
498 //\r
192f6d4c 499 DEBUG ((EFI_D_INFO, "DXE IPL Entry\n"));\r
500 Status = TempPtr.DxeIpl->Entry (\r
501 TempPtr.DxeIpl,\r
4140a663 502 &PrivateData.Ps,\r
192f6d4c 503 PrivateData.HobList\r
504 );\r
0308e20d 505 //\r
506 // Should never reach here.\r
507 //\r
192f6d4c 508 ASSERT_EFI_ERROR (Status);\r
0308e20d 509 CpuDeadLoop();\r
3a7daf9e
MH
510\r
511 UNREACHABLE ();\r
192f6d4c 512}\r