]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg PeiCore: Correct the comments of PeiResetSystem2
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
index c8561d52e1cfffba738fd91fe2e038ff6432acfa..8b58916e65b37dd76d6b276fcb3461c2ebeff2a4 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
   \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+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
 http://opensource.org/licenses/bsd-license.php\r
@@ -20,13 +20,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Ppi/MemoryDiscovered.h>\r
 #include <Ppi/StatusCode.h>\r
 #include <Ppi/Reset.h>\r
+#include <Ppi/Reset2.h>\r
 #include <Ppi/FirmwareVolume.h>\r
 #include <Ppi/FirmwareVolumeInfo.h>\r
+#include <Ppi/FirmwareVolumeInfo2.h>\r
 #include <Ppi/Decompress.h>\r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Ppi/LoadFile.h>\r
 #include <Ppi/Security2.h>\r
 #include <Ppi/TemporaryRamSupport.h>\r
+#include <Ppi/TemporaryRamDone.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeiCoreEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
@@ -38,12 +41,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/CacheMaintenanceLib.h>\r
-#include <Library/TimerLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <IndustryStandard/PeImage.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Guid/FirmwareFileSystem2.h>\r
+#include <Guid/FirmwareFileSystem3.h>\r
 #include <Guid/AprioriFileName.h>\r
 \r
 ///\r
@@ -87,9 +90,9 @@ typedef struct {
   /// \r
   INTN                    LastDispatchedNotify;\r
   ///\r
-  /// Ppi database.\r
+  /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.\r
   ///\r
-  PEI_PPI_LIST_POINTERS   PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
+  PEI_PPI_LIST_POINTERS   *PpiListPtrs;\r
 } PEI_PPI_DATABASE;\r
 \r
 \r
@@ -107,33 +110,83 @@ typedef struct {
   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
+  //\r
+  // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.\r
+  //\r
+  UINT8                               *PeimState;\r
+  //\r
+  // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.\r
+  //\r
+  EFI_PEI_FILE_HANDLE                 *FvFileHandles;\r
   BOOLEAN                             ScanFv;\r
+  UINT32                              AuthenticationStatus;\r
 } PEI_CORE_FV_HANDLE;\r
 \r
+typedef struct {\r
+  EFI_GUID                            FvFormat;\r
+  VOID                                *FvInfo;\r
+  UINT32                              FvInfoSize;\r
+  UINT32                              AuthenticationStatus;\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
   VOID*                               SectionData[CACHE_SETION_MAX_NUMBER];\r
   UINTN                               SectionSize[CACHE_SETION_MAX_NUMBER];\r
+  UINT32                              AuthenticationStatus[CACHE_SETION_MAX_NUMBER];\r
   UINTN                               AllSectionCount;\r
   UINTN                               SectionIndex;\r
 } CACHE_SECTION_DATA;\r
 \r
