]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/PrePi/AArch64/ModuleEntryPoint.S
ArmVirtPkg/PrePi: use correct callee saved regs
[mirror_edk2.git] / ArmVirtPkg / PrePi / AArch64 / ModuleEntryPoint.S
index 568d0086d662927c4aa9dcdbea0758744742e8a6..d6be3454183411e2d0ad4c92ea79e659412c5915 100644 (file)
@@ -25,8 +25,10 @@ GCC_ASM_IMPORT(ArmReadMpidr)
 GCC_ASM_IMPORT(ArmPlatformPeiBootAction)\r
 GCC_ASM_IMPORT(ArmPlatformStackSet)\r
 GCC_ASM_EXPORT(_ModuleEntryPoint)\r
+ASM_GLOBAL ASM_PFX(mSystemMemoryEnd)\r
 \r
-StartupAddr:        .8byte ASM_PFX(CEntryPoint)\r
+StartupAddr:                  .8byte ASM_PFX(CEntryPoint)\r
+ASM_PFX(mSystemMemoryEnd):    .8byte 0\r
 \r
 ASM_PFX(_ModuleEntryPoint):\r
   //\r
@@ -69,7 +71,7 @@ ASM_PFX(_ModuleEntryPoint):
   // Get ID of this CPU in Multicore system\r
   bl    ASM_PFX(ArmReadMpidr)\r
   // Keep a copy of the MpId register value\r
-  mov   x10, x0\r
+  mov   x20, x0\r
 \r
 // Check if we can install the stack at the top of the System Memory or if we need\r
 // to install the stacks at the bottom of the Firmware Device (case the FD is located\r
@@ -80,6 +82,8 @@ _SetupStackPosition:
   ldr   x2, PcdGet64 (PcdSystemMemorySize)\r
   sub   x2, x2, #1\r
   add   x1, x1, x2      // x1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize\r
+  adr   x2, mSystemMemoryEnd\r
+  str   x1, [x2]\r
 \r
   // Calculate Top of the Firmware Device\r
   ldr   x2, PcdGet64 (PcdFdBaseAddress)\r
@@ -109,40 +113,40 @@ _SetupStack:
   // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment\r
   // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the\r
   // top of the memory space)\r
-  adds  x11, x1, #1\r
+  adds  x21, x1, #1\r
   b.cs  _SetupOverflowStack\r
 \r
 _SetupAlignedStack:\r
-  mov   x1, x11\r
+  mov   x1, x21\r
   b     _GetBaseUefiMemory\r
 \r
 _SetupOverflowStack:\r
   // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE\r
   // aligned (4KB)\r
-  LoadConstantToReg (EFI_PAGE_MASK, x11)\r
-  and   x11, x11, x1\r
-  sub   x1, x1, x11\r
+  LoadConstantToReg (EFI_PAGE_MASK, x21)\r
+  and   x21, x21, x1\r
+  sub   x1, x1, x21\r
 \r
 _GetBaseUefiMemory:\r
   // Calculate the Base of the UEFI Memory\r
-  sub   x11, x1, x4\r
+  sub   x21, x1, x4\r
 \r
 _GetStackBase:\r
   // r1 = The top of the Mpcore Stacks\r
   // Stack for the primary core = PrimaryCoreStack\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
-  sub   x12, x1, x2\r
+  sub   x22, x1, x2\r
 \r
   // Stack for the secondary core = Number of Cores - 1\r
   LoadConstantToReg (FixedPcdGet32(PcdCoreCount), x0)\r
   sub   x0, x0, #1\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x1)\r
   mul   x1, x1, x0\r
-  sub   x12, x12, x1\r
+  sub   x22, x22, x1\r
 \r
-  // x12 = The base of the MpCore Stacks (primary stack & secondary stacks)\r
-  mov   x0, x12\r
-  mov   x1, x10\r
+  // x22 = The base of the MpCore Stacks (primary stack & secondary stacks)\r
+  mov   x0, x22\r
+  mov   x1, x20\r
   //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x3)\r
@@ -154,16 +158,10 @@ _GetStackBase:
   cmp   x0, #1\r
   bne   _PrepareArguments\r
 \r
-_ReserveGlobalVariable:\r
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x0)\r
-  // InitializePrimaryStack($GlobalVariableSize, $Tmp1, $Tmp2)\r
-  InitializePrimaryStack(x0, x1, x2)\r
-\r
 _PrepareArguments:\r
-  mov   x0, x10\r
-  mov   x1, x11\r
-  mov   x2, x12\r
-  mov   x3, sp\r
+  mov   x0, x20\r
+  mov   x1, x21\r
+  mov   x2, x22\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
@@ -173,7 +171,6 @@ _PrepareArguments:
   //    x0 = MpId\r
   //    x1 = UefiMemoryBase\r
   //    x2 = StacksBase\r
-  //    x3 = GlobalVariableBase\r
   blr   x4\r
 \r
 _NeverReturn:\r