#include <IndustryStandard/PeImage.h>\r
#include <Library/PeiServicesTablePointerLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PeiPiLib.h>\r
#include <Guid/FirmwareFileSystem2.h>\r
#include <Guid/AprioriFileName.h>\r
\r
} CACHE_SECTION_DATA;\r
\r
\r
-#define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')\r
+#define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C')\r
\r
///\r
/// Pei Core private data structure instance\r
UINTN CurrentPeimFvCount;\r
UINTN CurrentPeimCount;\r
EFI_PEI_FILE_HANDLE CurrentFileHandle;\r
+ BOOLEAN PeimNeedingDispatch;\r
+ BOOLEAN PeimDispatchOnThisPass;\r
+ BOOLEAN PeimDispatcherReenter;\r
UINTN AllFvCount;\r
EFI_PEI_FV_HANDLE AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
EFI_PEI_HOB_POINTERS HobList;\r
BOOLEAN PeiMemoryInstalled;\r
EFI_PHYSICAL_ADDRESS StackBase;\r
UINT64 StackSize;\r
- VOID *BottomOfCarHeap;\r
- VOID *TopOfCarHeap;\r
VOID *CpuIo;\r
EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi;\r
EFI_PEI_SERVICES ServiceTableShadow;\r
- UINTN SizeOfTemporaryMemory;\r
- UINTN SizeOfCacheAsRam;\r
- VOID *MaxTopOfCarHeap;\r
EFI_PEI_PPI_DESCRIPTOR *XipLoadFile;\r
EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin;\r
UINT64 PhysicalMemoryLength;\r
\r
/**\r
Function Pointer type for PeiCore function.\r
- @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
- environment, such as the size and location of temporary RAM, the stack location and\r
- the BFV location.\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
+ and location of temporary RAM, the stack location and the BFV location.\r
@param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
An empty PPI list consists of a single descriptor with the end-tag\r
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such\r
that both the PEI Foundation and any modules can leverage the associated service\r
calls and/or code in these early PPIs\r
- @param Data Pointer to old core data that is used to initialize the\r
+ @param OldCoreData Pointer to old core data that is used to initialize the\r
core's data areas.\r
**/\r
typedef\r
with the old core data.\r
\r
\r
- @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
- environment, such as the size and location of temporary RAM, the stack location and\r
- the BFV location.\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
+ and location of temporary RAM, the stack location and the BFV location.\r
@param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
An empty PPI list consists of a single descriptor with the end-tag\r
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
@param Data Pointer to old core data that is used to initialize the\r
core's data areas.\r
\r
- @retval EFI_NOT_FOUND Never reach\r
-\r
**/\r
-EFI_STATUS\r
+VOID\r
EFIAPI\r
PeiCore (\r
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
- IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList,\r
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,\r
IN VOID *Data\r
- )\r
-;\r
+ );\r
\r
//\r
// Dispatcher support functions\r
PeimDispatchReadiness (\r
IN EFI_PEI_SERVICES **PeiServices,\r
IN VOID *DependencyExpression\r
- )\r
-;\r
+ );\r
\r
/**\r
Conduct PEIM dispatch.\r
\r
- @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
- environment, such as the size and location of temporary RAM, the stack location and\r
- the BFV location.\r
+ @param SecCoreData Pointer to the data structure containing SEC to PEI handoff data\r
@param PrivateData Pointer to the private data passed in from caller\r
\r
- @retval EFI_SUCCESS Successfully dispatched PEIM.\r
- @retval EFI_NOT_FOUND The dispatch failed.\r
-\r
**/\r
VOID\r
PeiDispatcher (\r
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
IN PEI_CORE_INSTANCE *PrivateData\r
- )\r
-;\r
+ );\r
\r
/**\r
Initialize the Dispatcher's data members\r
@param PrivateData PeiCore's private data structure\r
@param OldCoreData Old data from SecCore\r
NULL if being run in non-permament memory mode.\r
- @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
- environment, such as the size and location of temporary RAM, the stack location and\r
- the BFV location.\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
+ and location of temporary RAM, the stack location and the BFV location.\r
\r
**/\r
VOID\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN PEI_CORE_INSTANCE *OldCoreData,\r
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
- )\r
-;\r
+ );\r
\r
/**\r
This routine parses the Dependency Expression, if available, and\r
\r
@param Private PeiCore's private data structure\r
@param FileHandle PEIM's file handle\r
- @param PeimCount Peim count in all dispatched PEIMs.\r
+ @param PeimCount The index of last dispatched PEIM.\r
\r
- @retval TRUE Can be dispatched\r
- @retval FALSE Cannot be dispatched\r
+ @retval TRUE Can be dispatched\r
+ @retval FALSE Cannot be dispatched\r
\r
**/\r
BOOLEAN\r
IN PEI_CORE_INSTANCE *Private,\r
IN EFI_PEI_FILE_HANDLE FileHandle,\r
IN UINTN PeimCount\r
- )\r
-;\r
+ );\r
\r
//\r
// PPI support functions\r
InitializePpiServices (\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN PEI_CORE_INSTANCE *OldCoreData\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
- Convert Ppi description and PpiData pointer in heap after temporary memory\r
- is migrated to permenent memory.\r
- \r
- @param PrivateData PeiCore's private data structure\r
- @param OldCheckingBottom The old checking bottom.\r
- @param OldCheckingTop The old checking top.\r
+ Migrate the Hob list from the temporary memory stack to PEI installed memory.\r
+\r
+ @param PrivateData Pointer to PeiCore's private data structure.\r
+ @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range\r
+ will be fixup for PpiData and PpiDescriptor pointer.\r
+ @param OldCheckingTop Top of temporary memory range. All Ppi in this range\r
+ will be fixup for PpiData and PpiDescriptor.\r
@param Fixup The address difference between\r
the new Hob list and old Hob list.\r
\r
IN UINTN OldCheckingBottom,\r
IN UINTN OldCheckingTop,\r
IN INTN Fixup\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
- Install PPI services.\r
+ Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
\r
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
@param PpiList Pointer to ppi array that want to be installed.\r
\r
@retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.\r
@retval EFI_INVALID_PARAMETER if PpiList is NULL pointer\r
- @retval EFI_INVALID_PARAMETER if any PPI in PpiList is not valid\r
+ if any PPI in PpiList is not valid\r
@retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI\r
\r
**/\r
PeiInstallPpi (\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
\r
@retval EFI_SUCCESS if the operation was successful\r
@retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
- @retval EFI_INVALID_PARAMETER if NewPpi is not valid\r
+ if NewPpi is not valid\r
@retval EFI_NOT_FOUND if the PPI was not in the database\r
\r
**/\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN UINTN Instance,\r
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
IN OUT VOID **Ppi\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
PeiNotifyPpi (\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
VOID\r
ProcessNotifyList (\r
IN PEI_CORE_INSTANCE *PrivateData\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN INTN InstallStopIndex,\r
IN INTN NotifyStartIndex,\r
IN INTN NotifyStopIndex\r
- )\r
-;\r
+ );\r
\r
//\r
// Boot mode support functions\r
EFIAPI\r
PeiGetBootMode (\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN OUT EFI_BOOT_MODE *BootMode\r
- )\r
-;\r
+ IN OUT EFI_BOOT_MODE *BootMode\r
+ );\r
\r
/**\r
This service enables PEIMs to update the boot mode variable.\r
PeiSetBootMode (\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN EFI_BOOT_MODE BootMode\r
- )\r
-;\r
+ );\r
\r
//\r
// Security support functions\r
InitializeSecurityServices (\r
IN EFI_PEI_SERVICES **PeiServices,\r
IN PEI_CORE_INSTANCE *OldCoreData\r
- )\r
-;\r
+ );\r
\r
/**\r
- Verify a Firmware volume\r
+ Verify a Firmware volume.\r
\r
@param CurrentFvAddress Pointer to the current Firmware Volume under consideration\r
\r
EFI_STATUS\r
VerifyFv (\r
IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN EFI_PEI_FV_HANDLE VolumeHandle,\r
IN EFI_PEI_FILE_HANDLE FileHandle\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
PeiGetHobList (\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN OUT VOID **HobList\r
- )\r
-;\r
+ );\r
\r
/**\r
Add a new HOB to the HOB List.\r
IN UINT16 Type,\r
IN UINT16 Length,\r
IN OUT VOID **Hob\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN EFI_BOOT_MODE BootMode,\r
IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
IN UINT64 MemoryLength\r
- )\r
-;\r
+ );\r
\r
\r
//\r
IN UINT8 SearchType,\r
IN EFI_PEI_FV_HANDLE FwVolHeader,\r
IN OUT EFI_PEI_FILE_HANDLE *FileHeader\r
- )\r
-;\r
+ );\r
\r
/**\r
Given the input file pointer, search for the next matching section in the\r
IN EFI_SECTION_TYPE SectionType,\r
IN EFI_PEI_FILE_HANDLE FfsFileHeader,\r
IN OUT VOID **SectionData\r
- )\r
-;\r
+ );\r
\r
/**\r
search the firmware volumes by index\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN UINTN Instance,\r
IN OUT EFI_PEI_FV_HANDLE *FwVolHeader\r
- )\r
-;\r
+ );\r
\r
//\r
// Memory support functions\r
Initialize the memory services.\r
\r
@param PrivateData PeiCore's private data structure\r
- @param SecCoreData Points to a data structure containing information about the PEI core's operating\r
- environment, such as the size and location of temporary RAM, the stack location and\r
- the BFV location.\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
+ and location of temporary RAM, the stack location and the BFV location.\r
@param OldCoreData Pointer to the PEI Core data.\r
NULL if being run in non-permament memory mode.\r
\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
IN PEI_CORE_INSTANCE *OldCoreData\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
IN UINT64 MemoryLength\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN EFI_MEMORY_TYPE MemoryType,\r
IN UINTN Pages,\r
OUT EFI_PHYSICAL_ADDRESS *Memory\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
- Memory allocation service on the CAR.\r
+ Memory allocation service on the temporary memory.\r
\r
\r
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN UINTN Size,\r
OUT VOID **Buffer\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
**/\r
EFI_STATUS\r
PeiLoadImage (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN EFI_PEI_FILE_HANDLE FileHandle,\r
OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
OUT UINT32 *AuthenticationState\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN UINT32 Instance,\r
IN CONST EFI_GUID *CallerId,\r
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
EFIAPI\r
PeiResetSystem (\r
IN CONST EFI_PEI_SERVICES **PeiServices\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
PeiInitializeFv (\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData\r
- )\r
-;\r
+ );\r
\r
/**\r
Process Firmware Volum Information once FvInfoPPI install.\r
IN EFI_PEI_SERVICES **PeiServices,\r
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
IN VOID *Ppi\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
IN CONST EFI_GUID *FileName,\r
IN EFI_PEI_FV_HANDLE VolumeHandle,\r
OUT EFI_PEI_FILE_HANDLE *FileHandle\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
PeiFfsGetFileInfo (\r
IN EFI_PEI_FILE_HANDLE FileHandle,\r
OUT EFI_FV_FILE_INFO *FileInfo\r
- )\r
-;\r
+ );\r
\r
/**\r
\r
PeiFfsGetVolumeInfo (\r
IN EFI_PEI_FV_HANDLE VolumeHandle,\r
OUT EFI_FV_INFO *VolumeInfo\r
- )\r
-;\r
+ );\r
\r
/**\r
This routine enable a PEIM to register itself to shadow when PEI Foundation\r
EFIAPI\r
PeiRegisterForShadow (\r
IN EFI_PEI_FILE_HANDLE FileHandle\r
- )\r
-;\r
+ );\r
\r
/**\r
Given the input file pointer, search for the next matching file in the\r
IN EFI_FV_FILETYPE SearchType,\r
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,\r
IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL\r
- )\r
-;\r
+ );\r
\r
/**\r
Initialize image service that install PeiLoadFilePpi.\r
InitializeImageServices (\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN PEI_CORE_INSTANCE *OldCoreData\r
- )\r
-;\r
+ );\r
\r
/**\r
Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
\r
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
- @param FileHandle File handle of a Fv type file.\r
+ @param ParentFvHandle Fv handle to parent Fv image that contain this Fv file.\r
+ @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.\r
@param AuthenticationState Pointer to attestation authentication state of image.\r
-\r
+ If return 0, means pass security checking.\r
\r
@retval EFI_NOT_FOUND FV image can't be found.\r
@retval EFI_SUCCESS Successfully to process it.\r
**/\r
EFI_STATUS\r
ProcessFvFile (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN EFI_PEI_FILE_HANDLE FvFileHandle,\r
- OUT UINT32 *AuthenticationState\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_FV_HANDLE ParentFvHandle,\r
+ IN EFI_PEI_FILE_HANDLE ParentFvFileHandle,\r
+ OUT UINT32 *AuthenticationState\r
+ );\r
+\r
+/**\r
+ The wrapper function of PeiLoadImageLoadImage().\r
+\r
+ @param This Pointer to EFI_PEI_LOAD_FILE_PPI.\r
+ @param FileHandle Pointer to the FFS file header of the image.\r
+ @param ImageAddressArg Pointer to PE/TE image.\r
+ @param ImageSizeArg Size of PE/TE image.\r
+ @param EntryPoint Pointer to entry point of specified image file for output.\r
+ @param AuthenticationState Pointer to attestation authentication state of image.\r
+\r
+ @return Status of PeiLoadImageLoadImage().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLoadImageLoadImageWrapper (\r
+ IN CONST EFI_PEI_LOAD_FILE_PPI *This,\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg, OPTIONAL\r
+ OUT UINT64 *ImageSizeArg, OPTIONAL\r
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint,\r
+ OUT UINT32 *AuthenticationState\r
+ );\r
+\r
+/**\r
+\r
+ Provide a callback for when the security PPI is installed.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param NotifyDescriptor The descriptor for the notification event.\r
+ @param Ppi Pointer to the PPI in question.\r
+\r
+ @return Always success\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SecurityPpiNotifyCallback (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
+ IN VOID *Ppi\r
);\r
\r
#endif\r