Skip to content

Commit c002aa9

Browse files
TTornblomJonatanAntoni
authored andcommitted
Create startup_ARMCA9.s
Startup file for IAR
1 parent 3e7eb8e commit c002aa9

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/******************************************************************************
2+
* @file startup_ARMCA9.s
3+
* @brief CMSIS Device System Source File for ARM Cortex-A9 Device Series
4+
* @version V1.00
5+
* @date 22 Feb 2017
6+
*
7+
* @note
8+
*
9+
******************************************************************************/
10+
/*
11+
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
12+
*
13+
* SPDX-License-Identifier: Apache-2.0
14+
*
15+
* Licensed under the Apache License, Version 2.0 (the License); you may
16+
* not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
*
19+
* www.apache.org/licenses/LICENSE-2.0
20+
*
21+
* Unless required by applicable law or agreed to in writing, software
22+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
23+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
* See the License for the specific language governing permissions and
25+
* limitations under the License.
26+
*/
27+
28+
MODULE ?startup_ARMCA9
29+
30+
/*----------------------------------------------------------------------------
31+
Exception / Interrupt Handler
32+
*----------------------------------------------------------------------------*/
33+
PUBWEAK Undef_Handler
34+
PUBWEAK SVC_Handler
35+
PUBWEAK PAbt_Handler
36+
PUBWEAK DAbt_Handler
37+
PUBWEAK IRQ_Handler
38+
PUBWEAK FIQ_Handler
39+
40+
/*----------------------------------------------------------------------------
41+
Exception / Interrupt Vector Table
42+
*----------------------------------------------------------------------------*/
43+
44+
section RESET:CODE(4)
45+
46+
Vectors:
47+
LDR PC, =Reset_Handler
48+
LDR PC, =Undef_Handler
49+
LDR PC, =SVC_Handler
50+
LDR PC, =PAbt_Handler
51+
LDR PC, =DAbt_Handler
52+
NOP
53+
LDR PC, =IRQ_Handler
54+
LDR PC, =FIQ_Handler
55+
56+
57+
section .text:CODE:NOROOT(4)
58+
59+
/*----------------------------------------------------------------------------
60+
Reset Handler called on controller reset
61+
*----------------------------------------------------------------------------*/
62+
EXTERN SystemInit
63+
EXTERN __main
64+
EXTERN Image$$FIQ_STACK$$ZI$$Limit
65+
EXTERN Image$$IRQ_STACK$$ZI$$Limit
66+
EXTERN Image$$SVC_STACK$$ZI$$Limit
67+
EXTERN Image$$ABT_STACK$$ZI$$Limit
68+
EXTERN Image$$UND_STACK$$ZI$$Limit
69+
EXTERN Image$$ARM_LIB_STACK$$ZI$$Limit
70+
71+
Reset_Handler:
72+
73+
// Mask interrupts
74+
CPSID if
75+
76+
// Put any cores other than 0 to sleep
77+
MRC p15, 0, R0, c0, c0, 5
78+
ANDS R0, R0, #3
79+
goToSleep:
80+
WFINE
81+
BNE goToSleep
82+
83+
// Reset SCTLR Settings
84+
MRC p15, 0, R0, c1, c0, 0 // Read CP15 System Control register
85+
BIC R0, R0, #(0x1 << 12) // Clear I bit 12 to disable I Cache
86+
BIC R0, R0, #(0x1 << 2) // Clear C bit 2 to disable D Cache
87+
BIC R0, R0, #0x1 // Clear M bit 0 to disable MMU
88+
BIC R0, R0, #(0x1 << 11) // Clear Z bit 11 to disable branch prediction
89+
BIC R0, R0, #(0x1 << 13) // Clear V bit 13 to disable hivecs
90+
MCR p15, 0, R0, c1, c0, 0 // Write value back to CP15 System Control register
91+
ISB
92+
93+
// Configure ACTLR
94+
MRC p15, 0, r0, c1, c0, 1 // Read CP15 Auxiliary Control Register
95+
ORR r0, r0, #(1 << 1) // Enable L2 prefetch hint (UNK/WI since r4p1)
96+
MCR p15, 0, r0, c1, c0, 1 // Write CP15 Auxiliary Control Register
97+
98+
// Set Vector Base Address Register (VBAR) to point to this application's vector table
99+
LDR R0, =Vectors
100+
MCR p15, 0, R0, c12, c0, 0
101+
102+
// Setup Stack for each exception mode
103+
CPS #0x11
104+
LDR SP, =Image$$FIQ_STACK$$ZI$$Limit
105+
CPS #0x12
106+
LDR SP, =Image$$IRQ_STACK$$ZI$$Limit
107+
CPS #0x13
108+
LDR SP, =Image$$SVC_STACK$$ZI$$Limit
109+
CPS #0x17
110+
LDR SP, =Image$$ABT_STACK$$ZI$$Limit
111+
CPS #0x1B
112+
LDR SP, =Image$$UND_STACK$$ZI$$Limit
113+
CPS #0x1F
114+
LDR SP, =Image$$ARM_LIB_STACK$$ZI$$Limit
115+
116+
// Call SystemInit
117+
BL SystemInit
118+
119+
// Unmask interrupts
120+
CPSIE if
121+
122+
// Call __main
123+
BL __main
124+
125+
/*----------------------------------------------------------------------------
126+
Default Handler for Exceptions / Interrupts
127+
*----------------------------------------------------------------------------*/
128+
Undef_Handler:
129+
SVC_Handler:
130+
PAbt_Handler:
131+
DAbt_Handler:
132+
IRQ_Handler:
133+
FIQ_Handler:
134+
Default_Handler:
135+
B .
136+
137+
END

0 commit comments

Comments
 (0)