]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain.h
Update shell binaries to newer version snapshot 2009-12-14 snapshot.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
index 6f040d015586837034ea2f0d2be0173e03182ac1..dc5ea221d6db2fddf3377af87ec7c279c4ee90da 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -43,7 +43,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -106,11 +105,20 @@ typedef struct {
 \r
 typedef struct {\r
   EFI_FIRMWARE_VOLUME_HEADER          *FvHeader;\r
+  EFI_PEI_FIRMWARE_VOLUME_PPI         *FvPpi;\r
+  EFI_PEI_FV_HANDLE                   FvHandle;\r
   UINT8                               PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   EFI_PEI_FILE_HANDLE                 FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   BOOLEAN                             ScanFv;\r
 } PEI_CORE_FV_HANDLE;\r
 \r
+typedef struct {\r
+  EFI_GUID                            FvFormat;\r
+  VOID                                *FvInfo;\r
+  UINT32                              FvInfoSize;\r
+  EFI_PEI_NOTIFY_DESCRIPTOR           NotifyDescriptor;\r
+} PEI_CORE_UNKNOW_FORMAT_FV_INFO;\r
+\r
 #define CACHE_SETION_MAX_NUMBER       0x10\r
 typedef struct {\r
   EFI_COMMON_SECTION_HEADER*          Section[CACHE_SETION_MAX_NUMBER];\r
@@ -121,17 +129,32 @@ typedef struct {
 } 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
 ///\r
 typedef struct{\r
   UINTN                              Signature;\r
-  EFI_PEI_SERVICES                   *PS;     // Point to ServiceTableShadow\r
+  \r
+  ///\r
+  /// Point to ServiceTableShadow\r
+  ///\r
+  EFI_PEI_SERVICES                   *PS;\r
   PEI_PPI_DATABASE                   PpiData;\r
+  \r
+  ///\r
+  /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
+  ///\r
   UINTN                              FvCount;\r
+  \r
+  ///\r
+  /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
+  ///\r
   PEI_CORE_FV_HANDLE                 Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
+  PEI_CORE_UNKNOW_FORMAT_FV_INFO     UnknownFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
+  UINTN                              UnknownFvInfoCount;\r
+  \r
   EFI_PEI_FILE_HANDLE                CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
   UINTN                              AprioriCount;\r
   UINTN                              CurrentPeimFvCount;\r
@@ -140,8 +163,6 @@ typedef struct{
   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                            SwitchStackSignal;\r
   BOOLEAN                            PeiMemoryInstalled;\r
@@ -166,16 +187,15 @@ typedef struct{
 \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
@@ -215,9 +235,8 @@ typedef struct {
   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
@@ -227,14 +246,12 @@ typedef struct {
   @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
@@ -274,9 +291,6 @@ PeimDispatchReadiness (
   @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
@@ -290,9 +304,8 @@ PeiDispatcher (
   @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
@@ -342,7 +355,7 @@ InitializePpiServices (
 \r
 /**\r
 \r
-  Migrate the Hob list from the CAR stack to PEI installed memory.\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
@@ -500,7 +513,7 @@ EFI_STATUS
 EFIAPI\r
 PeiGetBootMode (\r
   IN CONST EFI_PEI_SERVICES  **PeiServices,\r
-  IN OUT EFI_BOOT_MODE *BootMode\r
+  IN OUT   EFI_BOOT_MODE     *BootMode\r
   );\r
 \r
 /**\r
@@ -539,7 +552,7 @@ InitializeSecurityServices (
   );\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
@@ -638,19 +651,19 @@ PeiCoreBuildHobHandoffInfoTable (
 // FFS Fw Volume support functions\r
 //\r
 /**\r
-  Given the input file pointer, search for the next matching file in the\r
-  FFS volume as defined by SearchType. The search starts from FileHeader inside\r
-  the Firmware Volume defined by FwVolHeader.\r
-\r
+  Searches for the next matching file in the firmware volume.\r
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param SearchType      Filter to find only files of this type.\r
                          Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-  @param FwVolHeader     Pointer to the FV header of the volume to search.\r
-  @param FileHeader      Pointer to the current file from which to begin searching.\r
-                         This pointer will be updated upon return to reflect the file found.\r
-  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to find next file in given volume\r
+  @param VolumeHandle    Handle of firmware volume in which to search.\r
+  @param FileHandle      On entry, points to the current handle from which to begin searching or NULL to start\r
+                         at the beginning of the firmware volume. On exit, points the file handle of the next file\r
+                         in the volume or NULL if there are no more files.\r
+\r
+  @retval EFI_NOT_FOUND  The file was not found.\r
+  @retval EFI_NOT_FOUND  The header checksum was not zero.\r
+  @retval EFI_SUCCESS    The file was found.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -658,47 +671,48 @@ EFIAPI
 PeiFfsFindNextFile (\r
   IN CONST EFI_PEI_SERVICES      **PeiServices,\r
   IN UINT8                       SearchType,\r
-  IN EFI_PEI_FV_HANDLE           FwVolHeader,\r
-  IN OUT EFI_PEI_FILE_HANDLE     *FileHeader\r
+  IN EFI_PEI_FV_HANDLE           FvHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE     *FileHandle\r
   );\r
 \r
 /**\r
-  Given the input file pointer, search for the next matching section in the\r
-  FFS volume.\r
+  Searches for the next matching section within the specified file.\r
 \r
-  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
   @param SectionType     Filter to find only sections of this type.\r
-  @param FfsFileHeader   Pointer to the current file to search.\r
-  @param SectionData     Pointer to the Section matching SectionType in FfsFileHeader.\r
+  @param FileHandle      Pointer to the current file to search.\r
+  @param SectionData     A pointer to the discovered section, if successful.\r
                          NULL if section not found\r
 \r
-  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to find section data in given file\r
+  @retval EFI_NOT_FOUND  The section was not found.\r
+  @retval EFI_SUCCESS    The section was found.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiFfsFindSectionData (\r
-  IN CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN EFI_SECTION_TYPE            SectionType,\r
-  IN EFI_PEI_FILE_HANDLE         FfsFileHeader,\r
-  IN OUT VOID                    **SectionData\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN     EFI_SECTION_TYPE      SectionType,\r
+  IN     EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT VOID                     **SectionData\r
   );\r
 \r
 /**\r
-  search the firmware volumes by index\r
+  Search the firmware volumes by index\r
 \r
-  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param Instance               Instance of FV to find\r
-  @param FwVolHeader            Pointer to found Volume.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
+  @param Instance        This instance of the firmware volume to find. The value 0 is the Boot Firmware\r
+                         Volume (BFV).\r
+  @param VolumeHandle    On exit, points to the next volume handle or NULL if it does not exist.\r
 \r
-  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL\r
-  @retval EFI_SUCCESS           Firmware volume instance successfully found.\r
+  @retval EFI_INVALID_PARAMETER  VolumeHandle is NULL\r
+  @retval EFI_NOT_FOUND          The volume was not found.\r
+  @retval EFI_SUCCESS            The volume was found.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-PeiFvFindNextVolume (\r
+PeiFfsFindNextVolume (\r
   IN CONST EFI_PEI_SERVICES          **PeiServices,\r
   IN UINTN                           Instance,\r
   IN OUT EFI_PEI_FV_HANDLE           *FwVolHeader\r
@@ -712,9 +726,8 @@ PeiFvFindNextVolume (
   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
@@ -775,7 +788,7 @@ PeiAllocatePages (
 \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
@@ -812,7 +825,7 @@ PeiAllocatePool (
 **/\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
@@ -918,15 +931,14 @@ PeiFfsFindFileByName (
   );\r
 \r
 /**\r
-\r
   Returns information about a specific file.\r
 \r
+  @param FileHandle       Handle of the file.\r
+  @param FileInfo         Upon exit, points to the file’s information.\r
 \r
-  @param FileHandle         The handle to file.\r
-  @param FileInfo           Pointer to the file information.\r
-\r
-  @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.\r
-  @retval EFI_SUCCESS           Success to collect file info.\r
+  @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
+  @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
+  @retval EFI_SUCCESS           File information returned.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -937,14 +949,14 @@ PeiFfsGetFileInfo (
   );\r
 \r
 /**\r
+  Returns information about the specified volume.\r
 \r
-  Collect information of given Fv Volume.\r
+  @param VolumeHandle    Handle of the volume.\r
+  @param VolumeInfo      Upon exit, points to the volume’s information.\r
 \r
-  @param VolumeHandle           The handle to Fv Volume.\r
-  @param VolumeInfo             The pointer to volume information.\r
-\r
-  @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
-  @retval EFI_SUCCESS           Success to collect fv info.\r
+  @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
+  @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
+  @retval EFI_SUCCESS           Volume information returned.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -970,32 +982,6 @@ PeiRegisterForShadow (
   IN EFI_PEI_FILE_HANDLE       FileHandle\r
   );\r
 \r
-/**\r
-  Given the input file pointer, search for the next matching file in the\r
-  FFS volume as defined by SearchType. The search starts from FileHeader inside\r
-  the Firmware Volume defined by FwVolHeader.\r
-\r
-\r
-  @param FvHandle        Pointer to the FV header of the volume to search\r
-  @param FileName        File name\r
-  @param SearchType      Filter to find only files of this type.\r
-                         Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-  @param FileHandle      This parameter must point to a valid FFS volume.\r
-  @param AprioriFile     Pointer to AprioriFile image in this FV if has\r
-\r
-  @return EFI_NOT_FOUND  No files matching the search criteria were found\r
-  @retval EFI_SUCCESS    Success to search given file\r
-\r
-**/\r
-EFI_STATUS\r
-PeiFindFileEx (\r
-  IN  CONST EFI_PEI_FV_HANDLE        FvHandle,\r
-  IN  CONST EFI_GUID                 *FileName,   OPTIONAL\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
   Initialize image service that install PeiLoadFilePpi.\r
 \r
@@ -1013,22 +999,93 @@ InitializeImageServices (
   );\r
 \r
 /**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+  The wrapper function of PeiLoadImageLoadImage().\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 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
-                              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
+  @return Status of PeiLoadImageLoadImage().\r
 \r
 **/\r
 EFI_STATUS\r
-ProcessFvFile (\r
-  IN  EFI_PEI_SERVICES      **PeiServices,\r
-  IN  EFI_PEI_FILE_HANDLE   FvFileHandle,\r
-  OUT UINT32                *AuthenticationState\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
+/**\r
+  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+\r
+  @param ParentFvCoreHandle   Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
+  @param ParentFvFileHandle   File handle of a Fv type file that contain this Fv image.\r
+\r
+  @retval EFI_NOT_FOUND         FV image can't be found.\r
+  @retval EFI_SUCCESS           Successfully to process it.\r
+  @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
+  @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
+  \r
+**/\r
+EFI_STATUS\r
+ProcessFvFile (\r
+  IN  PEI_CORE_FV_HANDLE          *ParentFvCoreHandle,\r
+  IN  EFI_PEI_FILE_HANDLE         ParentFvFileHandle\r
+  );\r
+  \r
+/**\r
+  Get instance of PEI_CORE_FV_HANDLE for next volume according to given index.\r
+  \r
+  This routine also will install FvInfo ppi for FV hob in PI ways.\r
+  \r
+  @param Private    Pointer of PEI_CORE_INSTANCE\r
+  @param Instance   The index of FV want to be searched.\r
+  \r
+  @return Instance of PEI_CORE_FV_HANDLE.\r
+**/\r
+PEI_CORE_FV_HANDLE *\r
+FindNextCoreFvHandle (\r
+  IN PEI_CORE_INSTANCE  *Private,\r
+  IN UINTN              Instance\r
+  );\r
+    \r
+/**\r
+  After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
+  be re-installed with the instance in permanent memory and all cached FvPpi pointers in \r
+  PrivateData->Fv[] array should be fixed up to be pointed to the one in permenant\r
+  memory.\r
+  \r
+  @param PrivateData   Pointer to PEI_CORE_INSTANCE.\r
+**/  \r
+VOID\r
+PeiReinitializeFv (\r
+  IN  PEI_CORE_INSTANCE           *PrivateData\r
+  );\r
+      \r
 #endif\r