]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/Core: Create Migrated FV Info Hob for calculating hash (CVE-2019-11098)
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
index c37bc12b72f9cfb837a5593af1605dddf291b738..c27e8fc33bc64321b980a5d508e3075ce0da0070 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
-  \r
-Copyright (c) 2006 - 2010, 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
-http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -20,13 +14,18 @@ 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 <Ppi/SecHobData.h>\r
+#include <Ppi/PeiCoreFvLocation.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeiCoreEntryPoint.h>\r
 #include <Library/BaseLib.h>\r
@@ -38,17 +37,18 @@ 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
+#include <Guid/MigratedFvInfo.h>\r
 \r
 ///\r
 /// It is an FFS type extension used for PeiFindFileEx. It indicates current\r
-/// Ffs searching is for all PEIMs can be dispatched by PeiCore.\r
+/// FFS searching is for all PEIMs can be dispatched by PeiCore.\r
 ///\r
 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE   0xff\r
 \r
@@ -62,60 +62,97 @@ typedef union {
 } PEI_PPI_LIST_POINTERS;\r
 \r
 ///\r
-/// PPI database structure which contains two link: PpiList and NotifyList. PpiList\r
-/// is in head of PpiListPtrs array and notify is in end of PpiListPtrs.\r
+/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out of room\r
 ///\r
+#define PPI_GROWTH_STEP             64\r
+#define CALLBACK_NOTIFY_GROWTH_STEP 32\r
+#define DISPATCH_NOTIFY_GROWTH_STEP 8\r
+\r
 typedef struct {\r
+  UINTN                 CurrentCount;\r
+  UINTN                 MaxCount;\r
+  UINTN                 LastDispatchedCount;\r
   ///\r
-  /// index of end of PpiList link list.\r
+  /// MaxCount number of entries.\r
   ///\r
-  INTN                    PpiListEnd;\r
+  PEI_PPI_LIST_POINTERS *PpiPtrs;\r
+} PEI_PPI_LIST;\r
+\r
+typedef struct {\r
+  UINTN                 CurrentCount;\r
+  UINTN                 MaxCount;\r
   ///\r
-  /// index of end of notify link list.\r
+  /// MaxCount number of entries.\r
+  ///\r
+  PEI_PPI_LIST_POINTERS *NotifyPtrs;\r
+} PEI_CALLBACK_NOTIFY_LIST;\r
+\r
+typedef struct {\r
+  UINTN                 CurrentCount;\r
+  UINTN                 MaxCount;\r
+  UINTN                 LastDispatchedCount;\r
   ///\r
-  INTN                    NotifyListEnd;\r
+  /// MaxCount number of entries.\r
   ///\r
-  /// index of the dispatched notify list.\r
+  PEI_PPI_LIST_POINTERS *NotifyPtrs;\r
+} PEI_DISPATCH_NOTIFY_LIST;\r
+\r
+///\r
+/// PPI database structure which contains three links:\r
+/// PpiList, CallbackNotifyList and DispatchNotifyList.\r
+///\r
+typedef struct {\r
   ///\r
-  INTN                    DispatchListEnd;\r
+  /// PPI List.\r
   ///\r
-  /// index of last installed Ppi description in PpiList link list.\r
+  PEI_PPI_LIST              PpiList;\r
   ///\r
-  INTN                    LastDispatchedInstall;\r
+  /// Notify List at dispatch level.\r
   ///\r
-  /// index of last dispatched notify in Notify link list.\r
-  /// \r
-  INTN                    LastDispatchedNotify;\r
+  PEI_CALLBACK_NOTIFY_LIST  CallbackNotifyList;\r
   ///\r
-  /// Ppi database.\r
+  /// Notify List at callback level.\r
   ///\r
-  PEI_PPI_LIST_POINTERS   PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
+  PEI_DISPATCH_NOTIFY_LIST  DispatchNotifyList;\r
 } PEI_PPI_DATABASE;\r
 \r
