]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/PeiMain.h
Source level security checked
[mirror_edk2.git] / MdeModulePkg / Core / Pei / PeiMain.h
index 3cd642ea4f9635c30506caad28f41a39404d79e4..e629b2368a40c93d7d0fdf194db9f8d37456a393 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition of Pei Core Structures and Services\r
   \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -43,10 +43,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <IndustryStandard/PeImage.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/PeiPiLib.h>\r
 #include <Guid/FirmwareFileSystem2.h>\r
 #include <Guid/AprioriFileName.h>\r
 \r
+///\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
+///\r
 #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE   0xff\r
 \r
 ///\r
@@ -59,14 +62,33 @@ typedef union {
 } PEI_PPI_LIST_POINTERS;\r
 \r
 ///\r
-/// PPI database structure\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
 ///\r
 typedef struct {\r
+  ///\r
+  /// index of end of PpiList link list.\r
+  ///\r
   INTN                    PpiListEnd;\r
+  ///\r
+  /// index of end of notify link list.\r
+  ///\r
   INTN                    NotifyListEnd;\r
+  ///\r
+  /// index of the dispatched notify list.\r
+  ///\r
   INTN                    DispatchListEnd;\r
+  ///\r
+  /// index of last installed Ppi description in PpiList link list.\r
+  ///\r
   INTN                    LastDispatchedInstall;\r
+  ///\r
+  /// index of last dispatched notify in Notify link list.\r
+  /// \r
   INTN                    LastDispatchedNotify;\r
+  ///\r
+  /// Ppi database.\r
+  ///\r
   PEI_PPI_LIST_POINTERS   PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
 } PEI_PPI_DATABASE;\r
 \r
@@ -98,7 +120,7 @@ typedef struct {
 } CACHE_SECTION_DATA;\r
 \r
 \r
-#define PEI_CORE_HANDLE_SIGNATURE  EFI_SIGNATURE_32('P','e','i','C')\r
+#define PEI_CORE_HANDLE_SIGNATURE  SIGNATURE_32('P','e','i','C')\r
 \r
 ///\r
 /// Pei Core private data structure instance\r
