2 Definition of Pei Core Structures and Services
4 Copyright (c) 2006 - 2009, 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 EFI_PEI_FIRMWARE_VOLUME_PPI
*FvPpi
;
109 EFI_PEI_FV_HANDLE FvHandle
;
110 UINT8 PeimState
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
111 EFI_PEI_FILE_HANDLE FvFileHandles
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
113 } PEI_CORE_FV_HANDLE
;
119 EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor
;
120 } PEI_CORE_UNKNOW_FORMAT_FV_INFO
;
122 #define CACHE_SETION_MAX_NUMBER 0x10
124 EFI_COMMON_SECTION_HEADER
* Section
[CACHE_SETION_MAX_NUMBER
];
125 VOID
* SectionData
[CACHE_SETION_MAX_NUMBER
];
126 UINTN SectionSize
[CACHE_SETION_MAX_NUMBER
];
127 UINTN AllSectionCount
;
129 } CACHE_SECTION_DATA
;
132 #define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')
135 /// Pei Core private data structure instance
141 /// Point to ServiceTableShadow
143 EFI_PEI_SERVICES
*PS
;
144 PEI_PPI_DATABASE PpiData
;
147 /// The count of FVs which contains FFS and could be dispatched by PeiCore.
152 /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.
154 PEI_CORE_FV_HANDLE Fv
[FixedPcdGet32 (PcdPeiCoreMaxFvSupported
)];
155 PEI_CORE_UNKNOW_FORMAT_FV_INFO UnknownFvInfo
[FixedPcdGet32 (PcdPeiCoreMaxFvSupported
)];
156 UINTN UnknownFvInfoCount
;
158 EFI_PEI_FILE_HANDLE CurrentFvFileHandles
[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv
)];
160 UINTN CurrentPeimFvCount
;
161 UINTN CurrentPeimCount
;
162 EFI_PEI_FILE_HANDLE CurrentFileHandle
;
163 BOOLEAN PeimNeedingDispatch
;
164 BOOLEAN PeimDispatchOnThisPass
;
165 BOOLEAN PeimDispatcherReenter
;
166 EFI_PEI_HOB_POINTERS HobList
;
167 BOOLEAN SwitchStackSignal
;
168 BOOLEAN PeiMemoryInstalled
;
169 EFI_PHYSICAL_ADDRESS StackBase
;
172 EFI_PEI_SECURITY2_PPI
*PrivateSecurityPpi
;
173 EFI_PEI_SERVICES ServiceTableShadow
;
174 EFI_PEI_PPI_DESCRIPTOR
*XipLoadFile
;
175 EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin
;
176 UINT64 PhysicalMemoryLength
;
177 EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop
;
178 VOID
* ShadowedPeiCore
;
179 CACHE_SECTION_DATA CacheSection
;
183 /// Pei Core Instance Data Macros
185 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
186 CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
189 Function Pointer type for PeiCore function.
190 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
191 and location of temporary RAM, the stack location and the BFV location.
192 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
193 An empty PPI list consists of a single descriptor with the end-tag
194 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization
195 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such
196 that both the PEI Foundation and any modules can leverage the associated service
197 calls and/or code in these early PPIs
198 @param OldCoreData Pointer to old core data that is used to initialize the
203 (EFIAPI
*PEICORE_FUNCTION_POINTER
)(
204 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
205 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
,
206 IN PEI_CORE_INSTANCE
*OldCoreData
210 /// Union of temporarily used function pointers (to save stack space)
213 PEICORE_FUNCTION_POINTER PeiCore
;
214 EFI_PEIM_ENTRY_POINT2 PeimEntry
;
215 EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry
;
216 EFI_DXE_IPL_PPI
*DxeIpl
;
217 EFI_PEI_PPI_DESCRIPTOR
*PpiDescriptor
;
218 EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
;
220 } PEI_CORE_TEMP_POINTERS
;
223 CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
;
224 EFI_PEI_PPI_DESCRIPTOR
*PpiList
;
226 } PEI_CORE_PARAMETERS
;
233 The entry routine to Pei Core, invoked by PeiMain during transition
234 from SEC to PEI. After switching stack in the PEI core, it will restart
235 with the old core data.
238 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
239 and location of temporary RAM, the stack location and the BFV location.
240 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
241 An empty PPI list consists of a single descriptor with the end-tag
242 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization
243 phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such
244 that both the PEI Foundation and any modules can leverage the associated service
245 calls and/or code in these early PPIs
246 @param Data Pointer to old core data that is used to initialize the
253 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
254 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
,
259 // Dispatcher support functions
264 This is the POSTFIX version of the dependency evaluator. When a
265 PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
266 the evaluation stack. When that entry is poped from the evaluation
267 stack, the PPI is checked if it is installed. This method allows
268 some time savings as not all PPIs must be checked for certain
269 operation types (AND, OR).
272 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
273 @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to
274 the BNF described above and is stored in postfix notation.
276 @retval TRUE if it is a well-formed Grammar
277 @retval FALSE if the dependency expression overflows the evaluation stack
278 if the dependency expression underflows the evaluation stack
279 if the dependency expression is not a well-formed Grammar.
283 PeimDispatchReadiness (
284 IN EFI_PEI_SERVICES
**PeiServices
,
285 IN VOID
*DependencyExpression
289 Conduct PEIM dispatch.
291 @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data
292 @param PrivateData Pointer to the private data passed in from caller
297 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
298 IN PEI_CORE_INSTANCE
*PrivateData
302 Initialize the Dispatcher's data members
304 @param PrivateData PeiCore's private data structure
305 @param OldCoreData Old data from SecCore
306 NULL if being run in non-permament memory mode.
307 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
308 and location of temporary RAM, the stack location and the BFV location.
312 InitializeDispatcherData (
313 IN PEI_CORE_INSTANCE
*PrivateData
,
314 IN PEI_CORE_INSTANCE
*OldCoreData
,
315 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
319 This routine parses the Dependency Expression, if available, and
320 decides if the module can be executed.
323 @param Private PeiCore's private data structure
324 @param FileHandle PEIM's file handle
325 @param PeimCount The index of last dispatched PEIM.
327 @retval TRUE Can be dispatched
328 @retval FALSE Cannot be dispatched
333 IN PEI_CORE_INSTANCE
*Private
,
334 IN EFI_PEI_FILE_HANDLE FileHandle
,
339 // PPI support functions
343 Initialize PPI services.
345 @param PrivateData Pointer to the PEI Core data.
346 @param OldCoreData Pointer to old PEI Core data.
347 NULL if being run in non-permament memory mode.
351 InitializePpiServices (
352 IN PEI_CORE_INSTANCE
*PrivateData
,
353 IN PEI_CORE_INSTANCE
*OldCoreData
358 Migrate the Hob list from the temporary memory stack to PEI installed memory.
360 @param PrivateData Pointer to PeiCore's private data structure.
361 @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range
362 will be fixup for PpiData and PpiDescriptor pointer.
363 @param OldCheckingTop Top of temporary memory range. All Ppi in this range
364 will be fixup for PpiData and PpiDescriptor.
365 @param Fixup The address difference between
366 the new Hob list and old Hob list.
371 IN PEI_CORE_INSTANCE
*PrivateData
,
372 IN UINTN OldCheckingBottom
,
373 IN UINTN OldCheckingTop
,
379 Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.
381 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
382 @param PpiList Pointer to ppi array that want to be installed.
384 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.
385 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer
386 if any PPI in PpiList is not valid
387 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI
393 IN CONST EFI_PEI_SERVICES
**PeiServices
,
394 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
399 Re-Install PPI services.
401 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
402 @param OldPpi Pointer to the old PEI PPI Descriptors.
403 @param NewPpi Pointer to the new PEI PPI Descriptors.
405 @retval EFI_SUCCESS if the operation was successful
406 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL
407 if NewPpi is not valid
408 @retval EFI_NOT_FOUND if the PPI was not in the database
414 IN CONST EFI_PEI_SERVICES
**PeiServices
,
415 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
416 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
421 Locate a given named PPI.
424 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
425 @param Guid Pointer to GUID of the PPI.
426 @param Instance Instance Number to discover.
427 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,
428 returns a pointer to the descriptor (includes flags, etc)
429 @param Ppi Pointer to reference the found PPI
431 @retval EFI_SUCCESS if the PPI is in the database
432 @retval EFI_NOT_FOUND if the PPI is not in the database
438 IN CONST EFI_PEI_SERVICES
**PeiServices
,
439 IN CONST EFI_GUID
*Guid
,
441 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
447 Install a notification for a given PPI.
450 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
451 @param NotifyList Pointer to list of Descriptors to notify upon.
453 @retval EFI_SUCCESS if successful
454 @retval EFI_OUT_OF_RESOURCES if no space in the database
455 @retval EFI_INVALID_PARAMETER if not a good decriptor
461 IN CONST EFI_PEI_SERVICES
**PeiServices
,
462 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
467 Process the Notify List at dispatch level.
469 @param PrivateData PeiCore's private data structure.
474 IN PEI_CORE_INSTANCE
*PrivateData
479 Dispatch notifications.
481 @param PrivateData PeiCore's private data structure
482 @param NotifyType Type of notify to fire.
483 @param InstallStartIndex Install Beginning index.
484 @param InstallStopIndex Install Ending index.
485 @param NotifyStartIndex Notify Beginning index.
486 @param NotifyStopIndex Notify Ending index.
491 IN PEI_CORE_INSTANCE
*PrivateData
,
493 IN INTN InstallStartIndex
,
494 IN INTN InstallStopIndex
,
495 IN INTN NotifyStartIndex
,
496 IN INTN NotifyStopIndex
500 // Boot mode support functions
503 This service enables PEIMs to ascertain the present value of the boot mode.
505 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
506 @param BootMode A pointer to contain the value of the boot mode.
508 @retval EFI_SUCCESS The boot mode was returned successfully.
509 @retval EFI_INVALID_PARAMETER BootMode is NULL.
515 IN CONST EFI_PEI_SERVICES
**PeiServices
,
516 IN OUT EFI_BOOT_MODE
*BootMode
520 This service enables PEIMs to update the boot mode variable.
523 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
524 @param BootMode The value of the boot mode to set.
526 @return EFI_SUCCESS The value was successfully updated
532 IN CONST EFI_PEI_SERVICES
**PeiServices
,
533 IN EFI_BOOT_MODE BootMode
537 // Security support functions
541 Initialize the security services.
543 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
544 @param OldCoreData Pointer to the old core data.
545 NULL if being run in non-permament memory mode.
549 InitializeSecurityServices (
550 IN EFI_PEI_SERVICES
**PeiServices
,
551 IN PEI_CORE_INSTANCE
*OldCoreData
555 Verify a Firmware volume.
557 @param CurrentFvAddress Pointer to the current Firmware Volume under consideration
559 @retval EFI_SUCCESS Firmware Volume is legal
560 @retval EFI_SECURITY_VIOLATION Firmware Volume fails integrity test
565 IN EFI_FIRMWARE_VOLUME_HEADER
*CurrentFvAddress
570 Provide a callout to the security verification service.
573 @param PrivateData PeiCore's private data structure
574 @param VolumeHandle Handle of FV
575 @param FileHandle Handle of PEIM's ffs
577 @retval EFI_SUCCESS Image is OK
578 @retval EFI_SECURITY_VIOLATION Image is illegal
583 IN PEI_CORE_INSTANCE
*PrivateData
,
584 IN EFI_PEI_FV_HANDLE VolumeHandle
,
585 IN EFI_PEI_FILE_HANDLE FileHandle
590 Gets the pointer to the HOB List.
593 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
594 @param HobList Pointer to the HOB List.
596 @retval EFI_SUCCESS Get the pointer of HOB List
597 @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published
598 @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode)
604 IN CONST EFI_PEI_SERVICES
**PeiServices
,
605 IN OUT VOID
**HobList
609 Add a new HOB to the HOB List.
611 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
612 @param Type Type of the new HOB.
613 @param Length Length of the new HOB to allocate.
614 @param Hob Pointer to the new HOB.
616 @return EFI_SUCCESS Success to create hob.
617 @retval EFI_INVALID_PARAMETER if Hob is NULL
618 @retval EFI_NOT_AVAILABLE_YET if HobList is still not available.
619 @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
625 IN CONST EFI_PEI_SERVICES
**PeiServices
,
633 Builds a Handoff Information Table HOB
635 @param BootMode - Current Bootmode
636 @param MemoryBegin - Start Memory Address.
637 @param MemoryLength - Length of Memory.
639 @return EFI_SUCCESS Always success to initialize HOB.
643 PeiCoreBuildHobHandoffInfoTable (
644 IN EFI_BOOT_MODE BootMode
,
645 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
646 IN UINT64 MemoryLength
651 // FFS Fw Volume support functions
654 Searches for the next matching file in the firmware volume.
656 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
657 @param SearchType Filter to find only files of this type.
658 Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
659 @param VolumeHandle Handle of firmware volume in which to search.
660 @param FileHandle On entry, points to the current handle from which to begin searching or NULL to start
661 at the beginning of the firmware volume. On exit, points the file handle of the next file
662 in the volume or NULL if there are no more files.
664 @retval EFI_NOT_FOUND The file was not found.
665 @retval EFI_NOT_FOUND The header checksum was not zero.
666 @retval EFI_SUCCESS The file was found.
672 IN CONST EFI_PEI_SERVICES
**PeiServices
,
674 IN EFI_PEI_FV_HANDLE FvHandle
,
675 IN OUT EFI_PEI_FILE_HANDLE
*FileHandle
679 Searches for the next matching section within the specified file.
681 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
682 @param SectionType Filter to find only sections of this type.
683 @param FileHandle Pointer to the current file to search.
684 @param SectionData A pointer to the discovered section, if successful.
685 NULL if section not found
687 @retval EFI_NOT_FOUND The section was not found.
688 @retval EFI_SUCCESS The section was found.
693 PeiFfsFindSectionData (
694 IN CONST EFI_PEI_SERVICES
**PeiServices
,
695 IN EFI_SECTION_TYPE SectionType
,
696 IN EFI_PEI_FILE_HANDLE FileHandle
,
697 OUT VOID
**SectionData
701 Search the firmware volumes by index
703 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
704 @param Instance This instance of the firmware volume to find. The value 0 is the Boot Firmware
706 @param VolumeHandle On exit, points to the next volume handle or NULL if it does not exist.
708 @retval EFI_INVALID_PARAMETER VolumeHandle is NULL
709 @retval EFI_NOT_FOUND The volume was not found.
710 @retval EFI_SUCCESS The volume was found.
715 PeiFfsFindNextVolume (
716 IN CONST EFI_PEI_SERVICES
**PeiServices
,
718 IN OUT EFI_PEI_FV_HANDLE
*FwVolHeader
722 // Memory support functions
726 Initialize the memory services.
728 @param PrivateData PeiCore's private data structure
729 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
730 and location of temporary RAM, the stack location and the BFV location.
731 @param OldCoreData Pointer to the PEI Core data.
732 NULL if being run in non-permament memory mode.
736 InitializeMemoryServices (
737 IN PEI_CORE_INSTANCE
*PrivateData
,
738 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
739 IN PEI_CORE_INSTANCE
*OldCoreData
744 Install the permanent memory is now available.
745 Creates HOB (PHIT and Stack).
747 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
748 @param MemoryBegin Start of memory address.
749 @param MemoryLength Length of memory.
751 @return EFI_SUCCESS Always success.
756 PeiInstallPeiMemory (
757 IN CONST EFI_PEI_SERVICES
**PeiServices
,
758 IN EFI_PHYSICAL_ADDRESS MemoryBegin
,
759 IN UINT64 MemoryLength
764 Memory allocation service on permanent memory,
765 not usable prior to the memory installation.
768 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
769 @param MemoryType Type of memory to allocate.
770 @param Pages Number of pages to allocate.
771 @param Memory Pointer of memory allocated.
773 @retval EFI_SUCCESS The allocation was successful
774 @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
775 @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available
776 @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
777 to allocate the number of pages.
783 IN CONST EFI_PEI_SERVICES
**PeiServices
,
784 IN EFI_MEMORY_TYPE MemoryType
,
786 OUT EFI_PHYSICAL_ADDRESS
*Memory
791 Memory allocation service on the temporary memory.
794 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
795 @param Size Amount of memory required
796 @param Buffer Address of pointer to the buffer
798 @retval EFI_SUCCESS The allocation was successful
799 @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
800 to allocate the requested size.
806 IN CONST EFI_PEI_SERVICES
**PeiServices
,
813 Routine for load image file.
816 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
817 @param FileHandle Pointer to the FFS file header of the image.
818 @param EntryPoint Pointer to entry point of specified image file for output.
819 @param AuthenticationState Pointer to attestation authentication state of image.
821 @retval EFI_SUCCESS Image is successfully loaded.
822 @retval EFI_NOT_FOUND Fail to locate necessary PPI
823 @retval Others Fail to load file.
828 IN CONST EFI_PEI_SERVICES
**PeiServices
,
829 IN EFI_PEI_FILE_HANDLE FileHandle
,
830 OUT EFI_PHYSICAL_ADDRESS
*EntryPoint
,
831 OUT UINT32
*AuthenticationState
836 Core version of the Status Code reporter
839 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
840 @param CodeType Type of Status Code.
841 @param Value Value to output for Status Code.
842 @param Instance Instance Number of this status code.
843 @param CallerId ID of the caller of this status code.
844 @param Data Optional data associated with this status code.
846 @retval EFI_SUCCESS if status code is successfully reported
847 @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
852 PeiReportStatusCode (
853 IN CONST EFI_PEI_SERVICES
**PeiServices
,
854 IN EFI_STATUS_CODE_TYPE CodeType
,
855 IN EFI_STATUS_CODE_VALUE Value
,
857 IN CONST EFI_GUID
*CallerId
,
858 IN CONST EFI_STATUS_CODE_DATA
*Data OPTIONAL
863 Core version of the Reset System
866 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
868 @retval EFI_NOT_AVAILABLE_YET PPI not available yet.
869 @retval EFI_DEVICE_ERROR Did not reset system.
870 Otherwise, resets the system.
876 IN CONST EFI_PEI_SERVICES
**PeiServices
881 Initialize PeiCore Fv List.
884 @param PrivateData - Pointer to PEI_CORE_INSTANCE.
885 @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF.
890 IN PEI_CORE_INSTANCE
*PrivateData
,
891 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
895 Process Firmware Volum Information once FvInfoPPI install.
897 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
898 @param NotifyDescriptor Address of the notification descriptor data structure.
899 @param Ppi Address of the PPI that was installed.
901 @retval EFI_SUCCESS if the interface could be successfully installed
906 FirmwareVolmeInfoPpiNotifyCallback (
907 IN EFI_PEI_SERVICES
**PeiServices
,
908 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
914 Given the input VolumeHandle, search for the next matching name file.
916 @param FileName File name to search.
917 @param VolumeHandle The current FV to search.
918 @param FileHandle Pointer to the file matching name in VolumeHandle.
919 NULL if file not found
921 @retval EFI_NOT_FOUND No files matching the search criteria were found
922 @retval EFI_SUCCESS Success to search given file
927 PeiFfsFindFileByName (
928 IN CONST EFI_GUID
*FileName
,
929 IN EFI_PEI_FV_HANDLE VolumeHandle
,
930 OUT EFI_PEI_FILE_HANDLE
*FileHandle
934 Returns information about a specific file.
936 @param FileHandle Handle of the file.
937 @param FileInfo Upon exit, points to the file’s information.
939 @retval EFI_INVALID_PARAMETER If FileInfo is NULL.
940 @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.
941 @retval EFI_SUCCESS File information returned.
947 IN EFI_PEI_FILE_HANDLE FileHandle
,
948 OUT EFI_FV_FILE_INFO
*FileInfo
952 Returns information about the specified volume.
954 @param VolumeHandle Handle of the volume.
955 @param VolumeInfo Upon exit, points to the volume’s information.
957 @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.
958 @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.
959 @retval EFI_SUCCESS Volume information returned.
963 PeiFfsGetVolumeInfo (
964 IN EFI_PEI_FV_HANDLE VolumeHandle
,
965 OUT EFI_FV_INFO
*VolumeInfo
969 This routine enable a PEIM to register itself to shadow when PEI Foundation
970 discovery permanent memory.
972 @param FileHandle File handle of a PEIM.
974 @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself.
975 @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself.
976 @retval EFI_SUCCESS Successfully to register itself.
981 PeiRegisterForShadow (
982 IN EFI_PEI_FILE_HANDLE FileHandle
986 Initialize image service that install PeiLoadFilePpi.
988 @param PrivateData Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.
989 @param OldCoreData Pointer to Old PeiCore's private data.
990 If NULL, PeiCore is entered at first time, stack/heap in temporary memory.
991 If not NULL, PeiCore is entered at second time, stack/heap has been moved
996 InitializeImageServices (
997 IN PEI_CORE_INSTANCE
*PrivateData
,
998 IN PEI_CORE_INSTANCE
*OldCoreData
1002 The wrapper function of PeiLoadImageLoadImage().
1004 @param This Pointer to EFI_PEI_LOAD_FILE_PPI.
1005 @param FileHandle Pointer to the FFS file header of the image.
1006 @param ImageAddressArg Pointer to PE/TE image.
1007 @param ImageSizeArg Size of PE/TE image.
1008 @param EntryPoint Pointer to entry point of specified image file for output.
1009 @param AuthenticationState Pointer to attestation authentication state of image.
1011 @return Status of PeiLoadImageLoadImage().
1016 PeiLoadImageLoadImageWrapper (
1017 IN CONST EFI_PEI_LOAD_FILE_PPI
*This
,
1018 IN EFI_PEI_FILE_HANDLE FileHandle
,
1019 OUT EFI_PHYSICAL_ADDRESS
*ImageAddressArg
, OPTIONAL
1020 OUT UINT64
*ImageSizeArg
, OPTIONAL
1021 OUT EFI_PHYSICAL_ADDRESS
*EntryPoint
,
1022 OUT UINT32
*AuthenticationState
1027 Provide a callback for when the security PPI is installed.
1029 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
1030 @param NotifyDescriptor The descriptor for the notification event.
1031 @param Ppi Pointer to the PPI in question.
1033 @return Always success
1038 SecurityPpiNotifyCallback (
1039 IN EFI_PEI_SERVICES
**PeiServices
,
1040 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
1045 Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.
1047 @param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.
1048 @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.
1050 @retval EFI_NOT_FOUND FV image can't be found.
1051 @retval EFI_SUCCESS Successfully to process it.
1052 @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image
1053 @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section
1058 IN PEI_CORE_FV_HANDLE
*ParentFvCoreHandle
,
1059 IN EFI_PEI_FILE_HANDLE ParentFvFileHandle
1063 Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.
1065 This routine also will install FvInfo ppi for FV hob in PI ways.
1067 @param Private Pointer of PEI_CORE_INSTANCE
1068 @param Instance The index of FV want to be searched.
1070 @return Instance of PEI_CORE_FV_HANDLE.
1072 PEI_CORE_FV_HANDLE
*
1073 FindNextCoreFvHandle (
1074 IN PEI_CORE_INSTANCE
*Private
,
1079 After PeiCore image is shadowed into permanent memory, all build-in FvPpi should
1080 be re-installed with the instance in permanent memory and all cached FvPpi pointers in
1081 PrivateData->Fv[] array should be fixed up to be pointed to the one in permenant
1084 @param PrivateData Pointer to PEI_CORE_INSTANCE.
1088 IN PEI_CORE_INSTANCE
*PrivateData