-\r
 //\r
-// PEI_CORE_FV_HANDE.PeimState\r
+// PEI_CORE_FV_HANDLE.PeimState\r
 // Do not change these values as there is code doing math to change states.\r
 // Look for Private->Fv[FvCount].PeimState[PeimCount]++;\r
 //\r
 #define PEIM_STATE_NOT_DISPATCHED         0x00\r
 #define PEIM_STATE_DISPATCHED             0x01\r
-#define PEIM_STATE_REGISITER_FOR_SHADOW   0x02\r
+#define PEIM_STATE_REGISTER_FOR_SHADOW    0x02\r
 #define PEIM_STATE_DONE                   0x03\r
 \r
+//\r
+// Number of FV instances to grow by each time we run out of room\r
+//\r
+#define FV_GROWTH_STEP 8\r
+\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
+  UINTN                               PeimCount;\r
+  //\r
+  // Pointer to the buffer with the PeimCount number of Entries.\r
+  //\r
+  UINT8                               *PeimState;\r
+  //\r
+  // Pointer to the buffer with the PeimCount 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
@@ -124,38 +161,93 @@ typedef struct {
   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
+//\r
+// Number of files to grow by each time we run out of room\r
+//\r
+#define TEMP_FILE_GROWTH_STEP 32\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
   ///\r
   /// Point to ServiceTableShadow\r
   ///\r
   EFI_PEI_SERVICES                   *Ps;\r
   PEI_PPI_DATABASE                   PpiData;\r
-  \r
+\r
   ///\r
   /// The count of FVs which contains FFS and could be dispatched by PeiCore.\r
   ///\r
   UINTN                              FvCount;\r
-  \r
+\r
   ///\r
-  /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
+  /// The max count of 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                              MaxFvCount;\r
+\r
+  ///\r
+  /// Pointer to the buffer with the MaxFvCount 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;\r
+\r
+  ///\r
+  /// Pointer to the buffer with the MaxUnknownFvInfoCount 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                              MaxUnknownFvInfoCount;\r
   UINTN                              UnknownFvInfoCount;\r
-  \r
-  EFI_PEI_FILE_HANDLE                CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
+\r
+  ///\r
+  /// Pointer to the buffer FvFileHandlers in PEI_CORE_FV_HANDLE specified by CurrentPeimFvCount.\r
+  ///\r
+  EFI_PEI_FILE_HANDLE                *CurrentFvFileHandles;\r
   UINTN                              AprioriCount;\r
   UINTN                              CurrentPeimFvCount;\r
   UINTN                              CurrentPeimCount;\r
@@ -166,8 +258,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
@@ -175,25 +265,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
+  //\r
+  // Information for migrating memory pages allocated in pre-memory phase.\r
+  //\r
+  HOLE_MEMORY_DATA                   MemoryPages;\r
+  PEICORE_FUNCTION_POINTER           ShadowedPeiCore;\r
   CACHE_SECTION_DATA                 CacheSection;\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
+  // 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 offset 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
+  // memory range usage. It is a bit mapped array in which every bit indicates the corresponding 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
-} PEI_CORE_INSTANCE;\r
+\r
+  UINTN                             TempPeimCount;\r
+\r
+  //\r
+  // Pointer to the temp buffer with the TempPeimCount number of entries.\r
+  //\r
+  EFI_PEI_FILE_HANDLE               *TempFileHandles;\r
+  //\r
+  // Pointer to the temp buffer with the TempPeimCount number of entries.\r
+  //\r
+  EFI_GUID                          *TempFileGuid;\r
+\r
+  //\r
+  // Temp Memory Range is not covered by PeiTempMem and Stack.\r
+  // Those Memory Range will be migrated into physical memory.\r
+  //\r
+  HOLE_MEMORY_DATA                  HoleData[HOLE_MAX_NUMBER];\r
+};\r
 \r
 ///\r
 /// Pei Core Instance Data Macros\r
