3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 EFI PEI Core dispatch services
34 DiscoverPeimsAndOrderWithApriori (
35 IN PEI_CORE_INSTANCE
*Private
,
36 IN EFI_PEI_FV_HANDLE VolumeHandle
42 Discover all Peims and optional Apriori file in one FV. There is at most one
43 Apriori file in one FV.
47 Private - Pointer to the private data passed in from caller
48 VolumeHandle - Fv handle.
56 EFI_PEI_FV_HANDLE FileHandle
;
57 EFI_PEI_FILE_HANDLE AprioriFileHandle
;
64 EFI_PEI_FV_HANDLE TempFileHandles
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
65 EFI_GUID FileGuid
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
68 // Walk the FV and find all the PEIMs and the Apriori file.
70 AprioriFileHandle
= NULL
;
71 Private
->CurrentFvFileHandles
[0] = NULL
;
76 // If the current Fv has been scanned, directly get its cachable record.
78 if (Private
->Fv
[Private
->CurrentPeimFvCount
].ScanFv
) {
79 CopyMem (Private
->CurrentFvFileHandles
, Private
->Fv
[Private
->CurrentPeimFvCount
].FvFileHandles
, sizeof (Private
->CurrentFvFileHandles
));
84 // Go ahead to scan this Fv, and cache FileHandles within it.
86 for (PeimCount
= 0; PeimCount
< FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
); PeimCount
++) {
87 Status
= PeiFindFileEx (
90 PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE
,
94 if (Status
!= EFI_SUCCESS
) {
98 Private
->CurrentFvFileHandles
[PeimCount
] = FileHandle
;
101 Private
->AprioriCount
= 0;
102 if (AprioriFileHandle
!= NULL
) {
104 // Read the Apriori file
106 Status
= PeiServicesFfsFindSectionData (EFI_SECTION_RAW
, AprioriFileHandle
, (VOID
**) &Apriori
);
107 if (!EFI_ERROR (Status
)) {
109 // Calculate the number of PEIMs in the A Priori list
111 Private
->AprioriCount
= *(UINT32
*)(((EFI_FFS_FILE_HEADER
*)AprioriFileHandle
)->Size
) & 0x00FFFFFF;
112 Private
->AprioriCount
-= sizeof (EFI_FFS_FILE_HEADER
) - sizeof (EFI_COMMON_SECTION_HEADER
);
113 Private
->AprioriCount
/= sizeof (EFI_GUID
);
115 SetMem (FileGuid
, sizeof (FileGuid
), 0);
116 for (Index
= 0; Index
< PeimCount
; Index
++) {
118 // Make an array of file name guids that matches the FileHandle array so we can convert
119 // quickly from file name to file handle
121 CopyMem (&FileGuid
[Index
], &((EFI_FFS_FILE_HEADER
*)Private
->CurrentFvFileHandles
[Index
])->Name
,sizeof(EFI_GUID
));
125 // Walk through FileGuid array to find out who is invalid PEIM guid in Apriori file.
126 // Add avalible PEIMs in Apriori file into TempFileHandles array at first.
129 for (Index
= 0; Index2
< Private
->AprioriCount
; Index
++) {
130 while (Index2
< Private
->AprioriCount
) {
131 Guid
= ScanGuid (FileGuid
, PeimCount
* sizeof (EFI_GUID
), &Apriori
[Index2
++]);
139 PeimIndex
= ((UINTN
)Guid
- (UINTN
)&FileGuid
[0])/sizeof (EFI_GUID
);
140 TempFileHandles
[Index
] = Private
->CurrentFvFileHandles
[PeimIndex
];
143 // Since we have copied the file handle we can remove it from this list.
145 Private
->CurrentFvFileHandles
[PeimIndex
] = NULL
;
149 // Update valid Aprioricount
151 Private
->AprioriCount
= Index
;
154 // Add in any PEIMs not in the Apriori file
156 for (;Index
< PeimCount
; Index
++) {
157 for (Index2
= 0; Index2
< PeimCount
; Index2
++) {
158 if (Private
->CurrentFvFileHandles
[Index2
] != NULL
) {
159 TempFileHandles
[Index
] = Private
->CurrentFvFileHandles
[Index2
];
160 Private
->CurrentFvFileHandles
[Index2
] = NULL
;
166 //Index the end of array contains re-range Pei moudle.
168 TempFileHandles
[Index
] = NULL
;
171 // Private->CurrentFvFileHandles is currently in PEIM in the FV order.
172 // We need to update it to start with files in the A Priori list and
173 // then the remaining files in PEIM order.
175 CopyMem (Private
->CurrentFvFileHandles
, TempFileHandles
, sizeof (Private
->CurrentFvFileHandles
));
179 // Cache the current Fv File Handle. So that we don't have to scan the Fv again.
180 // Instead, we can retrieve the file handles within this Fv from cachable data.
182 Private
->Fv
[Private
->CurrentPeimFvCount
].ScanFv
= TRUE
;
183 CopyMem (Private
->Fv
[Private
->CurrentPeimFvCount
].FvFileHandles
, Private
->CurrentFvFileHandles
, sizeof (Private
->CurrentFvFileHandles
));
189 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
190 IN PEI_CORE_INSTANCE
*Private
197 Conduct PEIM dispatch.
201 SecCoreData - Points to a data structure containing information about the PEI core's operating
202 environment, such as the size and location of temporary RAM, the stack location and
204 PrivateData - Pointer to the private data passed in from caller
205 DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
209 EFI_SUCCESS - Successfully dispatched PEIM.
210 EFI_NOT_FOUND - The dispatch failed.
217 EFI_PEI_SERVICES
**PeiServices
;
219 EFI_PEI_FV_HANDLE VolumeHandle
;
220 EFI_PEI_FILE_HANDLE PeiCoreFileHandle
;
221 EFI_PEI_FILE_HANDLE PeimFileHandle
;
224 UINT32 AuthenticationState
;
225 EFI_PHYSICAL_ADDRESS EntryPoint
;
226 EFI_PEIM_ENTRY_POINT PeimEntryPoint
;
227 BOOLEAN PeimNeedingDispatch
;
228 BOOLEAN PeimDispatchOnThisPass
;
229 UINTN SaveCurrentPeimCount
;
230 UINTN SaveCurrentFvCount
;
231 EFI_PEI_FILE_HANDLE SaveCurrentFileHandle
;
233 PEI_CORE_PARAMETERS PeiCoreParameters
;
234 EFI_DEVICE_HANDLE_EXTENDED_DATA ExtendedData
;
235 EFI_FV_FILE_INFO FvFileInfo
;
238 PeiServices
= &Private
->PS
;
239 PeimEntryPoint
= NULL
;
240 PeimFileHandle
= NULL
;
243 if ((Private
->PeiMemoryInstalled
) && (Private
->HobList
.HandoffInformationTable
->BootMode
!= BOOT_ON_S3_RESUME
)) {
245 // Once real memory is available, shadow the RegisterForShadow modules. And meanwhile
246 // update the modules' status from PEIM_STATE_REGISITER_FOR_SHADOW to PEIM_STATE_DONE.
248 SaveCurrentPeimCount
= Private
->CurrentPeimCount
;
249 SaveCurrentFvCount
= Private
->CurrentPeimFvCount
;
250 SaveCurrentFileHandle
= Private
->CurrentFileHandle
;
252 for (Index1
= 0; Index1
<= SaveCurrentFvCount
; Index1
++) {
253 for (Index2
= 0; (Index2
< FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)) && (Private
->Fv
[Index1
].FvFileHandles
[Index2
] != NULL
); Index2
++) {
254 if (Private
->Fv
[Index1
].PeimState
[Index2
] == PEIM_STATE_REGISITER_FOR_SHADOW
) {
255 PeimFileHandle
= Private
->Fv
[Index1
].FvFileHandles
[Index2
];
256 Status
= PeiLoadImage (
262 if (Status
== EFI_SUCCESS
) {
264 // PEIM_STATE_REGISITER_FOR_SHADOW move to PEIM_STATE_DONE
266 Private
->Fv
[Index1
].PeimState
[Index2
]++;
267 Private
->CurrentFileHandle
= PeimFileHandle
;
268 Private
->CurrentPeimFvCount
= Index1
;
269 Private
->CurrentPeimCount
= Index2
;
271 // Call the PEIM entry point
273 PeimEntryPoint
= (EFI_PEIM_ENTRY_POINT
)(UINTN
)EntryPoint
;
275 PERF_START (0, "PEIM", NULL
, 0);
276 PeimEntryPoint(PeimFileHandle
, &Private
->PS
);
277 PERF_END (0, "PEIM", NULL
, 0);
281 // Process the Notify list and dispatch any notifies for
282 // newly installed PPIs.
284 ProcessNotifyList (Private
);
288 Private
->CurrentFileHandle
= SaveCurrentFileHandle
;
289 Private
->CurrentPeimFvCount
= SaveCurrentFvCount
;
290 Private
->CurrentPeimCount
= SaveCurrentPeimCount
;
294 // This is the main dispatch loop. It will search known FVs for PEIMs and
295 // attempt to dispatch them. If any PEIM gets dispatched through a single
296 // pass of the dispatcher, it will start over from the Bfv again to see
297 // if any new PEIMs dependencies got satisfied. With a well ordered
298 // FV where PEIMs are found in the order their dependencies are also
299 // satisfied, this dipatcher should run only once.
302 PeimNeedingDispatch
= FALSE
;
303 PeimDispatchOnThisPass
= FALSE
;
305 for (FvCount
= Private
->CurrentPeimFvCount
; FvCount
< Private
->FvCount
; FvCount
++) {
306 Private
->CurrentPeimFvCount
= FvCount
;
307 VolumeHandle
= Private
->Fv
[FvCount
].FvHeader
;
309 if (Private
->CurrentPeimCount
== 0) {
311 // When going through each FV, at first, search Apriori file to
312 // reorder all PEIMs to ensure the PEIMs in Apriori file to get
313 // dispatch at first.
315 DiscoverPeimsAndOrderWithApriori (Private
, VolumeHandle
);
319 // Start to dispatch all modules within the current Fv.
321 for (PeimCount
= Private
->CurrentPeimCount
;
322 (PeimCount
< FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)) && (Private
->CurrentFvFileHandles
[PeimCount
] != NULL
);
324 Private
->CurrentPeimCount
= PeimCount
;
325 PeimFileHandle
= Private
->CurrentFileHandle
= Private
->CurrentFvFileHandles
[PeimCount
];
327 if (Private
->Fv
[FvCount
].PeimState
[PeimCount
] == PEIM_STATE_NOT_DISPATCHED
) {
328 if (!DepexSatisfied (Private
, PeimFileHandle
, PeimCount
)) {
329 PeimNeedingDispatch
= TRUE
;
331 Status
= PeiFfsGetFileInfo (PeimFileHandle
, &FvFileInfo
);
332 ASSERT_EFI_ERROR (Status
);
333 if (FvFileInfo
.FileType
== EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
) {
335 // For Fv type file, Produce new FV PPI and FV hob
337 Status
= ProcessFvFile (PeiServices
, PeimFileHandle
, &AuthenticationState
);
340 // For PEIM driver, Load its entry point
342 Status
= PeiLoadImage (
350 if ((Status
== EFI_SUCCESS
)) {
352 // The PEIM has its dependencies satisfied, and is processed.
354 PERF_START (0, "PEIM", NULL
, 0);
356 ExtendedData
.Handle
= (EFI_HANDLE
)PeimFileHandle
;
358 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
360 EFI_SOFTWARE_PEI_CORE
| EFI_SW_PC_INIT_BEGIN
,
361 (VOID
*)(&ExtendedData
),
362 sizeof (ExtendedData
)
365 Status
= VerifyPeim (Private
, VolumeHandle
, PeimFileHandle
);
366 if (Status
!= EFI_SECURITY_VIOLATION
&& (AuthenticationState
== 0)) {
368 // PEIM_STATE_NOT_DISPATCHED move to PEIM_STATE_DISPATCHED
370 Private
->Fv
[FvCount
].PeimState
[PeimCount
]++;
372 if (FvFileInfo
.FileType
!= EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
) {
374 // Call the PEIM entry point for PEIM driver
376 PeimEntryPoint
= (EFI_PEIM_ENTRY_POINT
)(UINTN
)EntryPoint
;
377 PeimEntryPoint (PeimFileHandle
, PeiServices
);
380 // One module has been dispatched.
382 PeimDispatchOnThisPass
= TRUE
;
385 REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
387 EFI_SOFTWARE_PEI_CORE
| EFI_SW_PC_INIT_END
,
388 (VOID
*)(&ExtendedData
),
389 sizeof (ExtendedData
)
391 PERF_END (0, "PEIM", NULL
, 0);
395 // If PeiLoadImage fails, the section extraction PPI or Decompress PPI may not be ready,
396 // we flag that more Peims need to be dispatched.
398 PeimNeedingDispatch
= TRUE
;
402 // Process the Notify list and dispatch any notifies for
403 // newly installed PPIs.
405 ProcessNotifyList (Private
);
408 // If permanent memory was discovered and installed by this
409 // PEIM, shadow PEI Core and switch the stacks to the new memory.
411 if (Private
->SwitchStackSignal
) {
414 // Make sure we don't retry the same PEIM that added memory
416 Private
->CurrentPeimCount
++;
419 // Migrate IDT from CAR into real memory, so after stack switches to
420 // the new memory, the caller can get memory version PeiServiceTable.
422 MigrateIdtTable (PeiServices
);
425 // Since we are at dispatch level, only the Core's private data
426 // is preserved, nobody else should have any data on the stack.
427 // So we need to copy PEI core instance data to memory.
429 PrivateInMem
= AllocateCopyPool (sizeof (PEI_CORE_INSTANCE
), Private
);
430 ASSERT (PrivateInMem
!= NULL
);
433 // Shadow PEI Core. When permanent memory is avaiable, shadow
434 // PEI Core and PEIMs to get high performance.
436 PeiCoreFileHandle
= NULL
;
438 // Find the PEI Core in the BFV
440 Status
= PeiFindFileEx (
441 (EFI_PEI_FV_HANDLE
)Private
->Fv
[0].FvHeader
,
443 EFI_FV_FILETYPE_PEI_CORE
,
447 ASSERT_EFI_ERROR (Status
);
450 // Shadow PEI Core into memory so it will run faster
452 Status
= PeiLoadImage (PeiServices
, PeiCoreFileHandle
, &EntryPoint
, &AuthenticationState
);
453 ASSERT_EFI_ERROR (Status
);
456 // Switch to memory based stack and reenter PEI Core that has been
457 // shadowed to memory.
460 // Adjust the top of stack to be aligned at CPU_STACK_ALIGNMENT
462 TopOfStack
= (VOID
*)((UINTN
)Private
->StackBase
+ (UINTN
)Private
->StackSize
- CPU_STACK_ALIGNMENT
);
463 TopOfStack
= ALIGN_POINTER (TopOfStack
, CPU_STACK_ALIGNMENT
);
465 PeiCoreParameters
.SecCoreData
= SecCoreData
;
466 PeiCoreParameters
.PpiList
= NULL
;
467 PeiCoreParameters
.Data
= PrivateInMem
;
468 ASSERT (PeiCoreParameters
.Data
!= 0);
472 (VOID
*) ((UINTN
) EntryPoint
+ ((UINTN
) PeiCore
- (UINTN
) _ModuleEntryPoint
)),
473 (VOID
*) &PeiCoreParameters
,
475 (VOID
*)(UINTN
)Private
->StackBase
479 if ((Private
->PeiMemoryInstalled
) && (Private
->Fv
[FvCount
].PeimState
[PeimCount
] == PEIM_STATE_REGISITER_FOR_SHADOW
) && \
480 (Private
->HobList
.HandoffInformationTable
->BootMode
!= BOOT_ON_S3_RESUME
)) {
482 // If memory is availble we shadow images by default for performance reasons.
483 // We call the entry point a 2nd time so the module knows it's shadowed.
485 //PERF_START (PeiServices, L"PEIM", PeimFileHandle, 0);
486 PeimEntryPoint (PeimFileHandle
, PeiServices
);
487 //PERF_END (PeiServices, L"PEIM", PeimFileHandle, 0);
490 // PEIM_STATE_REGISITER_FOR_SHADOW move to PEIM_STATE_DONE
492 Private
->Fv
[FvCount
].PeimState
[PeimCount
]++;
495 // Process the Notify list and dispatch any notifies for
496 // newly installed PPIs.
498 ProcessNotifyList (Private
);
505 // We set to NULL here to optimize the 2nd entry to this routine after
506 // memory is found. This reprevents rescanning of the FV. We set to
507 // NULL here so we start at the begining of the next FV
509 Private
->CurrentFileHandle
= NULL
;
510 Private
->CurrentPeimCount
= 0;
512 // Before walking through the next FV,Private->CurrentFvFileHandles[]should set to NULL
514 SetMem (Private
->CurrentFvFileHandles
, sizeof (Private
->CurrentFvFileHandles
), 0);
518 // Before making another pass, we should set Private->CurrentPeimFvCount =0 to go
519 // through all the FV.
521 Private
->CurrentPeimFvCount
= 0;
524 // PeimNeedingDispatch being TRUE means we found a PEIM that did not get
525 // dispatched. So we need to make another pass
527 // PeimDispatchOnThisPass being TRUE means we dispatched a PEIM on this
528 // pass. If we did not dispatch a PEIM there is no point in trying again
529 // as it will fail the next time too (nothing has changed).
531 } while (PeimNeedingDispatch
&& PeimDispatchOnThisPass
);
536 InitializeDispatcherData (
537 IN PEI_CORE_INSTANCE
*PrivateData
,
538 IN PEI_CORE_INSTANCE
*OldCoreData
,
539 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
545 Initialize the Dispatcher's data members
549 PeiServices - The PEI core services table.
550 OldCoreData - Pointer to old core data (before switching stack).
551 NULL if being run in non-permament memory mode.
552 SecCoreData - Points to a data structure containing information about the PEI core's operating
553 environment, such as the size and location of temporary RAM, the stack location and
562 if (OldCoreData
== NULL
) {
563 PeiInitializeFv (PrivateData
, SecCoreData
);
572 IN PEI_CORE_INSTANCE
*Private
,
573 IN EFI_PEI_FILE_HANDLE FileHandle
,
580 This routine parses the Dependency Expression, if available, and
581 decides if the module can be executed.
584 PeiServices - The PEI Service Table
585 CurrentPeimAddress - Address of the PEIM Firmware File under investigation
588 TRUE - Can be dispatched
589 FALSE - Cannot be dispatched
596 if (PeimCount
< Private
->AprioriCount
) {
598 // If its in the A priori file then we set Depex to TRUE
604 // Depex section not in the encapsulated section.
606 Status
= PeiServicesFfsFindSectionData (
607 EFI_SECTION_PEI_DEPEX
,
612 if (EFI_ERROR (Status
)) {
614 // If there is no DEPEX, assume the module can be executed
620 // Evaluate a given DEPEX
622 return PeimDispatchReadiness (&Private
->PS
, DepexData
);
626 This routine enable a PEIM to register itself to shadow when PEI Foundation
627 discovery permanent memory.
629 @param FileHandle File handle of a PEIM.
631 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
632 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
633 @retval EFI_SUCCESS Successfully to register itself.
638 PeiRegisterForShadow (
639 IN EFI_PEI_FILE_HANDLE FileHandle
642 PEI_CORE_INSTANCE
*Private
;
643 Private
= PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
645 if (Private
->CurrentFileHandle
!= FileHandle
) {
647 // The FileHandle must be for the current PEIM
649 return EFI_NOT_FOUND
;
652 if (Private
->Fv
[Private
->CurrentPeimFvCount
].PeimState
[Private
->CurrentPeimCount
] >= PEIM_STATE_REGISITER_FOR_SHADOW
) {
654 // If the PEIM has already entered the PEIM_STATE_REGISTER_FOR_SHADOW or PEIM_STATE_DONE then it's already been started
656 return EFI_ALREADY_STARTED
;
659 Private
->Fv
[Private
->CurrentPeimFvCount
].PeimState
[Private
->CurrentPeimCount
] = PEIM_STATE_REGISITER_FOR_SHADOW
;
666 This routine invoke the PeiCore's entry in new stack environment.
668 @param Context1 The first context parameter is entry of PeiCore
669 @param Context2 The second context parameter is parameter structure point for PeiCore
679 PEI_CORE_ENTRY_POINT PeiCoreEntryPoint
;
680 PEI_CORE_PARAMETERS
*PeiCoreParameters
;
683 // Running on new stack in SEC Core
686 PeiCoreEntryPoint
= (PEI_CORE_ENTRY_POINT
) (UINTN
) Context1
;
687 PeiCoreParameters
= (PEI_CORE_PARAMETERS
*)Context2
;
690 // Call PEI Core using new stack
693 PeiCoreParameters
->SecCoreData
,
694 PeiCoreParameters
->PpiList
,
695 PeiCoreParameters
->Data
706 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
708 @param PeiServices Pointer to the PEI Core Services Table.
709 @param FileHandle File handle of a Fv type file.
710 @param AuthenticationState Pointer to attestation authentication state of image.
713 @retval EFI_NOT_FOUND FV image can't be found.
714 @retval EFI_SUCCESS Successfully to process it.
719 IN EFI_PEI_SERVICES
**PeiServices
,
720 IN EFI_PEI_FILE_HANDLE FvFileHandle
,
721 OUT UINT32
*AuthenticationState
725 EFI_PEI_FV_HANDLE FvImageHandle
;
726 EFI_FV_INFO FvImageInfo
;
729 EFI_PEI_HOB_POINTERS HobFv2
;
732 *AuthenticationState
= 0;
735 // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
738 HobFv2
.Raw
= GetHobList ();
739 while ((HobFv2
.Raw
= GetNextHob (EFI_HOB_TYPE_FV2
, HobFv2
.Raw
)) != NULL
) {
740 if (CompareGuid (&(((EFI_FFS_FILE_HEADER
*)FvFileHandle
)->Name
), &HobFv2
.FirmwareVolume2
->FileName
)) {
742 // this FILE has been dispatched, it will not be dispatched again.
746 HobFv2
.Raw
= GET_NEXT_HOB (HobFv2
);
750 // Find FvImage in FvFile
752 Status
= PeiFfsFindSectionData (
753 (CONST EFI_PEI_SERVICES
**) PeiServices
,
754 EFI_SECTION_FIRMWARE_VOLUME_IMAGE
,
756 (VOID
**)&FvImageHandle
759 if (EFI_ERROR (Status
)) {
763 // Collect FvImage Info.
765 Status
= PeiFfsGetVolumeInfo (FvImageHandle
, &FvImageInfo
);
766 ASSERT_EFI_ERROR (Status
);
768 // FvAlignment must be more than 8 bytes required by FvHeader structure.
770 FvAlignment
= 1 << ((FvImageInfo
.FvAttributes
& EFI_FVB2_ALIGNMENT
) >> 16);
771 if (FvAlignment
< 8) {
777 if ((UINTN
) FvImageInfo
.FvStart
% FvAlignment
!= 0) {
778 FvBuffer
= AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32
) FvImageInfo
.FvSize
), FvAlignment
);
779 if (FvBuffer
== NULL
) {
780 return EFI_OUT_OF_RESOURCES
;
782 CopyMem (FvBuffer
, FvImageInfo
.FvStart
, (UINTN
) FvImageInfo
.FvSize
);
784 // Update FvImageInfo after reload FvImage to new aligned memory
786 PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE
) FvBuffer
, &FvImageInfo
);
790 // Install FvPpi and Build FvHob
792 PiLibInstallFvInfoPpi (
795 (UINT32
) FvImageInfo
.FvSize
,
796 &(FvImageInfo
.FvName
),
797 &(((EFI_FFS_FILE_HEADER
*)FvFileHandle
)->Name
)
801 // Inform HOB consumer phase, i.e. DXE core, the existance of this FV
804 (EFI_PHYSICAL_ADDRESS
) (UINTN
) FvImageInfo
.FvStart
,
808 // Makes the encapsulated volume show up in DXE phase to skip processing of
809 // encapsulated file again.
812 (EFI_PHYSICAL_ADDRESS
) (UINTN
) FvImageInfo
.FvStart
,
815 &(((EFI_FFS_FILE_HEADER
*)FvFileHandle
)->Name
)