summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-04-02 15:11:21 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2012-04-06 13:46:32 +0200
commitf33330c0ff90adad8855250877a4a3d0a407bba4 (patch)
tree6b5ad86aeb2e6b0a57f78965e59c618b4a26f30f
parentbb0e4cc543e4c7bed6dff3a41d092b6867632535 (diff)
downloadrockbox-f33330c0ff90adad8855250877a4a3d0a407bba4.tar.gz
rockbox-f33330c0ff90adad8855250877a4a3d0a407bba4.zip
arm: factor all exception handlers out of the crt0.S files
Remove the implementations of all exceptions handlers from the various crt0.S files and have a single implementation in system-arm.h The new implementation is weak so that it can be overwritten by some specific code (like the unwinder) Change-Id: Ib3e041ed6037376bbe0e79286057e1051640dd90 Reviewed-on: http://gerrit.rockbox.org/205 Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
-rw-r--r--firmware/target/arm/crt0.S32
-rw-r--r--firmware/target/arm/imx233/crt0.S32
-rw-r--r--firmware/target/arm/imx31/crt0.S29
-rw-r--r--firmware/target/arm/rk27xx/crt0.S27
-rw-r--r--firmware/target/arm/s3c2440/crt0.S29
-rw-r--r--firmware/target/arm/s5l8700/crt0.S30
-rw-r--r--firmware/target/arm/s5l8702/crt0.S30
-rw-r--r--firmware/target/arm/system-arm.c50
-rw-r--r--firmware/target/arm/tcc77x/crt0.S29
-rw-r--r--firmware/target/arm/tcc780x/crt0.S29
-rw-r--r--firmware/target/arm/tms320dm320/crt0.S45
11 files changed, 50 insertions, 312 deletions
diff --git a/firmware/target/arm/crt0.S b/firmware/target/arm/crt0.S
index 7befecb593..b9cc27f5c5 100644
--- a/firmware/target/arm/crt0.S
+++ b/firmware/target/arm/crt0.S
@@ -137,38 +137,6 @@ newstart:
137 ldr ip, =main @ make sure we are using the virtual address 137 ldr ip, =main @ make sure we are using the virtual address
138 bx ip 138 bx ip
139 139
140/* All illegal exceptions call into UIE with exception address as first
141 * parameter. This is calculated differently depending on which exception
142 * we're in. Second parameter is exception number, used for a string lookup
143 * in UIE. */
144undef_instr_handler:
145 sub r0, lr, #4 @ r0 points to the faulty ARM instruction
146#ifdef USE_THUMB
147 mrs r1, spsr
148 tst r1, #(1<<5) @ T bit set ?
149 subne r0, lr, #2 @ if yes, r0 points to the faulty THUMB instruction
150#endif /* USE_THUMB */
151 mov r1, #0
152 b UIE
153
154/* We run sys mode most of the time, and should never see a software
155 * exception being thrown. Make it illegal and call UIE. */
156software_int_handler:
157reserved_handler:
158 sub r0, lr, #4
159 mov r1, #4
160 b UIE
161
162prefetch_abort_handler:
163 sub r0, lr, #4
164 mov r1, #1
165 b UIE
166
167data_abort_handler:
168 sub r0, lr, #8
169 mov r1, #2
170 b UIE
171
172/* Cache-align interrupt stacks */ 140/* Cache-align interrupt stacks */
173.balign 32 141.balign 32
174 142
diff --git a/firmware/target/arm/imx233/crt0.S b/firmware/target/arm/imx233/crt0.S
index 4ae083ccb2..ffc58d56fc 100644
--- a/firmware/target/arm/imx233/crt0.S
+++ b/firmware/target/arm/imx233/crt0.S
@@ -161,38 +161,6 @@ remap:
1611: 1611:
162 b 1b 162 b 1b
163 163
164/* All illegal exceptions call into UIE with exception address as first
165 * parameter. This is calculated differently depending on which exception
166 * we're in. Second parameter is exception number, used for a string lookup
167 * in UIE. */
168undef_instr_handler:
169 sub r0, lr, #4 @ r0 points to the faulty ARM instruction
170#ifdef USE_THUMB
171 mrs r1, spsr
172 tst r1, #(1<<5) @ T bit set ?
173 subne r0, lr, #2 @ if yes, r0 points to the faulty THUMB instruction
174#endif /* USE_THUMB */
175 mov r1, #0
176 b UIE
177
178/* We run sys mode most of the time, and should never see a software
179 * exception being thrown. Make it illegal and call UIE. */
180software_int_handler:
181reserved_handler:
182 sub r0, lr, #4
183 mov r1, #4
184 b UIE
185
186prefetch_abort_handler:
187 sub r0, lr, #4
188 mov r1, #1
189 b UIE
190
191data_abort_handler:
192 sub r0, lr, #8
193 mov r1, #2
194 b UIE
195
196/* 256 words of IRQ stack */ 164/* 256 words of IRQ stack */
197 .space 256*4 165 .space 256*4
198irq_stack: 166irq_stack:
diff --git a/firmware/target/arm/imx31/crt0.S b/firmware/target/arm/imx31/crt0.S
index 1c1ae55736..4e489800d4 100644
--- a/firmware/target/arm/imx31/crt0.S
+++ b/firmware/target/arm/imx31/crt0.S
@@ -326,35 +326,6 @@ remap_end:
326 .word 0 @ fiq_handler 326 .word 0 @ fiq_handler
327#endif /* BOOTLOADER */ 327#endif /* BOOTLOADER */
328 328
329 .text
330
331/* All illegal exceptions call into UIE with exception address as first
332 * parameter. This is calculated differently depending on which exception
333 * we're in. Second parameter is exception number, used for a string lookup
334 * in UIE. */
335undef_instr_handler:
336 sub r0, lr, #4
337 mov r1, #0
338 b UIE
339
340/* We run sys mode most of the time, and should never see a software
341 * exception being thrown. Make it illegal and call UIE. */
342software_int_handler:
343reserved_handler:
344 sub r0, lr, #4
345 mov r1, #4
346 b UIE
347
348prefetch_abort_handler:
349 sub r0, lr, #4
350 mov r1, #1
351 b UIE
352
353data_abort_handler:
354 sub r0, lr, #8
355 mov r1, #2
356 b UIE
357
358/* 256 words of IRQ stack */ 329/* 256 words of IRQ stack */
359 .section .bss 330 .section .bss
360 .balign 32 331 .balign 32
diff --git a/firmware/target/arm/rk27xx/crt0.S b/firmware/target/arm/rk27xx/crt0.S
index 1bbd46a12c..deea0eeaec 100644
--- a/firmware/target/arm/rk27xx/crt0.S
+++ b/firmware/target/arm/rk27xx/crt0.S
@@ -196,30 +196,3 @@ entry_point:
196 bhi 1b 196 bhi 1b
197 197
198 bl main 198 bl main
199
200/* All illegal exceptions call into UIE with exception address as first
201 * parameter. This is calculated differently depending on which exception
202 * we're in. Second parameter is exception number, used for a string lookup
203 * in UIE. */
204undef_instr_handler:
205 sub r0, lr, #4
206 mov r1, #0
207 b UIE
208
209prefetch_abort_handler:
210 sub r0, lr, #4
211 mov r1, #1
212 b UIE
213
214data_abort_handler:
215 sub r0, lr, #8
216 mov r1, #2
217 b UIE
218
219/* We run sys mode most of the time, and should never see a software
220 * exception being thrown. Make it illegal and call UIE */
221software_int_handler:
222reserved_handler:
223 sub r0, lr, #4
224 mov r1, #5
225 b UIE
diff --git a/firmware/target/arm/s3c2440/crt0.S b/firmware/target/arm/s3c2440/crt0.S
index 8cbd8ab91e..e103f4f49f 100644
--- a/firmware/target/arm/s3c2440/crt0.S
+++ b/firmware/target/arm/s3c2440/crt0.S
@@ -565,35 +565,6 @@ stackmunge:
565 */ 565 */
566 b vectors 566 b vectors
567 567
568/* All illegal exceptions call into UIE with exception address as first
569 parameter. This is calculated differently depending on which exception
570 we're in. Second parameter is exception number, used for a string lookup
571 in UIE.
572 */
573undef_instr_handler:
574 sub r0, lr, #4
575 mov r1, #0
576 b UIE
577
578/* We run sys mode most of the time, and should never see a software
579 exception being thrown. Make it illegal and call UIE.
580 */
581software_int_handler:
582reserved_handler:
583 sub r0, lr, #4
584 mov r1, #4
585 b UIE
586
587prefetch_abort_handler:
588 sub r0, lr, #4
589 mov r1, #1
590 b UIE
591
592data_abort_handler:
593 sub r0, lr, #8
594 mov r1, #2
595 b UIE
596
597#if defined(BOOTLOADER) 568#if defined(BOOTLOADER)
598fiq_handler: 569fiq_handler:
599 b UIE 570 b UIE
diff --git a/firmware/target/arm/s5l8700/crt0.S b/firmware/target/arm/s5l8700/crt0.S
index 0582ab0c8f..93bfa8f06c 100644
--- a/firmware/target/arm/s5l8700/crt0.S
+++ b/firmware/target/arm/s5l8700/crt0.S
@@ -507,33 +507,3 @@ start_loc:
507#endif 507#endif
508 508
509 bl main 509 bl main
510
511 .text
512/* .global UIE*/
513
514/* All illegal exceptions call into UIE with exception address as first
515 * parameter. This is calculated differently depending on which exception
516 * we're in. Second parameter is exception number, used for a string lookup
517 * in UIE. */
518undef_instr_handler:
519 sub r0, lr, #4
520 mov r1, #0
521 b UIE
522
523/* We run sys mode most of the time, and should never see a software
524 * exception being thrown. Make it illegal and call UIE. */
525software_int_handler:
526reserved_handler:
527 sub r0, lr, #4
528 mov r1, #4
529 b UIE
530
531prefetch_abort_handler:
532 sub r0, lr, #4
533 mov r1, #1
534 b UIE
535
536data_abort_handler:
537 sub r0, lr, #8
538 mov r1, #2
539 b UIE
diff --git a/firmware/target/arm/s5l8702/crt0.S b/firmware/target/arm/s5l8702/crt0.S
index e894e8f157..563e863a66 100644
--- a/firmware/target/arm/s5l8702/crt0.S
+++ b/firmware/target/arm/s5l8702/crt0.S
@@ -179,33 +179,3 @@ start_loc:
179 bhi 1b 179 bhi 1b
180 180
181 bl main 181 bl main
182
183 .text
184/* .global UIE*/
185
186/* All illegal exceptions call into UIE with exception address as first
187 * parameter. This is calculated differently depending on which exception
188 * we're in. Second parameter is exception number, used for a string lookup
189 * in UIE. */
190undef_instr_handler:
191 sub r0, lr, #4
192 mov r1, #0
193 b UIE
194
195/* We run sys mode most of the time, and should never see a software
196 * exception being thrown. Make it illegal and call UIE. */
197software_int_handler:
198reserved_handler:
199 sub r0, lr, #4
200 mov r1, #4
201 b UIE
202
203prefetch_abort_handler:
204 sub r0, lr, #4
205 mov r1, #1
206 b UIE
207
208data_abort_handler:
209 sub r0, lr, #8
210 mov r1, #2
211 b UIE
diff --git a/firmware/target/arm/system-arm.c b/firmware/target/arm/system-arm.c
index c4692bbf29..e687e1d82b 100644
--- a/firmware/target/arm/system-arm.c
+++ b/firmware/target/arm/system-arm.c
@@ -36,6 +36,56 @@ static const char* const uiename[] = {
36 "SWI" 36 "SWI"
37}; 37};
38 38
39void __attribute__((weak,naked)) data_abort_handler(void)
40{
41 asm volatile(
42 "sub r0, lr, #8 \n"
43 "mov r1, #2 \n"
44 "b UIE \n"
45 );
46}
47
48void __attribute__((weak,naked)) software_int_handler(void)
49{
50 asm volatile(
51 "sub r0, lr, #4 \n"
52 "mov r1, #4 \n"
53 "b UIE \n"
54 );
55}
56
57void __attribute__((weak,naked)) reserved_handler(void)
58{
59 asm volatile(
60 "sub r0, lr, #4 \n"
61 "mov r1, #4 \n"
62 "b UIE \n"
63 );
64}
65
66void __attribute__((weak,naked)) prefetch_abort_handler(void)
67{
68 asm volatile(
69 "sub r0, lr, #4 \n"
70 "mov r1, #1 \n"
71 "b UIE \n"
72 );
73}
74
75void __attribute__((weak,naked)) undef_instr_handler(void)
76{
77 asm volatile(
78 "sub r0, lr, #4 \n"
79#ifdef USE_THUMB
80 "mrs r1, spsr \n"
81 "tst r1, #(1 << 5) \n" // T bit set ?
82 "subne r0, lr, #2 \n" // if yes, offset to THUMB instruction
83#endif
84 "mov r1, #0 \n"
85 "b UIE \n"
86 );
87}
88
39/* Unexpected Interrupt or Exception handler. Currently only deals with 89/* Unexpected Interrupt or Exception handler. Currently only deals with
40 exceptions, but will deal with interrupts later. 90 exceptions, but will deal with interrupts later.
41 */ 91 */
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
index d0873102d4..aebd8974da 100644
--- a/firmware/target/arm/tcc77x/crt0.S
+++ b/firmware/target/arm/tcc77x/crt0.S
@@ -212,35 +212,6 @@ vectors_end:
212 212
213 .text 213 .text
214 214
215/* All illegal exceptions call into UIE with exception address as first
216 parameter. This is calculated differently depending on which exception
217 we're in. Second parameter is exception number, used for a string lookup
218 in UIE.
219 */
220undef_instr_handler:
221 sub r0, lr, #4
222 mov r1, #0
223 b UIE
224
225/* We run sys mode most of the time, and should never see a software
226 exception being thrown. Make it illegal and call UIE.
227 */
228software_int_handler:
229reserved_handler:
230 sub r0, lr, #4
231 mov r1, #4
232 b UIE
233
234prefetch_abort_handler:
235 sub r0, lr, #4
236 mov r1, #1
237 b UIE
238
239data_abort_handler:
240 sub r0, lr, #8
241 mov r1, #2
242 b UIE
243
244irq_handler: 215irq_handler:
245 stmfd sp!, {r0-r3, r12, lr} 216 stmfd sp!, {r0-r3, r12, lr}
246 bl irq 217 bl irq
diff --git a/firmware/target/arm/tcc780x/crt0.S b/firmware/target/arm/tcc780x/crt0.S
index 1dbccf9828..5d271616d0 100644
--- a/firmware/target/arm/tcc780x/crt0.S
+++ b/firmware/target/arm/tcc780x/crt0.S
@@ -282,35 +282,6 @@ vectors_end:
282 282
283 .text 283 .text
284 284
285/* All illegal exceptions call into UIE with exception address as first
286 parameter. This is calculated differently depending on which exception
287 we're in. Second parameter is exception number, used for a string lookup
288 in UIE.
289 */
290undef_instr_handler:
291 sub r0, lr, #4
292 mov r1, #0
293 b UIE
294
295/* We run sys mode most of the time, and should never see a software
296 exception being thrown. Make it illegal and call UIE.
297 */
298software_int_handler:
299reserved_handler:
300 sub r0, lr, #4
301 mov r1, #4
302 b UIE
303
304prefetch_abort_handler:
305 sub r0, lr, #4
306 mov r1, #1
307 b UIE
308
309data_abort_handler:
310 sub r0, lr, #8
311 mov r1, #2
312 b UIE
313
314#ifdef BOOTLOADER 285#ifdef BOOTLOADER
315fiq_handler: 286fiq_handler:
316 subs pc, lr, #4 287 subs pc, lr, #4
diff --git a/firmware/target/arm/tms320dm320/crt0.S b/firmware/target/arm/tms320dm320/crt0.S
index d53cff2b63..f1b2eb397c 100644
--- a/firmware/target/arm/tms320dm320/crt0.S
+++ b/firmware/target/arm/tms320dm320/crt0.S
@@ -292,51 +292,6 @@ _delay_cycles:
292.size _delay_cycles, .-_delay_cycles 292.size _delay_cycles, .-_delay_cycles
293 293
294/****************************************************************************** 294/******************************************************************************
295 * Unused exception vectors. These call the UIE function. *
296 * Arguements are: *
297 * r0: PC of exception *
298 * r1: Exception number. *
299 * Exception numbers are as defined: *
300 * 0: Undefined Instruction *
301 * 1: Prefetch Abort *
302 * 2: Data Abort *
303 * 3: DIV0 *
304 * 4: SWI *
305 * The exceptions return operations are documented in section A2.6 of the *
306 * ARM Architecture Reference Manual. *
307 ******************************************************************************/
308
309/* A2.6.3: Undefined Instruction Exception - LR=PC of next instruction */
310_undefined_instruction:
311 sub r0, lr, #4
312 mov r1, #0
313 bl UIE
314
315/* A2.6.4: Software Interrupt exception - These should not happen in Rockbox,
316 * make it illegal
317 */
318_software_interrupt:
319 sub r0, lr, #4
320 mov r1, #4
321 bl UIE
322
323/* A2.6.5 Prefetch Abort - This is also the BKPT instruction since this is a
324 * v5 target. Pass it on to UIE since it is not currently used.
325 */
326_prefetch_abort:
327 sub r0, lr, #4
328 mov r1, #1
329 bl UIE
330
331/* A2.6.6 Data Abort - There was a memory abort, can return after fixing cause
332 * with the LR address.
333 */
334_data_abort:
335 sub r0, lr, #8
336 mov r1, #2
337 bl UIE
338
339/******************************************************************************
340 * _dead_loop: Something really unexpected happened (like a reserved * 295 * _dead_loop: Something really unexpected happened (like a reserved *
341 * exception). Just hang. * 296 * exception). Just hang. *
342 ******************************************************************************/ 297 ******************************************************************************/