Update to use DEBUG/RELEASE properly in DSC now tools have been fixed. Add VectorBase...
[mirror_edk2.git] / ArmEbPkg / Sec / ModuleEntryPoint.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2008-2009 Apple Inc. All rights reserved.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15 #include <AsmMacroIoLib.h>
16 #include <Library/PcdLib.h>
17
18 .text
19 .align 3
20
21 .globl ASM_PFX(CEntryPoint)
22 .globl ASM_PFX(_ModuleEntryPoint)
23
24 ASM_PFX(_ModuleEntryPoint):
25
26 //
27 // Set stack based on PCD values. Need to do it this way to make C code work
28 // when it runs from FLASH.
29 //
30 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) /* stack base arg2 */
31 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) /* stack size arg3 */
32 add r4, r2, r3
33
34 //Enter SVC mode and set up SVC stack pointer
35 mov r0,#0x13|0x80|0x40
36 msr CPSR_c,r0
37 sub r4, r4, #0x400
38 mov r13,r4
39
40 // Call C entry point
41 LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) /* memory size arg1 */
42 LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) /* memory size arg0 */
43
44 blx ASM_PFX(CEntryPoint) /* Assume C code is ARM */
45
46 ShouldNeverGetHere:
47 /* _CEntryPoint should never return */
48 b ShouldNeverGetHere
49
50