@@ -201,27 +316,6 @@ typedef struct{
 #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
-\r
 ///\r
 /// Union of temporarily used function pointers (to save stack space)\r
 ///\r
@@ -251,7 +345,7 @@ typedef struct {
   with the old core data.\r
 \r
 \r
-  @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size \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
@@ -279,7 +373,7 @@ PeiCore (
 \r
   This is the POSTFIX version of the dependency evaluator.  When a\r
   PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
-  the evaluation stack.  When that entry is poped from the evaluation\r
+  the evaluation stack.  When that entry is popped from the evaluation\r
   stack, the PPI is checked if it is installed.  This method allows\r
   some time savings as not all PPIs must be checked for certain\r
   operation types (AND, OR).\r
@@ -301,6 +395,41 @@ PeimDispatchReadiness (
   IN VOID               *DependencyExpression\r
   );\r
 \r
+/**\r
+  Migrate a PEIM from temporary RAM to permanent memory.\r
+\r
+  @param PeimFileHandle       Pointer to the FFS file header of the image.\r
+  @param MigratedFileHandle   Pointer to the FFS file header of the migrated image.\r
+\r
+  @retval EFI_SUCCESS         Sucessfully migrated the PEIM to permanent memory.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MigratePeim (\r
+  IN  EFI_PEI_FILE_HANDLE     FileHandle,\r
+  IN  EFI_PEI_FILE_HANDLE     MigratedFileHandle\r
+  );\r
+\r
+/**\r
+  Migrate FVs out of temporary RAM before the cache is flushed.\r
+\r
+  @param Private         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
+\r
+  @retval EFI_SUCCESS           Succesfully migrated installed FVs from temporary RAM to permanent memory.\r
+  @retval EFI_OUT_OF_RESOURCES  Insufficient memory exists to allocate needed pages.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EvacuateTempRam (\r
+  IN PEI_CORE_INSTANCE            *Private,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
+  );\r
+\r
 /**\r
   Conduct PEIM dispatch.\r
 \r
@@ -319,7 +448,7 @@ PeiDispatcher (
 \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
+                         NULL if being run in non-permanent memory mode.\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
@@ -359,8 +488,8 @@ DepexSatisfied (
   Initialize PPI services.\r
 \r
   @param PrivateData     Pointer to the PEI Core data.\r
-  @param OldCoreData     Pointer to old PEI Core data. \r
-                         NULL if being run in non-permament memory mode.\r
+  @param OldCoreData     Pointer to old PEI Core data.\r
+                         NULL if being run in non-permanent memory mode.\r
 \r
 **/\r
 VOID\r
@@ -371,23 +500,61 @@ InitializePpiServices (
 \r
 /**\r
 \r
-  Migrate the Hob list from the temporary memory stack to PEI installed memory.\r
+  Migrate the Hob list from the temporary memory 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
+\r
+  Migrate Notify Pointers inside an FV from temporary memory to permanent memory.\r
+\r
+  @param PrivateData      Pointer to PeiCore's private data structure.\r
+  @param OrgFvHandle      Address of FV Handle in temporary memory.\r
+  @param FvHandle         Address of FV Handle in permanent memory.\r
+  @param FvSize           Size of the FV.\r
+\r
+**/\r
+VOID\r
+ConvertPpiPointersFv (\r
+  IN  PEI_CORE_INSTANCE       *PrivateData,\r
+  IN  UINTN                   OrgFvHandle,\r
+  IN  UINTN                   FvHandle,\r
+  IN  UINTN                   FvSize\r
+  );\r
+\r
+/**\r
+\r
+  Migrate PPI Pointers of PEI_CORE from temporary memory to permanent memory.\r
+\r
+  @param PrivateData      Pointer to PeiCore's private data structure.\r
+  @param CoreFvHandle     Address of PEI_CORE FV Handle in temporary memory.\r
+\r
+**/\r
+VOID\r
+ConvertPeiCorePpiPointers (\r
+  IN  PEI_CORE_INSTANCE        *PrivateData,\r
+  PEI_CORE_FV_HANDLE           CoreFvHandle\r
+  );\r
+\r
+/**\r
+\r
+  Dumps the PPI lists to debug output.\r
+\r
+  @param PrivateData     Points to PeiCore's private instance data.\r
+\r
+**/\r
+VOID\r
+DumpPpiList (\r
+  IN PEI_CORE_INSTANCE    *PrivateData\r
   );\r
 \r
 /**\r
@@ -395,7 +562,7 @@ ConvertPpiPointers (
   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
+  @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
@@ -468,7 +635,7 @@ PeiLocatePpi (
 \r
   @retval EFI_SUCCESS           if successful\r
   @retval EFI_OUT_OF_RESOURCES  if no space in the database\r
-  @retval EFI_INVALID_PARAMETER if not a good decriptor\r
+  @retval EFI_INVALID_PARAMETER if not a good descriptor\r
 \r
 **/\r
 EFI_STATUS\r
@@ -486,13 +653,13 @@ PeiNotifyPpi (
 \r
 **/\r
 VOID\r
-ProcessNotifyList (\r
+ProcessDispatchNotifyList (\r
   IN PEI_CORE_INSTANCE  *PrivateData\r
   );\r
 \r
 /**\r
 \r
-  Dispatch notifications.\r
+  Process notifications.\r
 \r
   @param PrivateData        PeiCore's private data structure\r
   @param NotifyType         Type of notify to fire.\r
@@ -503,7 +670,7 @@ ProcessNotifyList (
 \r
 **/\r
 VOID\r
-DispatchNotify (\r
+ProcessNotify (\r
   IN PEI_CORE_INSTANCE  *PrivateData,\r
   IN UINTN               NotifyType,\r
   IN INTN                InstallStartIndex,\r
@@ -512,6 +679,20 @@ DispatchNotify (
   IN INTN                NotifyStopIndex\r
   );\r
 \r
+/**\r
+  Process PpiList from SEC phase.\r
+\r
+  @param PeiServices    An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList        Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
+                        These PPI's will be installed and/or immediately signaled if they are notification type.\r
+\r
+**/\r
+VOID\r
+ProcessPpiListFromSec (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR   *PpiList\r
+  );\r
+\r
 //\r
 // Boot mode support functions\r
 //\r
@@ -558,7 +739,7 @@ PeiSetBootMode (
 \r
   @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param OldCoreData     Pointer to the old core data.\r
-                         NULL if being run in non-permament memory mode.\r
+                         NULL if being run in non-permanent memory mode.\r
 \r
 **/\r
 VOID\r
@@ -582,23 +763,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 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
@@ -629,7 +810,7 @@ PeiGetHobList (
   @param Length             Length of the new HOB to allocate.\r
   @param Hob                Pointer to the new HOB.\r
 \r
-  @return  EFI_SUCCESS           Success to create hob.\r
+  @return  EFI_SUCCESS           Success to create HOB.\r
   @retval  EFI_INVALID_PARAMETER if Hob is NULL\r
   @retval  EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
   @retval  EFI_OUT_OF_RESOURCES  if there is no more memory to grow the Hoblist.\r
@@ -662,6 +843,22 @@ PeiCoreBuildHobHandoffInfoTable (
   IN UINT64                MemoryLength\r
   );\r
 \r
+/**\r
+  Install SEC HOB data to the HOB List.\r
+\r
+  @param PeiServices    An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param SecHobList     Pointer to SEC HOB List.\r
+\r
+  @return EFI_SUCCESS           Success to install SEC HOB data.\r
+  @retval EFI_OUT_OF_RESOURCES  If there is no more memory to grow the Hoblist.\r
+\r
+**/\r
+EFI_STATUS\r
+PeiInstallSecHobData (\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_HOB_GENERIC_HEADER     *SecHobList\r
+  );\r
+\r
 \r
 //\r
 // FFS Fw Volume support functions\r
@@ -691,6 +888,37 @@ PeiFfsFindNextFile (
   IN OUT EFI_PEI_FILE_HANDLE     *FileHandle\r
   );\r
 \r
+/**\r
+  Go through the file to search SectionType section.\r
+  Search within encapsulation sections (compression and GUIDed) recursively,\r
+  until the match section is found.\r
+\r
+  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param SectionType          Filter to find only section of this type.\r
+  @param SectionInstance      Pointer to the filter to find the specific instance of section.\r
+  @param Section              From where to search.\r
+  @param SectionSize          The file size to search.\r
+  @param OutputBuffer         A pointer to the discovered section, if successful.\r
+                              NULL if section not found.\r
+  @param AuthenticationStatus Updated upon return to point to the authentication status for this section.\r
+  @param IsFfs3Fv             Indicates the FV format.\r
+\r
+  @return EFI_NOT_FOUND       The match section is not found.\r
+  @return EFI_SUCCESS         The match section is found.\r
+\r
+**/\r
+EFI_STATUS\r
+ProcessSection (\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_SECTION_TYPE           SectionType,\r
+  IN OUT UINTN                  *SectionInstance,\r
+  IN EFI_COMMON_SECTION_HEADER  *Section,\r
+  IN UINTN                      SectionSize,\r
+  OUT VOID                      **OutputBuffer,\r
+  OUT UINT32                    *AuthenticationStatus,\r
+  IN BOOLEAN                    IsFfs3Fv\r
+  );\r
+\r
 /**\r
   Searches for the next matching section within the specified file.\r
 \r
@@ -713,6 +941,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
@@ -742,10 +995,10 @@ PeiFfsFindNextVolume (
   Initialize the memory services.\r
 \r
   @param PrivateData     PeiCore's private data structure\r
-  @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size \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
+                         NULL if being run in non-permanent memory mode.\r
 \r
 **/\r
 VOID\r
@@ -776,30 +1029,108 @@ PeiInstallPeiMemory (
   );\r
 \r
 /**\r
+  Migrate memory pages allocated in pre-memory phase.\r
+  Copy memory pages at temporary heap top to permanent heap top.\r
 \r
-  Memory allocation service on permanent memory,\r
-  not usable prior to the memory installation.\r
+  @param[in] Private                Pointer to the private data passed in from caller.\r
+  @param[in] TemporaryRamMigrated   Temporary memory has been migrated to permanent memory.\r
 \r
+**/\r
+VOID\r
+MigrateMemoryPages (\r
+  IN PEI_CORE_INSTANCE      *Private,\r
+  IN BOOLEAN                TemporaryRamMigrated\r
+  );\r
 \r
-  @param PeiServices               An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param MemoryType                Type of memory to allocate.\r
-  @param Pages                     Number of pages to allocate.\r
-  @param Memory                    Pointer of memory allocated.\r
+/**\r
+  Removes any FV HOBs whose base address is not in PEI installed memory.\r
 \r
-  @retval EFI_SUCCESS              The allocation was successful\r
-  @retval EFI_INVALID_PARAMETER    Only AllocateAnyAddress is supported.\r
-  @retval EFI_NOT_AVAILABLE_YET    Called with permanent memory not available\r
-  @retval EFI_OUT_OF_RESOURCES     There is not enough HOB heap to satisfy the requirement\r
-                                   to allocate the number of pages.\r
+  @param[in] Private          Pointer to PeiCore's private data structure.\r
+\r
+**/\r
+VOID\r
+RemoveFvHobsInTemporaryMemory (\r
+  IN PEI_CORE_INSTANCE        *Private\r
+  );\r
+\r
+/**\r
+  Migrate the base address in firmware volume allocation HOBs\r
+  from temporary memory to PEI installed memory.\r
+\r
+  @param[in] PrivateData      Pointer to PeiCore's private data structure.\r
+  @param[in] OrgFvHandle      Address of FV Handle in temporary memory.\r
+  @param[in] FvHandle         Address of FV Handle in permanent memory.\r
+\r
+**/\r
+VOID\r
+ConvertFvHob (\r
+  IN PEI_CORE_INSTANCE          *PrivateData,\r
+  IN UINTN                      OrgFvHandle,\r
+  IN UINTN                      FvHandle\r
+  );\r
+\r
+/**\r
+  Migrate MemoryBaseAddress in memory allocation HOBs\r
+  from the temporary memory to PEI installed memory.\r
+\r
+  @param[in] PrivateData        Pointer to PeiCore's private data structure.\r
+\r
+**/\r
+VOID\r
+ConvertMemoryAllocationHobs (\r
+  IN PEI_CORE_INSTANCE          *PrivateData\r
+  );\r
+\r
+/**\r
+  The purpose of the service is to publish an interface that allows\r
+  PEIMs to allocate memory ranges that are managed by the PEI Foundation.\r
+\r
+  Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap.\r
+  After InstallPeiMemory() is called, PEI will allocate pages within the region\r
+  of memory provided by InstallPeiMemory() service in a best-effort fashion.\r
+  Location-specific allocations are not managed by the PEI foundation code.\r
+\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  MemoryType       The type of memory to allocate.\r
+  @param  Pages            The number of contiguous 4 KB pages to allocate.\r
+  @param  Memory           Pointer to a physical address. On output, the address is set to the base\r
+                           of the page range that was allocated.\r
+\r
+  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
+  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
+  @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r
+                                EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r
+                                EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiAllocatePages (\r
-  IN CONST EFI_PEI_SERVICES           **PeiServices,\r
-  IN EFI_MEMORY_TYPE            MemoryType,\r
-  IN UINTN                      Pages,\r
-  OUT EFI_PHYSICAL_ADDRESS      *Memory\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN       EFI_MEMORY_TYPE      MemoryType,\r
+  IN       UINTN                Pages,\r
+  OUT      EFI_PHYSICAL_ADDRESS *Memory\r
+  );\r
+\r
+/**\r
+  Frees memory pages.\r
+\r
+  @param[in] PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param[in] Memory             The base physical address of the pages to be freed.\r
+  @param[in] Pages              The number of contiguous 4 KB pages to free.\r
+\r
+  @retval EFI_SUCCESS           The requested pages were freed.\r
+  @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r
+  @retval EFI_NOT_FOUND         The requested memory pages were not allocated with\r
+                                AllocatePages().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFreePages (\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS       Memory,\r
+  IN UINTN                      Pages\r
   );\r
 \r
 /**\r
@@ -894,9 +1225,31 @@ 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.\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
+  Initialize PeiCore FV List.\r
 \r
 \r
   @param PrivateData     - Pointer to PEI_CORE_INSTANCE.\r
@@ -910,7 +1263,7 @@ PeiInitializeFv (
   );\r
 \r
 /**\r
-  Process Firmware Volum Information once FvInfoPPI install.\r
+  Process Firmware Volume Information once FvInfoPPI install.\r
 \r
   @param PeiServices       An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param NotifyDescriptor  Address of the notification descriptor data structure.\r
@@ -921,7 +1274,7 @@ PeiInitializeFv (
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-FirmwareVolmeInfoPpiNotifyCallback (\r
+FirmwareVolumeInfoPpiNotifyCallback (\r
   IN EFI_PEI_SERVICES              **PeiServices,\r
   IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
   IN VOID                          *Ppi\r
@@ -966,6 +1319,24 @@ 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
@@ -984,8 +1355,8 @@ PeiFfsGetVolumeInfo (
   );\r
 \r
 /**\r
-  This routine enable a PEIM to register itself to shadow when PEI Foundation\r
-  discovery permanent memory.\r
+  This routine enables a PEIM to register itself for shadow when the PEI Foundation\r
+  discovers permanent memory.\r
 \r
   @param FileHandle             File handle of a PEIM.\r
 \r
@@ -1007,7 +1378,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
@@ -1016,6 +1387,38 @@ InitializeImageServices (
   IN  PEI_CORE_INSTANCE   *OldCoreData\r
   );\r
 \r
+/**\r
+  Loads and relocates a PE/COFF image in place.\r
+\r
+  @param Pe32Data         The base address of the PE/COFF file that is to be loaded and relocated\r
+  @param ImageAddress     The base address of the relocated PE/COFF image\r
+\r
+  @retval EFI_SUCCESS     The file was loaded and relocated\r
+  @retval Others          The file not be loaded and error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+LoadAndRelocatePeCoffImageInPlace (\r
+  IN  VOID    *Pe32Data,\r
+  IN  VOID    *ImageAddress\r
+  );\r
+\r
+/**\r
+  Find the PE32 Data for an FFS file.\r
+\r
+  @param FileHandle       Pointer to the FFS file header of the image.\r
+  @param Pe32Data         Pointer to a (VOID *) PE32 Data pointer.\r
+\r
+  @retval EFI_SUCCESS      Image is successfully loaded.\r
+  @retval EFI_NOT_FOUND    Fail to locate PE32 Data.\r
+\r
+**/\r
+EFI_STATUS\r
+PeiGetPe32Data (\r
+  IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
+  OUT    VOID                         **Pe32Data\r
+  );\r
+\r
 /**\r
   The wrapper function of PeiLoadImageLoadImage().\r
 \r
@@ -1060,31 +1463,35 @@ SecurityPpiNotifyCallback (
   );\r
 \r
 /**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+  Get FV image(s) from the FV type file, then install FV INFO(2) PPI, Build FV(2, 3) 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
+  @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
 **/\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
-  \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
+  Gets a PEI_CORE_FV_HANDLE instance for the next volume according to the given index.\r
+\r
+  This routine also will install an instance of the FvInfo PPI for the FV HOB\r
+  as defined in the PI specification.\r
+\r
   @param Private    Pointer of PEI_CORE_INSTANCE\r
-  @param Instance   The index of FV want to be searched.\r
-  \r
+  @param Instance   Index of the FV to search\r
+\r
   @return Instance of PEI_CORE_FV_HANDLE.\r
 **/\r
 PEI_CORE_FV_HANDLE *\r
@@ -1092,19 +1499,19 @@ FindNextCoreFvHandle (
   IN PEI_CORE_INSTANCE  *Private,\r
   IN UINTN              Instance\r
   );\r
-    \r
+\r
 //\r
 // Default EFI_PEI_CPU_IO_PPI support for EFI_PEI_SERVICES table when PeiCore initialization.\r
-//    \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
+\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
@@ -1114,7 +1521,7 @@ FindNextCoreFvHandle (
   @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
+  @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1126,15 +1533,15 @@ PeiDefaultMemRead (
   IN  UINTN                             Count,\r
   IN  OUT VOID                          *Buffer\r
   );\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
+\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
@@ -1144,7 +1551,7 @@ PeiDefaultMemRead (
   @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
+  @retval EFI_NOT_YET_AVAILABLE The service has not been installed.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1156,14 +1563,14 @@ PeiDefaultMemWrite (
   IN  UINTN                             Count,\r
   IN  OUT VOID                          *Buffer\r
   );\r
-  \r
+\r
 /**\r
   IO-based read services.\r
-  \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
+  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
@@ -1185,14 +1592,14 @@ PeiDefaultIoRead (
   IN      UINTN                           Count,\r
   IN OUT  VOID                            *Buffer\r
   );\r
-  \r
+\r
 /**\r
   IO-based write services.\r
-  \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
+  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
@@ -1214,13 +1621,13 @@ PeiDefaultIoWrite (
   IN      UINTN                           Count,\r
   IN OUT  VOID                            *Buffer\r
   );\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
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1234,13 +1641,13 @@ PeiDefaultIoRead8 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\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
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1254,13 +1661,13 @@ PeiDefaultIoRead16 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\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
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1274,13 +1681,13 @@ PeiDefaultIoRead32 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\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
+\r
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1294,7 +1701,7 @@ PeiDefaultIoRead64 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\r
-  \r
+\r
 /**\r
   8-bit I/O write operations.\r
 \r
@@ -1311,7 +1718,7 @@ PeiDefaultIoWrite8 (
   IN  UINT64                      Address,\r
   IN  UINT8                       Data\r
   );\r
-  \r
+\r
 /**\r
   16-bit I/O write operations.\r
 \r
@@ -1328,7 +1735,7 @@ PeiDefaultIoWrite16 (
   IN  UINT64                      Address,\r
   IN  UINT16                      Data\r
   );\r
-  \r
+\r
 /**\r
   32-bit I/O write operations.\r
 \r
@@ -1345,7 +1752,7 @@ PeiDefaultIoWrite32 (
   IN  UINT64                      Address,\r
   IN  UINT32                      Data\r
   );\r
-  \r
+\r
 /**\r
   64-bit I/O write operations.\r
 \r
@@ -1362,13 +1769,13 @@ PeiDefaultIoWrite64 (
   IN  UINT64                      Address,\r
   IN  UINT64                      Data\r
   );\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
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1383,13 +1790,13 @@ PeiDefaultMemRead8 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\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
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1404,13 +1811,13 @@ PeiDefaultMemRead16 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\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
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1425,13 +1832,13 @@ PeiDefaultMemRead32 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\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
+  If the EFI_PEI_CPU_IO_PPI is not installed by platform/chipset PEIM, then\r
   return 0.\r
-  \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
@@ -1446,7 +1853,7 @@ PeiDefaultMemRead64 (
   IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
   IN  UINT64                      Address\r
   );\r
-  \r
+\r
 /**\r
   8-bit memory write operations.\r
 \r
@@ -1464,7 +1871,7 @@ PeiDefaultMemWrite8 (
   IN  UINT64                        Address,\r
   IN  UINT8                         Data\r
   );\r
-  \r
+\r
 /**\r
   16-bit memory write operations.\r
 \r
@@ -1500,7 +1907,7 @@ PeiDefaultMemWrite32 (
   IN  UINT64                        Address,\r
   IN  UINT32                        Data\r
   );\r
-  \r
+\r
 /**\r
   64-bit memory write operations.\r
 \r
@@ -1518,19 +1925,19 @@ PeiDefaultMemWrite64 (
   IN  UINT64                        Address,\r
   IN  UINT64                        Data\r
   );\r
-  \r
-extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;                                        \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
 /**\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
+  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
@@ -1542,7 +1949,7 @@ extern EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi;
   @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
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -1553,13 +1960,13 @@ PeiDefaultPciCfg2Read (
   IN        UINT64                    Address,\r
   IN OUT    VOID                      *Buffer\r
   );\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
+  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
@@ -1581,7 +1988,7 @@ PeiDefaultPciCfg2Write (
   IN        UINT64                    Address,\r
   IN OUT    VOID                      *Buffer\r
   );\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
@@ -1610,21 +2017,21 @@ PeiDefaultPciCfg2Modify (
   IN        UINT64                    Address,\r
   IN        VOID                      *SetBits,\r
   IN        VOID                      *ClearBits\r
-  );    \r
-  \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 permenant\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
+\r
   @param PrivateData   Pointer to PEI_CORE_INSTANCE.\r
-**/  \r
+**/\r
 VOID\r
 PeiReinitializeFv (\r
   IN  PEI_CORE_INSTANCE           *PrivateData\r
   );\r
-      \r
+\r
 #endif\r