]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
ArmPlatformPkg: clear frame pointer in startup code
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / AArch64 / PrePeiCoreEntryPoint.S
index 85d3450f62e4669fdd9dc95bee9b2f61a2e50694..9e2e49d62fa3726ef17b33f58d7cf107c13a96cd 100644 (file)
 //\r
 \r
 #include <AsmMacroIoLibV8.h>\r
-#include <Base.h>\r
-#include <Library/PcdLib.h>\r
-#include <AutoGen.h>\r
 \r
-.text\r
-.align 3\r
-\r
-GCC_ASM_IMPORT(CEntryPoint)\r
-GCC_ASM_IMPORT(ArmPlatformGetCorePosition)\r
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)\r
-GCC_ASM_IMPORT(ArmReadMpidr)\r
-GCC_ASM_IMPORT(ArmPlatformPeiBootAction)\r
-GCC_ASM_EXPORT(_ModuleEntryPoint)\r
-\r
-StartupAddr: .8byte CEntryPoint\r
-\r
-ASM_PFX(_ModuleEntryPoint):\r
+ASM_FUNC(_ModuleEntryPoint)\r
   // Do early platform specific actions\r
   bl    ASM_PFX(ArmPlatformPeiBootAction)\r
 \r
@@ -60,9 +45,7 @@ ASM_PFX(MainEntryPoint):
   bl    ASM_PFX(ArmPlatformIsPrimaryCore)\r
 \r
   // Get the top of the primary stacks (and the base of the secondary stacks)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), x1)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
-  add   x1, x1, x2\r
+  MOV64 (x1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize))\r
 \r
   // x0 is equal to 1 if I am the primary core\r
   cmp   x0, #1\r
@@ -79,20 +62,22 @@ _SetupSecondaryCoreStack:
   add   x0, x0, #1\r
 \r
   // StackOffset = CorePos * StackSize\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x2)\r
+  MOV32 (x2, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))\r
   mul   x0, x0, x2\r
   // SP = StackBase + StackOffset\r
   add   sp, x6, x0\r
 \r
 _PrepareArguments:\r
   // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
-  LoadConstantToReg (FixedPcdGet64(PcdFvBaseAddress), x2)\r
-  add   x2, x2, #8\r
-  ldr   x1, [x2]\r
+  MOV64 (x2, FixedPcdGet64(PcdFvBaseAddress))\r
+  ldr   x1, [x2, #8]\r
 \r
   // Move sec startup address into a data register\r
   // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
-  ldr   x3, StartupAddr\r
+  ldr   x3, =ASM_PFX(CEntryPoint)\r
+\r
+  // Set the frame pointer to NULL so any backtraces terminate here\r
+  mov   x29, xzr\r
 \r
   // Jump to PrePeiCore C code\r
   //    x0 = mp_id\r
@@ -102,4 +87,10 @@ _PrepareArguments:
 \r
 _SetupPrimaryCoreStack:\r
   mov   sp, x1\r
+  MOV64 (x8, FixedPcdGet64 (PcdCPUCoresStackBase))\r
+  MOV64 (x9, FixedPcdGet32 (PcdInitValueInTempStack) |\\r
+             FixedPcdGet32 (PcdInitValueInTempStack) << 32)\r
+0:stp   x9, x9, [x8], #16\r
+  cmp   x8, x1\r
+  b.lt  0b\r
   b     _PrepareArguments\r