]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmRealViewEbPkg/SecForPei/Arm/ModuleEntryPoint.S
Remove ArmEbPkg and replace with ArmRealViewEbPkg. Ported ArmRealViewEbPkg to have...
[mirror_edk2.git] / ArmRealViewEbPkg / SecForPei / Arm / ModuleEntryPoint.S
diff --git a/ArmRealViewEbPkg/SecForPei/Arm/ModuleEntryPoint.S b/ArmRealViewEbPkg/SecForPei/Arm/ModuleEntryPoint.S
new file mode 100755 (executable)
index 0000000..f87aa58
--- /dev/null
@@ -0,0 +1,79 @@
+#------------------------------------------------------------------------------ \r
+#\r
+# ARM EB Entry point. Reset vector in FV header will brach to\r
+# _ModuleEntryPoint. \r
+#\r
+# We use crazy macros, like LoadConstantToReg, since Xcode assembler \r
+# does not support = assembly syntax for ldr.\r
+#\r
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+#include <AsmMacroIoLib.h>\r
+#include <Base.h>\r
+#include <Library/PcdLib.h>\r
+#include <ArmEb/ArmEb.h>\r
+\r
+.text\r
+.align 3\r
+\r
+.globl ASM_PFX(CEntryPoint)\r
+.globl ASM_PFX(_ModuleEntryPoint)\r
+.globl ASM_PFX(StartupAddr)\r
+\r
+ASM_PFX(_ModuleEntryPoint):\r
\r
+  // Turn off remapping NOR to 0. We can now use DRAM in low memory\r
+  // CAN'T DO THIS HERE -- BRANCH FROM RESET VECTOR IS RELATIVE AND REMAINS IN REMAPPED NOR\r
+  //MmioOr32 (0x10001000 ,BIT8) //EB_SP810_CTRL_BASE\r
+\r
+  // Enable NEON register in case folks want to use them for optimizations (CopyMem)\r
+  mrc     p15, 0, r0, c1, c0, 2\r
+  orr     r0, r0, #0x00f00000   // Enable VFP access (V* instructions)\r
+  mcr     p15, 0, r0, c1, c0, 2\r
+  mov     r0, #0x40000000       // Set EN bit in FPEXC\r
+  mcr     p10,#0x7,r0,c8,c0,#0  // msr     FPEXC,r0 in ARM assembly\r
+   \r
+  // Set CPU vectors to 0 (which is currently flash)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCpuVectorBaseAddress) ,r0) // Get vector base\r
+  mcr     p15, 0, r0, c12, c0, 0\r
+  isb                               // Sync changes to control registers\r
+\r
+  //\r
+  // Set stack based on PCD values. Need to do it this way to make C code work \r
+  // when it runs from FLASH. \r
+  //  \r
+  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r0)    // temp ram base  arg 0 TODO: change "stackbase" to "temprambase"\r
+  LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r1)    // temp ram size  arg 1\r
+  lsr     r3, r1, #1   // r4 = size of temp mem / 2\r
+  add     r3, r3, r0  // r2 = temp ram base + r4\r
+  mov     r13, r3     // result: stack pointer = temp ram base + (size of temp mem / 2)\r
+    \r
+  // lr points to area in reset vector block containing PEI core address\r
+  ldr     r2, [lr]  // pei core   arg 3\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
+#ifndef __APPLE__\r
+// This does not generate a valid relocation for Xcode. Fix me...\r
+  ldr   r4, ASM_PFX(StartupAddr)\r
+\r
+  // jump to SEC C code\r
+  blx   r4\r
+#endif\r
+  \r
+\r
+ASM_PFX(ShouldNeverGetHere):\r
+  // _CEntryPoint should never return \r
+  b       ASM_PFX(ShouldNeverGetHere)\r
+\r
\r