]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Ppi/Ppi.c
MdeModulePkg PeiMain: Enhance the PEI Core to convert GUID/PPI pointers pointing...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Ppi / Ppi.c
index 9129c23159fa03c2dca239e0772d009ed7a66246..6664b5b898c2169b78bac16815ab1aab2320ce12 100644 (file)
@@ -105,15 +105,15 @@ ConvertPpiPointers (
         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
+          // 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
@@ -125,6 +125,41 @@ ConvertPpiPointers (
         } else {\r
           PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->StackOffset);\r
         }\r
+\r
+        //\r
+        // Try to convert the pointers in the PEIM descriptor\r
+        //\r
+\r
+        if (((UINTN)PpiPointer->Ppi->Guid < OldStackTop) &&\r
+            ((UINTN)PpiPointer->Ppi->Guid >= OldStackBottom)) {\r
+          //\r
+          // Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r
+          // from the the temporary stack to the permanent PEI stack.\r
+          //\r
+          if (PrivateData->StackOffsetPositive) {\r
+            PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + PrivateData->StackOffset);\r
+          } else {\r
+            PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - PrivateData->StackOffset);\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 < OldStackTop &&\r
+            (UINTN)PpiPointer->Ppi->Ppi >= OldStackBottom) {\r
+          //\r
+          // Convert the pointer to the PPI interface structure in the PPI descriptor\r
+          // from the the temporary stack to the permanent PEI stack.\r
+          //\r
+          if (PrivateData->StackOffsetPositive) {\r
+            PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->StackOffset);\r
+          } else {\r
+            PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - PrivateData->StackOffset);\r
+          }\r
+        }\r
       }\r
     }\r
   }\r