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