+#define HOLE_MAX_NUMBER       0x3\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS               Base;\r
+  UINTN                              Size;\r
+  UINTN                              Offset;\r
+  BOOLEAN                            OffsetPositive;\r
+} HOLE_MEMORY_DATA;\r
+\r
+///\r
+/// Forward declaration for PEI_CORE_INSTANCE\r
+///\r
+typedef struct _PEI_CORE_INSTANCE  PEI_CORE_INSTANCE;\r
+\r
+\r
+/**\r
+  Function Pointer type for PeiCore function.\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 OldCoreData     Pointer to old core data that is used to initialize the\r
+                         core's data areas.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEICORE_FUNCTION_POINTER)(\r
+  IN CONST  EFI_SEC_PEI_HAND_OFF    *SecCoreData,\r
+  IN CONST  EFI_PEI_PPI_DESCRIPTOR  *PpiList,\r
+  IN PEI_CORE_INSTANCE              *OldCoreData\r
+  );\r
 \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
+struct _PEI_CORE_INSTANCE {\r
   UINTN                              Signature;\r
   \r
   ///\r
   /// Point to ServiceTableShadow\r
   ///\r
-  EFI_PEI_SERVICES                   *PS;\r
+  EFI_PEI_SERVICES                   *Ps;\r
   PEI_PPI_DATABASE                   PpiData;\r
   \r
   ///\r
@@ -142,11 +195,22 @@ typedef struct{
   UINTN                              FvCount;\r
   \r
   ///\r
-  /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
+  /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.\r
+  /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.\r
   ///\r
-  PEI_CORE_FV_HANDLE                 Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
+  PEI_CORE_FV_HANDLE                 *Fv;\r
 \r
-  EFI_PEI_FILE_HANDLE                CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
+  ///\r
+  /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.\r
+  /// Each entry is for one FV which could not be dispatched by PeiCore.\r
+  ///\r
+  PEI_CORE_UNKNOW_FORMAT_FV_INFO     *UnknownFvInfo;\r
+  UINTN                              UnknownFvInfoCount;\r
+  \r
+  ///\r
+  /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.\r
+  ///\r
+  EFI_PEI_FILE_HANDLE                *CurrentFvFileHandles;\r
   UINTN                              AprioriCount;\r
   UINTN                              CurrentPeimFvCount;\r
   UINTN                              CurrentPeimCount;\r
@@ -157,8 +221,6 @@ typedef struct{
   EFI_PEI_HOB_POINTERS               HobList;\r
   BOOLEAN                            SwitchStackSignal;\r
   BOOLEAN                            PeiMemoryInstalled;\r
-  EFI_PHYSICAL_ADDRESS               StackBase;\r
-  UINT64                             StackSize;\r
   VOID                               *CpuIo;\r
   EFI_PEI_SECURITY2_PPI              *PrivateSecurityPpi;\r
   EFI_PEI_SERVICES                   ServiceTableShadow;\r
@@ -166,36 +228,50 @@ typedef struct{
   EFI_PHYSICAL_ADDRESS               PhysicalMemoryBegin;\r
   UINT64                             PhysicalMemoryLength;\r
   EFI_PHYSICAL_ADDRESS               FreePhysicalMemoryTop;\r
-  VOID*                              ShadowedPeiCore;\r
+  UINTN                              HeapOffset;\r
+  BOOLEAN                            HeapOffsetPositive;\r
+  UINTN                              StackOffset;\r
+  BOOLEAN                            StackOffsetPositive;\r
+  PEICORE_FUNCTION_POINTER           ShadowedPeiCore;\r
   CACHE_SECTION_DATA                 CacheSection;\r
-} PEI_CORE_INSTANCE;\r
+  //\r
+  // For Loading modules at fixed address feature to cache the top address below which the \r
+  // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field \r
+  // and  Ps should not be changed since maybe user could get this top address by using the offet to Ps. \r
+  //\r
+  EFI_PHYSICAL_ADDRESS               LoadModuleAtFixAddressTopAddress;\r
+  //\r
+  // The field is define for Loading modules at fixed address feature to tracker the PEI code\r
+  // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page\r
+  // available or not. \r
+  //\r
+  UINT64                            *PeiCodeMemoryRangeUsageBitMap;\r
+  //\r
+  // This field points to the shadowed image read function\r
+  //\r
+  PE_COFF_LOADER_READ_FILE          ShadowedImageRead;\r
+\r
+  //\r
+  // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number of entries.\r
+  //\r
+  EFI_PEI_FILE_HANDLE               *FileHandles;\r
+  //\r
+  // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of entries.\r
+  //\r
+  EFI_GUID                          *FileGuid;\r
+\r
+  //\r
+  // Temp Memory Range is not covered by PeiTempMem and Stack.\r
+  // Those Memory Range will be migrated into phisical memory. \r
+  //\r
+  HOLE_MEMORY_DATA                  HoleData[HOLE_MAX_NUMBER];\r
+};\r
 \r
 ///\r
 /// Pei Core Instance Data Macros\r
 ///\r
 #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
-  CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)\r
-\r
-/**\r
-  Function Pointer type for PeiCore function.\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 OldCoreData     Pointer to old core data that is used to initialize the\r
-                         core's data areas.\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *PEICORE_FUNCTION_POINTER)(\r
-  IN CONST  EFI_SEC_PEI_HAND_OFF    *SecCoreData,\r
-  IN CONST  EFI_PEI_PPI_DESCRIPTOR  *PpiList,\r
-  IN PEI_CORE_INSTANCE              *OldCoreData\r
-  );\r
+  CR(a, PEI_CORE_INSTANCE, Ps, PEI_CORE_HANDLE_SIGNATURE)\r
 \r
 ///\r
 /// Union of temporarily used function pointers (to save stack space)\r
@@ -348,21 +424,15 @@ InitializePpiServices (
 \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
+  @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 PrivateData     Pointer to PeiCore's private data structure.\r
 \r
 **/\r
 VOID\r
 ConvertPpiPointers (\r
-  IN PEI_CORE_INSTANCE       *PrivateData,\r
-  IN UINTN                   OldCheckingBottom,\r
-  IN UINTN                   OldCheckingTop,\r
-  IN INTN                    Fixup\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
+  IN PEI_CORE_INSTANCE           *PrivateData\r
   );\r
 \r
 /**\r
@@ -557,23 +627,23 @@ VerifyFv (
   );\r
 \r
 /**\r
-\r
   Provide a callout to the security verification service.\r
 \r
-\r
   @param PrivateData     PeiCore's private data structure\r
   @param VolumeHandle    Handle of FV\r
   @param FileHandle      Handle of PEIM's ffs\r
+  @param AuthenticationStatus Authentication status\r
 \r
   @retval EFI_SUCCESS              Image is OK\r
   @retval EFI_SECURITY_VIOLATION   Image is illegal\r
-\r
+  @retval EFI_NOT_FOUND            If security PPI is not installed.\r
 **/\r
 EFI_STATUS\r
 VerifyPeim (\r
   IN PEI_CORE_INSTANCE      *PrivateData,\r
   IN EFI_PEI_FV_HANDLE      VolumeHandle,\r
-  IN EFI_PEI_FILE_HANDLE    FileHandle\r
+  IN EFI_PEI_FILE_HANDLE    FileHandle,\r
+  IN UINT32                 AuthenticationStatus\r
   );\r
 \r
 /**\r
@@ -647,7 +717,7 @@ PeiCoreBuildHobHandoffInfoTable (
   @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 VolumeHandle    Handle of firmware volume in which to search.\r
+  @param FvHandle        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
@@ -688,6 +758,31 @@ PeiFfsFindSectionData (
   OUT VOID                     **SectionData\r
   );\r
 \r
+/**\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  SectionType           The value of the section type to find.\r
+  @param  SectionInstance       Section instance to find.\r
+  @param  FileHandle            Handle of the firmware file to search.\r
+  @param  SectionData           A pointer to the discovered section, if successful.\r
+  @param  AuthenticationStatus  A pointer to the authentication status for this section.\r
+\r
+  @retval EFI_SUCCESS      The section was found.\r
+  @retval EFI_NOT_FOUND    The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFindSectionData3 (\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN     EFI_SECTION_TYPE      SectionType,\r
+  IN     UINTN                 SectionInstance,\r
+  IN     EFI_PEI_FILE_HANDLE   FileHandle,\r
+  OUT VOID                     **SectionData,\r
+  OUT UINT32                   *AuthenticationStatus\r
+  );\r
+\r
 /**\r
   Search the firmware volumes by index\r
 \r
@@ -706,7 +801,7 @@ EFIAPI
 PeiFfsFindNextVolume (\r
   IN CONST EFI_PEI_SERVICES          **PeiServices,\r
   IN UINTN                           Instance,\r
-  IN OUT EFI_PEI_FV_HANDLE           *FwVolHeader\r
+  IN OUT EFI_PEI_FV_HANDLE           *VolumeHandle\r
   );\r
 \r
 //\r
@@ -806,6 +901,7 @@ PeiAllocatePool (
 \r
   @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param FileHandle             Pointer to the FFS file header of the image.\r
+  @param PeimState              The dispatch state of the input PEIM handle.\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
@@ -818,6 +914,7 @@ EFI_STATUS
 PeiLoadImage (\r
   IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
   IN  EFI_PEI_FILE_HANDLE         FileHandle,\r
+  IN  UINT8                       PeimState,\r
   OUT    EFI_PHYSICAL_ADDRESS     *EntryPoint,\r
   OUT    UINT32                   *AuthenticationState\r
   );\r
@@ -867,6 +964,30 @@ PeiResetSystem (
   IN CONST EFI_PEI_SERVICES   **PeiServices\r
   );\r
 \r
+/**\r
+  Resets the entire platform.\r
+\r
+  @param[in] ResetType      The type of reset to perform.\r
+  @param[in] ResetStatus    The status code for the reset.\r
+  @param[in] DataSize       The size, in bytes, of ResetData.\r
+  @param[in] ResetData      For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
+                            the data buffer starts with a Null-terminated string, optionally\r
+                            followed by additional binary data. The string is a description\r
+                            that the caller may use to further indicate the reason for the\r
+                            system reset. ResetData is only valid if ResetStatus is something\r
+                            other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
+                            where a minimum amount of ResetData is always required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiResetSystem2 (\r
+  IN EFI_RESET_TYPE     ResetType,\r
+  IN EFI_STATUS         ResetStatus,\r
+  IN UINTN              DataSize,\r
+  IN VOID               *ResetData OPTIONAL\r
+  );\r
+\r
 /**\r
 \r
   Initialize PeiCore Fv List.\r
@@ -925,7 +1046,7 @@ PeiFfsFindFileByName (
   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
+  @param FileInfo         Upon exit, points to the file's information.\r
 \r
   @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
   @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
@@ -939,11 +1060,29 @@ PeiFfsGetFileInfo (
   OUT EFI_FV_FILE_INFO    *FileInfo\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
+  @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
+EFIAPI \r
+PeiFfsGetFileInfo2 (\r
+  IN EFI_PEI_FILE_HANDLE  FileHandle,\r
+  OUT EFI_FV_FILE_INFO2   *FileInfo\r
+  );\r
+\r
 /**\r
   Returns information about the specified volume.\r
 \r
   @param VolumeHandle    Handle of the volume.\r
-  @param VolumeInfo      Upon exit, points to the volume’s information.\r
+  @param VolumeInfo      Upon exit, points to the volume's information.\r
 \r
   @retval EFI_INVALID_PARAMETER If VolumeHandle does not represent a valid volume.\r
   @retval EFI_INVALID_PARAMETER If VolumeInfo is NULL.\r
@@ -980,7 +1119,7 @@ PeiRegisterForShadow (
   @param OldCoreData     Pointer to Old PeiCore's private data.\r
                          If NULL, PeiCore is entered at first time, stack/heap in temporary memory.\r
                          If not NULL, PeiCore is entered at second time, stack/heap has been moved\r
-                         to permenent memory.\r
+                         to permanent memory.\r
 \r
 **/\r
 VOID\r
