]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Ppi/Ppi.c
MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxFvSupported
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Ppi / Ppi.c
index 9129c23159fa03c2dca239e0772d009ed7a66246..6f03858b8a94e282d56e5b2c367ddaf9fc5d8885 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PEI Core PPI services\r
-  \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   Initialize PPI services.\r
 \r
   @param PrivateData     Pointer to the PEI Core data.\r
-  @param OldCoreData     Pointer to old PEI Core data. \r
+  @param OldCoreData     Pointer to old PEI Core data.\r
                          NULL if being run in non-permament memory mode.\r
 \r
 **/\r
@@ -30,17 +30,156 @@ InitializePpiServices (
   )\r
 {\r
   if (OldCoreData == NULL) {\r
-    PrivateData->PpiData.NotifyListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r
-    PrivateData->PpiData.DispatchListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r
-    PrivateData->PpiData.LastDispatchedNotify = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r
+    PrivateData->PpiData.NotifyListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r
+    PrivateData->PpiData.DispatchListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r
+    PrivateData->PpiData.LastDispatchedNotify = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r
   }\r
 }\r
 \r
 /**\r
 \r
-  Migrate the Hob list from the temporary memory stack to PEI installed memory.\r
+  Migrate Pointer from the temporary memory to PEI installed memory.\r
+\r
+  @param Pointer         Pointer to the Pointer needs to be converted.\r
+  @param TempBottom      Base of old temporary memory\r
+  @param TempTop         Top of old temporary memory\r
+  @param Offset          Offset of new memory to old temporary memory.\r
+  @param OffsetPositive  Positive flag of Offset value.\r
 \r
-  @param SecCoreData     Points to a data structure containing SEC to PEI handoff data, such as the size \r
+**/\r
+VOID\r
+ConvertPointer (\r
+  IN OUT VOID              **Pointer,\r
+  IN UINTN                 TempBottom,\r
+  IN UINTN                 TempTop,\r
+  IN UINTN                 Offset,\r
+  IN BOOLEAN               OffsetPositive\r
+  )\r
+{\r
+  if (((UINTN) *Pointer < TempTop) &&\r
+    ((UINTN) *Pointer >= TempBottom)) {\r
+    if (OffsetPositive) {\r
+      *Pointer = (VOID *) ((UINTN) *Pointer + Offset);\r
+    } else {\r
+      *Pointer = (VOID *) ((UINTN) *Pointer - Offset);\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+\r
+  Migrate Pointer in ranges of the temporary memory to PEI installed memory.\r
+\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
+  @param Pointer         Pointer to the Pointer needs to be converted.\r
+\r
+**/\r
+VOID\r
+ConvertPointerInRanges (\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
+  IN PEI_CORE_INSTANCE           *PrivateData,\r
+  IN OUT VOID                    **Pointer\r
+  )\r
+{\r
+  UINT8                 IndexHole;\r
+\r
+  if (PrivateData->MemoryPages.Size != 0) {\r
+    //\r
+    // Convert PPI pointer in old memory pages\r
+    // It needs to be done before Convert PPI pointer in old Heap\r
+    //\r
+    ConvertPointer (\r
+      Pointer,\r
+      (UINTN)PrivateData->MemoryPages.Base,\r
+      (UINTN)PrivateData->MemoryPages.Base + PrivateData->MemoryPages.Size,\r
+      PrivateData->MemoryPages.Offset,\r
+      PrivateData->MemoryPages.OffsetPositive\r
+      );\r
+  }\r
+\r
+  //\r
+  // Convert PPI pointer in old Heap\r
+  //\r
+  ConvertPointer (\r
+    Pointer,\r
+    (UINTN)SecCoreData->PeiTemporaryRamBase,\r
+    (UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize,\r
+    PrivateData->HeapOffset,\r
+    PrivateData->HeapOffsetPositive\r
+    );\r
+\r
+  //\r
+  // Convert PPI pointer in old Stack\r
+  //\r
+  ConvertPointer (\r
+    Pointer,\r
+    (UINTN)SecCoreData->StackBase,\r
+    (UINTN)SecCoreData->StackBase + SecCoreData->StackSize,\r
+    PrivateData->StackOffset,\r
+    PrivateData->StackOffsetPositive\r
+    );\r
+\r
+  //\r
+  // Convert PPI pointer in old TempRam Hole\r
+  //\r
+  for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole ++) {\r
+    if (PrivateData->HoleData[IndexHole].Size == 0) {\r
+      continue;\r
+    }\r
+\r
+    ConvertPointer (\r
+      Pointer,\r
+      (UINTN)PrivateData->HoleData[IndexHole].Base,\r
+      (UINTN)PrivateData->HoleData[IndexHole].Base + PrivateData->HoleData[IndexHole].Size,\r
+      PrivateData->HoleData[IndexHole].Offset,\r
+      PrivateData->HoleData[IndexHole].OffsetPositive\r
+      );\r
+  }\r
+}\r
+\r
+/**\r
+\r
+  Migrate Single PPI Pointer from the temporary memory to PEI installed memory.\r
+\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
+  @param PpiPointer      Pointer to Ppi\r
+\r
+**/\r
+VOID\r
+ConvertSinglePpiPointer (\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
+  IN PEI_CORE_INSTANCE           *PrivateData,\r
+  IN PEI_PPI_LIST_POINTERS       *PpiPointer\r
+  )\r
+{\r
+  //\r
+  // 1. Convert the pointer to the PPI descriptor from the old TempRam\r
+  //    to the relocated physical memory.\r
+  // It (for the pointer to the PPI descriptor) needs to be done before 2 (for\r
+  // the pointer to the GUID) and 3 (for the pointer to the PPI interface structure).\r
+  //\r
+  ConvertPointerInRanges (SecCoreData, PrivateData, &PpiPointer->Raw);\r
+  //\r
+  // 2. Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r
+  //    from the old TempRam to the relocated physical memory.\r
+  //\r
+  ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **) &PpiPointer->Ppi->Guid);\r
+  //\r
+  // 3. Convert the pointer to the PPI interface structure in the PPI descriptor\r
+  //    from the old TempRam to the relocated physical memory.\r
+  //\r
+  ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **) &PpiPointer->Ppi->Ppi);\r
+}\r
+\r
+/**\r
+\r
+  Migrate PPI Pointers from the temporary memory to PEI installed memory.\r
+\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
@@ -52,92 +191,29 @@ ConvertPpiPointers (
   )\r
 {\r
   UINT8                 Index;\r
-  PEI_PPI_LIST_POINTERS *PpiPointer;\r
-  UINTN                 OldHeapTop;\r
-  UINTN                 OldHeapBottom;\r
-  UINTN                 OldStackTop;\r
-  UINTN                 OldStackBottom;\r
-\r
-  OldHeapBottom = (UINTN)SecCoreData->PeiTemporaryRamBase;\r
-  OldHeapTop = (UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize;\r
-  OldStackBottom = (UINTN)SecCoreData->StackBase;\r
-  OldStackTop = (UINTN)SecCoreData->StackBase + SecCoreData->StackSize;\r
-\r
-  for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {\r
-    if (Index < PrivateData->PpiData.PpiListEnd ||\r
-        Index > PrivateData->PpiData.NotifyListEnd) {\r
-      PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index];\r
-\r
-      if (((UINTN)PpiPointer->Raw < OldHeapTop) &&\r
-          ((UINTN)PpiPointer->Raw >= OldHeapBottom)) {\r
-        //\r
-        // Convert the pointer to the PPI descriptor from the old HOB heap\r
-        // to the relocated HOB heap.\r
-        //\r
-        if (PrivateData->HeapOffsetPositive) {\r
-          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + PrivateData->HeapOffset);\r
-        } else {\r
-          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->HeapOffset);\r
-        }\r
-\r
-        //\r
-        // Only when the PEIM descriptor is in the old HOB should it be necessary\r
-        // to try to convert the pointers in the PEIM descriptor\r
-        //\r
-\r
-        if (((UINTN)PpiPointer->Ppi->Guid < OldHeapTop) &&\r
-            ((UINTN)PpiPointer->Ppi->Guid >= OldHeapBottom)) {\r
-          //\r
-          // Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r
-          // from the old HOB heap to the relocated HOB heap.\r
-          //\r
-          if (PrivateData->HeapOffsetPositive) {\r
-            PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + PrivateData->HeapOffset);\r
-          } else {\r
-            PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - PrivateData->HeapOffset);\r
-          }\r
-        }\r
 \r
-        //\r
-        // Assume that no code is located in the temporary memory, so the pointer to\r
-        // the notification function in the NOTIFY descriptor needs not be converted.\r
-        //\r
-        if (Index < PrivateData->PpiData.PpiListEnd &&\r
-            (UINTN)PpiPointer->Ppi->Ppi < OldHeapTop &&\r
-            (UINTN)PpiPointer->Ppi->Ppi >= OldHeapBottom) {\r
-            //\r
-            // Convert the pointer to the PPI interface structure in the PPI descriptor\r
-            // from the old HOB heap to the relocated HOB heap.\r
-            //\r
-            if (PrivateData->HeapOffsetPositive) {\r
-              PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->HeapOffset);\r
-            } else {\r
-              PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - PrivateData->HeapOffset);\r
-            }\r
-        }\r
-      } else if (((UINTN)PpiPointer->Raw < OldStackTop) && ((UINTN)PpiPointer->Raw >= OldStackBottom)) {\r
-        //\r
-        // Convert the pointer to the PPI descriptor from the temporary stack\r
-        // to the permanent PEI stack.\r
-        //\r
-        if (PrivateData->StackOffsetPositive) {\r
-          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + PrivateData->StackOffset);\r
-        } else {\r
-          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->StackOffset);\r
-        }\r
-      }\r
+  for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {\r
+    if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) {\r
+      ConvertSinglePpiPointer (\r
+        SecCoreData,\r
+        PrivateData,\r
+        &PrivateData->PpiData.PpiListPtrs[Index]\r
+        );\r
     }\r
   }\r
 }\r
 \r
 /**\r
 \r
-  This function installs an interface in the PEI PPI database by GUID. \r
+  This function installs an interface in the PEI PPI database by GUID.\r
   The purpose of the service is to publish an interface that other parties\r
   can use to call additional PEIMs.\r
 \r
   @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param PpiList                    Pointer to a list of PEI PPI Descriptors.\r
+  @param Single                     TRUE if only single entry in the PpiList.\r
+                                    FALSE if the PpiList is ended with an entry which has the\r
+                                    EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field.\r
 \r
   @retval EFI_SUCCESS              if all PPIs in PpiList are successfully installed.\r
   @retval EFI_INVALID_PARAMETER    if PpiList is NULL pointer\r
@@ -146,10 +222,10 @@ ConvertPpiPointers (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
-PeiInstallPpi (\r
+InternalPeiInstallPpi (\r
   IN CONST EFI_PEI_SERVICES        **PeiServices,\r
-  IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList,\r
+  IN BOOLEAN                       Single\r
   )\r
 {\r
   PEI_CORE_INSTANCE *PrivateData;\r
@@ -196,11 +272,16 @@ PeiInstallPpi (
     PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;\r
     PrivateData->PpiData.PpiListEnd++;\r
 \r
-    //\r
-    // Continue until the end of the PPI List.\r
-    //\r
-    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
-        EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+    if (Single) {\r
+      //\r
+      // Only single entry in the PpiList.\r
+      //\r
+      break;\r
+    } else if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
+               EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      //\r
+      // Continue until the end of the PPI List.\r
+      //\r
       break;\r
     }\r
     PpiList++;\r
@@ -225,9 +306,34 @@ PeiInstallPpi (
 \r
 /**\r
 \r
-  This function reinstalls an interface in the PEI PPI database by GUID. \r
-  The purpose of the service is to publish an interface that other parties can \r
-  use to replace an interface of the same name in the protocol database with a \r
+  This function installs an interface in the PEI PPI database by GUID.\r
+  The purpose of the service is to publish an interface that other parties\r
+  can use to call additional PEIMs.\r
+\r
+  @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList                    Pointer to a list of PEI PPI Descriptors.\r
+\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
+EFIAPI\r
+PeiInstallPpi (\r
+  IN CONST EFI_PEI_SERVICES        **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList\r
+  )\r
+{\r
+  return InternalPeiInstallPpi (PeiServices, PpiList, FALSE);\r
+}\r
+\r
+/**\r
+\r
+  This function reinstalls an interface in the PEI PPI database by GUID.\r
+  The purpose of the service is to publish an interface that other parties can\r
+  use to replace an interface of the same name in the protocol database with a\r
   different interface.\r
 \r
   @param PeiServices            An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
@@ -279,7 +385,7 @@ PeiReInstallPpi (
   // Remove the old PPI from the database, add the new one.\r
   //\r
   DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));\r
-  ASSERT (Index < (INTN)(FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)));\r
+  ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));\r
   PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;\r
 \r
   //\r
@@ -370,23 +476,26 @@ PeiLocatePpi (
 \r
 /**\r
 \r
-  This function installs a notification service to be called back when a given \r
-  interface is installed or reinstalled. The purpose of the service is to publish \r
+  This function installs a notification service to be called back when a given\r
+  interface is installed or reinstalled. The purpose of the service is to publish\r
   an interface that other parties can use to call additional PPIs that may materialize later.\r
 \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
+  @param Single             TRUE if only single entry in the NotifyList.\r
+                            FALSE if the NotifyList is ended with an entry which has the\r
+                            EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field.\r
 \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
-EFIAPI\r
-PeiNotifyPpi (\r
+InternalPeiNotifyPpi (\r
   IN CONST EFI_PEI_SERVICES           **PeiServices,\r
-  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList,\r
+  IN BOOLEAN                          Single\r
   )\r
 {\r
   PEI_CORE_INSTANCE                *PrivateData;\r
@@ -441,8 +550,16 @@ PeiNotifyPpi (
 \r
     PrivateData->PpiData.NotifyListEnd--;\r
     DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));\r
-    if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
-        EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+    if (Single) {\r
+      //\r
+      // Only single entry in the NotifyList.\r
+      //\r
+      break;\r
+    } else if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
+               EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      //\r
+      // Continue until the end of the Notify List.\r
+      //\r
       break;\r
     }\r
     //\r
@@ -486,6 +603,30 @@ PeiNotifyPpi (
   return  EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  This function installs a notification service to be called back when a given\r
+  interface is installed or reinstalled. The purpose of the service is to publish\r
+  an interface that other parties can use to call additional PPIs that may materialize later.\r
+\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
+  @retval EFI_INVALID_PARAMETER if not a good descriptor\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiNotifyPpi (\r
+  IN CONST EFI_PEI_SERVICES           **PeiServices,\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  )\r
+{\r
+  return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE);\r
+}\r
+\r
 \r
 /**\r
 \r
@@ -537,7 +678,7 @@ ProcessNotifyList (
         EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r
         PrivateData->PpiData.LastDispatchedInstall,\r
         PrivateData->PpiData.PpiListEnd,\r
-        FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1,\r
+        PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,\r
         PrivateData->PpiData.DispatchListEnd\r
         );\r
       PrivateData->PpiData.LastDispatchedInstall = TempValue;\r
@@ -611,3 +752,62 @@ DispatchNotify (
   }\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
+  EFI_STATUS                Status;\r
+  EFI_SEC_HOB_DATA_PPI      *SecHobDataPpi;\r
+  EFI_HOB_GENERIC_HEADER    *SecHobList;\r
+\r
+  for (;;) {\r
+    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) != 0) {\r
+      //\r
+      // It is a notification PPI.\r
+      //\r
+      Status = InternalPeiNotifyPpi (PeiServices, (CONST EFI_PEI_NOTIFY_DESCRIPTOR *) PpiList, TRUE);\r
+      ASSERT_EFI_ERROR (Status);\r
+    } else {\r
+      //\r
+      // It is a normal PPI.\r
+      //\r
+      Status = InternalPeiInstallPpi (PeiServices, PpiList, TRUE);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+\r
+    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      //\r
+      // Continue until the end of the PPI List.\r
+      //\r
+      break;\r
+    }\r
+\r
+    PpiList++;\r
+  }\r
+\r
+  //\r
+  // If the EFI_SEC_HOB_DATA_PPI is in the list of PPIs passed to the PEI entry point,\r
+  // the PEI Foundation will call the GetHobs() member function and install all HOBs\r
+  // returned into the HOB list. It does this after installing all PPIs passed from SEC\r
+  // into the PPI database and before dispatching any PEIMs.\r
+  //\r
+  Status = PeiLocatePpi (PeiServices, &gEfiSecHobDataPpiGuid, 0, NULL, (VOID **) &SecHobDataPpi);\r
+  if (!EFI_ERROR (Status)) {\r
+    Status = SecHobDataPpi->GetHobs (SecHobDataPpi, &SecHobList);\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = PeiInstallSecHobData (PeiServices, SecHobList);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+}\r
+\r