]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
ArmPlatformPkg: clear frame pointer in startup code
[mirror_edk2.git] / ArmPlatformPkg / PrePi / AArch64 / ModuleEntryPoint.S
index e442819539ab614a63bd968a189902b6fd029de8..2069161b957dd2b52ccc749cc1c63e9c8045c675 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//  Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
+//  Copyright (c) 2011-2015, 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
 //\r
 \r
 #include <AsmMacroIoLibV8.h>\r
-#include <Base.h>\r
-#include <Library/PcdLib.h>\r
-#include <AutoGen.h>\r
 \r
-#include <Chipset/ArmV7.h>\r
-\r
-.text\r
-.align 3\r
-\r
-GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)\r
-GCC_ASM_IMPORT(ArmReadMpidr)\r
-GCC_ASM_IMPORT(ArmPlatformPeiBootAction)\r
-GCC_ASM_IMPORT(ArmPlatformStackSet)\r
-GCC_ASM_EXPORT(_ModuleEntryPoint)\r
-\r
-StartupAddr:        .dword       ASM_PFX(CEntryPoint)\r
-\r
-ASM_PFX(_ModuleEntryPoint):\r
+ASM_FUNC(_ModuleEntryPoint)\r
   // Do early platform specific actions\r
   bl    ASM_PFX(ArmPlatformPeiBootAction)\r
 \r
@@ -42,21 +26,20 @@ _SetSVCMode:
 // 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
 // at the top of the DRAM)\r
+_SystemMemoryEndInit:\r
+  ldr   x1, mSystemMemoryEnd\r
+\r
 _SetupStackPosition:\r
-  // Compute Top of System Memory\r
-  LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), x1)\r
-  LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), x2)\r
-  sub   x2, x2, #1\r
-  add   x1, x1, x2      // x1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize\r
+  // r1 = SystemMemoryTop\r
 \r
   // Calculate Top of the Firmware Device\r
-  LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2)\r
-  LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3)\r
+  MOV64 (x2, FixedPcdGet64(PcdFdBaseAddress))\r
+  MOV32 (x3, FixedPcdGet32(PcdFdSize) - 1)\r
   sub   x3, x3, #1\r
   add   x3, x3, x2      // x3 = FdTop = PcdFdBaseAddress + PcdFdSize\r
 \r
   // UEFI Memory Size (stacks are allocated in this region)\r
-  LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), x4)\r
+  MOV32 (x4, FixedPcdGet32(PcdSystemMemoryUefiRegionSize))\r
 \r
   //\r
   // Reserve the memory for the UEFI region (contain stacks on its top)\r
@@ -87,9 +70,7 @@ _SetupAlignedStack:
 _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
+  and   x1, x1, ~EFI_PAGE_MASK\r
 \r
 _GetBaseUefiMemory:\r
   // Calculate the Base of the UEFI Memory\r
@@ -98,22 +79,19 @@ _GetBaseUefiMemory:
 _GetStackBase:\r
   // r1 = The top of the Mpcore Stacks\r
   // Stack for the primary core = PrimaryCoreStack\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
+  MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))\r
   sub   x12, 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
+  MOV32 (x1, (FixedPcdGet32(PcdCoreCount) - 1) * FixedPcdGet32(PcdCPUCoreSecondaryStackSize))\r
   sub   x12, x12, x1\r
 \r
   // x12 = The base of the MpCore Stacks (primary stack & secondary stacks)\r
   mov   x0, x12\r
   mov   x1, x10\r
   //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x3)\r
+  MOV32 (x2, FixedPcdGet32(PcdCPUCorePrimaryStackSize))\r
+  MOV32 (x3, FixedPcdGet32(PcdCPUCoreSecondaryStackSize))\r
   bl    ASM_PFX(ArmPlatformStackSet)\r
 \r
   // Is it the Primary Core ?\r
@@ -122,26 +100,22 @@ _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
 \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   x4, StartupAddr\r
+  ldr   x4, =ASM_PFX(CEntryPoint)\r
+\r
+  // Set the frame pointer to NULL so any backtraces terminate here\r
+  mov   x29, xzr\r
 \r
   // Jump to PrePiCore C code\r
   //    x0 = MpId\r
   //    x1 = UefiMemoryBase\r
   //    x2 = StacksBase\r
-  //    x3 = GlobalVariableBase\r
   blr   x4\r
 \r
 _NeverReturn:\r