2 Definition of Pei Core Structures and Services
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Ppi/DxeIpl.h>
20 #include <Ppi/MemoryDiscovered.h>
21 #include <Ppi/StatusCode.h>
22 #include <Ppi/Reset.h>
23 #include <Ppi/FirmwareVolume.h>
24 #include <Ppi/FirmwareVolumeInfo.h>
25 #include <Ppi/Decompress.h>
26 #include <Ppi/GuidedSectionExtraction.h>
27 #include <Ppi/LoadFile.h>
28 #include <Ppi/Security2.h>
29 #include <Ppi/TemporaryRamSupport.h>
30 #include <Library/DebugLib.h>
31 #include <Library/PeiCoreEntryPoint.h>
32 #include <Library/BaseLib.h>
33 #include <Library/HobLib.h>
34 #include <Library/PerformanceLib.h>
35 #include <Library/PeiServicesLib.h>
36 #include <Library/ReportStatusCodeLib.h>
37 #include <Library/PeCoffLib.h>
38 #include <Library/PeCoffGetEntryPointLib.h>
39 #include <Library/BaseMemoryLib.h>
40 #include <Library/CacheMaintenanceLib.h>
41 #include <Library/TimerLib.h>
42 #include <Library/PcdLib.h>
43 #include <IndustryStandard/PeImage.h>
44 #include <Library/PeiServicesTablePointerLib.h>
45 #include <Library/MemoryAllocationLib.h>
46 #include <Guid/FirmwareFileSystem2.h>
47 #include <Guid/AprioriFileName.h>
50 /// It is an FFS type extension used for PeiFindFileEx. It indicates current
51 /// Ffs searching is for all PEIMs can be dispatched by PeiCore.
53 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff
56 /// Pei Core private data structures
59 EFI_PEI_PPI_DESCRIPTOR
*Ppi
;
60 EFI_PEI_NOTIFY_DESCRIPTOR
*Notify
;
62 } PEI_PPI_LIST_POINTERS
;
65 /// PPI database structure which contains two link: PpiList and NotifyList. PpiList
66 /// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.
70 /// index of end of PpiList link list.
74 /// index of end of notify link list.
78 /// index of the dispatched notify list.
82 /// index of last installed Ppi description in PpiList link list.
84 INTN LastDispatchedInstall
;
86 /// index of last dispatched notify in Notify link list.
88 INTN LastDispatchedNotify
;
92 PEI_PPI_LIST_POINTERS PpiListPtrs
[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported
)];
97 // PEI_CORE_FV_HANDE.PeimState
98 // Do not change these values as there is code doing math to change states.
99 // Look for Private->Fv[FvCount].PeimState[PeimCount]++;
101 #define PEIM_STATE_NOT_DISPATCHED 0x00
102 #define PEIM_STATE_DISPATCHED 0x01
103 #define PEIM_STATE_REGISITER_FOR_SHADOW 0x02
104 #define PEIM_STATE_DONE 0x03
107 EFI_FIRMWARE_VOLUME_HEADER
*FvHeader
;
108 UINT8 PeimState
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
109 EFI_PEI_FILE_HANDLE FvFileHandles
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
111 } PEI_CORE_FV_HANDLE
;
113 #define CACHE_SETION_MAX_NUMBER 0x10
115 EFI_COMMON_SECTION_HEADER
* Section
[CACHE_SETION_MAX_NUMBER
];
116 VOID
* SectionData
[CACHE_SETION_MAX_NUMBER
];
117 UINTN SectionSize
[CACHE_SETION_MAX_NUMBER
];
118 UINTN AllSectionCount
;
120 } CACHE_SECTION_DATA
;
123 #define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')
126 /// Pei Core private data structure instance
130 EFI_PEI_SERVICES
*PS
; // Point to ServiceTableShadow
131 PEI_PPI_DATABASE PpiData
;
133 PEI_CORE_FV_HANDLE Fv
[FixedPcdGet32 (PcdPeiCoreMaxFvSupported
)];
134 EFI_PEI_FILE_HANDLE CurrentFvFileHandles
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
136 UINTN CurrentPeimFvCount
;
137 UINTN CurrentPeimCount
;
138 EFI_PEI_FILE_HANDLE CurrentFileHandle
;
139 BOOLEAN PeimNeedingDispatch
;
140 BOOLEAN PeimDispatchOnThisPass
;
141 BOOLEAN PeimDispatcherReenter
;
143 EFI_PEI_FV_HANDLE AllFv
[FixedPcdGet32 (PcdPeiCoreMaxFvSupported
)];
144 EFI_PEI_HOB_POINTERS HobList
;
145 BOOLEAN SwitchStackSignal
;
146 BOOLEAN PeiMemoryInstalled
;
147 EFI_PHYSICAL_ADDRESS StackBase
;
150 EFI_PEI_SECURITY2_PPI
*PrivateSecurityPpi
;
151 EFI_PEI_SERVICES ServiceTableShadow
;
152 EFI_PEI_PPI_DESCRIPTOR
*XipLoadFile
;
153 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin
;
154 UINT64 PhysicalMemoryLength
;
155 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop
;
156 VOID
* ShadowedPeiCore
;
157 CACHE_SECTION_DATA CacheSection
;
161 /// Pei Core Instance Data Macros
163 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
164 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
167 Function Pointer type for PeiCore function.
168 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
169 and location of temporary RAM, the stack location and the BFV location.
170 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
171 An empty PPI list consists of a single descriptor with the end-tag
172 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization
173 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such
174 that both the PEI Foundation and any modules can leverage the associated service
175 calls and/or code in these early PPIs
176 @param OldCoreData Pointer to old core data that is used to initialize the
181 (EFIAPI
*PEICORE_FUNCTION_POINTER
)(
182 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
183 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
,
184 IN PEI_CORE_INSTANCE
*OldCoreData
188 /// Union of temporarily used function pointers (to save stack space)
191 PEICORE_FUNCTION_POINTER PeiCore
;
192 EFI_PEIM_ENTRY_POINT2 PeimEntry
;
193 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry
;
194 EFI_DXE_IPL_PPI
*DxeIpl
;
195 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
196 EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
;
198 } PEI_CORE_TEMP_POINTERS
;
201 CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
;
202 EFI_PEI_PPI_DESCRIPTOR
*PpiList
;
204 } PEI_CORE_PARAMETERS
;
211 The entry routine to Pei Core, invoked by PeiMain during transition
212 from SEC to PEI. After switching stack in the PEI core, it will restart
213 with the old core data.
216 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
217 and location of temporary RAM, the stack location and the BFV location.
218 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
219 An empty PPI list consists of a single descriptor with the end-tag
220 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization
221 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such
222 that both the PEI Foundation and any modules can leverage the associated service
223 calls and/or code in these early PPIs
224 @param Data Pointer to old core data that is used to initialize the
227 @retval EFI_NOT_FOUND Never reach
233 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
234 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
,
239 // Dispatcher support functions
244 This is the POSTFIX version of the dependency evaluator. When a
245 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
246 the evaluation stack. When that entry is poped from the evaluation
247 stack, the PPI is checked if it is installed. This method allows
248 some time savings as not all PPIs must be checked for certain
249 operation types (AND, OR).
252 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
253 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to
254 the BNF described above and is stored in postfix notation.
256 @retval TRUE if it is a well-formed Grammar
257 @retval FALSE if the dependency expression overflows the evaluation stack
258 if the dependency expression underflows the evaluation stack
259 if the dependency expression is not a well-formed Grammar.
263 PeimDispatchReadiness (
264 IN EFI_PEI_SERVICES
**PeiServices
,
265 IN VOID
*DependencyExpression
269 Conduct PEIM dispatch.
271 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data
272 @param PrivateData Pointer to the private data passed in from caller
277 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
278 IN PEI_CORE_INSTANCE
*PrivateData
282 Initialize the Dispatcher's data members
284 @param PrivateData PeiCore's private data structure
285 @param OldCoreData Old data from SecCore
286 NULL if being run in non-permament memory mode.
287 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
288 and location of temporary RAM, the stack location and the BFV location.
292 InitializeDispatcherData (
293 IN PEI_CORE_INSTANCE
*PrivateData
,
294 IN PEI_CORE_INSTANCE
*OldCoreData
,
295 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
299 This routine parses the Dependency Expression, if available, and
300 decides if the module can be executed.
303 @param Private PeiCore's private data structure
304 @param FileHandle PEIM's file handle
305 @param PeimCount The index of last dispatched PEIM.
307 @retval TRUE Can be dispatched
308 @retval FALSE Cannot be dispatched
313 IN PEI_CORE_INSTANCE
*Private
,
314 IN EFI_PEI_FILE_HANDLE FileHandle
,
319 // PPI support functions
323 Initialize PPI services.
325 @param PrivateData Pointer to the PEI Core data.
326 @param OldCoreData Pointer to old PEI Core data.
327 NULL if being run in non-permament memory mode.
331 InitializePpiServices (
332 IN PEI_CORE_INSTANCE
*PrivateData
,
333 IN PEI_CORE_INSTANCE
*OldCoreData
338 Migrate the Hob list from the CAR stack to PEI installed memory.
340 @param PrivateData Pointer to PeiCore's private data structure.
341 @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range
342 will be fixup for PpiData and PpiDescriptor pointer.
343 @param OldCheckingTop Top of temporary memory range. All Ppi in this range
344 will be fixup for PpiData and PpiDescriptor.
345 @param Fixup The address difference between
346 the new Hob list and old Hob list.
351 IN PEI_CORE_INSTANCE
*PrivateData
,
352 IN UINTN OldCheckingBottom
,
353 IN UINTN OldCheckingTop
,
359 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.
361 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
362 @param PpiList Pointer to ppi array that want to be installed.
364 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.
365 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer
366 if any PPI in PpiList is not valid
367 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI
373 IN CONST EFI_PEI_SERVICES
**PeiServices
,
374 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
379 Re-Install PPI services.
381 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
382 @param OldPpi Pointer to the old PEI PPI Descriptors.
383 @param NewPpi Pointer to the new PEI PPI Descriptors.
385 @retval EFI_SUCCESS if the operation was successful
386 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL
387 if NewPpi is not valid
388 @retval EFI_NOT_FOUND if the PPI was not in the database
394 IN CONST EFI_PEI_SERVICES
**PeiServices
,
395 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
396 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
401 Locate a given named PPI.
404 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
405 @param Guid Pointer to GUID of the PPI.
406 @param Instance Instance Number to discover.
407 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,
408 returns a pointer to the descriptor (includes flags, etc)
409 @param Ppi Pointer to reference the found PPI
411 @retval EFI_SUCCESS if the PPI is in the database
412 @retval EFI_NOT_FOUND if the PPI is not in the database
418 IN CONST EFI_PEI_SERVICES
**PeiServices
,
419 IN CONST EFI_GUID
*Guid
,
421 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
427 Install a notification for a given PPI.
430 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
431 @param NotifyList Pointer to list of Descriptors to notify upon.
433 @retval EFI_SUCCESS if successful
434 @retval EFI_OUT_OF_RESOURCES if no space in the database
435 @retval EFI_INVALID_PARAMETER if not a good decriptor
441 IN CONST EFI_PEI_SERVICES
**PeiServices
,
442 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
447 Process the Notify List at dispatch level.
449 @param PrivateData PeiCore's private data structure.
454 IN PEI_CORE_INSTANCE
*PrivateData
459 Dispatch notifications.
461 @param PrivateData PeiCore's private data structure
462 @param NotifyType Type of notify to fire.
463 @param InstallStartIndex Install Beginning index.
464 @param InstallStopIndex Install Ending index.
465 @param NotifyStartIndex Notify Beginning index.
466 @param NotifyStopIndex Notify Ending index.
471 IN PEI_CORE_INSTANCE
*PrivateData
,
473 IN INTN InstallStartIndex
,
474 IN INTN InstallStopIndex
,
475 IN INTN NotifyStartIndex
,
476 IN INTN NotifyStopIndex
480 // Boot mode support functions
483 This service enables PEIMs to ascertain the present value of the boot mode.
485 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
486 @param BootMode A pointer to contain the value of the boot mode.
488 @retval EFI_SUCCESS The boot mode was returned successfully.
489 @retval EFI_INVALID_PARAMETER BootMode is NULL.
495 IN CONST EFI_PEI_SERVICES
**PeiServices
,
496 IN OUT EFI_BOOT_MODE
*BootMode
500 This service enables PEIMs to update the boot mode variable.
503 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
504 @param BootMode The value of the boot mode to set.
506 @return EFI_SUCCESS The value was successfully updated
512 IN CONST EFI_PEI_SERVICES
**PeiServices
,
513 IN EFI_BOOT_MODE BootMode
517 // Security support functions
521 Initialize the security services.
523 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
524 @param OldCoreData Pointer to the old core data.
525 NULL if being run in non-permament memory mode.
529 InitializeSecurityServices (
530 IN EFI_PEI_SERVICES
**PeiServices
,
531 IN PEI_CORE_INSTANCE
*OldCoreData
535 Verify a Firmware volume.
537 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration
539 @retval EFI_SUCCESS Firmware Volume is legal
540 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test
545 IN EFI_FIRMWARE_VOLUME_HEADER
*CurrentFvAddress
550 Provide a callout to the security verification service.
553 @param PrivateData PeiCore's private data structure
554 @param VolumeHandle Handle of FV
555 @param FileHandle Handle of PEIM's ffs
557 @retval EFI_SUCCESS Image is OK
558 @retval EFI_SECURITY_VIOLATION Image is illegal
563 IN PEI_CORE_INSTANCE
*PrivateData
,
564 IN EFI_PEI_FV_HANDLE VolumeHandle
,
565 IN EFI_PEI_FILE_HANDLE FileHandle
570 Gets the pointer to the HOB List.
573 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
574 @param HobList Pointer to the HOB List.
576 @retval EFI_SUCCESS Get the pointer of HOB List
577 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published
578 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)
584 IN CONST EFI_PEI_SERVICES
**PeiServices
,
585 IN OUT VOID
**HobList
589 Add a new HOB to the HOB List.
591 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
592 @param Type Type of the new HOB.
593 @param Length Length of the new HOB to allocate.
594 @param Hob Pointer to the new HOB.
596 @return EFI_SUCCESS Success to create hob.
597 @retval EFI_INVALID_PARAMETER if Hob is NULL
598 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.
599 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
605 IN CONST EFI_PEI_SERVICES
**PeiServices
,
613 Builds a Handoff Information Table HOB
615 @param BootMode - Current Bootmode
616 @param MemoryBegin - Start Memory Address.
617 @param MemoryLength - Length of Memory.
619 @return EFI_SUCCESS Always success to initialize HOB.
623 PeiCoreBuildHobHandoffInfoTable (
624 IN EFI_BOOT_MODE BootMode
,
625 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
626 IN UINT64 MemoryLength
631 // FFS Fw Volume support functions
634 Given the input file pointer, search for the next matching file in the
635 FFS volume as defined by SearchType. The search starts from FileHeader inside
636 the Firmware Volume defined by FwVolHeader.
639 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
640 @param SearchType Filter to find only files of this type.
641 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
642 @param FwVolHeader Pointer to the FV header of the volume to search.
643 @param FileHeader Pointer to the current file from which to begin searching.
644 This pointer will be updated upon return to reflect the file found.
645 @retval EFI_NOT_FOUND No files matching the search criteria were found
646 @retval EFI_SUCCESS Success to find next file in given volume
652 IN CONST EFI_PEI_SERVICES
**PeiServices
,
654 IN EFI_PEI_FV_HANDLE FwVolHeader
,
655 IN OUT EFI_PEI_FILE_HANDLE
*FileHeader
659 Given the input file pointer, search for the next matching section in the
662 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
663 @param SectionType Filter to find only sections of this type.
664 @param FfsFileHeader Pointer to the current file to search.
665 @param SectionData Pointer to the Section matching SectionType in FfsFileHeader.
666 NULL if section not found
668 @retval EFI_NOT_FOUND No files matching the search criteria were found
669 @retval EFI_SUCCESS Success to find section data in given file
674 PeiFfsFindSectionData (
675 IN CONST EFI_PEI_SERVICES
**PeiServices
,
676 IN EFI_SECTION_TYPE SectionType
,
677 IN EFI_PEI_FILE_HANDLE FfsFileHeader
,
678 IN OUT VOID
**SectionData
682 search the firmware volumes by index
684 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
685 @param Instance Instance of FV to find
686 @param FwVolHeader Pointer to found Volume.
688 @retval EFI_INVALID_PARAMETER FwVolHeader is NULL
689 @retval EFI_SUCCESS Firmware volume instance successfully found.
694 PeiFvFindNextVolume (
695 IN CONST EFI_PEI_SERVICES
**PeiServices
,
697 IN OUT EFI_PEI_FV_HANDLE
*FwVolHeader
701 // Memory support functions
705 Initialize the memory services.
707 @param PrivateData PeiCore's private data structure
708 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
709 and location of temporary RAM, the stack location and the BFV location.
710 @param OldCoreData Pointer to the PEI Core data.
711 NULL if being run in non-permament memory mode.
715 InitializeMemoryServices (
716 IN PEI_CORE_INSTANCE
*PrivateData
,
717 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
718 IN PEI_CORE_INSTANCE
*OldCoreData
723 Install the permanent memory is now available.
724 Creates HOB (PHIT and Stack).
726 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
727 @param MemoryBegin Start of memory address.
728 @param MemoryLength Length of memory.
730 @return EFI_SUCCESS Always success.
735 PeiInstallPeiMemory (
736 IN CONST EFI_PEI_SERVICES
**PeiServices
,
737 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
738 IN UINT64 MemoryLength
743 Memory allocation service on permanent memory,
744 not usable prior to the memory installation.
747 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
748 @param MemoryType Type of memory to allocate.
749 @param Pages Number of pages to allocate.
750 @param Memory Pointer of memory allocated.
752 @retval EFI_SUCCESS The allocation was successful
753 @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
754 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available
755 @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
756 to allocate the number of pages.
762 IN CONST EFI_PEI_SERVICES
**PeiServices
,
763 IN EFI_MEMORY_TYPE MemoryType
,
765 OUT EFI_PHYSICAL_ADDRESS
*Memory
770 Memory allocation service on the CAR.
773 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
774 @param Size Amount of memory required
775 @param Buffer Address of pointer to the buffer
777 @retval EFI_SUCCESS The allocation was successful
778 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
779 to allocate the requested size.
785 IN CONST EFI_PEI_SERVICES
**PeiServices
,
792 Routine for load image file.
795 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
796 @param FileHandle Pointer to the FFS file header of the image.
797 @param EntryPoint Pointer to entry point of specified image file for output.
798 @param AuthenticationState Pointer to attestation authentication state of image.
800 @retval EFI_SUCCESS Image is successfully loaded.
801 @retval EFI_NOT_FOUND Fail to locate necessary PPI
802 @retval Others Fail to load file.
807 IN CONST EFI_PEI_SERVICES
**PeiServices
,
808 IN EFI_PEI_FILE_HANDLE FileHandle
,
809 OUT EFI_PHYSICAL_ADDRESS
*EntryPoint
,
810 OUT UINT32
*AuthenticationState
815 Core version of the Status Code reporter
818 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
819 @param CodeType Type of Status Code.
820 @param Value Value to output for Status Code.
821 @param Instance Instance Number of this status code.
822 @param CallerId ID of the caller of this status code.
823 @param Data Optional data associated with this status code.
825 @retval EFI_SUCCESS if status code is successfully reported
826 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
831 PeiReportStatusCode (
832 IN CONST EFI_PEI_SERVICES
**PeiServices
,
833 IN EFI_STATUS_CODE_TYPE CodeType
,
834 IN EFI_STATUS_CODE_VALUE Value
,
836 IN CONST EFI_GUID
*CallerId
,
837 IN CONST EFI_STATUS_CODE_DATA
*Data OPTIONAL
842 Core version of the Reset System
845 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
847 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.
848 @retval EFI_DEVICE_ERROR Did not reset system.
849 Otherwise, resets the system.
855 IN CONST EFI_PEI_SERVICES
**PeiServices
860 Initialize PeiCore Fv List.
863 @param PrivateData - Pointer to PEI_CORE_INSTANCE.
864 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
869 IN PEI_CORE_INSTANCE
*PrivateData
,
870 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
874 Process Firmware Volum Information once FvInfoPPI install.
876 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
877 @param NotifyDescriptor Address of the notification descriptor data structure.
878 @param Ppi Address of the PPI that was installed.
880 @retval EFI_SUCCESS if the interface could be successfully installed
885 FirmwareVolmeInfoPpiNotifyCallback (
886 IN EFI_PEI_SERVICES
**PeiServices
,
887 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
893 Given the input VolumeHandle, search for the next matching name file.
895 @param FileName File name to search.
896 @param VolumeHandle The current FV to search.
897 @param FileHandle Pointer to the file matching name in VolumeHandle.
898 NULL if file not found
900 @retval EFI_NOT_FOUND No files matching the search criteria were found
901 @retval EFI_SUCCESS Success to search given file
906 PeiFfsFindFileByName (
907 IN CONST EFI_GUID
*FileName
,
908 IN EFI_PEI_FV_HANDLE VolumeHandle
,
909 OUT EFI_PEI_FILE_HANDLE
*FileHandle
914 Returns information about a specific file.
917 @param FileHandle The handle to file.
918 @param FileInfo Pointer to the file information.
920 @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.
921 @retval EFI_SUCCESS Success to collect file info.
927 IN EFI_PEI_FILE_HANDLE FileHandle
,
928 OUT EFI_FV_FILE_INFO
*FileInfo
933 Collect information of given Fv Volume.
935 @param VolumeHandle The handle to Fv Volume.
936 @param VolumeInfo The pointer to volume information.
938 @retval EFI_INVALID_PARAMETER VolumeInfo is NULL
939 @retval EFI_SUCCESS Success to collect fv info.
943 PeiFfsGetVolumeInfo (
944 IN EFI_PEI_FV_HANDLE VolumeHandle
,
945 OUT EFI_FV_INFO
*VolumeInfo
949 This routine enable a PEIM to register itself to shadow when PEI Foundation
950 discovery permanent memory.
952 @param FileHandle File handle of a PEIM.
954 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
955 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
956 @retval EFI_SUCCESS Successfully to register itself.
961 PeiRegisterForShadow (
962 IN EFI_PEI_FILE_HANDLE FileHandle
966 Given the input file pointer, search for the next matching file in the
967 FFS volume as defined by SearchType. The search starts from FileHeader inside
968 the Firmware Volume defined by FwVolHeader.
971 @param FvHandle Pointer to the FV header of the volume to search
972 @param FileName File name
973 @param SearchType Filter to find only files of this type.
974 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
975 @param FileHandle This parameter must point to a valid FFS volume.
976 @param AprioriFile Pointer to AprioriFile image in this FV if has
978 @return EFI_NOT_FOUND No files matching the search criteria were found
979 @retval EFI_SUCCESS Success to search given file
984 IN CONST EFI_PEI_FV_HANDLE FvHandle
,
985 IN CONST EFI_GUID
*FileName
, OPTIONAL
986 IN EFI_FV_FILETYPE SearchType
,
987 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
,
988 IN OUT EFI_PEI_FV_HANDLE
*AprioriFile OPTIONAL
992 Initialize image service that install PeiLoadFilePpi.
994 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.
995 @param OldCoreData Pointer to Old PeiCore's private data.
996 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.
997 If not NULL, PeiCore is entered at second time, stack/heap has been moved
1002 InitializeImageServices (
1003 IN PEI_CORE_INSTANCE
*PrivateData
,
1004 IN PEI_CORE_INSTANCE
*OldCoreData
1008 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
1010 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1011 @param FvFileHandle File handle of a Fv type file.
1012 @param AuthenticationState Pointer to attestation authentication state of image.
1013 If return 0, means pass security checking.
1015 @retval EFI_NOT_FOUND FV image can't be found.
1016 @retval EFI_SUCCESS Successfully to process it.
1021 IN CONST EFI_PEI_SERVICES
**PeiServices
,
1022 IN EFI_PEI_FILE_HANDLE FvFileHandle
,
1023 OUT UINT32
*AuthenticationState
1027 The wrapper function of PeiLoadImageLoadImage().
1029 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.
1030 @param FileHandle Pointer to the FFS file header of the image.
1031 @param ImageAddressArg Pointer to PE/TE image.
1032 @param ImageSizeArg Size of PE/TE image.
1033 @param EntryPoint Pointer to entry point of specified image file for output.
1034 @param AuthenticationState Pointer to attestation authentication state of image.
1036 @return Status of PeiLoadImageLoadImage().
1041 PeiLoadImageLoadImageWrapper (
1042 IN CONST EFI_PEI_LOAD_FILE_PPI
*This
,
1043 IN EFI_PEI_FILE_HANDLE FileHandle
,
1044 OUT EFI_PHYSICAL_ADDRESS
*ImageAddressArg
, OPTIONAL
1045 OUT UINT64
*ImageSizeArg
, OPTIONAL
1046 OUT EFI_PHYSICAL_ADDRESS
*EntryPoint
,
1047 OUT UINT32
*AuthenticationState
1052 Provide a callback for when the security PPI is installed.
1054 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1055 @param NotifyDescriptor The descriptor for the notification event.
1056 @param Ppi Pointer to the PPI in question.
1058 @return Always success
1063 SecurityPpiNotifyCallback (
1064 IN EFI_PEI_SERVICES
**PeiServices
,
1065 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,