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