blob: 3727537f5825c92925915f3a9240b7bd63e6dd1d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/kernel/entry-armv.S
3 *
4 * Copyright (C) 1996,1997,1998 Russell King.
5 * ARM700 fix by Matthew Godbolt (linux-user@willothewisp.demon.co.uk)
Hyok S. Choiafeb90c2006-01-13 21:05:25 +00006 * nommu support by Hyok S. Choi (hyok.choi@samsung.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Low-level vector interface routines
13 *
14 * Note: there is a StrongARM bug in the STMIA rn, {regs}^ instruction that causes
15 * it to save wrong values... Be aware!
16 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Nicolas Pitref09b9972005-10-29 21:44:55 +010018#include <asm/memory.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/glue.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/vfpmacros.h>
Russell Kingbce495d2005-04-26 15:21:02 +010021#include <asm/arch/entry-macro.S>
Russell Kingd6551e82006-06-21 13:31:52 +010022#include <asm/thread_notify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include "entry-header.S"
25
26/*
Russell King187a51a2005-05-21 18:14:44 +010027 * Interrupt handling. Preserves r7, r8, r9
28 */
29 .macro irq_handler
Dan Williamsf80dff92007-02-16 22:16:32 +010030 get_irqnr_preamble r5, lr
Russell King187a51a2005-05-21 18:14:44 +0100311: get_irqnr_and_base r0, r6, r5, lr
32 movne r1, sp
33 @
34 @ routine called with r0 = irq number, r1 = struct pt_regs *
35 @
36 adrne lr, 1b
37 bne asm_do_IRQ
Russell King791be9b2005-05-21 18:16:44 +010038
39#ifdef CONFIG_SMP
40 /*
41 * XXX
42 *
43 * this macro assumes that irqstat (r6) and base (r5) are
44 * preserved from get_irqnr_and_base above
45 */
46 test_for_ipi r0, r6, r5, lr
47 movne r0, sp
48 adrne lr, 1b
49 bne do_IPI
Russell King37ee16a2005-11-08 19:08:05 +000050
51#ifdef CONFIG_LOCAL_TIMERS
52 test_for_ltirq r0, r6, r5, lr
53 movne r0, sp
54 adrne lr, 1b
55 bne do_local_timer
56#endif
Russell King791be9b2005-05-21 18:16:44 +010057#endif
58
Russell King187a51a2005-05-21 18:14:44 +010059 .endm
60
Nicolas Pitre785d3cd2007-12-03 15:27:56 -050061#ifdef CONFIG_KPROBES
62 .section .kprobes.text,"ax",%progbits
63#else
64 .text
65#endif
66
Russell King187a51a2005-05-21 18:14:44 +010067/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 * Invalid mode handlers
69 */
Russell Kingccea7a12005-05-31 22:22:32 +010070 .macro inv_entry, reason
71 sub sp, sp, #S_FRAME_SIZE
72 stmib sp, {r1 - lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 mov r1, #\reason
74 .endm
75
76__pabt_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010077 inv_entry BAD_PREFETCH
78 b common_invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80__dabt_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010081 inv_entry BAD_DATA
82 b common_invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84__irq_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010085 inv_entry BAD_IRQ
86 b common_invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88__und_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010089 inv_entry BAD_UNDEFINSTR
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Russell Kingccea7a12005-05-31 22:22:32 +010091 @
92 @ XXX fall through to common_invalid
93 @
94
95@
96@ common_invalid - generic code for failed exception (re-entrant version of handlers)
97@
98common_invalid:
99 zero_fp
100
101 ldmia r0, {r4 - r6}
102 add r0, sp, #S_PC @ here for interlock avoidance
103 mov r7, #-1 @ "" "" "" ""
104 str r4, [sp] @ save preserved r0
105 stmia r0, {r5 - r7} @ lr_<exception>,
106 @ cpsr_<exception>, "old_r0"
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 mov r0, sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 b bad_mode
110
111/*
112 * SVC mode handlers
113 */
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000114
115#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5)
116#define SPFIX(code...) code
117#else
118#define SPFIX(code...)
119#endif
120
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500121 .macro svc_entry, stack_hole=0
122 sub sp, sp, #(S_FRAME_SIZE + \stack_hole)
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000123 SPFIX( tst sp, #4 )
124 SPFIX( bicne sp, sp, #4 )
Russell Kingccea7a12005-05-31 22:22:32 +0100125 stmib sp, {r1 - r12}
126
127 ldmia r0, {r1 - r3}
128 add r5, sp, #S_SP @ here for interlock avoidance
129 mov r4, #-1 @ "" "" "" ""
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500130 add r0, sp, #(S_FRAME_SIZE + \stack_hole)
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000131 SPFIX( addne r0, r0, #4 )
Russell Kingccea7a12005-05-31 22:22:32 +0100132 str r1, [sp] @ save the "real" r0 copied
133 @ from the exception stack
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 mov r1, lr
136
137 @
138 @ We are now ready to fill in the remaining blanks on the stack:
139 @
140 @ r0 - sp_svc
141 @ r1 - lr_svc
142 @ r2 - lr_<exception>, already fixed up for correct return/restart
143 @ r3 - spsr_<exception>
144 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
145 @
146 stmia r5, {r0 - r4}
147 .endm
148
149 .align 5
150__dabt_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100151 svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153 @
154 @ get ready to re-enable interrupts if appropriate
155 @
156 mrs r9, cpsr
157 tst r3, #PSR_I_BIT
158 biceq r9, r9, #PSR_I_BIT
159
160 @
161 @ Call the processor-specific abort handler:
162 @
163 @ r2 - aborted context pc
164 @ r3 - aborted context cpsr
165 @
166 @ The abort handler must return the aborted address in r0, and
167 @ the fault status register in r1. r9 must be preserved.
168 @
169#ifdef MULTI_ABORT
170 ldr r4, .LCprocfns
171 mov lr, pc
172 ldr pc, [r4]
173#else
174 bl CPU_ABORT_HANDLER
175#endif
176
177 @
178 @ set desired IRQ state, then call main handler
179 @
180 msr cpsr_c, r9
181 mov r2, sp
182 bl do_DataAbort
183
184 @
185 @ IRQs off again before pulling preserved data off the stack
186 @
Russell King1ec42c02005-04-26 15:18:26 +0100187 disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189 @
190 @ restore SPSR and restart the instruction
191 @
192 ldr r0, [sp, #S_PSR]
193 msr spsr_cxsf, r0
194 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
195
196 .align 5
197__irq_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100198 svc_entry
199
Russell King7ad1bcb2006-08-27 12:07:02 +0100200#ifdef CONFIG_TRACE_IRQFLAGS
201 bl trace_hardirqs_off
202#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100204 get_thread_info tsk
205 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
206 add r7, r8, #1 @ increment it
207 str r7, [tsk, #TI_PREEMPT]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#endif
Russell Kingccea7a12005-05-31 22:22:32 +0100209
Russell King187a51a2005-05-21 18:14:44 +0100210 irq_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100212 ldr r0, [tsk, #TI_FLAGS] @ get flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 tst r0, #_TIF_NEED_RESCHED
214 blne svc_preempt
215preempt_return:
Russell King706fdd92005-05-21 18:15:45 +0100216 ldr r0, [tsk, #TI_PREEMPT] @ read preempt value
217 str r8, [tsk, #TI_PREEMPT] @ restore preempt count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 teq r0, r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 strne r0, [r0, -r0] @ bug()
220#endif
221 ldr r0, [sp, #S_PSR] @ irqs are already disabled
222 msr spsr_cxsf, r0
Russell King7ad1bcb2006-08-27 12:07:02 +0100223#ifdef CONFIG_TRACE_IRQFLAGS
224 tst r0, #PSR_I_BIT
225 bleq trace_hardirqs_on
226#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
228
229 .ltorg
230
231#ifdef CONFIG_PREEMPT
232svc_preempt:
Russell King706fdd92005-05-21 18:15:45 +0100233 teq r8, #0 @ was preempt count = 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 ldreq r6, .LCirq_stat
235 movne pc, lr @ no
236 ldr r0, [r6, #4] @ local_irq_count
237 ldr r1, [r6, #8] @ local_bh_count
238 adds r0, r0, r1
239 movne pc, lr
240 mov r7, #0 @ preempt_schedule_irq
Russell King706fdd92005-05-21 18:15:45 +0100241 str r7, [tsk, #TI_PREEMPT] @ expects preempt_count == 0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421: bl preempt_schedule_irq @ irq en/disable is done inside
Russell King706fdd92005-05-21 18:15:45 +0100243 ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 tst r0, #_TIF_NEED_RESCHED
245 beq preempt_return @ go again
246 b 1b
247#endif
248
249 .align 5
250__und_svc:
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500251#ifdef CONFIG_KPROBES
252 @ If a kprobe is about to simulate a "stmdb sp..." instruction,
253 @ it obviously needs free stack space which then will belong to
254 @ the saved context.
255 svc_entry 64
256#else
Russell Kingccea7a12005-05-31 22:22:32 +0100257 svc_entry
Nicolas Pitred30a0c82007-12-14 15:56:01 -0500258#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260 @
261 @ call emulation code, which returns using r9 if it has emulated
262 @ the instruction, or the more conventional lr if we are to treat
263 @ this as a real undefined instruction
264 @
265 @ r0 - instruction
266 @
267 ldr r0, [r2, #-4]
268 adr r9, 1f
269 bl call_fpe
270
271 mov r0, sp @ struct pt_regs *regs
272 bl do_undefinstr
273
274 @
275 @ IRQs off again before pulling preserved data off the stack
276 @
Russell King1ec42c02005-04-26 15:18:26 +01002771: disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
279 @
280 @ restore SPSR and restart the instruction
281 @
282 ldr lr, [sp, #S_PSR] @ Get SVC cpsr
283 msr spsr_cxsf, lr
284 ldmia sp, {r0 - pc}^ @ Restore SVC registers
285
286 .align 5
287__pabt_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100288 svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
290 @
291 @ re-enable interrupts if appropriate
292 @
293 mrs r9, cpsr
294 tst r3, #PSR_I_BIT
295 biceq r9, r9, #PSR_I_BIT
296 msr cpsr_c, r9
297
298 @
299 @ set args, then call main handler
300 @
301 @ r0 - address of faulting instruction
302 @ r1 - pointer to registers on stack
303 @
304 mov r0, r2 @ address (pc)
305 mov r1, sp @ regs
306 bl do_PrefetchAbort @ call abort handler
307
308 @
309 @ IRQs off again before pulling preserved data off the stack
310 @
Russell King1ec42c02005-04-26 15:18:26 +0100311 disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
313 @
314 @ restore SPSR and restart the instruction
315 @
316 ldr r0, [sp, #S_PSR]
317 msr spsr_cxsf, r0
318 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
319
320 .align 5
Russell King49f680e2005-05-31 18:02:00 +0100321.LCcralign:
322 .word cr_alignment
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323#ifdef MULTI_ABORT
324.LCprocfns:
325 .word processor
326#endif
327.LCfp:
328 .word fp_enter
329#ifdef CONFIG_PREEMPT
330.LCirq_stat:
331 .word irq_stat
332#endif
333
334/*
335 * User mode handlers
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000336 *
337 * EABI note: sp_svc is always 64-bit aligned here, so should S_FRAME_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 */
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000339
340#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) && (S_FRAME_SIZE & 7)
341#error "sizeof(struct pt_regs) must be a multiple of 8"
342#endif
343
Russell Kingccea7a12005-05-31 22:22:32 +0100344 .macro usr_entry
345 sub sp, sp, #S_FRAME_SIZE
346 stmib sp, {r1 - r12}
347
348 ldmia r0, {r1 - r3}
349 add r0, sp, #S_PC @ here for interlock avoidance
350 mov r4, #-1 @ "" "" "" ""
351
352 str r1, [sp] @ save the "real" r0 copied
353 @ from the exception stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
355 @
356 @ We are now ready to fill in the remaining blanks on the stack:
357 @
358 @ r2 - lr_<exception>, already fixed up for correct return/restart
359 @ r3 - spsr_<exception>
360 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
361 @
362 @ Also, separately save sp_usr and lr_usr
363 @
Russell Kingccea7a12005-05-31 22:22:32 +0100364 stmia r0, {r2 - r4}
365 stmdb r0, {sp, lr}^
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
367 @
368 @ Enable the alignment trap while in kernel mode
369 @
Russell King49f680e2005-05-31 18:02:00 +0100370 alignment_trap r0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372 @
373 @ Clear FP to mark the first stack frame
374 @
375 zero_fp
376 .endm
377
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100378 .macro kuser_cmpxchg_check
379#if __LINUX_ARM_ARCH__ < 6 && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
380#ifndef CONFIG_MMU
381#warning "NPTL on non MMU needs fixing"
382#else
383 @ Make sure our user space atomic helper is restarted
384 @ if it was interrupted in a critical region. Here we
385 @ perform a quick test inline since it should be false
386 @ 99.9999% of the time. The rest is done out of line.
387 cmp r2, #TASK_SIZE
388 blhs kuser_cmpxchg_fixup
389#endif
390#endif
391 .endm
392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 .align 5
394__dabt_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100395 usr_entry
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100396 kuser_cmpxchg_check
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
398 @
399 @ Call the processor-specific abort handler:
400 @
401 @ r2 - aborted context pc
402 @ r3 - aborted context cpsr
403 @
404 @ The abort handler must return the aborted address in r0, and
405 @ the fault status register in r1.
406 @
407#ifdef MULTI_ABORT
408 ldr r4, .LCprocfns
409 mov lr, pc
410 ldr pc, [r4]
411#else
412 bl CPU_ABORT_HANDLER
413#endif
414
415 @
416 @ IRQs on, then call the main handler
417 @
Russell King1ec42c02005-04-26 15:18:26 +0100418 enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 mov r2, sp
420 adr lr, ret_from_exception
421 b do_DataAbort
422
423 .align 5
424__irq_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100425 usr_entry
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100426 kuser_cmpxchg_check
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427
Russell King7ad1bcb2006-08-27 12:07:02 +0100428#ifdef CONFIG_TRACE_IRQFLAGS
429 bl trace_hardirqs_off
430#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100433 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
434 add r7, r8, #1 @ increment it
435 str r7, [tsk, #TI_PREEMPT]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436#endif
Russell Kingccea7a12005-05-31 22:22:32 +0100437
Russell King187a51a2005-05-21 18:14:44 +0100438 irq_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100440 ldr r0, [tsk, #TI_PREEMPT]
441 str r8, [tsk, #TI_PREEMPT]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 teq r0, r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443 strne r0, [r0, -r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444#endif
Russell King7ad1bcb2006-08-27 12:07:02 +0100445#ifdef CONFIG_TRACE_IRQFLAGS
446 bl trace_hardirqs_on
447#endif
Russell Kingccea7a12005-05-31 22:22:32 +0100448
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 mov why, #0
450 b ret_to_user
451
452 .ltorg
453
454 .align 5
455__und_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100456 usr_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457
458 tst r3, #PSR_T_BIT @ Thumb mode?
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000459 bne __und_usr_unknown @ ignore FP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 sub r4, r2, #4
461
462 @
463 @ fall through to the emulation code, which returns using r9 if
464 @ it has emulated the instruction, or the more conventional lr
465 @ if we are to treat this as a real undefined instruction
466 @
467 @ r0 - instruction
468 @
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 adr r9, ret_from_exception
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000470 adr lr, __und_usr_unknown
Nicolas Pitred28a1702007-11-23 22:38:54 +01004711: ldrt r0, [r4]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 @
473 @ fallthrough to call_fpe
474 @
475
476/*
477 * The out of line fixup for the ldrt above.
478 */
479 .section .fixup, "ax"
4802: mov pc, r9
481 .previous
482 .section __ex_table,"a"
483 .long 1b, 2b
484 .previous
485
486/*
487 * Check whether the instruction is a co-processor instruction.
488 * If yes, we need to call the relevant co-processor handler.
489 *
490 * Note that we don't do a full check here for the co-processor
491 * instructions; all instructions with bit 27 set are well
492 * defined. The only instructions that should fault are the
493 * co-processor instructions. However, we have to watch out
494 * for the ARM6/ARM7 SWI bug.
495 *
496 * Emulators may wish to make use of the following registers:
497 * r0 = instruction opcode.
498 * r2 = PC+4
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000499 * r9 = normal "successful" return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 * r10 = this threads thread_info structure.
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000501 * lr = unrecognised instruction return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 */
503call_fpe:
504 tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27
505#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
506 and r8, r0, #0x0f000000 @ mask out op-code bits
507 teqne r8, #0x0f000000 @ SWI (ARM6/7 bug)?
508#endif
509 moveq pc, lr
510 get_thread_info r10 @ get current thread
511 and r8, r0, #0x00000f00 @ mask out CP number
512 mov r7, #1
513 add r6, r10, #TI_USED_CP
514 strb r7, [r6, r8, lsr #8] @ set appropriate used_cp[]
515#ifdef CONFIG_IWMMXT
516 @ Test if we need to give access to iWMMXt coprocessors
517 ldr r5, [r10, #TI_FLAGS]
518 rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only
519 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
520 bcs iwmmxt_task_enable
521#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 add pc, pc, r8, lsr #6
523 mov r0, r0
524
525 mov pc, lr @ CP#0
526 b do_fpe @ CP#1 (FPE)
527 b do_fpe @ CP#2 (FPE)
528 mov pc, lr @ CP#3
Lennert Buytenhekc17fad12006-06-27 23:03:03 +0100529#ifdef CONFIG_CRUNCH
530 b crunch_task_enable @ CP#4 (MaverickCrunch)
531 b crunch_task_enable @ CP#5 (MaverickCrunch)
532 b crunch_task_enable @ CP#6 (MaverickCrunch)
533#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 mov pc, lr @ CP#4
535 mov pc, lr @ CP#5
536 mov pc, lr @ CP#6
Lennert Buytenhekc17fad12006-06-27 23:03:03 +0100537#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 mov pc, lr @ CP#7
539 mov pc, lr @ CP#8
540 mov pc, lr @ CP#9
541#ifdef CONFIG_VFP
542 b do_vfp @ CP#10 (VFP)
543 b do_vfp @ CP#11 (VFP)
544#else
545 mov pc, lr @ CP#10 (VFP)
546 mov pc, lr @ CP#11 (VFP)
547#endif
548 mov pc, lr @ CP#12
549 mov pc, lr @ CP#13
550 mov pc, lr @ CP#14 (Debug)
551 mov pc, lr @ CP#15 (Control)
552
553do_fpe:
Russell King5d25ac02006-03-15 12:33:43 +0000554 enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 ldr r4, .LCfp
556 add r10, r10, #TI_FPSTATE @ r10 = workspace
557 ldr pc, [r4] @ Call FP module USR entry point
558
559/*
560 * The FP module is called with these registers set:
561 * r0 = instruction
562 * r2 = PC+4
563 * r9 = normal "successful" return address
564 * r10 = FP workspace
565 * lr = unrecognised FP instruction return address
566 */
567
568 .data
569ENTRY(fp_enter)
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000570 .word no_fp
Nicolas Pitre785d3cd2007-12-03 15:27:56 -0500571 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000573no_fp: mov pc, lr
574
575__und_usr_unknown:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 mov r0, sp
577 adr lr, ret_from_exception
578 b do_undefinstr
579
580 .align 5
581__pabt_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100582 usr_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583
Russell King1ec42c02005-04-26 15:18:26 +0100584 enable_irq @ Enable interrupts
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 mov r0, r2 @ address (pc)
586 mov r1, sp @ regs
587 bl do_PrefetchAbort @ call abort handler
588 /* fall through */
589/*
590 * This is the return code to user mode for abort handlers
591 */
592ENTRY(ret_from_exception)
593 get_thread_info tsk
594 mov why, #0
595 b ret_to_user
596
597/*
598 * Register switch for ARMv3 and ARMv4 processors
599 * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
600 * previous and next are guaranteed not to be the same.
601 */
602ENTRY(__switch_to)
603 add ip, r1, #TI_CPU_SAVE
604 ldr r3, [r2, #TI_TP_VALUE]
605 stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack
Russell Kingd6551e82006-06-21 13:31:52 +0100606#ifdef CONFIG_MMU
607 ldr r6, [r2, #TI_CPU_DOMAIN]
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000608#endif
Russell Kingb8763862005-08-10 14:52:52 +0100609#if __LINUX_ARM_ARCH__ >= 6
Russell King43cc1982006-02-22 21:13:28 +0000610#ifdef CONFIG_CPU_32v6K
Russell Kingb8763862005-08-10 14:52:52 +0100611 clrex
612#else
Russell King73394322005-09-23 21:49:58 +0100613 strex r5, r4, [ip] @ Clear exclusive monitor
Russell Kingb8763862005-08-10 14:52:52 +0100614#endif
615#endif
Nicolas Pitre4b0e07a2005-05-05 23:24:45 +0100616#if defined(CONFIG_HAS_TLS_REG)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100617 mcr p15, 0, r3, c13, c0, 3 @ set TLS register
Nicolas Pitre4b0e07a2005-05-05 23:24:45 +0100618#elif !defined(CONFIG_TLS_REG_EMUL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 mov r4, #0xffff0fff
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100620 str r3, [r4, #-15] @ TLS val at 0xffff0ff0
621#endif
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000622#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000624#endif
Russell Kingd6551e82006-06-21 13:31:52 +0100625 mov r5, r0
626 add r4, r2, #TI_CPU_SAVE
627 ldr r0, =thread_notify_head
628 mov r1, #THREAD_NOTIFY_SWITCH
629 bl atomic_notifier_call_chain
630 mov r0, r5
631 ldmia r4, {r4 - sl, fp, sp, pc} @ Load all regs saved previously
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632
633 __INIT
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100634
635/*
636 * User helpers.
637 *
638 * These are segment of kernel provided user code reachable from user space
639 * at a fixed address in kernel memory. This is used to provide user space
640 * with some operations which require kernel help because of unimplemented
641 * native feature and/or instructions in many ARM CPUs. The idea is for
642 * this code to be executed directly in user mode for best efficiency but
643 * which is too intimate with the kernel counter part to be left to user
644 * libraries. In fact this code might even differ from one CPU to another
645 * depending on the available instruction set and restrictions like on
646 * SMP systems. In other words, the kernel reserves the right to change
647 * this code as needed without warning. Only the entry points and their
648 * results are guaranteed to be stable.
649 *
650 * Each segment is 32-byte aligned and will be moved to the top of the high
651 * vector page. New segments (if ever needed) must be added in front of
652 * existing ones. This mechanism should be used only for things that are
653 * really small and justified, and not be abused freely.
654 *
655 * User space is expected to implement those things inline when optimizing
656 * for a processor that has the necessary native support, but only if such
657 * resulting binaries are already to be incompatible with earlier ARM
658 * processors due to the use of unsupported instructions other than what
659 * is provided here. In other words don't make binaries unable to run on
660 * earlier processors just for the sake of not using these kernel helpers
661 * if your compiled code is not going to use the new instructions for other
662 * purpose.
663 */
664
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100665 .macro usr_ret, reg
666#ifdef CONFIG_ARM_THUMB
667 bx \reg
668#else
669 mov pc, \reg
670#endif
671 .endm
672
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100673 .align 5
674 .globl __kuser_helper_start
675__kuser_helper_start:
676
677/*
678 * Reference prototype:
679 *
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000680 * void __kernel_memory_barrier(void)
681 *
682 * Input:
683 *
684 * lr = return address
685 *
686 * Output:
687 *
688 * none
689 *
690 * Clobbered:
691 *
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100692 * none
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000693 *
694 * Definition and user space usage example:
695 *
696 * typedef void (__kernel_dmb_t)(void);
697 * #define __kernel_dmb (*(__kernel_dmb_t *)0xffff0fa0)
698 *
699 * Apply any needed memory barrier to preserve consistency with data modified
700 * manually and __kuser_cmpxchg usage.
701 *
702 * This could be used as follows:
703 *
704 * #define __kernel_dmb() \
705 * asm volatile ( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #95" \
Paul Brook6896eec2006-03-28 22:19:29 +0100706 * : : : "r0", "lr","cc" )
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000707 */
708
709__kuser_memory_barrier: @ 0xffff0fa0
710
711#if __LINUX_ARM_ARCH__ >= 6 && defined(CONFIG_SMP)
712 mcr p15, 0, r0, c7, c10, 5 @ dmb
713#endif
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100714 usr_ret lr
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000715
716 .align 5
717
718/*
719 * Reference prototype:
720 *
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100721 * int __kernel_cmpxchg(int oldval, int newval, int *ptr)
722 *
723 * Input:
724 *
725 * r0 = oldval
726 * r1 = newval
727 * r2 = ptr
728 * lr = return address
729 *
730 * Output:
731 *
732 * r0 = returned value (zero or non-zero)
733 * C flag = set if r0 == 0, clear if r0 != 0
734 *
735 * Clobbered:
736 *
737 * r3, ip, flags
738 *
739 * Definition and user space usage example:
740 *
741 * typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
742 * #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
743 *
744 * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
745 * Return zero if *ptr was changed or non-zero if no exchange happened.
746 * The C flag is also set if *ptr was changed to allow for assembly
747 * optimization in the calling code.
748 *
Nicolas Pitre5964eae2006-02-08 21:19:37 +0000749 * Notes:
750 *
751 * - This routine already includes memory barriers as needed.
752 *
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100753 * For example, a user space atomic_add implementation could look like this:
754 *
755 * #define atomic_add(ptr, val) \
756 * ({ register unsigned int *__ptr asm("r2") = (ptr); \
757 * register unsigned int __result asm("r1"); \
758 * asm volatile ( \
759 * "1: @ atomic_add\n\t" \
760 * "ldr r0, [r2]\n\t" \
761 * "mov r3, #0xffff0fff\n\t" \
762 * "add lr, pc, #4\n\t" \
763 * "add r1, r0, %2\n\t" \
764 * "add pc, r3, #(0xffff0fc0 - 0xffff0fff)\n\t" \
765 * "bcc 1b" \
766 * : "=&r" (__result) \
767 * : "r" (__ptr), "rIL" (val) \
768 * : "r0","r3","ip","lr","cc","memory" ); \
769 * __result; })
770 */
771
772__kuser_cmpxchg: @ 0xffff0fc0
773
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100774#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100775
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100776 /*
777 * Poor you. No fast solution possible...
778 * The kernel itself must perform the operation.
779 * A special ghost syscall is used for that (see traps.c).
780 */
Nicolas Pitre5e097442006-01-18 22:38:49 +0000781 stmfd sp!, {r7, lr}
782 mov r7, #0xff00 @ 0xfff0 into r7 for EABI
783 orr r7, r7, #0xf0
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100784 swi #0x9ffff0
Nicolas Pitre5e097442006-01-18 22:38:49 +0000785 ldmfd sp!, {r7, pc}
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100786
787#elif __LINUX_ARM_ARCH__ < 6
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100788
Nicolas Pitre49bca4c2006-02-08 21:19:37 +0000789#ifdef CONFIG_MMU
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100790
791 /*
792 * The only thing that can break atomicity in this cmpxchg
793 * implementation is either an IRQ or a data abort exception
794 * causing another process/thread to be scheduled in the middle
795 * of the critical sequence. To prevent this, code is added to
796 * the IRQ and data abort exception handlers to set the pc back
797 * to the beginning of the critical section if it is found to be
798 * within that critical section (see kuser_cmpxchg_fixup).
799 */
8001: ldr r3, [r2] @ load current val
801 subs r3, r3, r0 @ compare with oldval
8022: streq r1, [r2] @ store newval if eq
803 rsbs r0, r3, #0 @ set return val and C flag
804 usr_ret lr
805
806 .text
807kuser_cmpxchg_fixup:
808 @ Called from kuser_cmpxchg_check macro.
809 @ r2 = address of interrupted insn (must be preserved).
810 @ sp = saved regs. r7 and r8 are clobbered.
811 @ 1b = first critical insn, 2b = last critical insn.
812 @ If r2 >= 1b and r2 <= 2b then saved pc_usr is set to 1b.
813 mov r7, #0xffff0fff
814 sub r7, r7, #(0xffff0fff - (0xffff0fc0 + (1b - __kuser_cmpxchg)))
815 subs r8, r2, r7
816 rsbcss r8, r8, #(2b - 1b)
817 strcs r7, [sp, #S_PC]
818 mov pc, lr
819 .previous
820
Nicolas Pitre49bca4c2006-02-08 21:19:37 +0000821#else
822#warning "NPTL on non MMU needs fixing"
823 mov r0, #-1
824 adds r0, r0, #0
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100825 usr_ret lr
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100826#endif
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100827
828#else
829
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000830#ifdef CONFIG_SMP
831 mcr p15, 0, r0, c7, c10, 5 @ dmb
832#endif
Nicolas Pitreb49c0f22007-11-20 17:20:29 +01008331: ldrex r3, [r2]
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100834 subs r3, r3, r0
835 strexeq r3, r1, [r2]
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100836 teqeq r3, #1
837 beq 1b
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100838 rsbs r0, r3, #0
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100839 /* beware -- each __kuser slot must be 8 instructions max */
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000840#ifdef CONFIG_SMP
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100841 b __kuser_memory_barrier
842#else
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100843 usr_ret lr
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100844#endif
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100845
846#endif
847
848 .align 5
849
850/*
851 * Reference prototype:
852 *
853 * int __kernel_get_tls(void)
854 *
855 * Input:
856 *
857 * lr = return address
858 *
859 * Output:
860 *
861 * r0 = TLS value
862 *
863 * Clobbered:
864 *
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100865 * none
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100866 *
867 * Definition and user space usage example:
868 *
869 * typedef int (__kernel_get_tls_t)(void);
870 * #define __kernel_get_tls (*(__kernel_get_tls_t *)0xffff0fe0)
871 *
872 * Get the TLS value as previously set via the __ARM_NR_set_tls syscall.
873 *
874 * This could be used as follows:
875 *
876 * #define __kernel_get_tls() \
877 * ({ register unsigned int __val asm("r0"); \
878 * asm( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #31" \
879 * : "=r" (__val) : : "lr","cc" ); \
880 * __val; })
881 */
882
883__kuser_get_tls: @ 0xffff0fe0
884
Nicolas Pitre4b0e07a2005-05-05 23:24:45 +0100885#if !defined(CONFIG_HAS_TLS_REG) && !defined(CONFIG_TLS_REG_EMUL)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100886 ldr r0, [pc, #(16 - 8)] @ TLS stored at 0xffff0ff0
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100887#else
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100888 mrc p15, 0, r0, c13, c0, 3 @ read TLS register
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100889#endif
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100890 usr_ret lr
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100891
892 .rep 5
893 .word 0 @ pad up to __kuser_helper_version
894 .endr
895
896/*
897 * Reference declaration:
898 *
899 * extern unsigned int __kernel_helper_version;
900 *
901 * Definition and user space usage example:
902 *
903 * #define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
904 *
905 * User space may read this to determine the curent number of helpers
906 * available.
907 */
908
909__kuser_helper_version: @ 0xffff0ffc
910 .word ((__kuser_helper_end - __kuser_helper_start) >> 5)
911
912 .globl __kuser_helper_end
913__kuser_helper_end:
914
915
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916/*
917 * Vector stubs.
918 *
Russell King79335232005-04-26 15:17:42 +0100919 * This code is copied to 0xffff0200 so we can use branches in the
920 * vectors, rather than ldr's. Note that this code must not
921 * exceed 0x300 bytes.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 *
923 * Common stub entry macro:
924 * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
Russell Kingccea7a12005-05-31 22:22:32 +0100925 *
926 * SP points to a minimal amount of processor-private memory, the address
927 * of which is copied into r0 for the mode specific abort handler.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000929 .macro vector_stub, name, mode, correction=0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 .align 5
931
932vector_\name:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 .if \correction
934 sub lr, lr, #\correction
935 .endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936
Russell Kingccea7a12005-05-31 22:22:32 +0100937 @
938 @ Save r0, lr_<exception> (parent PC) and spsr_<exception>
939 @ (parent CPSR)
940 @
941 stmia sp, {r0, lr} @ save r0, lr
942 mrs lr, spsr
943 str lr, [sp, #8] @ save spsr
944
945 @
946 @ Prepare for SVC32 mode. IRQs remain disabled.
947 @
948 mrs r0, cpsr
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000949 eor r0, r0, #(\mode ^ SVC_MODE)
Russell Kingccea7a12005-05-31 22:22:32 +0100950 msr spsr_cxsf, r0
951
952 @
953 @ the branch table must immediately follow this code
954 @
Russell Kingccea7a12005-05-31 22:22:32 +0100955 and lr, lr, #0x0f
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000956 mov r0, sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 ldr lr, [pc, lr, lsl #2]
Russell Kingccea7a12005-05-31 22:22:32 +0100958 movs pc, lr @ branch to handler in SVC mode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 .endm
960
Russell King79335232005-04-26 15:17:42 +0100961 .globl __stubs_start
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962__stubs_start:
963/*
964 * Interrupt dispatcher
965 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000966 vector_stub irq, IRQ_MODE, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967
968 .long __irq_usr @ 0 (USR_26 / USR_32)
969 .long __irq_invalid @ 1 (FIQ_26 / FIQ_32)
970 .long __irq_invalid @ 2 (IRQ_26 / IRQ_32)
971 .long __irq_svc @ 3 (SVC_26 / SVC_32)
972 .long __irq_invalid @ 4
973 .long __irq_invalid @ 5
974 .long __irq_invalid @ 6
975 .long __irq_invalid @ 7
976 .long __irq_invalid @ 8
977 .long __irq_invalid @ 9
978 .long __irq_invalid @ a
979 .long __irq_invalid @ b
980 .long __irq_invalid @ c
981 .long __irq_invalid @ d
982 .long __irq_invalid @ e
983 .long __irq_invalid @ f
984
985/*
986 * Data abort dispatcher
987 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
988 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000989 vector_stub dabt, ABT_MODE, 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990
991 .long __dabt_usr @ 0 (USR_26 / USR_32)
992 .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32)
993 .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32)
994 .long __dabt_svc @ 3 (SVC_26 / SVC_32)
995 .long __dabt_invalid @ 4
996 .long __dabt_invalid @ 5
997 .long __dabt_invalid @ 6
998 .long __dabt_invalid @ 7
999 .long __dabt_invalid @ 8
1000 .long __dabt_invalid @ 9
1001 .long __dabt_invalid @ a
1002 .long __dabt_invalid @ b
1003 .long __dabt_invalid @ c
1004 .long __dabt_invalid @ d
1005 .long __dabt_invalid @ e
1006 .long __dabt_invalid @ f
1007
1008/*
1009 * Prefetch abort dispatcher
1010 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
1011 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001012 vector_stub pabt, ABT_MODE, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013
1014 .long __pabt_usr @ 0 (USR_26 / USR_32)
1015 .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32)
1016 .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32)
1017 .long __pabt_svc @ 3 (SVC_26 / SVC_32)
1018 .long __pabt_invalid @ 4
1019 .long __pabt_invalid @ 5
1020 .long __pabt_invalid @ 6
1021 .long __pabt_invalid @ 7
1022 .long __pabt_invalid @ 8
1023 .long __pabt_invalid @ 9
1024 .long __pabt_invalid @ a
1025 .long __pabt_invalid @ b
1026 .long __pabt_invalid @ c
1027 .long __pabt_invalid @ d
1028 .long __pabt_invalid @ e
1029 .long __pabt_invalid @ f
1030
1031/*
1032 * Undef instr entry dispatcher
1033 * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
1034 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001035 vector_stub und, UND_MODE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036
1037 .long __und_usr @ 0 (USR_26 / USR_32)
1038 .long __und_invalid @ 1 (FIQ_26 / FIQ_32)
1039 .long __und_invalid @ 2 (IRQ_26 / IRQ_32)
1040 .long __und_svc @ 3 (SVC_26 / SVC_32)
1041 .long __und_invalid @ 4
1042 .long __und_invalid @ 5
1043 .long __und_invalid @ 6
1044 .long __und_invalid @ 7
1045 .long __und_invalid @ 8
1046 .long __und_invalid @ 9
1047 .long __und_invalid @ a
1048 .long __und_invalid @ b
1049 .long __und_invalid @ c
1050 .long __und_invalid @ d
1051 .long __und_invalid @ e
1052 .long __und_invalid @ f
1053
1054 .align 5
1055
1056/*=============================================================================
1057 * Undefined FIQs
1058 *-----------------------------------------------------------------------------
1059 * Enter in FIQ mode, spsr = ANY CPSR, lr = ANY PC
1060 * MUST PRESERVE SVC SPSR, but need to switch to SVC mode to show our msg.
1061 * Basically to switch modes, we *HAVE* to clobber one register... brain
1062 * damage alert! I don't think that we can execute any code in here in any
1063 * other mode than FIQ... Ok you can switch to another mode, but you can't
1064 * get out of that mode without clobbering one register.
1065 */
1066vector_fiq:
1067 disable_fiq
1068 subs pc, lr, #4
1069
1070/*=============================================================================
1071 * Address exception handler
1072 *-----------------------------------------------------------------------------
1073 * These aren't too critical.
1074 * (they're not supposed to happen, and won't happen in 32-bit data mode).
1075 */
1076
1077vector_addrexcptn:
1078 b vector_addrexcptn
1079
1080/*
1081 * We group all the following data together to optimise
1082 * for CPUs with separate I & D caches.
1083 */
1084 .align 5
1085
1086.LCvswi:
1087 .word vector_swi
1088
Russell King79335232005-04-26 15:17:42 +01001089 .globl __stubs_end
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090__stubs_end:
1091
Russell King79335232005-04-26 15:17:42 +01001092 .equ stubs_offset, __vectors_start + 0x200 - __stubs_start
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093
Russell King79335232005-04-26 15:17:42 +01001094 .globl __vectors_start
1095__vectors_start:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 swi SYS_ERROR0
Russell King79335232005-04-26 15:17:42 +01001097 b vector_und + stubs_offset
1098 ldr pc, .LCvswi + stubs_offset
1099 b vector_pabt + stubs_offset
1100 b vector_dabt + stubs_offset
1101 b vector_addrexcptn + stubs_offset
1102 b vector_irq + stubs_offset
1103 b vector_fiq + stubs_offset
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104
Russell King79335232005-04-26 15:17:42 +01001105 .globl __vectors_end
1106__vectors_end:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107
1108 .data
1109
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .globl cr_alignment
1111 .globl cr_no_alignment
1112cr_alignment:
1113 .space 4
1114cr_no_alignment:
1115 .space 4