]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/PrePi.c
MdeModulePkg: Add PiDxeS3BootScriptLib
[mirror_edk2.git] / ArmPlatformPkg / PrePi / PrePi.c
index 5a88b47fe92d0d52c24a25a03a7e2f768a2ce20a..7fe6fc36fa1ed91f94af2adbd5a4d2976653a21a 100755 (executable)
@@ -19,6 +19,7 @@
 #include <Library/IoLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/PrePiHobListPointerLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/PerformanceLib.h>\r
 \r
@@ -52,7 +53,7 @@ PrePiMain (
   IN  UINT64                    StartTimeStamp\r
   )\r
 {\r
-  EFI_HOB_HANDOFF_INFO_TABLE**  PrePiHobBase;\r
+  EFI_HOB_HANDOFF_INFO_TABLE*   HobList;\r
   EFI_STATUS                    Status;\r
   CHAR8                         Buffer[100];\r
   UINTN                         CharCount;\r
@@ -76,19 +77,21 @@ PrePiMain (
   InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r
   SaveAndSetDebugTimerInterrupt (TRUE);\r
 \r
-  PrePiHobBase = (EFI_HOB_HANDOFF_INFO_TABLE**)(PcdGet32 (PcdCPUCoresNonSecStackBase) + (PcdGet32 (PcdCPUCoresNonSecStackSize) / 2) - PcdGet32 (PcdHobListPtrGlobalOffset));\r
-\r
   UefiMemoryTop = UefiMemoryBase + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);\r
   StacksSize = PcdGet32 (PcdCPUCoresNonSecStackSize) * PcdGet32 (PcdMPCoreMaxCores);\r
   StacksBase = UefiMemoryTop - StacksSize;\r
 \r
+  // Check the PcdCPUCoresNonSecStackBase match with the calculated StackBase\r
+  ASSERT (StacksBase == PcdGet32 (PcdCPUCoresNonSecStackBase));\r
+  \r
   // Declare the PI/UEFI memory region\r
-  *PrePiHobBase = HobConstructor (\r
+  HobList = HobConstructor (\r
     (VOID*)UefiMemoryBase,\r
     FixedPcdGet32 (PcdSystemMemoryUefiRegionSize),\r
     (VOID*)UefiMemoryBase,\r
     (VOID*)StacksBase  // The top of the UEFI Memory is reserved for the stacks\r
     );\r
+  PrePeiSetHobList (HobList);\r
 \r
   // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)\r
   Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));\r
@@ -106,9 +109,6 @@ PrePiMain (
 \r
   BuildMemoryTypeInformationHob ();\r
 \r
-  InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL, NULL);\r
-  SaveAndSetDebugTimerInterrupt (TRUE);\r
-\r
   // Now, the HOB List has been initialized, we can register performance information\r
   PERF_START (NULL, "PEI", NULL, StartTimeStamp);\r
 \r
@@ -140,12 +140,14 @@ CEntryPoint (
   )\r
 {\r
   UINT64   StartTimeStamp;\r
-\r
\r
   if ((CoreId == ARM_PRIMARY_CORE) && PerformanceMeasurementEnabled ()) {\r
     // Initialize the Timer Library to setup the Timer HW controller\r
     TimerConstructor ();\r
     // We cannot call yet the PerformanceLib because the HOB List has not been initialized\r
     StartTimeStamp = GetPerformanceCounter ();\r
+  } else {\r
+    StartTimeStamp = 0;\r
   }\r
 \r
   // Clean Data cache\r