]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PrePiHobListPointerLib: Fixed pointer calculation
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 18 Aug 2011 11:23:28 +0000 (11:23 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 18 Aug 2011 11:23:28 +0000 (11:23 +0000)
In the PrePi module, the global variables are located at the top of the stack.
At the opposite of the PeiCore where the global variables are located in the
middle of the stack. The top stack region is reserved for Temporary Memory.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12167 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointer.c
ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf

index dfcc27edf50ab055f7803b448115756c11874d01..a18a02a9bb603c87b6398e770b04dd787e39c719 100755 (executable)
 #include <Library/DebugLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
-//
-// Have to use build system to set the original value in case we are running
-// from FLASH and globals don't work. So if you do a GetHobList() and gHobList
-// and gHobList is NULL the PCD default values are used.
-//
-VOID *gHobList = NULL;\r
-\r
-\r
 /**\r
   Returns the pointer to the HOB list.\r
 \r
@@ -39,11 +31,10 @@ PrePeiGetHobList (
   VOID\r
   )\r
 {\r
-  if (gHobList == NULL) {\r
-    return (VOID *)*(UINTN*)(PcdGet32 (PcdCPUCoresNonSecStackBase) + (PcdGet32 (PcdCPUCoresNonSecStackSize) / 2) - PcdGet32 (PcdHobListPtrGlobalOffset));\r
-  } else {\r
-    return gHobList;\r
-  }\r
+  return (VOID *)*(UINTN*)(PcdGet32 (PcdCPUCoresNonSecStackBase) +\r
+                           PcdGet32 (PcdCPUCoresNonSecStackSize) -\r
+                           PcdGet32 (PcdPeiGlobalVariableSize) +\r
+                           PcdGet32 (PcdHobListPtrGlobalOffset));\r
 }\r
 \r
 \r
@@ -60,10 +51,15 @@ PrePeiSetHobList (
   IN  VOID      *HobList\r
   )\r
 {\r
-  gHobList = HobList;\r
-  \r
-  //\r
-  // If this code is running from ROM this could fail\r
-  //\r
-  return (gHobList == HobList) ? EFI_SUCCESS: EFI_UNSUPPORTED;\r
+  UINTN* HobListPtr;\r
+\r
+  HobListPtr = (UINTN*)(PcdGet32 (PcdCPUCoresNonSecStackBase) +\r
+                        PcdGet32 (PcdCPUCoresNonSecStackSize) -\r
+                        PcdGet32 (PcdPeiGlobalVariableSize) +\r
+                        PcdGet32 (PcdHobListPtrGlobalOffset));\r
+\r
+  *HobListPtr = (UINTN)HobList;\r
+\r
+  return EFI_SUCCESS;\r
 }\r
+\r
index 5142f19a4ed5c98fc5c11ef966881b331e6341df..c1fa999da55ab8e018171646406c9872bf45ec8f 100755 (executable)
@@ -34,4 +34,5 @@
   gArmPlatformTokenSpaceGuid.PcdHobListPtrGlobalOffset\r
   gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackBase\r
   gArmPlatformTokenSpaceGuid.PcdCPUCoresNonSecStackSize\r
+  gArmPlatformTokenSpaceGuid.PcdPeiGlobalVariableSize\r
   
\ No newline at end of file