]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Ppi/Ppi.c
Enhance the PEI Core to convert pointers pointing to PPI descriptors on the temporary...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Ppi / Ppi.c
index 65dc5be9fcd96ae5519c15b769f44dee5a117277..9129c23159fa03c2dca239e0772d009ed7a66246 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PEI Core PPI services\r
   \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, 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
@@ -40,44 +40,44 @@ InitializePpiServices (
 \r
   Migrate the Hob list from the temporary memory stack 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 FixupPositive       TRUE if new Hob list is above the old Hob list.  \r
-                             Otherwise FALSE.\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 UINTN                   Fixup,\r
-  IN BOOLEAN                 FixupPositive\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
+  IN PEI_CORE_INSTANCE           *PrivateData\r
   )\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 < OldCheckingTop) &&\r
-          ((UINTN)PpiPointer->Raw >= OldCheckingBottom)) {\r
+      if (((UINTN)PpiPointer->Raw < OldHeapTop) &&\r
+          ((UINTN)PpiPointer->Raw >= OldHeapBottom)) {\r
         //\r
-        // Convert the pointer to the PEIM descriptor from the old HOB heap\r
+        // Convert the pointer to the PPI descriptor from the old HOB heap\r
         // to the relocated HOB heap.\r
         //\r
-        if (FixupPositive) {\r
-          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup);\r
+        if (PrivateData->HeapOffsetPositive) {\r
+          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + PrivateData->HeapOffset);\r
         } else {\r
-          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - Fixup);\r
+          PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->HeapOffset);\r
         }\r
 \r
         //\r
@@ -85,16 +85,16 @@ ConvertPpiPointers (
         // to try to convert the pointers in the PEIM descriptor\r
         //\r
 \r
-        if (((UINTN)PpiPointer->Ppi->Guid < OldCheckingTop) &&\r
-            ((UINTN)PpiPointer->Ppi->Guid >= OldCheckingBottom)) {\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 (FixupPositive) {\r
-            PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup);\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 - Fixup);\r
+            PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - PrivateData->HeapOffset);\r
           }\r
         }\r
 \r
@@ -103,18 +103,28 @@ ConvertPpiPointers (
         // the notification function in the NOTIFY descriptor needs not be converted.\r
         //\r
         if (Index < PrivateData->PpiData.PpiListEnd &&\r
-            (UINTN)PpiPointer->Ppi->Ppi < OldCheckingTop &&\r
-            (UINTN)PpiPointer->Ppi->Ppi >= OldCheckingBottom) {\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 (FixupPositive) {\r
-              PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + Fixup);\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 - Fixup);\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
     }\r
   }\r