@@ -1033,19 +1172,22 @@ SecurityPpiNotifyCallback (
   );\r
 \r
 /**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+  Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.\r
 \r
+  @param PrivateData          PeiCore's private data structure\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 EFI_SECURITY_VIOLATION Image is illegal\r
   @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
   \r
 **/\r
 EFI_STATUS\r
 ProcessFvFile (\r
+  IN  PEI_CORE_INSTANCE           *PrivateData,\r
   IN  PEI_CORE_FV_HANDLE          *ParentFvCoreHandle,\r
   IN  EFI_PEI_FILE_HANDLE         ParentFvFileHandle\r
   );\r
@@ -1066,4 +1208,538 @@ FindNextCoreFvHandle (
   IN UINTN              Instance\r
   );\r
     \r
+//\r
+// Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
+//    \r
+\r
+/**\r
+  Memory-based read services.\r
+  \r
+  This function is to perform the Memory Access Read service based on installed \r
+  instance of the EFI_PEI_CPU_IO_PPI. \r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return EFI_NOT_YET_AVAILABLE. \r
+   \r
+  @param  PeiServices           An indirect pointer to the PEI Services Table\r
+                                published by the PEI Foundation.\r
+  @param  This                  Pointer to local data for the interface.\r
+  @param  Width                 The width of the access. Enumerated in bytes.\r
+  @param  Address               The physical address of the access.\r
+  @param  Count                 The number of accesses to perform.\r
+  @param  Buffer                A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_YET_AVAILABLE The service has not been installed.     \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultMemRead (\r
+  IN  CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI          *This,\r
+  IN  EFI_PEI_CPU_IO_PPI_WIDTH          Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+  \r
+/**\r
+  Memory-based write services.\r
+   \r
+  This function is to perform the Memory Access Write service based on installed \r
+  instance of the EFI_PEI_CPU_IO_PPI. \r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return EFI_NOT_YET_AVAILABLE. \r
+   \r
+  @param  PeiServices           An indirect pointer to the PEI Services Table\r
+                                published by the PEI Foundation.\r
+  @param  This                  Pointer to local data for the interface.\r
+  @param  Width                 The width of the access. Enumerated in bytes.\r
+  @param  Address               The physical address of the access.\r
+  @param  Count                 The number of accesses to perform.\r
+  @param  Buffer                A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_YET_AVAILABLE The service has not been installed.     \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultMemWrite (\r
+  IN  CONST EFI_PEI_SERVICES            **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI          *This,\r
+  IN  EFI_PEI_CPU_IO_PPI_WIDTH          Width,\r
+  IN  UINT64                            Address,\r
+  IN  UINTN                             Count,\r
+  IN  OUT VOID                          *Buffer\r
+  );\r
+  \r
+/**\r
+  IO-based read services.\r
+  \r
+  This function is to perform the IO-base read service for the EFI_PEI_CPU_IO_PPI.\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return EFI_NOT_YET_AVAILABLE. \r
+  \r
+  @param  PeiServices           An indirect pointer to the PEI Services Table\r
+                                published by the PEI Foundation.\r
+  @param  This                  Pointer to local data for the interface.\r
+  @param  Width                 The width of the access. Enumerated in bytes.\r
+  @param  Address               The physical address of the access.\r
+  @param  Count                 The number of accesses to perform.\r
+  @param  Buffer                A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultIoRead (\r
+  IN      CONST EFI_PEI_SERVICES          **PeiServices,\r
+  IN      CONST EFI_PEI_CPU_IO_PPI        *This,\r
+  IN      EFI_PEI_CPU_IO_PPI_WIDTH        Width,\r
+  IN      UINT64                          Address,\r
+  IN      UINTN                           Count,\r
+  IN OUT  VOID                            *Buffer\r
+  );\r
+  \r
+/**\r
+  IO-based write services.\r
+  \r
+  This function is to perform the IO-base write service for the EFI_PEI_CPU_IO_PPI.\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return EFI_NOT_YET_AVAILABLE. \r
+  \r
+  @param  PeiServices           An indirect pointer to the PEI Services Table\r
+                                published by the PEI Foundation.\r
+  @param  This                  Pointer to local data for the interface.\r
+  @param  Width                 The width of the access. Enumerated in bytes.\r
+  @param  Address               The physical address of the access.\r
+  @param  Count                 The number of accesses to perform.\r
+  @param  Buffer                A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultIoWrite (\r
+  IN      CONST EFI_PEI_SERVICES          **PeiServices,\r
+  IN      CONST EFI_PEI_CPU_IO_PPI        *This,\r
+  IN      EFI_PEI_CPU_IO_PPI_WIDTH        Width,\r
+  IN      UINT64                          Address,\r
+  IN      UINTN                           Count,\r
+  IN OUT  VOID                            *Buffer\r
+  );\r
+  \r
+/**\r
+  8-bit I/O read operations.\r
+  \r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return An 8-bit value returned from the I/O space.\r
+**/\r
+UINT8\r
+EFIAPI\r
+PeiDefaultIoRead8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  Reads an 16-bit I/O port.\r
+  \r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return A 16-bit value returned from the I/O space.\r
+**/\r
+UINT16\r
+EFIAPI\r
+PeiDefaultIoRead16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  Reads an 32-bit I/O port.\r
+  \r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return A 32-bit value returned from the I/O space.\r
+**/\r
+UINT32\r
+EFIAPI\r
+PeiDefaultIoRead32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  Reads an 64-bit I/O port.\r
+  \r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return A 64-bit value returned from the I/O space.\r
+**/\r
+UINT64\r
+EFIAPI\r
+PeiDefaultIoRead64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  8-bit I/O write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultIoWrite8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT8                       Data\r
+  );\r
+  \r
+/**\r
+  16-bit I/O write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultIoWrite16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT16                      Data\r
+  );\r
+  \r
+/**\r
+  32-bit I/O write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultIoWrite32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT32                      Data\r
+  );\r
+  \r
+/**\r
+  64-bit I/O write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultIoWrite64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT64                      Data\r
+  );\r
+  \r
+/**\r
+  8-bit memory read operations.\r
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return An 8-bit value returned from the memory space.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PeiDefaultMemRead8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  16-bit memory read operations.\r
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return An 16-bit value returned from the memory space.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+PeiDefaultMemRead16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  32-bit memory read operations.\r
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return An 32-bit value returned from the memory space.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+PeiDefaultMemRead32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  64-bit memory read operations.\r
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then \r
+  return 0.\r
+  \r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+\r
+  @return An 64-bit value returned from the memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+PeiDefaultMemRead64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+  \r
+/**\r
+  8-bit memory write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultMemWrite8 (\r
+  IN  CONST EFI_PEI_SERVICES        **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI      *This,\r
+  IN  UINT64                        Address,\r
+  IN  UINT8                         Data\r
+  );\r
+  \r
+/**\r
+  16-bit memory write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultMemWrite16 (\r
+  IN  CONST EFI_PEI_SERVICES        **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI      *This,\r
+  IN  UINT64                        Address,\r
+  IN  UINT16                        Data\r
+  );\r
+\r
+/**\r
+  32-bit memory write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultMemWrite32 (\r
+  IN  CONST EFI_PEI_SERVICES        **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI      *This,\r
+  IN  UINT64                        Address,\r
+  IN  UINT32                        Data\r
+  );\r
+  \r
+/**\r
+  64-bit memory write operations.\r
+\r
+  @param  PeiServices    An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This           Pointer to local data for the interface.\r
+  @param  Address        The physical address of the access.\r
+  @param  Data           The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDefaultMemWrite64 (\r
+  IN  CONST EFI_PEI_SERVICES        **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI      *This,\r
+  IN  UINT64                        Address,\r
+  IN  UINT64                        Data\r
+  );\r
+  \r
+extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;                                        \r
+\r
+//\r
+// Default EFI_PEI_PCI_CFG2_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
+// \r
+\r
+/**\r
+  Reads from a given location in the PCI configuration space.\r
+\r
+  If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then \r
+  return EFI_NOT_YET_AVAILABLE. \r
+  \r
+  @param  PeiServices     An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This            Pointer to local data for the interface.\r
+  @param  Width           The width of the access. Enumerated in bytes.\r
+                          See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
+  @param  Address         The physical address of the access. The format of\r
+                          the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
+  @param  Buffer          A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER The invalid access width.\r
+  @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
+  \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultPciCfg2Read (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN OUT    VOID                      *Buffer\r
+  );\r
+  \r
+/**\r
+  Write to a given location in the PCI configuration space.\r
+\r
+  If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM, then \r
+  return EFI_NOT_YET_AVAILABLE. \r
+  \r
+  @param  PeiServices     An indirect pointer to the PEI Services Table published by the PEI Foundation.\r
+  @param  This            Pointer to local data for the interface.\r
+  @param  Width           The width of the access. Enumerated in bytes.\r
+                          See EFI_PEI_PCI_CFG_PPI_WIDTH above.\r
+  @param  Address         The physical address of the access. The format of\r
+                          the address is described by EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS.\r
+  @param  Buffer          A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER The invalid access width.\r
+  @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultPciCfg2Write (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN OUT    VOID                      *Buffer\r
+  );\r
+  \r
+/**\r
+  This function performs a read-modify-write operation on the contents from a given\r
+  location in the PCI configuration space.\r
+\r
+  @param  PeiServices     An indirect pointer to the PEI Services Table\r
+                          published by the PEI Foundation.\r
+  @param  This            Pointer to local data for the interface.\r
+  @param  Width           The width of the access. Enumerated in bytes. Type\r
+                          EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().\r
+  @param  Address         The physical address of the access.\r
+  @param  SetBits         Points to value to bitwise-OR with the read configuration value.\r
+                          The size of the value is determined by Width.\r
+  @param  ClearBits       Points to the value to negate and bitwise-AND with the read configuration value.\r
+                          The size of the value is determined by Width.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER The invalid access width.\r
+  @retval EFI_NOT_YET_AVAILABLE If the EFI_PEI_PCI_CFG2_PPI is not installed by platform/chipset PEIM.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiDefaultPciCfg2Modify (\r
+  IN CONST  EFI_PEI_SERVICES          **PeiServices,\r
+  IN CONST  EFI_PEI_PCI_CFG2_PPI      *This,\r
+  IN        EFI_PEI_PCI_CFG_PPI_WIDTH Width,\r
+  IN        UINT64                    Address,\r
+  IN        VOID                      *SetBits,\r
+  IN        VOID                      *ClearBits\r
+  );    \r
+  \r
+extern EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi;\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 permanent\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