-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathstart.S
223 lines (178 loc) · 5.2 KB
/
start.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
* armboot - Startup Code for ARM720 CPU-core
*
* Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
* Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
/* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs */
.equ IRQ_DISABLE, 0x80 /* when I bit is set, IRQ is disabled */
.equ FIQ_DISABLE, 0x40 /* when F bit is set, FIQ is disabled */
.equ USR_MODE, 0x10
.equ FIQ_MODE, 0x11
.equ IRQ_MODE, 0x12
.equ SVC_MODE, 0x13
.equ ABT_MODE, 0x17
.equ UND_MODE, 0x1B
.equ SYS_MODE, 0x1F
.equ usr_stack_size, 1024
.equ irq_stack_size, 256
.equ fiq_stack_size, 256
.equ und_stack_size, 256
.equ abt_stack_size, 16
.equ sup_stack_size, 16
/*
*************************************************************************
*
* Jump vector table as in table 3.1 in [1]
*
*************************************************************************
*/
.section .start
.set base, .
.set _rom_data_init, 0x108d0
.globl _start
_start: b _begin
ldr pc, _undefined_instruction
ldr pc, _software_interrupt
ldr pc, _prefetch_abort
ldr pc, _data_abort
ldr pc, _not_used
ldr pc, _irq
ldr pc, _fiq
#ifdef USE_ROM_VARS
/* these vectors are used for rom patching */
.org 0x20
.code 16
_RPTV_0_START:
bx lr /* do nothing */
.org 0x60
_RPTV_1_START:
bx lr /* do nothing */
.org 0xa0
_RPTV_2_START:
bx lr /* do nothing */
.org 0xe0
_RPTV_3_START:
bx lr /* do nothing */
.org 0x120
ROM_var_start: .word 0
.org 0x7ff
ROM_var_end: .word 0
#endif /*USE_ROM_VARS*/
.code 32
.align
_begin:
/* FIQ mode stack */
msr CPSR_c, #(FIQ_MODE | IRQ_DISABLE | FIQ_DISABLE)
ldr sp, =__fiq_stack_top__ /* set the FIQ stack pointer */
/* IRQ mode stack */
msr CPSR_c, #(IRQ_MODE | IRQ_DISABLE | FIQ_DISABLE)
ldr sp, =__irq_stack_top__ /* set the IRQ stack pointer */
/* Supervisor mode stack */
msr CPSR_c, #(SVC_MODE | IRQ_DISABLE | FIQ_DISABLE)
ldr sp, =__svc_stack_top__ /* set the SVC stack pointer */
/* Undefined mode stack */
msr CPSR_c, #(UND_MODE | IRQ_DISABLE | FIQ_DISABLE)
ldr sp, =__und_stack_top__ /* set the UND stack pointer */
/* Abort mode stack */
msr CPSR_c, #(ABT_MODE | IRQ_DISABLE | FIQ_DISABLE)
ldr sp, =__abt_stack_top__ /* set the ABT stack pointer */
/* System mode stack */
msr CPSR_c, #(SYS_MODE | IRQ_DISABLE | FIQ_DISABLE)
ldr sp, =__sys_stack_top__ /* set the SYS stack pointer */
#ifdef USE_ROM_VARS
ldr r12,=_rom_data_init
mov lr,pc
bx r12
#endif
msr CPSR_c, #(SYS_MODE)
/* Clear BSS */
clear_bss:
ldr r0, _bss_start /* find start of bss segment */
ldr r1, _bss_end /* stop here */
mov r2, #0x00000000 /* clear */
clbss_l:
str r2, [r0] /* clear loop... */
add r0, r0, #4
cmp r0, r1
blt clbss_l
b main
// ldr r1,=_system_stack
// msr cpsr_c,#(SVC_MODE | I_BIT | F_BIT)
// add r1,r1,#sup_stack_size
// mov sp,r1
// msr cpsr_c,#(IRQ_MODE | I_BIT | F_BIT)
// add r1,r1,#irq_stack_size
// mov sp,r1
// msr cpsr_c,#(FIQ_MODE | I_BIT | F_BIT)
// add r1,r1,#fiq_stack_size
// mov sp,r1
// msr cpsr_c,#(ABT_MODE | I_BIT | F_BIT)
// add r1,r1,#abt_stack_size
// mov sp,r1
// msr cpsr_c,#(UND_MODE | I_BIT | F_BIT)
// add r1,r1,#und_stack_size
// mov sp,r1
// msr cpsr_c,#(USR_MODE | I_BIT | F_BIT)
// bl _rom_data_init+.-base
// msr cpsr_c,#(SVC_MODE) // turn on interrupts --- for debug only
// msr cpsr_c,#(USR_MODE) // turn on interrupts --- for debug only
// add r1,r1,#usr_stack_size
// mov sp,r1
_undefined_instruction: .word undefined_instruction
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_abort: .word data_abort
_not_used: .word not_used
_irq: .word irq
_fiq: .word fiq
.balignl 16,0xdeadbeef
/*
* These are defined in the board-specific linker script.
*/
.globl _bss_start
_bss_start:
.word __bss_start
.globl _bss_end
_bss_end:
.word _end
_system_stack:
. = . + usr_stack_size + irq_stack_size + fiq_stack_size + und_stack_size + abt_stack_size + sup_stack_size
/*
* exception handlers
*/
.align 5
undefined_instruction:
.align 5
software_interrupt:
.align 5
prefetch_abort:
nop
.align 5
data_abort:
.align 5
not_used:
.align 5
//irq:
//
// .align 5
fiq:
.align 5