]> git.proxmox.com Git - mirror_edk2.git/blob - BeagleBoardPkg/Sec/Arm/ModuleEntryPoint.S
89bcab77ef9f52a15e122245cf7072453558174d
[mirror_edk2.git] / BeagleBoardPkg / Sec / Arm / 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 //Disable L2 cache
27 mrc p15, 0, r0, c1, c0, 1 // read Auxiliary Control Register
28 bic r0, r0, #0x00000002 // disable L2 cache
29 mcr p15, 0, r0, c1, c0, 1 // store Auxiliary Control Register
30
31 //Enable Strict alignment checking & Instruction cache
32 mrc p15, 0, r0, c1, c0, 0
33 bic r0, r0, #0x00002300 /* clear bits 13, 9:8 (--V- --RS) */
34 bic r0, r0, #0x00000005 /* clear bits 0, 2 (---- -C-M) */
35 orr r0, r0, #0x00000002 /* set bit 1 (A) Align */
36 orr r0, r0, #0x00001000 /* set bit 12 (I) enable I-Cache */
37 mcr p15, 0, r0, c1, c0, 0
38
39 // Set CPU vectors to start of DRAM
40 mov r0, #0x80000000
41 mcr p15, 0, r0, c12, c0, 0
42
43 /* before we call C code, lets setup the stack pointer */
44 stack_pointer_setup:
45
46 //
47 // Set stack based on PCD values. Need to do it this way to make C code work
48 // when it runs from FLASH.
49 //
50 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackBase) ,r2) /* stack base arg2 */
51 LoadConstantToReg (FixedPcdGet32(PcdPrePiStackSize) ,r3) /* stack size arg3 */
52 add r4, r2, r3
53
54 //Enter IRQ mode and set up IRQ stack pointer
55 mov r0,#0x12|0x80|0x40
56 msr CPSR_c,r0
57 mov r13,r4
58
59 //Enter Abort mode and set up Abort stack pointer
60 mov r0,#0x17|0x80|0x40
61 msr CPSR_c,r0
62 sub r4, r4, #0x400
63 mov r13,r4
64
65 //Enter Undefined mode and set up Undefined stack pointer
66 mov r0,#0x1b|0x80|0x40
67 msr CPSR_c,r0
68 sub r4, r4, #0x400
69 mov r13,r4
70
71 //Enter SVC mode and set up SVC stack pointer
72 mov r0,#0x13|0x80|0x40
73 msr CPSR_c,r0
74 sub r4, r4, #0x400
75 mov r13,r4
76
77 //Enter System mode and set up System stack pointer
78 mov r0,#0x1f|0x80|0x40
79 msr CPSR_c,r0
80 sub r4, r4, #0x400
81 mov r13,r4
82
83 // Call C entry point
84 LoadConstantToReg (FixedPcdGet32(PcdMemorySize) ,r1) /* memory size arg1 */
85 LoadConstantToReg (FixedPcdGet32(PcdMemoryBase) ,r0) /* memory size arg0 */
86
87
88 blx ASM_PFX(CEntryPoint) /* Assume C code is ARM */
89
90 ShouldNeverGetHere:
91 /* _CEntryPoint should never return */
92 b ShouldNeverGetHere
93
94