-
Notifications
You must be signed in to change notification settings - Fork 111
/
start.s
190 lines (154 loc) · 4.38 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
/*=============================================================================
Copyright (C) 2016-2017 Authors of rpi-open-firmware
All rights reserved.
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.
FILE DESCRIPTION
Entry.
A small explanation. The ROM loads bootcode.bin at 0x80000000 and jumps to
0x80000200. This region corresponds to L1/L2 cached IO and cache is never
evicted as long as we don't touch memory above that. This gives us 128KB
of memory at startup.
Exception names are from the public release from:
brcm_usrlib\dag\vmcsx\vcfw\rtos\none\rtos_none.c
=============================================================================*/
.text
empty_space:
.space 0x200
/* MMIO-mapped registers for the interrupt table */
.set IC0_BASE, 0x7e002000
.set IC0_VADDR, 0x7e002030
.set IC1_BASE, 0x7e002800
.set IC1_VADDR, 0x7e002830
/* main entry point */
.globl _start
.align 2
_start:
version r0
mov r5, r0
/* vectors */
mov r3, #0x1B000
mov r1, r3
/*
* populate the exception vector table using PC relative labels
* so the code isnt position dependent
*/
.macro RegExceptionHandler label, exception_number
lea r2, fleh_\label
st r2, (r1)
add r1, #4
.endm
RegExceptionHandler zero, #0
RegExceptionHandler misaligned, #1
RegExceptionHandler dividebyzero, #2
RegExceptionHandler undefinedinstruction, #3
RegExceptionHandler forbiddeninstruction, #4
RegExceptionHandler illegalmemory, #5
RegExceptionHandler buserror, #6
RegExceptionHandler floatingpoint, #7
RegExceptionHandler isp, #8
RegExceptionHandler dummy, #9
RegExceptionHandler icache, #10
RegExceptionHandler veccore, #11
RegExceptionHandler badl2alias, #12
RegExceptionHandler breakpoint, #13
RegExceptionHandler unknown, #14
RegExceptionHandler unknown, #15
RegExceptionHandler unknown, #16
RegExceptionHandler unknown, #17
RegExceptionHandler unknown, #18
RegExceptionHandler unknown, #19
RegExceptionHandler unknown, #20
RegExceptionHandler unknown, #21
RegExceptionHandler unknown, #22
RegExceptionHandler unknown, #23
RegExceptionHandler unknown, #24
RegExceptionHandler unknown, #25
RegExceptionHandler unknown, #26
RegExceptionHandler unknown, #27
RegExceptionHandler unknown, #28
RegExceptionHandler unknown, #29
RegExceptionHandler unknown, #30
RegExceptionHandler unknown, #31
add r1, r3, #128
lea r2, fleh_irq
add r4, r3, #572
L_setup_hw_irq:
st r2, (r1)
add r1, #4
ble r1, r4, L_setup_hw_irq
/*
* load the interrupt and normal stack pointers. these
* are chosen to be near the top of the available cache memory
*/
mov r28, #0x1D000
mov sp, #0x1C000
/* jump to C code */
mov r0, r5
lea r1, _start
bl _main
/************************************************************
* Exception Handling
************************************************************/
.macro SaveRegsLower
stm lr, (--sp)
stm r0-r5, (--sp)
.endm
.macro SaveRegsUpper
stm r6-r15, (--sp)
stm r16-r23, (--sp)
.endm
.macro SaveRegsAll
SaveRegsLower
SaveRegsUpper
.endm
fatal_exception:
SaveRegsUpper
mov r0, sp
b sleh_fatal
.macro ExceptionHandler label, exception_number
fleh_\label:
SaveRegsLower
mov r1, \exception_number
b fatal_exception
.endm
ExceptionHandler zero, #0
ExceptionHandler misaligned, #1
ExceptionHandler dividebyzero, #2
ExceptionHandler undefinedinstruction, #3
ExceptionHandler forbiddeninstruction, #4
ExceptionHandler illegalmemory, #5
ExceptionHandler buserror, #6
ExceptionHandler floatingpoint, #7
ExceptionHandler isp, #8
ExceptionHandler dummy, #9
ExceptionHandler icache, #10
ExceptionHandler veccore, #11
ExceptionHandler badl2alias, #12
ExceptionHandler breakpoint, #13
ExceptionHandler unknown, #14
fleh_irq:
SaveRegsAll
/* top of savearea */
mov r0, sp
mov r1, r29
bl sleh_irq
return_from_exception:
ldm r16-r23, (sp++)
ldm r6-r15, (sp++)
ldm r0-r5, (sp++)
ld lr, (sp++)
rti
/* include chainloader */
.align 2
.globl L_arm_code_start
L_arm_code_start:
.incbin "arm_chainloader/build/arm_chainloader.bin"
.globl L_arm_code_end
L_arm_code_end: