-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.s
226 lines (201 loc) · 4.56 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
224
225
226
/*
* LED board startup code for STM32F030C8T6
*
* Written by Calvin Owens <[email protected]>
*
* To the extent possible under law, I waive all copyright and related or
* neighboring rights. You should have received a copy of the CC0 license along
* with this work. If not, see http://creativecommons.org/publicdomain/zero/1.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
.cpu cortex-m0
.fpu softvfp
.syntax unified
.thumb
/*
* These five constants are defined in link.ld, and ultimately the linker will
* decide what their literal values are at build time.
*/
.word ____stack
.word ____data_init
.word ____data_start
.word ____data_end
.word ____bss_start
.word ____bss_end
.global __reset
.section .text.__reset
.type __reset, %function
.size __reset, .-__reset
/*
* Execution starts here.
*/
__reset:
ldr r0, =____stack
mov sp, r0
/*
* Copy the data segment from NVMEM to SRAM.
*/
movs r0, #0
ldr r1, =____data_start
ldr r2, =____data_end
subs r2, r2, r1
ldr r3, =____data_init
copy_data_section_to_sram:
ldr r4, [r3, r0]
str r4, [r1, r0]
adds r0, r0, #4
cmp r0, r2
blo copy_data_section_to_sram
/*
* Zero the BSS segment in SRAM.
*/
movs r0, #0
ldr r1, =____bss_start
ldr r2, =____bss_end
subs r2, r2, r1
movs r3, #0
zero_bss_section_in_sram:
str r3, [r1, r0]
adds r0, r0, #4
cmp r0, r2
blo zero_bss_section_in_sram
/*
* Branch to main()
*/
bl main
.section .text.irq_none, "ax", %progbits
.type irq_none, %function
.size irq_none, .-irq_none
/*
* This stub enters an infinite loop, for debugging.
*/
irq_none:
b irq_none
.section .isr, "a", %progbits
.type isr_vector, %object
.size isr_vector, .-isr_vector
/*
* This is the array of function pointers the hardware calls to handle
* the various possible faults and interrupts.
*/
isr_vector:
.word ____stack
.word __reset
.word __nmi
.word __hardfault
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word __svc
.word 0
.word 0
.word __pendsv
.word __systick
.word irq_wwdg
.word 0
.word irq_rtc
.word irq_flash
.word irq_rcc
.word irq_exti01
.word irq_exti23
.word irq_exti45
.word 0
.word irq_dma1_ch1
.word irq_dma1_ch23
.word irq_dma1_ch45
.word irq_adc1
.word irq_tim1_brk
.word irq_tim1_cc
.word 0
.word irq_tim3
.word 0
.word 0
.word irq_tim14
.word irq_tim15
.word irq_tim16
.word irq_tim17
.word irq_i2c1
.word irq_i2c2
.word irq_spi1
.word irq_spi2
.word irq_usart1
.word irq_usart2
.word 0
.word 0
.word 0
.word 0
/*
* Declare symbols for all the handlers as weak, so they can be overriden in the
* main C source code without editing this file.
*/
.weak irq_adc1
.weak irq_dma1_ch1
.weak irq_dma1_ch23
.weak irq_dma1_ch45
.weak irq_exti01
.weak irq_exti23
.weak irq_exti45
.weak irq_flash
.weak irq_i2c1
.weak irq_i2c2
.weak irq_rcc
.weak irq_rtc
.weak irq_spi1
.weak irq_spi2
.weak irq_tim14
.weak irq_tim15
.weak irq_tim16
.weak irq_tim17
.weak irq_tim1_brk
.weak irq_tim1_cc
.weak irq_tim3
.weak irq_usart1
.weak irq_usart2
.weak irq_wwdg
.weak __hardfault
.weak __nmi
.weak __pendsv
.weak __svc
.weak __systick
/*
* For debugging, use an infinite loop as the default interrupt action.
*/
.thumb_set irq_adc1, irq_none
.thumb_set irq_dma1_ch1, irq_none
.thumb_set irq_dma1_ch23, irq_none
.thumb_set irq_dma1_ch45, irq_none
.thumb_set irq_exti01, irq_none
.thumb_set irq_exti23, irq_none
.thumb_set irq_exti45, irq_none
.thumb_set irq_flash, irq_none
.thumb_set irq_i2c1, irq_none
.thumb_set irq_i2c2, irq_none
.thumb_set irq_rcc, irq_none
.thumb_set irq_rtc, irq_none
.thumb_set irq_spi1, irq_none
.thumb_set irq_spi2, irq_none
.thumb_set irq_tim14, irq_none
.thumb_set irq_tim15, irq_none
.thumb_set irq_tim16, irq_none
.thumb_set irq_tim17, irq_none
.thumb_set irq_tim1_brk, irq_none
.thumb_set irq_tim1_cc, irq_none
.thumb_set irq_tim3, irq_none
.thumb_set irq_usart1, irq_none
.thumb_set irq_usart2, irq_none
.thumb_set irq_wwdg, irq_none
.thumb_set __hardfault, irq_none
.thumb_set __nmi, irq_none
.thumb_set __pendsv, irq_none
.thumb_set __svc, irq_none
.thumb_set __systick, irq_none