@@ -114,6 +136,9 @@ typedef struct{
   UINTN                              CurrentPeimFvCount;\r
   UINTN                              CurrentPeimCount;\r
   EFI_PEI_FILE_HANDLE                CurrentFileHandle;\r
+  BOOLEAN                            PeimNeedingDispatch;\r
+  BOOLEAN                            PeimDispatchOnThisPass;\r
+  BOOLEAN                            PeimDispatcherReenter;\r
   UINTN                              AllFvCount;\r
   EFI_PEI_FV_HANDLE                  AllFv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
   EFI_PEI_HOB_POINTERS               HobList;\r
@@ -121,14 +146,9 @@ typedef struct{
   BOOLEAN                            PeiMemoryInstalled;\r
   EFI_PHYSICAL_ADDRESS               StackBase;\r
   UINT64                             StackSize;\r
-  VOID                               *BottomOfCarHeap;\r
-  VOID                               *TopOfCarHeap;\r
   VOID                               *CpuIo;\r
   EFI_PEI_SECURITY2_PPI              *PrivateSecurityPpi;\r
   EFI_PEI_SERVICES                   ServiceTableShadow;\r
-  UINTN                              SizeOfTemporaryMemory;\r
-  UINTN                              SizeOfCacheAsRam;\r
-  VOID                               *MaxTopOfCarHeap;\r
   EFI_PEI_PPI_DESCRIPTOR             *XipLoadFile;\r
   EFI_PHYSICAL_ADDRESS               PhysicalMemoryBegin;\r
   UINT64                             PhysicalMemoryLength;\r
@@ -143,9 +163,22 @@ 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 *PEI_CORE_ENTRY_POINT)(\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
@@ -155,7 +188,7 @@ EFI_STATUS
 /// Union of temporarily used function pointers (to save stack space)\r
 ///\r
 typedef union {\r
-  PEI_CORE_ENTRY_POINT         PeiCore;\r
+  PEICORE_FUNCTION_POINTER     PeiCore;\r
   EFI_PEIM_ENTRY_POINT2        PeimEntry;\r
   EFI_PEIM_NOTIFY_ENTRY_POINT  PeimNotifyEntry;\r
   EFI_DXE_IPL_PPI              *DxeIpl;\r
@@ -164,8 +197,6 @@ typedef union {
   VOID                         *Raw;\r
 } PEI_CORE_TEMP_POINTERS;\r
 \r
-\r
-\r
 typedef struct {\r
   CONST EFI_SEC_PEI_HAND_OFF    *SecCoreData;\r
   EFI_PEI_PPI_DESCRIPTOR        *PpiList;\r
@@ -182,9 +213,8 @@ typedef struct {
   with the old core data.\r
 \r
 \r
-  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
-                         environment, such as the size and location of temporary RAM, the stack location and\r
-                         the BFV location.\r
+  @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size \r
+                         and location of temporary RAM, the stack location and the BFV location.\r
   @param PpiList         Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
                          An empty PPI list consists of a single descriptor with the end-tag\r
                          EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization\r
@@ -194,17 +224,14 @@ typedef struct {
   @param Data            Pointer to old core data that is used to initialize the\r
                          core's data areas.\r
 \r
-  @retval EFI_NOT_FOUND  Never reach\r
-\r
 **/\r
-EFI_STATUS\r
+VOID\r
 EFIAPI\r
 PeiCore (\r
   IN CONST EFI_SEC_PEI_HAND_OFF        *SecCoreData,\r
-  IN CONST EFI_PEI_PPI_DESCRIPTOR      *PpList,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR      *PpiList,\r
   IN VOID                              *Data\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // Dispatcher support functions\r
@@ -220,7 +247,7 @@ PeiCore (
   operation types (AND, OR).\r
 \r
 \r
-  @param PeiServices            Calling context.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param DependencyExpression   Pointer to a dependency expression.  The Grammar adheres to\r
                                 the BNF described above and is stored in postfix notation.\r
 \r
@@ -234,29 +261,20 @@ BOOLEAN
 PeimDispatchReadiness (\r
   IN EFI_PEI_SERVICES   **PeiServices,\r
   IN VOID               *DependencyExpression\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Conduct PEIM dispatch.\r
 \r
-  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
-                         environment, such as the size and location of temporary RAM, the stack location and\r
-                         the BFV location.\r
-                         PrivateData          - Pointer to the private data passed in from caller\r
-                         DispatchData         - Pointer to PEI_CORE_DISPATCH_DATA data.\r
-  @param Private         EDES_TODO: Add parameter description\r
-\r
-  @retval EFI_SUCCESS    Successfully dispatched PEIM.\r
-  @retval EFI_NOT_FOUND  The dispatch failed.\r
+  @param SecCoreData     Pointer to the data structure containing SEC to PEI handoff data\r
+  @param PrivateData     Pointer to the private data passed in from caller\r
 \r
 **/\r
 VOID\r
 PeiDispatcher (\r
   IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
   IN PEI_CORE_INSTANCE           *PrivateData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Initialize the Dispatcher's data members\r
@@ -264,9 +282,8 @@ PeiDispatcher (
   @param PrivateData     PeiCore's private data structure\r
   @param OldCoreData     Old data from SecCore\r
                          NULL if being run in non-permament memory mode.\r
-  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
-                         environment, such as the size and location of temporary RAM, the stack location and\r
-                         the BFV location.\r
+  @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size\r
+                         and location of temporary RAM, the stack location and the BFV location.\r
 \r
 **/\r
 VOID\r
@@ -274,8 +291,7 @@ InitializeDispatcherData (
   IN PEI_CORE_INSTANCE            *PrivateData,\r
   IN PEI_CORE_INSTANCE            *OldCoreData,\r
   IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   This routine parses the Dependency Expression, if available, and\r
@@ -284,10 +300,10 @@ InitializeDispatcherData (
 \r
   @param Private         PeiCore's private data structure\r
   @param FileHandle      PEIM's file handle\r
-  @param PeimCount       Peim count in all dispatched PEIMs.\r
+  @param PeimCount       The index of last dispatched PEIM.\r
 \r
-  @retval TRUE   Can be dispatched\r
-  @retval FALSE  Cannot be dispatched\r
+  @retval TRUE           Can be dispatched\r
+  @retval FALSE          Cannot be dispatched\r
 \r
 **/\r
 BOOLEAN\r
@@ -295,8 +311,7 @@ DepexSatisfied (
   IN PEI_CORE_INSTANCE          *Private,\r
   IN EFI_PEI_FILE_HANDLE        FileHandle,\r
   IN UINTN                      PeimCount\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // PPI support functions\r
@@ -314,16 +329,17 @@ VOID
 InitializePpiServices (\r
   IN PEI_CORE_INSTANCE   *PrivateData,\r
   IN PEI_CORE_INSTANCE   *OldCoreData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Migrate the Hob list from the CAR stack to PEI installed memory.\r
 \r
-  @param PeiServices         The PEI core services table.\r
-  @param OldCheckingBottom   The old checking bottom.\r
-  @param OldCheckingTop      The old checking top.\r
+  @param PrivateData         Pointer to PeiCore's private data structure.\r
+  @param OldCheckingBottom   Bottom of temporary memory range. All Ppi in this range\r
+                             will be fixup for PpiData and PpiDescriptor pointer.\r
+  @param OldCheckingTop      Top of temporary memory range. All Ppi in this range\r
+                             will be fixup for PpiData and PpiDescriptor.\r
   @param Fixup               The address difference between\r
                              the new Hob list and old Hob list.\r
 \r
@@ -334,20 +350,19 @@ ConvertPpiPointers (
   IN UINTN                   OldCheckingBottom,\r
   IN UINTN                   OldCheckingTop,\r
   IN INTN                    Fixup\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
-  Install PPI services.\r
+  Install PPI services. It is implementation of EFI_PEI_SERVICE.InstallPpi.\r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param PpiList         - Pointer to a list of PEI PPI Descriptors.\r
+  @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList                    Pointer to ppi array that want to be installed.\r
 \r
-  @retval EFI_SUCCESS             - if all PPIs in PpiList are successfully installed.\r
-  @retval EFI_INVALID_PARAMETER   - if PpiList is NULL pointer\r
-  @retval EFI_INVALID_PARAMETER   - if any PPI in PpiList is not valid\r
-  @retval EFI_OUT_OF_RESOURCES    - if there is no more memory resource to install PPI\r
+  @retval EFI_SUCCESS               if all PPIs in PpiList are successfully installed.\r
+  @retval EFI_INVALID_PARAMETER     if PpiList is NULL pointer\r
+                                    if any PPI in PpiList is not valid\r
+  @retval EFI_OUT_OF_RESOURCES      if there is no more memory resource to install PPI\r
 \r
 **/\r
 EFI_STATUS\r
@@ -355,21 +370,20 @@ EFIAPI
 PeiInstallPpi (\r
   IN CONST EFI_PEI_SERVICES        **PeiServices,\r
   IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Re-Install PPI services.\r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param OldPpi          - Pointer to the old PEI PPI Descriptors.\r
-  @param NewPpi          - Pointer to the new PEI PPI Descriptors.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param OldPpi                 Pointer to the old PEI PPI Descriptors.\r
+  @param NewPpi                 Pointer to the new PEI PPI Descriptors.\r
 \r
-  @retval EFI_SUCCESS           if the operation was successful\r
-  @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
-  @retval EFI_INVALID_PARAMETER - if NewPpi is not valid\r
-  @retval EFI_NOT_FOUND         if the PPI was not in the database\r
+  @retval EFI_SUCCESS           if the operation was successful\r
+  @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r
+                                if NewPpi is not valid\r
+  @retval EFI_NOT_FOUND         if the PPI was not in the database\r
 \r
 **/\r
 EFI_STATUS\r
@@ -378,20 +392,19 @@ PeiReInstallPpi (
   IN CONST EFI_PEI_SERVICES        **PeiServices,\r
   IN CONST EFI_PEI_PPI_DESCRIPTOR  *OldPpi,\r
   IN CONST EFI_PEI_PPI_DESCRIPTOR  *NewPpi\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Locate a given named PPI.\r
 \r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param Guid            Pointer to GUID of the PPI.\r
-  @param Instance        Instance Number to discover.\r
-  @param PpiDescriptor   Pointer to reference the found descriptor. If not NULL,\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param Guid            Pointer to GUID of the PPI.\r
+  @param Instance        Instance Number to discover.\r
+  @param PpiDescriptor   Pointer to reference the found descriptor. If not NULL,\r
                          returns a pointer to the descriptor (includes flags, etc)\r
-  @param Ppi             Pointer to reference the found PPI\r
+  @param Ppi             Pointer to reference the found PPI\r
 \r
   @retval EFI_SUCCESS   if the PPI is in the database\r
   @retval EFI_NOT_FOUND if the PPI is not in the database\r
@@ -400,21 +413,20 @@ PeiReInstallPpi (
 EFI_STATUS\r
 EFIAPI\r
 PeiLocatePpi (\r
-  IN CONST EFI_PEI_SERVICES            **PeiServices,\r
-  IN CONST EFI_GUID                    *Guid,\r
+  IN CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN CONST EFI_GUID              *Guid,\r
   IN UINTN                       Instance,\r
   IN OUT EFI_PEI_PPI_DESCRIPTOR  **PpiDescriptor,\r
   IN OUT VOID                    **Ppi\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Install a notification for a given PPI.\r
 \r
 \r
-  @param PeiServices     - Pointer to the PEI Service Table\r
-  @param NotifyList      - Pointer to list of Descriptors to notify upon.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param NotifyList             Pointer to list of Descriptors to notify upon.\r
 \r
   @retval EFI_SUCCESS           if successful\r
   @retval EFI_OUT_OF_RESOURCES  if no space in the database\r
@@ -426,8 +438,7 @@ EFIAPI
 PeiNotifyPpi (\r
   IN CONST EFI_PEI_SERVICES           **PeiServices,\r
   IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
@@ -439,8 +450,7 @@ PeiNotifyPpi (
 VOID\r
 ProcessNotifyList (\r
   IN PEI_CORE_INSTANCE  *PrivateData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
@@ -462,8 +472,7 @@ DispatchNotify (
   IN INTN                InstallStopIndex,\r
   IN INTN                NotifyStartIndex,\r
   IN INTN                NotifyStopIndex\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // Boot mode support functions\r
@@ -471,7 +480,7 @@ DispatchNotify (
 /**\r
   This service enables PEIMs to ascertain the present value of the boot mode.\r
 \r
-  @param PeiServices            The PEI core services table.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param BootMode               A pointer to contain the value of the boot mode.\r
 \r
   @retval EFI_SUCCESS           The boot mode was returned successfully.\r
@@ -482,18 +491,17 @@ EFI_STATUS
 EFIAPI\r
 PeiGetBootMode (\r
   IN CONST EFI_PEI_SERVICES  **PeiServices,\r
-  IN OUT EFI_BOOT_MODE *BootMode\r
-  )\r
-;\r
+  IN OUT   EFI_BOOT_MODE     *BootMode\r
+  );\r
 \r
 /**\r
   This service enables PEIMs to update the boot mode variable.\r
 \r
 \r
-  @param PeiServices     - The PEI core services table.\r
-  @param BootMode        The value of the boot mode to set.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param BootMode        The value of the boot mode to set.\r
 \r
-  @return EFI_SUCCESS    The value was successfully updated\r
+  @return EFI_SUCCESS    The value was successfully updated\r
 \r
 **/\r
 EFI_STATUS\r
@@ -501,8 +509,7 @@ EFIAPI
 PeiSetBootMode (\r
   IN CONST EFI_PEI_SERVICES  **PeiServices,\r
   IN EFI_BOOT_MODE     BootMode\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // Security support functions\r
@@ -511,7 +518,7 @@ PeiSetBootMode (
 \r
   Initialize the security services.\r
 \r
-  @param PeiServices     The PEI core services table.\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
 \r
@@ -520,11 +527,10 @@ VOID
 InitializeSecurityServices (\r
   IN EFI_PEI_SERVICES  **PeiServices,\r
   IN PEI_CORE_INSTANCE *OldCoreData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
-  Verify a Firmware volume\r
+  Verify a Firmware volume.\r
 \r
   @param CurrentFvAddress           Pointer to the current Firmware Volume under consideration\r
 \r
@@ -535,8 +541,7 @@ InitializeSecurityServices (
 EFI_STATUS\r
 VerifyFv (\r
   IN EFI_FIRMWARE_VOLUME_HEADER  *CurrentFvAddress\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
@@ -556,15 +561,14 @@ VerifyPeim (
   IN PEI_CORE_INSTANCE      *PrivateData,\r
   IN EFI_PEI_FV_HANDLE      VolumeHandle,\r
   IN EFI_PEI_FILE_HANDLE    FileHandle\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Gets the pointer to the HOB List.\r
 \r
 \r
-  @param PeiServices                   The PEI core services table.\r
+  @param PeiServices                   An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param HobList                       Pointer to the HOB List.\r
 \r
   @retval EFI_SUCCESS                  Get the pointer of HOB List\r
@@ -577,16 +581,15 @@ EFIAPI
 PeiGetHobList (\r
   IN CONST EFI_PEI_SERVICES  **PeiServices,\r
   IN OUT VOID          **HobList\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Add a new HOB to the HOB List.\r
 \r
-  @param PeiServices     - The PEI core services table.\r
-  @param Type            - Type of the new HOB.\r
-  @param Length          - Length of the new HOB to allocate.\r
-  @param Hob             - Pointer to the new HOB.\r
+  @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param Type               Type of the new HOB.\r
+  @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
   @retval  EFI_INVALID_PARAMETER if Hob is NULL\r
@@ -601,8 +604,7 @@ PeiCreateHob (
   IN UINT16            Type,\r
   IN UINT16            Length,\r
   IN OUT VOID          **Hob\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
@@ -620,8 +622,7 @@ PeiCoreBuildHobHandoffInfoTable (
   IN EFI_BOOT_MODE         BootMode,\r
   IN EFI_PHYSICAL_ADDRESS  MemoryBegin,\r
   IN UINT64                MemoryLength\r
-  )\r
-;\r
+  );\r
 \r
 \r
 //\r
@@ -633,11 +634,11 @@ PeiCoreBuildHobHandoffInfoTable (
   the Firmware Volume defined by FwVolHeader.\r
 \r
 \r
-  @param PeiServices     Pointer to the PEI Core Services Table.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param SearchType      Filter to find only files of this type.\r
                          Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
-  @param VolumeHandle    Pointer to the FV header of the volume to search.\r
-  @param FileHandle      Pointer to the current file from which to begin searching.\r
+  @param FwVolHeader     Pointer to the FV header of the volume to search.\r
+  @param FileHeader      Pointer to the current file from which to begin searching.\r
                          This pointer will be updated upon return to reflect the file found.\r
   @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
   @retval EFI_SUCCESS    Success to find next file in given volume\r
@@ -650,17 +651,15 @@ PeiFfsFindNextFile (
   IN UINT8                       SearchType,\r
   IN EFI_PEI_FV_HANDLE           FwVolHeader,\r
   IN OUT EFI_PEI_FILE_HANDLE     *FileHeader\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Given the input file pointer, search for the next matching section in the\r
   FFS volume.\r
 \r
-\r
-  @param PeiServices     Pointer to the PEI Core Services Table.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param SectionType     Filter to find only sections of this type.\r
-  @param FileHandle      Pointer to the current file to search.\r
+  @param FfsFileHeader   Pointer to the current file to search.\r
   @param SectionData     Pointer to the Section matching SectionType in FfsFileHeader.\r
                          NULL if section not found\r
 \r
@@ -675,28 +674,26 @@ PeiFfsFindSectionData (
   IN EFI_SECTION_TYPE            SectionType,\r
   IN EFI_PEI_FILE_HANDLE         FfsFileHeader,\r
   IN OUT VOID                    **SectionData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   search the firmware volumes by index\r
 \r
-  @param PeiServices     The PEI core services table.\r
-  @param Instance        Instance of FV to find\r
-  @param VolumeHandle    Pointer to found Volume.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param Instance               Instance of FV to find\r
+  @param FwVolHeader            Pointer to found Volume.\r
 \r
-  @retval EFI_INVALID_PARAMETER  FwVolHeader is NULL\r
-  @retval EFI_SUCCESS            Firmware volume instance successfully found.\r
+  @retval EFI_INVALID_PARAMETER FwVolHeader is NULL\r
+  @retval EFI_SUCCESS           Firmware volume instance successfully found.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 PeiFvFindNextVolume (\r
-  IN CONST EFI_PEI_SERVICES                **PeiServices,\r
+  IN CONST EFI_PEI_SERVICES          **PeiServices,\r
   IN UINTN                           Instance,\r
   IN OUT EFI_PEI_FV_HANDLE           *FwVolHeader\r
-  )\r
-;\r
+  );\r
 \r
 //\r
 // Memory support functions\r
@@ -705,11 +702,9 @@ PeiFvFindNextVolume (
 \r
   Initialize the memory services.\r
 \r
-\r
-  @param PrivateData     Add parameter description\r
-  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
-                         environment, such as the size and location of temporary RAM, the stack location and\r
-                         the BFV location.\r
+  @param 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
+                         and location of temporary RAM, the stack location and the BFV location.\r
   @param OldCoreData     Pointer to the PEI Core data.\r
                          NULL if being run in non-permament memory mode.\r
 \r
@@ -719,17 +714,16 @@ InitializeMemoryServices (
   IN PEI_CORE_INSTANCE           *PrivateData,\r
   IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
   IN PEI_CORE_INSTANCE           *OldCoreData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Install the permanent memory is now available.\r
   Creates HOB (PHIT and Stack).\r
 \r
-  @param PeiServices     - The PEI core services table.\r
-  @param MemoryBegin     Start of memory address.\r
-  @param MemoryLength    Length of memory.\r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param MemoryBegin     Start of memory address.\r
+  @param MemoryLength    Length of memory.\r
 \r
   @return EFI_SUCCESS Always success.\r
 \r
@@ -740,8 +734,7 @@ PeiInstallPeiMemory (
   IN CONST EFI_PEI_SERVICES      **PeiServices,\r
   IN EFI_PHYSICAL_ADDRESS  MemoryBegin,\r
   IN UINT64                MemoryLength\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
@@ -749,10 +742,10 @@ PeiInstallPeiMemory (
   not usable prior to the memory installation.\r
 \r
 \r
-  @param PeiServices     - The PEI core services table.\r
-  @param MemoryType      - Type of memory to allocate.\r
-  @param Pages           - Number of pages to allocate.\r
-  @param Memory          - Pointer of memory allocated.\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
   @retval EFI_SUCCESS              The allocation was successful\r
   @retval EFI_INVALID_PARAMETER    Only AllocateAnyAddress is supported.\r
@@ -768,17 +761,16 @@ PeiAllocatePages (
   IN EFI_MEMORY_TYPE            MemoryType,\r
   IN UINTN                      Pages,\r
   OUT EFI_PHYSICAL_ADDRESS      *Memory\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Memory allocation service on the CAR.\r
 \r
 \r
-  @param PeiServices     - The PEI core services table.\r
-  @param Size            - Amount of memory required\r
-  @param Buffer          - Address of pointer to the buffer\r
+  @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param Size               Amount of memory required\r
+  @param Buffer             Address of pointer to the buffer\r
 \r
   @retval EFI_SUCCESS              The allocation was successful\r
   @retval EFI_OUT_OF_RESOURCES     There is not enough heap to satisfy the requirement\r
@@ -791,44 +783,42 @@ PeiAllocatePool (
   IN CONST EFI_PEI_SERVICES           **PeiServices,\r
   IN UINTN                      Size,\r
   OUT VOID                      **Buffer\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Routine for load image file.\r
 \r
 \r
-  @param PeiServices     - The PEI core services table.\r
-  @param FileHandle      - Pointer to the FFS file header of the image.\r
-  @param EntryPoint      - Pointer to entry point of specified image file for output.\r
-  @param AuthenticationState - Pointer to attestation authentication state of image.\r
+  @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 EntryPoint             Pointer to entry point of specified image file for output.\r
+  @param AuthenticationState    Pointer to attestation authentication state of image.\r
 \r
-  @retval EFI_SUCCESS    - Image is successfully loaded.\r
-  @retval EFI_NOT_FOUND  - Fail to locate necessary PPI\r
-  @retval Others         - Fail to load file.\r
+  @retval EFI_SUCCESS     Image is successfully loaded.\r
+  @retval EFI_NOT_FOUND   Fail to locate necessary PPI\r
+  @retval Others          Fail to load file.\r
 \r
 **/\r
 EFI_STATUS\r
 PeiLoadImage (\r
-  IN  EFI_PEI_SERVICES            **PeiServices,\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
   IN  EFI_PEI_FILE_HANDLE         FileHandle,\r
   OUT    EFI_PHYSICAL_ADDRESS     *EntryPoint,\r
   OUT    UINT32                   *AuthenticationState\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Core version of the Status Code reporter\r
 \r
 \r
-  @param PeiServices     The PEI core services table.\r
-  @param CodeType        Type of Status Code.\r
-  @param Value           Value to output for Status Code.\r
-  @param Instance        Instance Number of this status code.\r
-  @param CallerId        ID of the caller of this status code.\r
-  @param Data            Optional data associated with this status code.\r
+  @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param CodeType               Type of Status Code.\r
+  @param Value                  Value to output for Status Code.\r
+  @param Instance               Instance Number of this status code.\r
+  @param CallerId               ID of the caller of this status code.\r
+  @param Data                   Optional data associated with this status code.\r
 \r
   @retval EFI_SUCCESS             if status code is successfully reported\r
   @retval EFI_NOT_AVAILABLE_YET   if StatusCodePpi has not been installed\r
@@ -843,15 +833,14 @@ PeiReportStatusCode (
   IN UINT32                   Instance,\r
   IN CONST EFI_GUID                 *CallerId,\r
   IN CONST EFI_STATUS_CODE_DATA     *Data OPTIONAL\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Core version of the Reset System\r
 \r
 \r
-  @param PeiServices     - The PEI core services table.\r
+  @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
 \r
   @retval EFI_NOT_AVAILABLE_YET     PPI not available yet.\r
   @retval EFI_DEVICE_ERROR          Did not reset system.\r
@@ -862,8 +851,7 @@ EFI_STATUS
 EFIAPI\r
 PeiResetSystem (\r
   IN CONST EFI_PEI_SERVICES   **PeiServices\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
@@ -873,23 +861,19 @@ PeiResetSystem (
   @param PrivateData     - Pointer to PEI_CORE_INSTANCE.\r
   @param SecCoreData     - Pointer to EFI_SEC_PEI_HAND_OFF.\r
 \r
-  @return NONE\r
-\r
 **/\r
 VOID\r
 PeiInitializeFv (\r
   IN  PEI_CORE_INSTANCE           *PrivateData,\r
   IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Process Firmware Volum Information once FvInfoPPI install.\r
 \r
-\r
-  @param PeiServices     - General purpose services available to every PEIM.\r
-  @param NotifyDescriptor EDES_TODO: Add parameter description\r
-  @param Ppi             EDES_TODO: Add parameter description\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
+  @param Ppi               Address of the PPI that was installed.\r
 \r
   @retval EFI_SUCCESS if the interface could be successfully installed\r
 \r
@@ -900,20 +884,19 @@ FirmwareVolmeInfoPpiNotifyCallback (
   IN EFI_PEI_SERVICES              **PeiServices,\r
   IN EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor,\r
   IN VOID                          *Ppi\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Given the input VolumeHandle, search for the next matching name file.\r
 \r
+  @param FileName        File name to search.\r
+  @param VolumeHandle    The current FV to search.\r
+  @param FileHandle      Pointer to the file matching name in VolumeHandle.\r
+                         NULL if file not found\r
 \r
-  @param FileName        - File name to search.\r
-  @param VolumeHandle    - The current FV to search.\r
-  @param FileHandle      - Pointer to the file matching name in VolumeHandle.\r
-                         - NULL if file not found\r
-\r
-  @return EFI_STATUS\r
+  @retval EFI_NOT_FOUND  No files matching the search criteria were found\r
+  @retval EFI_SUCCESS    Success to search given file\r
 \r
 **/\r
 EFI_STATUS\r
@@ -922,16 +905,15 @@ PeiFfsFindFileByName (
   IN  CONST EFI_GUID        *FileName,\r
   IN  EFI_PEI_FV_HANDLE     VolumeHandle,\r
   OUT EFI_PEI_FILE_HANDLE   *FileHandle\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Returns information about a specific file.\r
 \r
 \r
-  @param FileHandle      - The handle to file.\r
-  @param FileInfo        - Pointer to the file information.\r
+  @param FileHandle         The handle to file.\r
+  @param FileInfo           Pointer to the file information.\r
 \r
   @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo.\r
   @retval EFI_SUCCESS           Success to collect file info.\r
@@ -942,15 +924,14 @@ EFIAPI
 PeiFfsGetFileInfo (\r
   IN EFI_PEI_FILE_HANDLE  FileHandle,\r
   OUT EFI_FV_FILE_INFO    *FileInfo\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
 \r
   Collect information of given Fv Volume.\r
 \r
-  @param VolumeHandle    - The handle to Fv Volume.\r
-  @param VolumeInfo      - The pointer to volume information.\r
+  @param VolumeHandle           The handle to Fv Volume.\r
+  @param VolumeInfo             The pointer to volume information.\r
 \r
   @retval EFI_INVALID_PARAMETER VolumeInfo is NULL\r
   @retval EFI_SUCCESS           Success to collect fv info.\r
@@ -960,8 +941,7 @@ EFIAPI
 PeiFfsGetVolumeInfo (\r
   IN EFI_PEI_FV_HANDLE  VolumeHandle,\r
   OUT EFI_FV_INFO       *VolumeInfo\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   This routine enable a PEIM to register itself to shadow when PEI Foundation\r
@@ -978,8 +958,7 @@ EFI_STATUS
 EFIAPI\r
 PeiRegisterForShadow (\r
   IN EFI_PEI_FILE_HANDLE       FileHandle\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Given the input file pointer, search for the next matching file in the\r
@@ -1005,32 +984,31 @@ PeiFindFileEx (
   IN        EFI_FV_FILETYPE          SearchType,\r
   IN OUT    EFI_PEI_FILE_HANDLE      *FileHandle,\r
   IN OUT    EFI_PEI_FV_HANDLE        *AprioriFile  OPTIONAL\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
+  Initialize image service that install PeiLoadFilePpi.\r
 \r
-  Install Pei Load File PPI.\r
-\r
-\r
-  @param PrivateData     - Pointer to PEI_CORE_INSTANCE.\r
-  @param OldCoreData     - Pointer to PEI_CORE_INSTANCE.\r
+  @param PrivateData     Pointer to PeiCore's private data structure PEI_CORE_INSTANCE.\r
+  @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
 \r
 **/\r
 VOID\r
 InitializeImageServices (\r
   IN  PEI_CORE_INSTANCE   *PrivateData,\r
   IN  PEI_CORE_INSTANCE   *OldCoreData\r
-  )\r
-;\r
+  );\r
 \r
 /**\r
   Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
 \r
-  @param PeiServices          Pointer to the PEI Core Services Table.\r
-  @param FileHandle           File handle of a Fv type file.\r
+  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param FvFileHandle         File handle of a Fv type file.\r
   @param AuthenticationState  Pointer to attestation authentication state of image.\r
-\r
+                              If return 0, means pass security checking.\r
 \r
   @retval EFI_NOT_FOUND       FV image can't be found.\r
   @retval EFI_SUCCESS         Successfully to process it.\r
@@ -1038,9 +1016,52 @@ InitializeImageServices (
 **/\r
 EFI_STATUS\r
 ProcessFvFile (\r
-  IN  EFI_PEI_SERVICES      **PeiServices,\r
-  IN  EFI_PEI_FILE_HANDLE   FvFileHandle,\r
-  OUT UINT32                *AuthenticationState\r
+  IN  CONST EFI_PEI_SERVICES **PeiServices,\r
+  IN  EFI_PEI_FILE_HANDLE    FvFileHandle,\r
+  OUT UINT32                 *AuthenticationState\r
+  );\r
+\r
+/**\r
+  The wrapper function of PeiLoadImageLoadImage().\r
+\r
+  @param This                 Pointer to EFI_PEI_LOAD_FILE_PPI.\r
+  @param FileHandle           Pointer to the FFS file header of the image.\r
+  @param ImageAddressArg      Pointer to PE/TE image.\r
+  @param ImageSizeArg         Size of PE/TE image.\r
+  @param EntryPoint           Pointer to entry point of specified image file for output.\r
+  @param AuthenticationState  Pointer to attestation authentication state of image.\r
+\r
+  @return Status of PeiLoadImageLoadImage().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLoadImageLoadImageWrapper (\r
+  IN     CONST EFI_PEI_LOAD_FILE_PPI  *This,\r
+  IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
+  OUT    EFI_PHYSICAL_ADDRESS         *ImageAddressArg,  OPTIONAL\r
+  OUT    UINT64                       *ImageSizeArg,     OPTIONAL\r
+  OUT    EFI_PHYSICAL_ADDRESS         *EntryPoint,\r
+  OUT    UINT32                       *AuthenticationState\r
+  );\r
+\r
+/**\r
+\r
+  Provide a callback for when the security PPI is installed.\r
+\r
+  @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param NotifyDescriptor   The descriptor for the notification event.\r
+  @param Ppi                Pointer to the PPI in question.\r
+\r
+  @return Always success\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SecurityPpiNotifyCallback (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
+  IN VOID                       *Ppi\r
   );\r
 \r
 #endif\r