]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Ppi/Ppi.c
MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Ppi / Ppi.c
index 6f03858b8a94e282d56e5b2c367ddaf9fc5d8885..c33dfdf8aa5f3201fc9f16afb30d7eda64095ec4 100644 (file)
@@ -14,28 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "PeiMain.h"\r
 \r
-/**\r
-\r
-  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
-\r
-**/\r
-VOID\r
-InitializePpiServices (\r
-  IN PEI_CORE_INSTANCE *PrivateData,\r
-  IN PEI_CORE_INSTANCE *OldCoreData\r
-  )\r
-{\r
-  if (OldCoreData == NULL) {\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 Pointer from the temporary memory to PEI installed memory.\r
@@ -192,14 +170,37 @@ ConvertPpiPointers (
 {\r
   UINT8                 Index;\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
+  // Convert normal PPIs.\r
+  //\r
+  for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {\r
+    ConvertSinglePpiPointer (\r
+      SecCoreData,\r
+      PrivateData,\r
+      &PrivateData->PpiData.PpiList.PpiPtrs[Index]\r
+      );\r
+  }\r
+\r
+  //\r
+  // Convert Callback Notification PPIs.\r
+  //\r
+  for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {\r
+    ConvertSinglePpiPointer (\r
+      SecCoreData,\r
+      PrivateData,\r
+      &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index]\r
+      );\r
+  }\r
+\r
+  //\r
+  // Convert Dispatch Notification PPIs.\r
+  //\r
+  for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {\r
+    ConvertSinglePpiPointer (\r
+      SecCoreData,\r
+      PrivateData,\r
+      &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]\r
+      );\r
   }\r
 }\r
 \r
@@ -228,10 +229,11 @@ InternalPeiInstallPpi (
   IN BOOLEAN                       Single\r
   )\r
 {\r
-  PEI_CORE_INSTANCE *PrivateData;\r
-  INTN              Index;\r
-  INTN              LastCallbackInstall;\r
-\r
+  PEI_CORE_INSTANCE     *PrivateData;\r
+  PEI_PPI_LIST          *PpiListPointer;\r
+  UINTN                 Index;\r
+  UINTN                 LastCount;\r
+  VOID                  *TempPtr;\r
 \r
   if (PpiList == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -239,8 +241,9 @@ InternalPeiInstallPpi (
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r
 \r
-  Index = PrivateData->PpiData.PpiListEnd;\r
-  LastCallbackInstall = Index;\r
+  PpiListPointer = &PrivateData->PpiData.PpiList;\r
+  Index = PpiListPointer->CurrentCount;\r
+  LastCount = Index;\r
 \r
   //\r
   // This is loop installs all PPI descriptors in the PpiList.  It is terminated\r
@@ -249,28 +252,38 @@ InternalPeiInstallPpi (
   //\r
 \r
   for (;;) {\r
-    //\r
-    // Since PpiData is used for NotifyList and PpiList, max resource\r
-    // is reached if the Install reaches the NotifyList\r
-    // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement.\r
-    //\r
-    if (Index == PrivateData->PpiData.NotifyListEnd + 1) {\r
-      return  EFI_OUT_OF_RESOURCES;\r
-    }\r
     //\r
     // Check if it is a valid PPI.\r
     // If not, rollback list to exclude all in this list.\r
     // Try to indicate which item failed.\r
     //\r
     if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {\r
-      PrivateData->PpiData.PpiListEnd = LastCallbackInstall;\r
+      PpiListPointer->CurrentCount = LastCount;\r
       DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));\r
       return  EFI_INVALID_PARAMETER;\r
     }\r
 \r
+    if (Index >= PpiListPointer->MaxCount) {\r
+      //\r
+      // Run out of room, grow the buffer.\r
+      //\r
+      TempPtr = AllocateZeroPool (\r
+                  sizeof (PEI_PPI_LIST_POINTERS) * (PpiListPointer->MaxCount + PPI_GROWTH_STEP)\r
+                  );\r
+      ASSERT (TempPtr != NULL);\r
+      CopyMem (\r
+        TempPtr,\r
+        PpiListPointer->PpiPtrs,\r
+        sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount\r
+        );\r
+      PpiListPointer->PpiPtrs = TempPtr;\r
+      PpiListPointer->MaxCount = PpiListPointer->MaxCount + PPI_GROWTH_STEP;\r
+    }\r
+\r
     DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));\r
-    PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;\r
-    PrivateData->PpiData.PpiListEnd++;\r
+    PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList;\r
+    Index++;\r
+    PpiListPointer->CurrentCount++;\r
 \r
     if (Single) {\r
       //\r
@@ -284,23 +297,24 @@ InternalPeiInstallPpi (
       //\r
       break;\r
     }\r
+    //\r
+    // Go to the next descriptor.\r
+    //\r
     PpiList++;\r
-    Index++;\r
   }\r
 \r
   //\r
-  // Dispatch any callback level notifies for newly installed PPIs.\r
+  // Process any callback level notifies for newly installed PPIs.\r
   //\r
-  DispatchNotify (\r
+  ProcessNotify (\r
     PrivateData,\r
     EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r
-    LastCallbackInstall,\r
-    PrivateData->PpiData.PpiListEnd,\r
-    PrivateData->PpiData.DispatchListEnd,\r
-    PrivateData->PpiData.NotifyListEnd\r
+    LastCount,\r
+    PpiListPointer->CurrentCount,\r
+    0,\r
+    PrivateData->PpiData.CallbackNotifyList.CurrentCount\r
     );\r
 \r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -355,7 +369,7 @@ PeiReInstallPpi (
   )\r
 {\r
   PEI_CORE_INSTANCE   *PrivateData;\r
-  INTN                Index;\r
+  UINTN               Index;\r
 \r
 \r
   if ((OldPpi == NULL) || (NewPpi == NULL)) {\r
@@ -372,35 +386,33 @@ PeiReInstallPpi (
   // Find the old PPI instance in the database.  If we can not find it,\r
   // return the EFI_NOT_FOUND error.\r
   //\r
-  for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {\r
-    if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {\r
+  for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {\r
+    if (OldPpi == PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi) {\r
       break;\r
     }\r
   }\r
-  if (Index == PrivateData->PpiData.PpiListEnd) {\r
+  if (Index == PrivateData->PpiData.PpiList.CurrentCount) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
   //\r
-  // Remove the old PPI from the database, add the new one.\r
+  // Replace the old PPI with the new one.\r
   //\r
   DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));\r
-  ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));\r
-  PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;\r
+  PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;\r
 \r
   //\r
-  // Dispatch any callback level notifies for the newly installed PPI.\r
+  // Process any callback level notifies for the newly installed PPI.\r
   //\r
-  DispatchNotify (\r
+  ProcessNotify (\r
     PrivateData,\r
     EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r
     Index,\r
     Index+1,\r
-    PrivateData->PpiData.DispatchListEnd,\r
-    PrivateData->PpiData.NotifyListEnd\r
+    0,\r
+    PrivateData->PpiData.CallbackNotifyList.CurrentCount\r
     );\r
 \r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -430,10 +442,10 @@ PeiLocatePpi (
   IN OUT VOID                      **Ppi\r
   )\r
 {\r
-  PEI_CORE_INSTANCE   *PrivateData;\r
-  INTN                Index;\r
-  EFI_GUID            *CheckGuid;\r
-  EFI_PEI_PPI_DESCRIPTOR  *TempPtr;\r
+  PEI_CORE_INSTANCE         *PrivateData;\r
+  UINTN                     Index;\r
+  EFI_GUID                  *CheckGuid;\r
+  EFI_PEI_PPI_DESCRIPTOR    *TempPtr;\r
 \r
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r
@@ -441,8 +453,8 @@ PeiLocatePpi (
   //\r
   // Search the data base for the matching instance of the GUIDed PPI.\r
   //\r
-  for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {\r
-    TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;\r
+  for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {\r
+    TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;\r
     CheckGuid = TempPtr->Guid;\r
 \r
     //\r
@@ -498,15 +510,14 @@ InternalPeiNotifyPpi (
   IN BOOLEAN                          Single\r
   )\r
 {\r
-  PEI_CORE_INSTANCE                *PrivateData;\r
-  INTN                             Index;\r
-  INTN                             NotifyIndex;\r
-  INTN                             LastCallbackNotify;\r
-  EFI_PEI_NOTIFY_DESCRIPTOR        *NotifyPtr;\r
-  UINTN                            NotifyDispatchCount;\r
-\r
-\r
-  NotifyDispatchCount = 0;\r
+  PEI_CORE_INSTANCE         *PrivateData;\r
+  PEI_CALLBACK_NOTIFY_LIST  *CallbackNotifyListPointer;\r
+  UINTN                     CallbackNotifyIndex;\r
+  UINTN                     LastCallbackNotifyCount;\r
+  PEI_DISPATCH_NOTIFY_LIST  *DispatchNotifyListPointer;\r
+  UINTN                     DispatchNotifyIndex;\r
+  UINTN                     LastDispatchNotifyCount;\r
+  VOID                      *TempPtr;\r
 \r
   if (NotifyList == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -514,8 +525,13 @@ InternalPeiNotifyPpi (
 \r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r
 \r
-  Index = PrivateData->PpiData.NotifyListEnd;\r
-  LastCallbackNotify = Index;\r
+  CallbackNotifyListPointer = &PrivateData->PpiData.CallbackNotifyList;\r
+  CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;\r
+  LastCallbackNotifyCount = CallbackNotifyIndex;\r
+\r
+  DispatchNotifyListPointer = &PrivateData->PpiData.DispatchNotifyList;\r
+  DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;\r
+  LastDispatchNotifyCount = DispatchNotifyIndex;\r
 \r
   //\r
   // This is loop installs all Notify descriptors in the NotifyList.  It is\r
@@ -524,32 +540,60 @@ InternalPeiNotifyPpi (
   //\r
 \r
   for (;;) {\r
-    //\r
-    // Since PpiData is used for NotifyList and InstallList, max resource\r
-    // is reached if the Install reaches the PpiList\r
-    // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement.\r
-    //\r
-    if (Index == PrivateData->PpiData.PpiListEnd - 1) {\r
-      return  EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
     //\r
     // If some of the PPI data is invalid restore original Notify PPI database value\r
     //\r
     if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {\r
-        PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;\r
-        DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify));\r
+        CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;\r
+        DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;\r
+        DEBUG((DEBUG_ERROR, "ERROR -> NotifyPpi: %g %p\n", NotifyList->Guid, NotifyList->Notify));\r
       return  EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {\r
-      NotifyDispatchCount ++;\r
+    if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {\r
+      if (CallbackNotifyIndex >= CallbackNotifyListPointer->MaxCount) {\r
+        //\r
+        // Run out of room, grow the buffer.\r
+        //\r
+        TempPtr = AllocateZeroPool (\r
+                    sizeof (PEI_PPI_LIST_POINTERS) * (CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP)\r
+                    );\r
+        ASSERT (TempPtr != NULL);\r
+        CopyMem (\r
+          TempPtr,\r
+          CallbackNotifyListPointer->NotifyPtrs,\r
+          sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->MaxCount\r
+          );\r
+        CallbackNotifyListPointer->NotifyPtrs = TempPtr;\r
+        CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;\r
+      }\r
+      CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;\r
+      CallbackNotifyIndex++;\r
+      CallbackNotifyListPointer->CurrentCount++;\r
+    } else {\r
+      if (DispatchNotifyIndex >= DispatchNotifyListPointer->MaxCount) {\r
+        //\r
+        // Run out of room, grow the buffer.\r
+        //\r
+        TempPtr = AllocateZeroPool (\r
+                    sizeof (PEI_PPI_LIST_POINTERS) * (DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP)\r
+                    );\r
+        ASSERT (TempPtr != NULL);\r
+        CopyMem (\r
+          TempPtr,\r
+          DispatchNotifyListPointer->NotifyPtrs,\r
+          sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->MaxCount\r
+          );\r
+        DispatchNotifyListPointer->NotifyPtrs = TempPtr;\r
+        DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;\r
+      }\r
+      DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;\r
+      DispatchNotifyIndex++;\r
+      DispatchNotifyListPointer->CurrentCount++;\r
     }\r
 \r
-    PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;\r
-\r
-    PrivateData->PpiData.NotifyListEnd--;\r
     DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));\r
+\r
     if (Single) {\r
       //\r
       // Only single entry in the NotifyList.\r
@@ -563,41 +607,21 @@ InternalPeiNotifyPpi (
       break;\r
     }\r
     //\r
-    // Go the next descriptor. Remember the NotifyList moves down.\r
+    // Go to the next descriptor.\r
     //\r
     NotifyList++;\r
-    Index--;\r
-  }\r
-\r
-  //\r
-  // If there is Dispatch Notify PPI installed put them on the bottom\r
-  //\r
-  if (NotifyDispatchCount > 0) {\r
-    for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {\r
-      if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {\r
-        NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;\r
-\r
-        for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){\r
-          PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;\r
-        }\r
-        PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;\r
-        PrivateData->PpiData.DispatchListEnd--;\r
-      }\r
-    }\r
-\r
-    LastCallbackNotify -= NotifyDispatchCount;\r
   }\r
 \r
   //\r
-  // Dispatch any callback level notifies for all previously installed PPIs.\r
+  // Process any callback level notifies for all previously installed PPIs.\r
   //\r
-  DispatchNotify (\r
+  ProcessNotify (\r
     PrivateData,\r
     EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r
     0,\r
-    PrivateData->PpiData.PpiListEnd,\r
-    LastCallbackNotify,\r
-    PrivateData->PpiData.NotifyListEnd\r
+    PrivateData->PpiData.PpiList.CurrentCount,\r
+    LastCallbackNotifyCount,\r
+    CallbackNotifyListPointer->CurrentCount\r
     );\r
 \r
   return  EFI_SUCCESS;\r
@@ -627,7 +651,6 @@ PeiNotifyPpi (
   return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE);\r
 }\r
 \r
-\r
 /**\r
 \r
   Process the Notify List at dispatch level.\r
@@ -636,55 +659,56 @@ PeiNotifyPpi (
 \r
 **/\r
 VOID\r
-ProcessNotifyList (\r
+ProcessDispatchNotifyList (\r
   IN PEI_CORE_INSTANCE  *PrivateData\r
   )\r
 {\r
-  INTN                    TempValue;\r
+  UINTN                 TempValue;\r
 \r
   while (TRUE) {\r
     //\r
     // Check if the PEIM that was just dispatched resulted in any\r
     // Notifies getting installed.  If so, go process any dispatch\r
     // level Notifies that match the previouly installed PPIs.\r
-    // Use "while" instead of "if" since DispatchNotify can modify\r
-    // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.\r
+    // Use "while" instead of "if" since ProcessNotify can modify\r
+    // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have\r
+    // to iterate until the same.\r
     //\r
-    while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {\r
-      TempValue = PrivateData->PpiData.DispatchListEnd;\r
-      DispatchNotify (\r
+    while (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount != PrivateData->PpiData.DispatchNotifyList.CurrentCount) {\r
+      TempValue = PrivateData->PpiData.DispatchNotifyList.CurrentCount;\r
+      ProcessNotify (\r
         PrivateData,\r
         EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r
         0,\r
-        PrivateData->PpiData.LastDispatchedInstall,\r
-        PrivateData->PpiData.LastDispatchedNotify,\r
-        PrivateData->PpiData.DispatchListEnd\r
+        PrivateData->PpiData.PpiList.LastDispatchedCount,\r
+        PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount,\r
+        PrivateData->PpiData.DispatchNotifyList.CurrentCount\r
         );\r
-      PrivateData->PpiData.LastDispatchedNotify = TempValue;\r
+      PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount = TempValue;\r
     }\r
 \r
-\r
     //\r
     // Check if the PEIM that was just dispatched resulted in any\r
     // PPIs getting installed.  If so, go process any dispatch\r
     // level Notifies that match the installed PPIs.\r
-    // Use "while" instead of "if" since DispatchNotify can modify\r
-    // PpiListEnd (with InstallPpi) so we have to iterate until the same.\r
+    // Use "while" instead of "if" since ProcessNotify can modify\r
+    // PpiList.CurrentCount (with InstallPpi) so we have to iterate\r
+    // until the same.\r
     //\r
-    while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {\r
-      TempValue = PrivateData->PpiData.PpiListEnd;\r
-      DispatchNotify (\r
+    while (PrivateData->PpiData.PpiList.LastDispatchedCount != PrivateData->PpiData.PpiList.CurrentCount) {\r
+      TempValue = PrivateData->PpiData.PpiList.CurrentCount;\r
+      ProcessNotify (\r
         PrivateData,\r
         EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r
-        PrivateData->PpiData.LastDispatchedInstall,\r
-        PrivateData->PpiData.PpiListEnd,\r
-        PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,\r
-        PrivateData->PpiData.DispatchListEnd\r
+        PrivateData->PpiData.PpiList.LastDispatchedCount,\r
+        PrivateData->PpiData.PpiList.CurrentCount,\r
+        0,\r
+        PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount\r
         );\r
-      PrivateData->PpiData.LastDispatchedInstall = TempValue;\r
+      PrivateData->PpiData.PpiList.LastDispatchedCount = TempValue;\r
     }\r
 \r
-    if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {\r
+    if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount == PrivateData->PpiData.DispatchNotifyList.CurrentCount) {\r
       break;\r
     }\r
   }\r
@@ -693,7 +717,7 @@ ProcessNotifyList (
 \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
@@ -704,7 +728,7 @@ ProcessNotifyList (
 \r
 **/\r
 VOID\r
-DispatchNotify (\r
+ProcessNotify (\r
   IN PEI_CORE_INSTANCE  *PrivateData,\r
   IN UINTN               NotifyType,\r
   IN INTN                InstallStartIndex,\r
@@ -713,22 +737,23 @@ DispatchNotify (
   IN INTN                NotifyStopIndex\r
   )\r
 {\r
-  INTN                   Index1;\r
-  INTN                   Index2;\r
-  EFI_GUID                *SearchGuid;\r
-  EFI_GUID                *CheckGuid;\r
-  EFI_PEI_NOTIFY_DESCRIPTOR   *NotifyDescriptor;\r
-\r
-  //\r
-  // Remember that Installs moves up and Notifies moves down.\r
-  //\r
-  for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {\r
-    NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;\r
+  INTN                          Index1;\r
+  INTN                          Index2;\r
+  EFI_GUID                      *SearchGuid;\r
+  EFI_GUID                      *CheckGuid;\r
+  EFI_PEI_NOTIFY_DESCRIPTOR     *NotifyDescriptor;\r
+\r
+  for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {\r
+    if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {\r
+      NotifyDescriptor = PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index1].Notify;\r
+    } else {\r
+      NotifyDescriptor = PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index1].Notify;\r
+    }\r
 \r
     CheckGuid = NotifyDescriptor->Guid;\r
 \r
     for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {\r
-      SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;\r
+      SearchGuid = PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid;\r
       //\r
       // Don't use CompareGuid function here for performance reasons.\r
       // Instead we compare the GUID as INT32 at a time and branch\r
@@ -745,7 +770,7 @@ DispatchNotify (
         NotifyDescriptor->Notify (\r
                             (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r
                             NotifyDescriptor,\r
-                            (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi\r
+                            (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi\r
                             );\r
       }\r
     }\r