]>
Commit | Line | Data |
---|---|---|
192f6d4c | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Dispatcher.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | EFI PEI Core dispatch services\r | |
19 | \r | |
20 | Revision History\r | |
21 | \r | |
22 | --*/\r | |
23 | \r | |
192f6d4c | 24 | #include <PeiMain.h>\r |
25 | \r | |
b67be021 | 26 | //\r |
27 | //CAR is filled with this initial value during SEC phase\r | |
28 | //\r | |
a7715e73 | 29 | #define INIT_CAR_VALUE 0x5AA55AA5\r |
30 | \r | |
797a9d67 | 31 | typedef struct {\r |
32 | EFI_STATUS_CODE_DATA DataHeader;\r | |
33 | EFI_HANDLE Handle;\r | |
34 | } PEIM_FILE_HANDLE_EXTENDED_DATA;\r | |
35 | \r | |
b0d803fe | 36 | VOID\r |
37 | DiscoverPeimsAndOrderWithApriori (\r | |
38 | IN PEI_CORE_INSTANCE *Private,\r | |
39 | IN EFI_PEI_FV_HANDLE VolumeHandle\r | |
40 | )\r | |
41 | /*++\r | |
42 | \r | |
43 | Routine Description:\r | |
44 | \r | |
45 | Discover all Peims and optional Apriori file in one FV. There is at most one\r | |
46 | Apriori file in one FV.\r | |
47 | \r | |
48 | Arguments:\r | |
49 | \r | |
50 | Private - Pointer to the private data passed in from caller\r | |
51 | VolumeHandle - Fv handle.\r | |
52 | Returns:\r | |
53 | \r | |
54 | NONE\r | |
55 | \r | |
58dcdada | 56 | --*/\r |
b0d803fe | 57 | {\r |
58 | EFI_STATUS Status;\r | |
59 | EFI_PEI_FV_HANDLE FileHandle;\r | |
177aabe6 | 60 | EFI_PEI_FILE_HANDLE AprioriFileHandle;\r |
b0d803fe | 61 | EFI_GUID *Apriori;\r |
62 | UINTN Index;\r | |
63 | UINTN Index2;\r | |
64 | UINTN PeimIndex;\r | |
65 | UINTN PeimCount;\r | |
66 | EFI_GUID *Guid;\r | |
177aabe6 | 67 | EFI_PEI_FV_HANDLE TempFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r |
68 | EFI_GUID FileGuid[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r | |
b0d803fe | 69 | \r |
70 | //\r | |
71 | // Walk the FV and find all the PEIMs and the Apriori file.\r | |
72 | //\r | |
73 | AprioriFileHandle = NULL;\r | |
74 | Private->CurrentFvFileHandles[0] = NULL;\r | |
75 | Guid = NULL;\r | |
76 | FileHandle = NULL;\r | |
77 | \r | |
78 | //\r | |
79 | // If the current Fv has been scanned, directly get its cachable record.\r | |
80 | //\r | |
81 | if (Private->Fv[Private->CurrentPeimFvCount].ScanFv) {\r | |
82 | CopyMem (Private->CurrentFvFileHandles, Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, sizeof (Private->CurrentFvFileHandles));\r | |
83 | return;\r | |
84 | }\r | |
85 | \r | |
86 | //\r | |
87 | // Go ahead to scan this Fv, and cache FileHandles within it.\r | |
88 | //\r | |
177aabe6 | 89 | for (PeimCount = 0; PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv); PeimCount++) {\r |
b0d803fe | 90 | Status = PeiFindFileEx (\r |
58dcdada | 91 | VolumeHandle,\r |
92 | NULL,\r | |
93 | PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE,\r | |
b0d803fe | 94 | &FileHandle,\r |
95 | &AprioriFileHandle\r | |
96 | );\r | |
97 | if (Status != EFI_SUCCESS) {\r | |
98 | break;\r | |
99 | }\r | |
58dcdada | 100 | \r |
b0d803fe | 101 | Private->CurrentFvFileHandles[PeimCount] = FileHandle;\r |
102 | }\r | |
103 | \r | |
58dcdada | 104 | Private->AprioriCount = 0;\r |
b0d803fe | 105 | if (AprioriFileHandle != NULL) {\r |
106 | //\r | |
107 | // Read the Apriori file\r | |
108 | //\r | |
177aabe6 | 109 | Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, AprioriFileHandle, (VOID **) &Apriori);\r |
b0d803fe | 110 | if (!EFI_ERROR (Status)) {\r |
111 | //\r | |
112 | // Calculate the number of PEIMs in the A Priori list\r | |
113 | //\r | |
114 | Private->AprioriCount = *(UINT32 *)(((EFI_FFS_FILE_HEADER *)AprioriFileHandle)->Size) & 0x00FFFFFF;\r | |
58dcdada | 115 | Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);\r |
b0d803fe | 116 | Private->AprioriCount /= sizeof (EFI_GUID);\r |
58dcdada | 117 | \r |
b0d803fe | 118 | SetMem (FileGuid, sizeof (FileGuid), 0);\r |
119 | for (Index = 0; Index < PeimCount; Index++) {\r | |
120 | //\r | |
121 | // Make an array of file name guids that matches the FileHandle array so we can convert\r | |
122 | // quickly from file name to file handle\r | |
123 | //\r | |
58dcdada | 124 | CopyMem (&FileGuid[Index], &((EFI_FFS_FILE_HEADER *)Private->CurrentFvFileHandles[Index])->Name,sizeof(EFI_GUID));\r |
b0d803fe | 125 | }\r |
126 | \r | |
127 | //\r | |
128 | // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori file.\r | |
58dcdada | 129 | // Add avalible PEIMs in Apriori file into TempFileHandles array at first.\r |
b0d803fe | 130 | //\r |
131 | Index2 = 0;\r | |
132 | for (Index = 0; Index2 < Private->AprioriCount; Index++) {\r | |
133 | while (Index2 < Private->AprioriCount) {\r | |
134 | Guid = ScanGuid (FileGuid, PeimCount * sizeof (EFI_GUID), &Apriori[Index2++]);\r | |
135 | if (Guid != NULL) {\r | |
136 | break;\r | |
137 | }\r | |
138 | }\r | |
139 | if (Guid == NULL) {\r | |
58dcdada | 140 | break;\r |
b0d803fe | 141 | }\r |
142 | PeimIndex = ((UINTN)Guid - (UINTN)&FileGuid[0])/sizeof (EFI_GUID);\r | |
143 | TempFileHandles[Index] = Private->CurrentFvFileHandles[PeimIndex];\r | |
144 | \r | |
145 | //\r | |
146 | // Since we have copied the file handle we can remove it from this list.\r | |
147 | //\r | |
148 | Private->CurrentFvFileHandles[PeimIndex] = NULL;\r | |
149 | }\r | |
150 | \r | |
151 | //\r | |
152 | // Update valid Aprioricount\r | |
153 | //\r | |
154 | Private->AprioriCount = Index;\r | |
58dcdada | 155 | \r |
b0d803fe | 156 | //\r |
157 | // Add in any PEIMs not in the Apriori file\r | |
158 | //\r | |
159 | for (;Index < PeimCount; Index++) {\r | |
160 | for (Index2 = 0; Index2 < PeimCount; Index2++) {\r | |
161 | if (Private->CurrentFvFileHandles[Index2] != NULL) {\r | |
162 | TempFileHandles[Index] = Private->CurrentFvFileHandles[Index2];\r | |
163 | Private->CurrentFvFileHandles[Index2] = NULL;\r | |
164 | break;\r | |
165 | }\r | |
166 | }\r | |
167 | }\r | |
168 | //\r | |
169 | //Index the end of array contains re-range Pei moudle.\r | |
170 | //\r | |
171 | TempFileHandles[Index] = NULL;\r | |
58dcdada | 172 | \r |
b0d803fe | 173 | //\r |
174 | // Private->CurrentFvFileHandles is currently in PEIM in the FV order.\r | |
58dcdada | 175 | // We need to update it to start with files in the A Priori list and\r |
176 | // then the remaining files in PEIM order.\r | |
b0d803fe | 177 | //\r |
178 | CopyMem (Private->CurrentFvFileHandles, TempFileHandles, sizeof (Private->CurrentFvFileHandles));\r | |
179 | }\r | |
180 | }\r | |
181 | //\r | |
182 | // Cache the current Fv File Handle. So that we don't have to scan the Fv again.\r | |
183 | // Instead, we can retrieve the file handles within this Fv from cachable data.\r | |
184 | //\r | |
185 | Private->Fv[Private->CurrentPeimFvCount].ScanFv = TRUE;\r | |
186 | CopyMem (Private->Fv[Private->CurrentPeimFvCount].FvFileHandles, Private->CurrentFvFileHandles, sizeof (Private->CurrentFvFileHandles));\r | |
58dcdada | 187 | \r |
188 | }\r | |
189 | \r | |
190 | VOID*\r | |
191 | ShadowPeiCore(\r | |
192 | EFI_PEI_SERVICES **PeiServices,\r | |
193 | PEI_CORE_INSTANCE *PrivateInMem\r | |
194 | )\r | |
195 | {\r | |
196 | EFI_PEI_FILE_HANDLE PeiCoreFileHandle;\r | |
197 | EFI_PHYSICAL_ADDRESS EntryPoint;\r | |
198 | EFI_STATUS Status;\r | |
199 | UINT32 AuthenticationState;\r | |
200 | \r | |
201 | PeiCoreFileHandle = NULL;\r | |
202 | \r | |
203 | //\r | |
204 | // Find the PEI Core in the BFV\r | |
205 | //\r | |
206 | Status = PeiFindFileEx (\r | |
207 | (EFI_PEI_FV_HANDLE)PrivateInMem->Fv[0].FvHeader,\r | |
208 | NULL,\r | |
209 | EFI_FV_FILETYPE_PEI_CORE,\r | |
210 | &PeiCoreFileHandle,\r | |
211 | NULL\r | |
212 | );\r | |
213 | ASSERT_EFI_ERROR (Status);\r | |
214 | \r | |
215 | //\r | |
216 | // Shadow PEI Core into memory so it will run faster\r | |
217 | //\r | |
218 | Status = PeiLoadImage (\r | |
219 | PeiServices,\r | |
220 | *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle),\r | |
221 | &EntryPoint,\r | |
222 | &AuthenticationState\r | |
223 | );\r | |
224 | ASSERT_EFI_ERROR (Status);\r | |
225 | \r | |
226 | return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r | |
b0d803fe | 227 | }\r |
228 | \r | |
229 | VOID\r | |
192f6d4c | 230 | PeiDispatcher (\r |
5aae0aa7 | 231 | IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r |
b0d803fe | 232 | IN PEI_CORE_INSTANCE *Private\r |
192f6d4c | 233 | )\r |
234 | \r | |
235 | /*++\r | |
236 | \r | |
237 | Routine Description:\r | |
238 | \r | |
239 | Conduct PEIM dispatch.\r | |
240 | \r | |
241 | Arguments:\r | |
242 | \r | |
5aae0aa7 | 243 | SecCoreData - Points to a data structure containing information about the PEI core's operating\r |
244 | environment, such as the size and location of temporary RAM, the stack location and\r | |
245 | the BFV location.\r | |
192f6d4c | 246 | PrivateData - Pointer to the private data passed in from caller\r |
247 | DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.\r | |
248 | \r | |
249 | Returns:\r | |
250 | \r | |
251 | EFI_SUCCESS - Successfully dispatched PEIM.\r | |
252 | EFI_NOT_FOUND - The dispatch failed.\r | |
253 | \r | |
254 | --*/\r | |
255 | {\r | |
b0d803fe | 256 | EFI_STATUS Status;\r |
257 | UINT32 Index1;\r | |
258 | UINT32 Index2;\r | |
259 | EFI_PEI_SERVICES **PeiServices;\r | |
58dcdada | 260 | EFI_PEI_FV_HANDLE VolumeHandle;\r |
b0d803fe | 261 | EFI_PEI_FILE_HANDLE PeimFileHandle;\r |
262 | UINTN FvCount;\r | |
263 | UINTN PeimCount;\r | |
264 | UINT32 AuthenticationState;\r | |
265 | EFI_PHYSICAL_ADDRESS EntryPoint;\r | |
797a9d67 | 266 | EFI_PEIM_ENTRY_POINT2 PeimEntryPoint;\r |
b0d803fe | 267 | BOOLEAN PeimNeedingDispatch;\r |
268 | BOOLEAN PeimDispatchOnThisPass;\r | |
269 | UINTN SaveCurrentPeimCount;\r | |
1053e0c5 | 270 | UINTN SaveCurrentFvCount;\r |
b0d803fe | 271 | EFI_PEI_FILE_HANDLE SaveCurrentFileHandle;\r |
797a9d67 | 272 | PEIM_FILE_HANDLE_EXTENDED_DATA ExtendedData;\r |
58dcdada | 273 | EFI_PHYSICAL_ADDRESS NewPermenentMemoryBase;\r |
274 | TEMPORARY_RAM_SUPPORT_PPI *TemporaryRamSupportPpi;\r | |
275 | EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffTable;\r | |
276 | EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffTable;\r | |
277 | INTN Offset;\r | |
278 | PEI_CORE_INSTANCE *PrivateInMem;\r | |
279 | UINT64 NewPeiStackSize;\r | |
280 | UINT64 OldPeiStackSize;\r | |
281 | UINT64 StackGap;\r | |
288f9b38 | 282 | EFI_FV_FILE_INFO FvFileInfo;\r |
58dcdada | 283 | UINTN OldCheckingTop;\r |
284 | UINTN OldCheckingBottom;\r | |
b0d803fe | 285 | \r |
286 | \r | |
287 | PeiServices = &Private->PS;\r | |
288 | PeimEntryPoint = NULL;\r | |
289 | PeimFileHandle = NULL;\r | |
288f9b38 | 290 | EntryPoint = 0;\r |
b0d803fe | 291 | \r |
292 | if ((Private->PeiMemoryInstalled) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r | |
293 | //\r | |
294 | // Once real memory is available, shadow the RegisterForShadow modules. And meanwhile\r | |
295 | // update the modules' status from PEIM_STATE_REGISITER_FOR_SHADOW to PEIM_STATE_DONE.\r | |
296 | //\r | |
297 | SaveCurrentPeimCount = Private->CurrentPeimCount;\r | |
1053e0c5 | 298 | SaveCurrentFvCount = Private->CurrentPeimFvCount;\r |
b0d803fe | 299 | SaveCurrentFileHandle = Private->CurrentFileHandle;\r |
300 | \r | |
1053e0c5 | 301 | for (Index1 = 0; Index1 <= SaveCurrentFvCount; Index1++) {\r |
177aabe6 | 302 | for (Index2 = 0; (Index2 < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->Fv[Index1].FvFileHandles[Index2] != NULL); Index2++) {\r |
b0d803fe | 303 | if (Private->Fv[Index1].PeimState[Index2] == PEIM_STATE_REGISITER_FOR_SHADOW) {\r |
58dcdada | 304 | PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];\r |
b0d803fe | 305 | Status = PeiLoadImage (\r |
58dcdada | 306 | &Private->PS,\r |
307 | PeimFileHandle,\r | |
308 | &EntryPoint,\r | |
b0d803fe | 309 | &AuthenticationState\r |
310 | );\r | |
311 | if (Status == EFI_SUCCESS) {\r | |
312 | //\r | |
313 | // PEIM_STATE_REGISITER_FOR_SHADOW move to PEIM_STATE_DONE\r | |
314 | //\r | |
315 | Private->Fv[Index1].PeimState[Index2]++;\r | |
1053e0c5 | 316 | Private->CurrentFileHandle = PeimFileHandle;\r |
58dcdada | 317 | Private->CurrentPeimFvCount = Index1;\r |
318 | Private->CurrentPeimCount = Index2;\r | |
b0d803fe | 319 | //\r |
320 | // Call the PEIM entry point\r | |
321 | //\r | |
797a9d67 | 322 | PeimEntryPoint = (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint;\r |
58dcdada | 323 | \r |
b0d803fe | 324 | PERF_START (0, "PEIM", NULL, 0);\r |
797a9d67 | 325 | PeimEntryPoint(PeimFileHandle, (const EFI_PEI_SERVICES **) &Private->PS);\r |
b0d803fe | 326 | PERF_END (0, "PEIM", NULL, 0);\r |
58dcdada | 327 | }\r |
328 | \r | |
b0d803fe | 329 | //\r |
330 | // Process the Notify list and dispatch any notifies for\r | |
331 | // newly installed PPIs.\r | |
332 | //\r | |
333 | ProcessNotifyList (Private);\r | |
334 | }\r | |
335 | }\r | |
336 | }\r | |
58dcdada | 337 | Private->CurrentFileHandle = SaveCurrentFileHandle;\r |
338 | Private->CurrentPeimFvCount = SaveCurrentFvCount;\r | |
339 | Private->CurrentPeimCount = SaveCurrentPeimCount;\r | |
b0d803fe | 340 | }\r |
192f6d4c | 341 | \r |
342 | //\r | |
343 | // This is the main dispatch loop. It will search known FVs for PEIMs and\r | |
344 | // attempt to dispatch them. If any PEIM gets dispatched through a single\r | |
345 | // pass of the dispatcher, it will start over from the Bfv again to see\r | |
346 | // if any new PEIMs dependencies got satisfied. With a well ordered\r | |
347 | // FV where PEIMs are found in the order their dependencies are also\r | |
348 | // satisfied, this dipatcher should run only once.\r | |
349 | //\r | |
b0d803fe | 350 | do {\r |
351 | PeimNeedingDispatch = FALSE;\r | |
352 | PeimDispatchOnThisPass = FALSE;\r | |
353 | \r | |
354 | for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r | |
355 | Private->CurrentPeimFvCount = FvCount;\r | |
356 | VolumeHandle = Private->Fv[FvCount].FvHeader;\r | |
192f6d4c | 357 | \r |
b0d803fe | 358 | if (Private->CurrentPeimCount == 0) {\r |
359 | //\r | |
360 | // When going through each FV, at first, search Apriori file to\r | |
58dcdada | 361 | // reorder all PEIMs to ensure the PEIMs in Apriori file to get\r |
b0d803fe | 362 | // dispatch at first.\r |
363 | //\r | |
364 | DiscoverPeimsAndOrderWithApriori (Private, VolumeHandle);\r | |
365 | }\r | |
192f6d4c | 366 | \r |
367 | //\r | |
b0d803fe | 368 | // Start to dispatch all modules within the current Fv.\r |
192f6d4c | 369 | //\r |
58dcdada | 370 | for (PeimCount = Private->CurrentPeimCount;\r |
371 | (PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)) && (Private->CurrentFvFileHandles[PeimCount] != NULL);\r | |
b0d803fe | 372 | PeimCount++) {\r |
373 | Private->CurrentPeimCount = PeimCount;\r | |
374 | PeimFileHandle = Private->CurrentFileHandle = Private->CurrentFvFileHandles[PeimCount];\r | |
375 | \r | |
376 | if (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_NOT_DISPATCHED) {\r | |
377 | if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {\r | |
378 | PeimNeedingDispatch = TRUE;\r | |
379 | } else {\r | |
288f9b38 LG |
380 | Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);\r |
381 | ASSERT_EFI_ERROR (Status);\r | |
382 | if (FvFileInfo.FileType == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r | |
383 | //\r | |
384 | // For Fv type file, Produce new FV PPI and FV hob\r | |
385 | //\r | |
386 | Status = ProcessFvFile (PeiServices, PeimFileHandle, &AuthenticationState);\r | |
387 | } else {\r | |
388 | //\r | |
389 | // For PEIM driver, Load its entry point\r | |
390 | //\r | |
391 | Status = PeiLoadImage (\r | |
58dcdada | 392 | PeiServices,\r |
393 | PeimFileHandle,\r | |
394 | &EntryPoint,\r | |
288f9b38 LG |
395 | &AuthenticationState\r |
396 | );\r | |
397 | }\r | |
398 | \r | |
b0d803fe | 399 | if ((Status == EFI_SUCCESS)) {\r |
192f6d4c | 400 | //\r |
58dcdada | 401 | // The PEIM has its dependencies satisfied, and its entry point\r |
402 | // has been found, so invoke it.\r | |
192f6d4c | 403 | //\r |
b0d803fe | 404 | PERF_START (0, "PEIM", NULL, 0);\r |
192f6d4c | 405 | \r |
b0d803fe | 406 | ExtendedData.Handle = (EFI_HANDLE)PeimFileHandle;\r |
192f6d4c | 407 | \r |
408 | REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r | |
409 | EFI_PROGRESS_CODE,\r | |
797a9d67 | 410 | FixedPcdGet32(PcdStatusCodeValuePeimDispatch),\r |
192f6d4c | 411 | (VOID *)(&ExtendedData),\r |
412 | sizeof (ExtendedData)\r | |
413 | );\r | |
414 | \r | |
b0d803fe | 415 | Status = VerifyPeim (Private, VolumeHandle, PeimFileHandle);\r |
416 | if (Status != EFI_SECURITY_VIOLATION && (AuthenticationState == 0)) {\r | |
417 | //\r | |
418 | // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED\r | |
419 | //\r | |
420 | Private->Fv[FvCount].PeimState[PeimCount]++;\r | |
58dcdada | 421 | \r |
288f9b38 LG |
422 | if (FvFileInfo.FileType != EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {\r |
423 | //\r | |
424 | // Call the PEIM entry point for PEIM driver\r | |
425 | //\r | |
797a9d67 | 426 | PeimEntryPoint = (EFI_PEIM_ENTRY_POINT2)(UINTN)EntryPoint;\r |
427 | PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r | |
288f9b38 | 428 | }\r |
797a9d67 | 429 | \r |
b0d803fe | 430 | PeimDispatchOnThisPass = TRUE;\r |
192f6d4c | 431 | }\r |
432 | \r | |
433 | REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r | |
434 | EFI_PROGRESS_CODE,\r | |
797a9d67 | 435 | FixedPcdGet32(PcdStatusCodeValuePeimDispatch),\r |
192f6d4c | 436 | (VOID *)(&ExtendedData),\r |
437 | sizeof (ExtendedData)\r | |
438 | );\r | |
b0d803fe | 439 | PERF_END (0, "PEIM", NULL, 0);\r |
440 | \r | |
58dcdada | 441 | }\r |
442 | \r | |
443 | if (Private->SwitchStackSignal) {\r | |
a7715e73 | 444 | //\r |
445 | // Before switch stack from CAR to permenent memory, caculate the heap and stack\r | |
446 | // usage in temporary memory for debuging.\r | |
447 | //\r | |
448 | DEBUG_CODE_BEGIN ();\r | |
96317468 | 449 | UINT32 *StackPointer;\r |
a7715e73 | 450 | \r |
96317468 | 451 | for (StackPointer = (UINT32*)SecCoreData->StackBase;\r |
452 | (StackPointer < (UINT32*)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)) \\r | |
a7715e73 | 453 | && (*StackPointer == INIT_CAR_VALUE);\r |
454 | StackPointer ++);\r | |
455 | \r | |
456 | DEBUG ((EFI_D_INFO, "Total Cache as RAM: %d bytes.\n", SecCoreData->TemporaryRamSize));\r | |
457 | DEBUG ((EFI_D_INFO, " CAR stack ever used: %d bytes.\n",\r | |
458 | (SecCoreData->StackSize - ((UINTN) StackPointer - (UINTN)SecCoreData->StackBase))\r | |
459 | ));\r | |
460 | DEBUG ((EFI_D_INFO, " CAR heap used: %d bytes.\n",\r | |
461 | ((UINTN) Private->HobList.HandoffInformationTable->EfiFreeMemoryBottom -\r | |
462 | (UINTN) Private->HobList.Raw)\r | |
463 | ));\r | |
464 | DEBUG_CODE_END ();\r | |
465 | \r | |
a3a15d21 | 466 | //\r |
58dcdada | 467 | // Reserve the size of new stack at bottom of physical memory\r |
a3a15d21 | 468 | //\r |
58dcdada | 469 | OldPeiStackSize = Private->StackSize;\r |
470 | NewPeiStackSize = (RShiftU64 (Private->PhysicalMemoryLength, 1) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;\r | |
471 | if (FixedPcdGet32(PcdPeiCoreMaxPeiStackSize) > (UINT32) NewPeiStackSize) {\r | |
472 | Private->StackSize = NewPeiStackSize;\r | |
473 | } else {\r | |
474 | Private->StackSize = FixedPcdGet32(PcdPeiCoreMaxPeiStackSize);\r | |
475 | }\r | |
192f6d4c | 476 | \r |
58dcdada | 477 | //\r |
478 | // In theory, the size of new stack in permenent memory should large than\r | |
479 | // size of old stack in temporary memory.\r | |
480 | // But if new stack is smaller than the size of old stack, we also reserve\r | |
481 | // the size of old stack at bottom of permenent memory.\r | |
482 | //\r | |
483 | StackGap = 0;\r | |
484 | if (Private->StackSize > OldPeiStackSize) {\r | |
485 | StackGap = Private->StackSize - OldPeiStackSize;\r | |
486 | }\r | |
b0d803fe | 487 | \r |
58dcdada | 488 | //\r |
489 | // Update HandOffHob for new installed permenent memory\r | |
490 | //\r | |
491 | OldHandOffTable = Private->HobList.HandoffInformationTable;\r | |
492 | OldCheckingBottom = (UINTN)OldHandOffTable;\r | |
493 | OldCheckingTop = (UINTN)(OldCheckingBottom + SecCoreData->TemporaryRamSize);\r | |
192f6d4c | 494 | \r |
495 | //\r | |
58dcdada | 496 | // The whole temporary memory will be migrated to physical memory.\r |
497 | // CAUTION: The new base is computed accounding to gap of new stack.\r | |
192f6d4c | 498 | //\r |
58dcdada | 499 | NewPermenentMemoryBase = Private->PhysicalMemoryBegin + StackGap;\r |
500 | Offset = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->TemporaryRamBase;\r | |
501 | NewHandOffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + Offset);\r | |
502 | PrivateInMem = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + Offset);\r | |
192f6d4c | 503 | \r |
504 | //\r | |
58dcdada | 505 | // TemporaryRamSupportPpi is produced by platform's SEC\r |
192f6d4c | 506 | //\r |
58dcdada | 507 | Status = PeiLocatePpi (\r |
508 | (CONST EFI_PEI_SERVICES **) PeiServices,\r | |
509 | &gEfiTemporaryRamSupportPpiGuid,\r | |
510 | 0,\r | |
511 | NULL,\r | |
512 | (VOID**)&TemporaryRamSupportPpi\r | |
513 | );\r | |
514 | \r | |
81c7803c | 515 | \r |
58dcdada | 516 | if (!EFI_ERROR (Status)) {\r |
517 | TemporaryRamSupportPpi->TemporaryRamMigration (\r | |
518 | (CONST EFI_PEI_SERVICES **) PeiServices,\r | |
519 | (EFI_PHYSICAL_ADDRESS)(UINTN) SecCoreData->TemporaryRamBase,\r | |
520 | (EFI_PHYSICAL_ADDRESS)(UINTN) NewPermenentMemoryBase,\r | |
521 | SecCoreData->TemporaryRamSize\r | |
522 | );\r | |
523 | \r | |
524 | } else {\r | |
525 | CopyMem (\r | |
526 | (VOID*)(UINTN) NewPermenentMemoryBase,\r | |
527 | SecCoreData->TemporaryRamBase,\r | |
528 | SecCoreData->TemporaryRamSize\r | |
529 | );\r | |
530 | }\r | |
531 | \r | |
532 | \r | |
533 | //\r | |
b0d803fe | 534 | //\r |
58dcdada | 535 | // Fixup the PeiCore's private data\r |
b0d803fe | 536 | //\r |
58dcdada | 537 | PrivateInMem->PS = &PrivateInMem->ServiceTableShadow;\r |
538 | PrivateInMem->CpuIo = &PrivateInMem->ServiceTableShadow.CpuIo;\r | |
539 | PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + Offset);\r | |
540 | PrivateInMem->StackBase = (EFI_PHYSICAL_ADDRESS)(((UINTN)PrivateInMem->PhysicalMemoryBegin + EFI_PAGE_MASK) & ~EFI_PAGE_MASK);\r | |
541 | \r | |
542 | PeiServices = &PrivateInMem->PS;\r | |
543 | \r | |
544 | //\r | |
545 | // Fixup for PeiService's address\r | |
546 | //\r | |
547 | SetPeiServicesTablePointer(PeiServices);\r | |
548 | \r | |
549 | //\r | |
550 | // Update HandOffHob for new installed permenent memory\r | |
551 | //\r | |
552 | NewHandOffTable->EfiEndOfHobList =\r | |
173b35e4 | 553 | (EFI_PHYSICAL_ADDRESS)((UINTN) NewHandOffTable->EfiEndOfHobList + Offset);\r |
58dcdada | 554 | NewHandOffTable->EfiMemoryTop = PrivateInMem->PhysicalMemoryBegin +\r |
555 | PrivateInMem->PhysicalMemoryLength;\r | |
556 | NewHandOffTable->EfiMemoryBottom = PrivateInMem->PhysicalMemoryBegin;\r | |
557 | NewHandOffTable->EfiFreeMemoryTop = PrivateInMem->FreePhysicalMemoryTop;\r | |
558 | NewHandOffTable->EfiFreeMemoryBottom = NewHandOffTable->EfiEndOfHobList +\r | |
559 | sizeof (EFI_HOB_GENERIC_HEADER);\r | |
560 | \r | |
561 | //\r | |
562 | // We need convert the PPI desciptor's pointer\r | |
563 | //\r | |
564 | ConvertPpiPointers ((CONST EFI_PEI_SERVICES **)PeiServices, \r | |
565 | OldCheckingBottom, \r | |
566 | OldCheckingTop, \r | |
567 | NewHandOffTable);\r | |
568 | \r | |
569 | DEBUG ((EFI_D_INFO, "Stack Hob: BaseAddress=0x%X Length=0x%X\n",\r | |
570 | (UINTN)PrivateInMem->StackBase,\r | |
571 | PrivateInMem->StackSize));\r | |
572 | BuildStackHob (PrivateInMem->StackBase, PrivateInMem->StackSize);\r | |
573 | \r | |
574 | //\r | |
575 | // After the whole temporary memory is migrated, then we can allocate page in\r | |
576 | // permenent memory.\r | |
577 | //\r | |
578 | PrivateInMem->PeiMemoryInstalled = TRUE;\r | |
579 | \r | |
580 | //\r | |
581 | // Make sure we don't retry the same PEIM that added memory\r | |
582 | //\r | |
583 | PrivateInMem->CurrentPeimCount++;\r | |
192f6d4c | 584 | \r |
585 | //\r | |
b0d803fe | 586 | // Shadow PEI Core. When permanent memory is avaiable, shadow\r |
587 | // PEI Core and PEIMs to get high performance.\r | |
192f6d4c | 588 | //\r |
58dcdada | 589 | PrivateInMem->ShadowedPeiCore = ShadowPeiCore (\r |
590 | PeiServices,\r | |
591 | PrivateInMem\r | |
592 | );\r | |
b0d803fe | 593 | //\r |
58dcdada | 594 | // Process the Notify list and dispatch any notifies for\r |
595 | // newly installed PPIs.\r | |
b0d803fe | 596 | //\r |
58dcdada | 597 | ProcessNotifyList (PrivateInMem);\r |
598 | \r | |
b0d803fe | 599 | //\r |
58dcdada | 600 | // Entry PEI Phase 2\r |
b0d803fe | 601 | //\r |
58dcdada | 602 | PeiCore (SecCoreData, NULL, PrivateInMem);\r |
b0d803fe | 603 | \r |
58dcdada | 604 | //\r |
605 | // Code should not come here\r | |
606 | //\r | |
607 | ASSERT_EFI_ERROR(FALSE);\r | |
192f6d4c | 608 | }\r |
192f6d4c | 609 | \r |
58dcdada | 610 | //\r |
611 | // Process the Notify list and dispatch any notifies for\r | |
612 | // newly installed PPIs.\r | |
613 | //\r | |
614 | ProcessNotifyList (Private);\r | |
615 | \r | |
b0d803fe | 616 | if ((Private->PeiMemoryInstalled) && (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_REGISITER_FOR_SHADOW) && \\r |
617 | (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {\r | |
618 | //\r | |
58dcdada | 619 | // If memory is availble we shadow images by default for performance reasons.\r |
620 | // We call the entry point a 2nd time so the module knows it's shadowed.\r | |
b0d803fe | 621 | //\r |
622 | //PERF_START (PeiServices, L"PEIM", PeimFileHandle, 0);\r | |
797a9d67 | 623 | PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r |
b0d803fe | 624 | //PERF_END (PeiServices, L"PEIM", PeimFileHandle, 0);\r |
58dcdada | 625 | \r |
b0d803fe | 626 | //\r |
627 | // PEIM_STATE_REGISITER_FOR_SHADOW move to PEIM_STATE_DONE\r | |
628 | //\r | |
629 | Private->Fv[FvCount].PeimState[PeimCount]++;\r | |
192f6d4c | 630 | \r |
192f6d4c | 631 | //\r |
b0d803fe | 632 | // Process the Notify list and dispatch any notifies for\r |
633 | // newly installed PPIs.\r | |
192f6d4c | 634 | //\r |
b0d803fe | 635 | ProcessNotifyList (Private);\r |
192f6d4c | 636 | }\r |
637 | }\r | |
638 | }\r | |
192f6d4c | 639 | }\r |
192f6d4c | 640 | \r |
b0d803fe | 641 | //\r |
642 | // We set to NULL here to optimize the 2nd entry to this routine after\r | |
643 | // memory is found. This reprevents rescanning of the FV. We set to\r | |
644 | // NULL here so we start at the begining of the next FV\r | |
645 | //\r | |
646 | Private->CurrentFileHandle = NULL;\r | |
647 | Private->CurrentPeimCount = 0;\r | |
648 | //\r | |
649 | // Before walking through the next FV,Private->CurrentFvFileHandles[]should set to NULL\r | |
650 | //\r | |
651 | SetMem (Private->CurrentFvFileHandles, sizeof (Private->CurrentFvFileHandles), 0);\r | |
192f6d4c | 652 | }\r |
653 | \r | |
654 | //\r | |
58dcdada | 655 | // Before making another pass, we should set Private->CurrentPeimFvCount =0 to go\r |
b0d803fe | 656 | // through all the FV.\r |
192f6d4c | 657 | //\r |
b0d803fe | 658 | Private->CurrentPeimFvCount = 0;\r |
192f6d4c | 659 | \r |
660 | //\r | |
58dcdada | 661 | // PeimNeedingDispatch being TRUE means we found a PEIM that did not get\r |
b0d803fe | 662 | // dispatched. So we need to make another pass\r |
192f6d4c | 663 | //\r |
58dcdada | 664 | // PeimDispatchOnThisPass being TRUE means we dispatched a PEIM on this\r |
b0d803fe | 665 | // pass. If we did not dispatch a PEIM there is no point in trying again\r |
666 | // as it will fail the next time too (nothing has changed).\r | |
192f6d4c | 667 | //\r |
b0d803fe | 668 | } while (PeimNeedingDispatch && PeimDispatchOnThisPass);\r |
192f6d4c | 669 | \r |
192f6d4c | 670 | }\r |
671 | \r | |
672 | VOID\r | |
673 | InitializeDispatcherData (\r | |
b0d803fe | 674 | IN PEI_CORE_INSTANCE *PrivateData,\r |
192f6d4c | 675 | IN PEI_CORE_INSTANCE *OldCoreData,\r |
5aae0aa7 | 676 | IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r |
192f6d4c | 677 | )\r |
678 | /*++\r | |
679 | \r | |
680 | Routine Description:\r | |
681 | \r | |
682 | Initialize the Dispatcher's data members\r | |
683 | \r | |
684 | Arguments:\r | |
685 | \r | |
686 | PeiServices - The PEI core services table.\r | |
687 | OldCoreData - Pointer to old core data (before switching stack).\r | |
688 | NULL if being run in non-permament memory mode.\r | |
5aae0aa7 | 689 | SecCoreData - Points to a data structure containing information about the PEI core's operating\r |
690 | environment, such as the size and location of temporary RAM, the stack location and\r | |
691 | the BFV location.\r | |
192f6d4c | 692 | \r |
693 | Returns:\r | |
694 | \r | |
695 | None.\r | |
696 | \r | |
697 | --*/\r | |
698 | {\r | |
192f6d4c | 699 | if (OldCoreData == NULL) {\r |
b0d803fe | 700 | PeiInitializeFv (PrivateData, SecCoreData);\r |
192f6d4c | 701 | }\r |
702 | \r | |
703 | return;\r | |
704 | }\r | |
705 | \r | |
706 | \r | |
192f6d4c | 707 | BOOLEAN\r |
708 | DepexSatisfied (\r | |
b0d803fe | 709 | IN PEI_CORE_INSTANCE *Private,\r |
710 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
711 | IN UINTN PeimCount\r | |
192f6d4c | 712 | )\r |
713 | /*++\r | |
714 | \r | |
715 | Routine Description:\r | |
716 | \r | |
717 | This routine parses the Dependency Expression, if available, and\r | |
718 | decides if the module can be executed.\r | |
719 | \r | |
720 | Arguments:\r | |
721 | PeiServices - The PEI Service Table\r | |
722 | CurrentPeimAddress - Address of the PEIM Firmware File under investigation\r | |
723 | \r | |
724 | Returns:\r | |
725 | TRUE - Can be dispatched\r | |
726 | FALSE - Cannot be dispatched\r | |
727 | \r | |
728 | --*/\r | |
729 | {\r | |
288f9b38 LG |
730 | EFI_STATUS Status;\r |
731 | VOID *DepexData;\r | |
b0d803fe | 732 | \r |
733 | if (PeimCount < Private->AprioriCount) {\r | |
734 | //\r | |
735 | // If its in the A priori file then we set Depex to TRUE\r | |
736 | //\r | |
737 | return TRUE;\r | |
738 | }\r | |
58dcdada | 739 | \r |
288f9b38 | 740 | //\r |
58dcdada | 741 | // Depex section not in the encapsulated section.\r |
288f9b38 LG |
742 | //\r |
743 | Status = PeiServicesFfsFindSectionData (\r | |
744 | EFI_SECTION_PEI_DEPEX,\r | |
58dcdada | 745 | FileHandle,\r |
288f9b38 LG |
746 | (VOID **)&DepexData\r |
747 | );\r | |
b0d803fe | 748 | \r |
192f6d4c | 749 | if (EFI_ERROR (Status)) {\r |
b0d803fe | 750 | //\r |
751 | // If there is no DEPEX, assume the module can be executed\r | |
752 | //\r | |
192f6d4c | 753 | return TRUE;\r |
754 | }\r | |
755 | \r | |
756 | //\r | |
757 | // Evaluate a given DEPEX\r | |
758 | //\r | |
b0d803fe | 759 | return PeimDispatchReadiness (&Private->PS, DepexData);\r |
192f6d4c | 760 | }\r |
761 | \r | |
14e8823a | 762 | /**\r |
763 | This routine enable a PEIM to register itself to shadow when PEI Foundation\r | |
764 | discovery permanent memory.\r | |
765 | \r | |
766 | @param FileHandle File handle of a PEIM.\r | |
58dcdada | 767 | \r |
14e8823a | 768 | @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.\r |
769 | @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.\r | |
770 | @retval EFI_SUCCESS Successfully to register itself.\r | |
771 | \r | |
58dcdada | 772 | **/\r |
14e8823a | 773 | EFI_STATUS\r |
774 | EFIAPI\r | |
775 | PeiRegisterForShadow (\r | |
776 | IN EFI_PEI_FILE_HANDLE FileHandle\r | |
777 | )\r | |
778 | {\r | |
779 | PEI_CORE_INSTANCE *Private;\r | |
780 | Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());\r | |
781 | \r | |
782 | if (Private->CurrentFileHandle != FileHandle) {\r | |
783 | //\r | |
784 | // The FileHandle must be for the current PEIM\r | |
785 | //\r | |
786 | return EFI_NOT_FOUND;\r | |
787 | }\r | |
788 | \r | |
789 | if (Private->Fv[Private->CurrentPeimFvCount].PeimState[Private->CurrentPeimCount] >= PEIM_STATE_REGISITER_FOR_SHADOW) {\r | |
790 | //\r | |
791 | // If the PEIM has already entered the PEIM_STATE_REGISTER_FOR_SHADOW or PEIM_STATE_DONE then it's already been started\r | |
792 | //\r | |
793 | return EFI_ALREADY_STARTED;\r | |
794 | }\r | |
58dcdada | 795 | \r |
14e8823a | 796 | Private->Fv[Private->CurrentPeimFvCount].PeimState[Private->CurrentPeimCount] = PEIM_STATE_REGISITER_FOR_SHADOW;\r |
797 | \r | |
798 | return EFI_SUCCESS;\r | |
799 | }\r | |
800 | \r | |
b0d803fe | 801 | \r |
288f9b38 LG |
802 | \r |
803 | /**\r | |
804 | Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r | |
805 | \r | |
806 | @param PeiServices Pointer to the PEI Core Services Table.\r | |
807 | @param FileHandle File handle of a Fv type file.\r | |
808 | @param AuthenticationState Pointer to attestation authentication state of image.\r | |
809 | \r | |
58dcdada | 810 | \r |
288f9b38 LG |
811 | @retval EFI_NOT_FOUND FV image can't be found.\r |
812 | @retval EFI_SUCCESS Successfully to process it.\r | |
813 | \r | |
814 | **/\r | |
815 | EFI_STATUS\r | |
816 | ProcessFvFile (\r | |
817 | IN EFI_PEI_SERVICES **PeiServices,\r | |
818 | IN EFI_PEI_FILE_HANDLE FvFileHandle,\r | |
819 | OUT UINT32 *AuthenticationState\r | |
820 | )\r | |
821 | {\r | |
822 | EFI_STATUS Status;\r | |
823 | EFI_PEI_FV_HANDLE FvImageHandle;\r | |
824 | EFI_FV_INFO FvImageInfo;\r | |
825 | UINT32 FvAlignment;\r | |
826 | VOID *FvBuffer;\r | |
827 | EFI_PEI_HOB_POINTERS HobFv2;\r | |
58dcdada | 828 | \r |
288f9b38 LG |
829 | FvBuffer = NULL;\r |
830 | *AuthenticationState = 0;\r | |
831 | \r | |
832 | //\r | |
58dcdada | 833 | // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r |
288f9b38 LG |
834 | // been extracted.\r |
835 | //\r | |
836 | HobFv2.Raw = GetHobList ();\r | |
837 | while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {\r | |
838 | if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobFv2.FirmwareVolume2->FileName)) {\r | |
839 | //\r | |
840 | // this FILE has been dispatched, it will not be dispatched again.\r | |
841 | //\r | |
842 | return EFI_SUCCESS;\r | |
843 | }\r | |
844 | HobFv2.Raw = GET_NEXT_HOB (HobFv2);\r | |
845 | }\r | |
58dcdada | 846 | \r |
288f9b38 LG |
847 | //\r |
848 | // Find FvImage in FvFile\r | |
849 | //\r | |
850 | Status = PeiFfsFindSectionData (\r | |
851 | (CONST EFI_PEI_SERVICES **) PeiServices,\r | |
852 | EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r | |
853 | FvFileHandle,\r | |
854 | (VOID **)&FvImageHandle\r | |
855 | );\r | |
58dcdada | 856 | \r |
288f9b38 LG |
857 | if (EFI_ERROR (Status)) {\r |
858 | return Status;\r | |
859 | }\r | |
860 | //\r | |
861 | // Collect FvImage Info.\r | |
862 | //\r | |
863 | Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r | |
864 | ASSERT_EFI_ERROR (Status);\r | |
865 | //\r | |
866 | // FvAlignment must be more than 8 bytes required by FvHeader structure.\r | |
867 | //\r | |
868 | FvAlignment = 1 << ((FvImageInfo.FvAttributes & EFI_FVB2_ALIGNMENT) >> 16);\r | |
869 | if (FvAlignment < 8) {\r | |
870 | FvAlignment = 8;\r | |
871 | }\r | |
58dcdada | 872 | //\r |
288f9b38 LG |
873 | // Check FvImage\r |
874 | //\r | |
875 | if ((UINTN) FvImageInfo.FvStart % FvAlignment != 0) {\r | |
876 | FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvImageInfo.FvSize), FvAlignment);\r | |
877 | if (FvBuffer == NULL) {\r | |
878 | return EFI_OUT_OF_RESOURCES;\r | |
879 | }\r | |
880 | CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN) FvImageInfo.FvSize);\r | |
881 | //\r | |
882 | // Update FvImageInfo after reload FvImage to new aligned memory\r | |
883 | //\r | |
884 | PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo);\r | |
885 | }\r | |
58dcdada | 886 | \r |
288f9b38 LG |
887 | //\r |
888 | // Install FvPpi and Build FvHob\r | |
889 | //\r | |
890 | PiLibInstallFvInfoPpi (\r | |
891 | NULL,\r | |
892 | FvImageInfo.FvStart,\r | |
893 | (UINT32) FvImageInfo.FvSize,\r | |
894 | &(FvImageInfo.FvName),\r | |
895 | &(((EFI_FFS_FILE_HEADER*)FvFileHandle)->Name)\r | |
896 | );\r | |
897 | \r | |
898 | //\r | |
899 | // Inform HOB consumer phase, i.e. DXE core, the existance of this FV\r | |
900 | //\r | |
901 | BuildFvHob (\r | |
902 | (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r | |
903 | FvImageInfo.FvSize\r | |
904 | );\r | |
905 | //\r | |
906 | // Makes the encapsulated volume show up in DXE phase to skip processing of\r | |
907 | // encapsulated file again.\r | |
908 | //\r | |
909 | BuildFv2Hob (\r | |
910 | (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r | |
911 | FvImageInfo.FvSize,\r | |
912 | &FvImageInfo.FvName,\r | |
913 | &(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name)\r | |
914 | );\r | |
58dcdada | 915 | \r |
288f9b38 LG |
916 | return EFI_SUCCESS;\r |
917 | }\r |