--- /dev/null
+#------------------------------------------------------------------------------ \r
+#\r
+# Copyright (c) 2008-2009 Apple Inc. All rights reserved.\r
+#\r
+# All rights reserved. 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 <Library/PcdLib.h>\r
+\r
+.text\r
+.align 3\r
+\r
+.globl ASM_PFX(CEntryPoint)\r
+.globl ASM_PFX(_ModuleEntryPoint)\r
+\r
+ASM_PFX(_ModuleEntryPoint):\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) ,r2) /* stack base arg2 */\r
+ LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) /* stack size arg3 */\r
+ add r4, r2, r3\r
+\r
+ //Enter SVC mode and set up SVC stack pointer\r
+ mov r0,#0x13|0x80|0x40\r
+ msr CPSR_c,r0\r
+ sub r4, r4, #0x400\r
+ mov r13,r4\r
+\r
+ // Call C entry point\r
+ LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) /* memory size arg1 */\r
+ LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) /* memory size arg0 */\r
+\r
+ blx ASM_PFX(CEntryPoint) /* Assume C code is ARM */\r
+\r
+ShouldNeverGetHere:\r
+ /* _CEntryPoint should never return */\r
+ b ShouldNeverGetHere\r
+\r
+ \r