]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/PrePi.c
BaseTools: Copy Brotli algorithm 3rd party source code for tool
[mirror_edk2.git] / ArmPlatformPkg / PrePi / PrePi.c
old mode 100755 (executable)
new mode 100644 (file)
index e8b1ff7..e548cca
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Ppi/ArmMpCoreInfo.h>\r
 #include <Guid/LzmaDecompress.h>\r
-#include <Guid/ArmGlobalVariableHob.h>\r
 \r
 #include "PrePi.h"\r
 #include "LzmaDecompress.h"\r
 \r
-#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > (UINT32)(FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize))) || \\r
-                  ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet32 (PcdSystemMemoryBase)))\r
+#define IS_XIP() (((UINT64)FixedPcdGet64 (PcdFdBaseAddress) > mSystemMemoryEnd) || \\r
+                  ((FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase)))\r
 \r
-// Not used when PrePi in run in XIP mode\r
-UINTN mGlobalVariableBase = 0;\r
+UINT64 mSystemMemoryEnd = FixedPcdGet64(PcdSystemMemoryBase) +\r
+                          FixedPcdGet64(PcdSystemMemorySize) - 1;\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -48,23 +47,6 @@ LzmaDecompressLibConstructor (
   VOID\r
   );\r
 \r
-VOID\r
-EFIAPI\r
-BuildGlobalVariableHob (\r
-  IN EFI_PHYSICAL_ADDRESS         GlobalVariableBase,\r
-  IN UINT32                       GlobalVariableSize\r
-  )\r
-{\r
-  ARM_HOB_GLOBAL_VARIABLE  *Hob;\r
-\r
-  Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, sizeof (ARM_HOB_GLOBAL_VARIABLE));\r
-  ASSERT(Hob != NULL);\r
-\r
-  CopyGuid (&(Hob->Header.Name), &gArmGlobalVariableGuid);\r
-  Hob->GlobalVariableBase = GlobalVariableBase;\r
-  Hob->GlobalVariableSize = GlobalVariableSize;\r
-}\r
-\r
 EFI_STATUS\r
 GetPlatformPpi (\r
   IN  EFI_GUID  *PpiGuid,\r
@@ -93,7 +75,6 @@ VOID
 PrePiMain (\r
   IN  UINTN                     UefiMemoryBase,\r
   IN  UINTN                     StacksBase,\r
-  IN  UINTN                     GlobalVariableBase,\r
   IN  UINT64                    StartTimeStamp\r
   )\r
 {\r
@@ -107,9 +88,9 @@ PrePiMain (
   UINTN                         StacksSize;\r
 \r
   // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)\r
-  ASSERT (IS_XIP() || \r
-          ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet32 (PcdSystemMemoryBase)) &&\r
-           ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT32)(FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize)))));\r
+  ASSERT (IS_XIP() ||\r
+          ((FixedPcdGet64 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&\r
+           ((UINT64)(FixedPcdGet64 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT64)mSystemMemoryEnd)));\r
 \r
   // Initialize the architecture specific bits\r
   ArchInitialize ();\r
@@ -123,7 +104,7 @@ PrePiMain (
   // Initialize the Debug Agent for Source Level Debugging\r
   InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r
   SaveAndSetDebugTimerInterrupt (TRUE);\r
-  \r
+\r
   // Declare the PI/UEFI memory region\r
   HobList = HobConstructor (\r
     (VOID*)UefiMemoryBase,\r
@@ -139,15 +120,13 @@ PrePiMain (
 \r
   // Create the Stacks HOB (reserve the memory for all stacks)\r
   if (ArmIsMpCore ()) {\r
-    StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) + (FixedPcdGet32(PcdClusterCount) * 4 * FixedPcdGet32(PcdCPUCoreSecondaryStackSize));\r
+    StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize) +\r
+                 ((FixedPcdGet32 (PcdCoreCount) - 1) * FixedPcdGet32 (PcdCPUCoreSecondaryStackSize));\r
   } else {\r
     StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);\r
   }\r
   BuildStackHob (StacksBase, StacksSize);\r
 \r
-  // Declare the Global Variable HOB\r
-  BuildGlobalVariableHob (GlobalVariableBase, FixedPcdGet32 (PcdPeiGlobalVariableSize));\r
-\r
   //TODO: Call CpuPei as a library\r
   BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));\r
 \r
@@ -202,13 +181,10 @@ VOID
 CEntryPoint (\r
   IN  UINTN                     MpId,\r
   IN  UINTN                     UefiMemoryBase,\r
-  IN  UINTN                     StacksBase,\r
-  IN  UINTN                     GlobalVariableBase\r
+  IN  UINTN                     StacksBase\r
   )\r
 {\r
   UINT64   StartTimeStamp;\r
\r
-  ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1));\r
 \r
   // Initialize the platform specific controllers\r
   ArmPlatformInitialize (MpId);\r
@@ -222,22 +198,18 @@ CEntryPoint (
     StartTimeStamp = 0;\r
   }\r
 \r
-  // Clean Data cache\r
-  ArmCleanInvalidateDataCache ();\r
-\r
+  // Data Cache enabled on Primary core when MMU is enabled.\r
+  ArmDisableDataCache ();\r
+  // Invalidate Data cache\r
+  ArmInvalidateDataCache ();\r
   // Invalidate instruction cache\r
   ArmInvalidateInstructionCache ();\r
-\r
-  //TODO:Drain Write Buffer\r
-\r
-  // Enable Instruction & Data caches\r
-  ArmEnableDataCache ();\r
+  // Enable Instruction Caches on all cores.\r
   ArmEnableInstructionCache ();\r
 \r
   // Define the Global Variable region when we are not running in XIP\r
   if (!IS_XIP()) {\r
     if (ArmPlatformIsPrimaryCore (MpId)) {\r
-      mGlobalVariableBase = GlobalVariableBase;\r
       if (ArmIsMpCore()) {\r
         // Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT)\r
         ArmCallSEV ();\r
@@ -247,11 +219,11 @@ CEntryPoint (
       ArmCallWFE ();\r
     }\r
   }\r
-  \r
+\r
   // If not primary Jump to Secondary Main\r
   if (ArmPlatformIsPrimaryCore (MpId)) {\r
     // Goto primary Main.\r
-    PrimaryMain (UefiMemoryBase, StacksBase, GlobalVariableBase, StartTimeStamp);\r
+    PrimaryMain (UefiMemoryBase, StacksBase, StartTimeStamp);\r
   } else {\r
     SecondaryMain (MpId);\r
   }\r