blob: 8de21f51e48cc1f4988ba5ad2d5ac75240fab37a [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
61/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 * Invalid mode handlers
63 */
Russell Kingccea7a12005-05-31 22:22:32 +010064 .macro inv_entry, reason
65 sub sp, sp, #S_FRAME_SIZE
66 stmib sp, {r1 - lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 mov r1, #\reason
68 .endm
69
70__pabt_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010071 inv_entry BAD_PREFETCH
72 b common_invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74__dabt_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010075 inv_entry BAD_DATA
76 b common_invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78__irq_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010079 inv_entry BAD_IRQ
80 b common_invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82__und_invalid:
Russell Kingccea7a12005-05-31 22:22:32 +010083 inv_entry BAD_UNDEFINSTR
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Russell Kingccea7a12005-05-31 22:22:32 +010085 @
86 @ XXX fall through to common_invalid
87 @
88
89@
90@ common_invalid - generic code for failed exception (re-entrant version of handlers)
91@
92common_invalid:
93 zero_fp
94
95 ldmia r0, {r4 - r6}
96 add r0, sp, #S_PC @ here for interlock avoidance
97 mov r7, #-1 @ "" "" "" ""
98 str r4, [sp] @ save preserved r0
99 stmia r0, {r5 - r7} @ lr_<exception>,
100 @ cpsr_<exception>, "old_r0"
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 mov r0, sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 b bad_mode
104
105/*
106 * SVC mode handlers
107 */
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000108
109#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5)
110#define SPFIX(code...) code
111#else
112#define SPFIX(code...)
113#endif
114
Russell Kingccea7a12005-05-31 22:22:32 +0100115 .macro svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 sub sp, sp, #S_FRAME_SIZE
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000117 SPFIX( tst sp, #4 )
118 SPFIX( bicne sp, sp, #4 )
Russell Kingccea7a12005-05-31 22:22:32 +0100119 stmib sp, {r1 - r12}
120
121 ldmia r0, {r1 - r3}
122 add r5, sp, #S_SP @ here for interlock avoidance
123 mov r4, #-1 @ "" "" "" ""
124 add r0, sp, #S_FRAME_SIZE @ "" "" "" ""
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000125 SPFIX( addne r0, r0, #4 )
Russell Kingccea7a12005-05-31 22:22:32 +0100126 str r1, [sp] @ save the "real" r0 copied
127 @ from the exception stack
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 mov r1, lr
130
131 @
132 @ We are now ready to fill in the remaining blanks on the stack:
133 @
134 @ r0 - sp_svc
135 @ r1 - lr_svc
136 @ r2 - lr_<exception>, already fixed up for correct return/restart
137 @ r3 - spsr_<exception>
138 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
139 @
140 stmia r5, {r0 - r4}
141 .endm
142
143 .align 5
144__dabt_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100145 svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147 @
148 @ get ready to re-enable interrupts if appropriate
149 @
150 mrs r9, cpsr
151 tst r3, #PSR_I_BIT
152 biceq r9, r9, #PSR_I_BIT
153
154 @
155 @ Call the processor-specific abort handler:
156 @
157 @ r2 - aborted context pc
158 @ r3 - aborted context cpsr
159 @
160 @ The abort handler must return the aborted address in r0, and
161 @ the fault status register in r1. r9 must be preserved.
162 @
163#ifdef MULTI_ABORT
164 ldr r4, .LCprocfns
165 mov lr, pc
166 ldr pc, [r4]
167#else
168 bl CPU_ABORT_HANDLER
169#endif
170
171 @
172 @ set desired IRQ state, then call main handler
173 @
174 msr cpsr_c, r9
175 mov r2, sp
176 bl do_DataAbort
177
178 @
179 @ IRQs off again before pulling preserved data off the stack
180 @
Russell King1ec42c02005-04-26 15:18:26 +0100181 disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 @
184 @ restore SPSR and restart the instruction
185 @
186 ldr r0, [sp, #S_PSR]
187 msr spsr_cxsf, r0
188 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
189
190 .align 5
191__irq_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100192 svc_entry
193
Russell King7ad1bcb2006-08-27 12:07:02 +0100194#ifdef CONFIG_TRACE_IRQFLAGS
195 bl trace_hardirqs_off
196#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100198 get_thread_info tsk
199 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
200 add r7, r8, #1 @ increment it
201 str r7, [tsk, #TI_PREEMPT]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202#endif
Russell Kingccea7a12005-05-31 22:22:32 +0100203
Russell King187a51a2005-05-21 18:14:44 +0100204 irq_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100206 ldr r0, [tsk, #TI_FLAGS] @ get flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 tst r0, #_TIF_NEED_RESCHED
208 blne svc_preempt
209preempt_return:
Russell King706fdd92005-05-21 18:15:45 +0100210 ldr r0, [tsk, #TI_PREEMPT] @ read preempt value
211 str r8, [tsk, #TI_PREEMPT] @ restore preempt count
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 teq r0, r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 strne r0, [r0, -r0] @ bug()
214#endif
215 ldr r0, [sp, #S_PSR] @ irqs are already disabled
216 msr spsr_cxsf, r0
Russell King7ad1bcb2006-08-27 12:07:02 +0100217#ifdef CONFIG_TRACE_IRQFLAGS
218 tst r0, #PSR_I_BIT
219 bleq trace_hardirqs_on
220#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
222
223 .ltorg
224
225#ifdef CONFIG_PREEMPT
226svc_preempt:
Russell King706fdd92005-05-21 18:15:45 +0100227 teq r8, #0 @ was preempt count = 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 ldreq r6, .LCirq_stat
229 movne pc, lr @ no
230 ldr r0, [r6, #4] @ local_irq_count
231 ldr r1, [r6, #8] @ local_bh_count
232 adds r0, r0, r1
233 movne pc, lr
234 mov r7, #0 @ preempt_schedule_irq
Russell King706fdd92005-05-21 18:15:45 +0100235 str r7, [tsk, #TI_PREEMPT] @ expects preempt_count == 0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361: bl preempt_schedule_irq @ irq en/disable is done inside
Russell King706fdd92005-05-21 18:15:45 +0100237 ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 tst r0, #_TIF_NEED_RESCHED
239 beq preempt_return @ go again
240 b 1b
241#endif
242
243 .align 5
244__und_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100245 svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247 @
248 @ call emulation code, which returns using r9 if it has emulated
249 @ the instruction, or the more conventional lr if we are to treat
250 @ this as a real undefined instruction
251 @
252 @ r0 - instruction
253 @
254 ldr r0, [r2, #-4]
255 adr r9, 1f
256 bl call_fpe
257
258 mov r0, sp @ struct pt_regs *regs
259 bl do_undefinstr
260
261 @
262 @ IRQs off again before pulling preserved data off the stack
263 @
Russell King1ec42c02005-04-26 15:18:26 +01002641: disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266 @
267 @ restore SPSR and restart the instruction
268 @
269 ldr lr, [sp, #S_PSR] @ Get SVC cpsr
270 msr spsr_cxsf, lr
271 ldmia sp, {r0 - pc}^ @ Restore SVC registers
272
273 .align 5
274__pabt_svc:
Russell Kingccea7a12005-05-31 22:22:32 +0100275 svc_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277 @
278 @ re-enable interrupts if appropriate
279 @
280 mrs r9, cpsr
281 tst r3, #PSR_I_BIT
282 biceq r9, r9, #PSR_I_BIT
283 msr cpsr_c, r9
284
285 @
286 @ set args, then call main handler
287 @
288 @ r0 - address of faulting instruction
289 @ r1 - pointer to registers on stack
290 @
291 mov r0, r2 @ address (pc)
292 mov r1, sp @ regs
293 bl do_PrefetchAbort @ call abort handler
294
295 @
296 @ IRQs off again before pulling preserved data off the stack
297 @
Russell King1ec42c02005-04-26 15:18:26 +0100298 disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
300 @
301 @ restore SPSR and restart the instruction
302 @
303 ldr r0, [sp, #S_PSR]
304 msr spsr_cxsf, r0
305 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
306
307 .align 5
Russell King49f680e2005-05-31 18:02:00 +0100308.LCcralign:
309 .word cr_alignment
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310#ifdef MULTI_ABORT
311.LCprocfns:
312 .word processor
313#endif
314.LCfp:
315 .word fp_enter
316#ifdef CONFIG_PREEMPT
317.LCirq_stat:
318 .word irq_stat
319#endif
320
321/*
322 * User mode handlers
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000323 *
324 * EABI note: sp_svc is always 64-bit aligned here, so should S_FRAME_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 */
Nicolas Pitre2dede2d2006-01-14 16:18:08 +0000326
327#if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) && (S_FRAME_SIZE & 7)
328#error "sizeof(struct pt_regs) must be a multiple of 8"
329#endif
330
Russell Kingccea7a12005-05-31 22:22:32 +0100331 .macro usr_entry
332 sub sp, sp, #S_FRAME_SIZE
333 stmib sp, {r1 - r12}
334
335 ldmia r0, {r1 - r3}
336 add r0, sp, #S_PC @ here for interlock avoidance
337 mov r4, #-1 @ "" "" "" ""
338
339 str r1, [sp] @ save the "real" r0 copied
340 @ from the exception stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
342 @
343 @ We are now ready to fill in the remaining blanks on the stack:
344 @
345 @ r2 - lr_<exception>, already fixed up for correct return/restart
346 @ r3 - spsr_<exception>
347 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
348 @
349 @ Also, separately save sp_usr and lr_usr
350 @
Russell Kingccea7a12005-05-31 22:22:32 +0100351 stmia r0, {r2 - r4}
352 stmdb r0, {sp, lr}^
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 @
355 @ Enable the alignment trap while in kernel mode
356 @
Russell King49f680e2005-05-31 18:02:00 +0100357 alignment_trap r0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359 @
360 @ Clear FP to mark the first stack frame
361 @
362 zero_fp
363 .endm
364
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100365 .macro kuser_cmpxchg_check
366#if __LINUX_ARM_ARCH__ < 6 && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
367#ifndef CONFIG_MMU
368#warning "NPTL on non MMU needs fixing"
369#else
370 @ Make sure our user space atomic helper is restarted
371 @ if it was interrupted in a critical region. Here we
372 @ perform a quick test inline since it should be false
373 @ 99.9999% of the time. The rest is done out of line.
374 cmp r2, #TASK_SIZE
375 blhs kuser_cmpxchg_fixup
376#endif
377#endif
378 .endm
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 .align 5
381__dabt_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100382 usr_entry
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100383 kuser_cmpxchg_check
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385 @
386 @ Call the processor-specific abort handler:
387 @
388 @ r2 - aborted context pc
389 @ r3 - aborted context cpsr
390 @
391 @ The abort handler must return the aborted address in r0, and
392 @ the fault status register in r1.
393 @
394#ifdef MULTI_ABORT
395 ldr r4, .LCprocfns
396 mov lr, pc
397 ldr pc, [r4]
398#else
399 bl CPU_ABORT_HANDLER
400#endif
401
402 @
403 @ IRQs on, then call the main handler
404 @
Russell King1ec42c02005-04-26 15:18:26 +0100405 enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 mov r2, sp
407 adr lr, ret_from_exception
408 b do_DataAbort
409
410 .align 5
411__irq_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100412 usr_entry
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100413 kuser_cmpxchg_check
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
Russell King7ad1bcb2006-08-27 12:07:02 +0100415#ifdef CONFIG_TRACE_IRQFLAGS
416 bl trace_hardirqs_off
417#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 get_thread_info tsk
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100420 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
421 add r7, r8, #1 @ increment it
422 str r7, [tsk, #TI_PREEMPT]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423#endif
Russell Kingccea7a12005-05-31 22:22:32 +0100424
Russell King187a51a2005-05-21 18:14:44 +0100425 irq_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426#ifdef CONFIG_PREEMPT
Russell King706fdd92005-05-21 18:15:45 +0100427 ldr r0, [tsk, #TI_PREEMPT]
428 str r8, [tsk, #TI_PREEMPT]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 teq r0, r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 strne r0, [r0, -r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431#endif
Russell King7ad1bcb2006-08-27 12:07:02 +0100432#ifdef CONFIG_TRACE_IRQFLAGS
433 bl trace_hardirqs_on
434#endif
Russell Kingccea7a12005-05-31 22:22:32 +0100435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 mov why, #0
437 b ret_to_user
438
439 .ltorg
440
441 .align 5
442__und_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100443 usr_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
445 tst r3, #PSR_T_BIT @ Thumb mode?
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000446 bne __und_usr_unknown @ ignore FP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 sub r4, r2, #4
448
449 @
450 @ fall through to the emulation code, which returns using r9 if
451 @ it has emulated the instruction, or the more conventional lr
452 @ if we are to treat this as a real undefined instruction
453 @
454 @ r0 - instruction
455 @
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 adr r9, ret_from_exception
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000457 adr lr, __und_usr_unknown
Nicolas Pitred28a1702007-11-23 22:38:54 +01004581: ldrt r0, [r4]
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 @
460 @ fallthrough to call_fpe
461 @
462
463/*
464 * The out of line fixup for the ldrt above.
465 */
466 .section .fixup, "ax"
4672: mov pc, r9
468 .previous
469 .section __ex_table,"a"
470 .long 1b, 2b
471 .previous
472
473/*
474 * Check whether the instruction is a co-processor instruction.
475 * If yes, we need to call the relevant co-processor handler.
476 *
477 * Note that we don't do a full check here for the co-processor
478 * instructions; all instructions with bit 27 set are well
479 * defined. The only instructions that should fault are the
480 * co-processor instructions. However, we have to watch out
481 * for the ARM6/ARM7 SWI bug.
482 *
Catalin Marinasb5872db2008-01-10 19:16:17 +0100483 * NEON is a special case that has to be handled here. Not all
484 * NEON instructions are co-processor instructions, so we have
485 * to make a special case of checking for them. Plus, there's
486 * five groups of them, so we have a table of mask/opcode pairs
487 * to check against, and if any match then we branch off into the
488 * NEON handler code.
489 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 * Emulators may wish to make use of the following registers:
491 * r0 = instruction opcode.
492 * r2 = PC+4
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000493 * r9 = normal "successful" return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 * r10 = this threads thread_info structure.
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000495 * lr = unrecognised instruction return address
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 */
497call_fpe:
Catalin Marinasb5872db2008-01-10 19:16:17 +0100498#ifdef CONFIG_NEON
499 adr r6, .LCneon_opcodes
5002:
501 ldr r7, [r6], #4 @ mask value
502 cmp r7, #0 @ end mask?
503 beq 1f
504 and r8, r0, r7
505 ldr r7, [r6], #4 @ opcode bits matching in mask
506 cmp r8, r7 @ NEON instruction?
507 bne 2b
508 get_thread_info r10
509 mov r7, #1
510 strb r7, [r10, #TI_USED_CP + 10] @ mark CP#10 as used
511 strb r7, [r10, #TI_USED_CP + 11] @ mark CP#11 as used
512 b do_vfp @ let VFP handler handle this
5131:
514#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27
516#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
517 and r8, r0, #0x0f000000 @ mask out op-code bits
518 teqne r8, #0x0f000000 @ SWI (ARM6/7 bug)?
519#endif
520 moveq pc, lr
521 get_thread_info r10 @ get current thread
522 and r8, r0, #0x00000f00 @ mask out CP number
523 mov r7, #1
524 add r6, r10, #TI_USED_CP
525 strb r7, [r6, r8, lsr #8] @ set appropriate used_cp[]
526#ifdef CONFIG_IWMMXT
527 @ Test if we need to give access to iWMMXt coprocessors
528 ldr r5, [r10, #TI_FLAGS]
529 rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only
530 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
531 bcs iwmmxt_task_enable
532#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 add pc, pc, r8, lsr #6
534 mov r0, r0
535
536 mov pc, lr @ CP#0
537 b do_fpe @ CP#1 (FPE)
538 b do_fpe @ CP#2 (FPE)
539 mov pc, lr @ CP#3
Lennert Buytenhekc17fad12006-06-27 23:03:03 +0100540#ifdef CONFIG_CRUNCH
541 b crunch_task_enable @ CP#4 (MaverickCrunch)
542 b crunch_task_enable @ CP#5 (MaverickCrunch)
543 b crunch_task_enable @ CP#6 (MaverickCrunch)
544#else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 mov pc, lr @ CP#4
546 mov pc, lr @ CP#5
547 mov pc, lr @ CP#6
Lennert Buytenhekc17fad12006-06-27 23:03:03 +0100548#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 mov pc, lr @ CP#7
550 mov pc, lr @ CP#8
551 mov pc, lr @ CP#9
552#ifdef CONFIG_VFP
553 b do_vfp @ CP#10 (VFP)
554 b do_vfp @ CP#11 (VFP)
555#else
556 mov pc, lr @ CP#10 (VFP)
557 mov pc, lr @ CP#11 (VFP)
558#endif
559 mov pc, lr @ CP#12
560 mov pc, lr @ CP#13
561 mov pc, lr @ CP#14 (Debug)
562 mov pc, lr @ CP#15 (Control)
563
Catalin Marinasb5872db2008-01-10 19:16:17 +0100564#ifdef CONFIG_NEON
565 .align 6
566
567.LCneon_opcodes:
568 .word 0xfe000000 @ mask
569 .word 0xf2000000 @ opcode
570
571 .word 0xff100000 @ mask
572 .word 0xf4000000 @ opcode
573
574 .word 0x00000000 @ mask
575 .word 0x00000000 @ opcode
576#endif
577
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578do_fpe:
Russell King5d25ac02006-03-15 12:33:43 +0000579 enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 ldr r4, .LCfp
581 add r10, r10, #TI_FPSTATE @ r10 = workspace
582 ldr pc, [r4] @ Call FP module USR entry point
583
584/*
585 * The FP module is called with these registers set:
586 * r0 = instruction
587 * r2 = PC+4
588 * r9 = normal "successful" return address
589 * r10 = FP workspace
590 * lr = unrecognised FP instruction return address
591 */
592
593 .data
594ENTRY(fp_enter)
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000595 .word no_fp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 .text
597
Russell Kingdb6ccbb2007-01-06 22:53:48 +0000598no_fp: mov pc, lr
599
600__und_usr_unknown:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 mov r0, sp
602 adr lr, ret_from_exception
603 b do_undefinstr
604
605 .align 5
606__pabt_usr:
Russell Kingccea7a12005-05-31 22:22:32 +0100607 usr_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608
Russell King1ec42c02005-04-26 15:18:26 +0100609 enable_irq @ Enable interrupts
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 mov r0, r2 @ address (pc)
611 mov r1, sp @ regs
612 bl do_PrefetchAbort @ call abort handler
613 /* fall through */
614/*
615 * This is the return code to user mode for abort handlers
616 */
617ENTRY(ret_from_exception)
618 get_thread_info tsk
619 mov why, #0
620 b ret_to_user
621
622/*
623 * Register switch for ARMv3 and ARMv4 processors
624 * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
625 * previous and next are guaranteed not to be the same.
626 */
627ENTRY(__switch_to)
628 add ip, r1, #TI_CPU_SAVE
629 ldr r3, [r2, #TI_TP_VALUE]
630 stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack
Russell Kingd6551e82006-06-21 13:31:52 +0100631#ifdef CONFIG_MMU
632 ldr r6, [r2, #TI_CPU_DOMAIN]
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000633#endif
Russell Kingb8763862005-08-10 14:52:52 +0100634#if __LINUX_ARM_ARCH__ >= 6
Russell King43cc1982006-02-22 21:13:28 +0000635#ifdef CONFIG_CPU_32v6K
Russell Kingb8763862005-08-10 14:52:52 +0100636 clrex
637#else
Russell King73394322005-09-23 21:49:58 +0100638 strex r5, r4, [ip] @ Clear exclusive monitor
Russell Kingb8763862005-08-10 14:52:52 +0100639#endif
640#endif
Nicolas Pitre4b0e07a2005-05-05 23:24:45 +0100641#if defined(CONFIG_HAS_TLS_REG)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100642 mcr p15, 0, r3, c13, c0, 3 @ set TLS register
Nicolas Pitre4b0e07a2005-05-05 23:24:45 +0100643#elif !defined(CONFIG_TLS_REG_EMUL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 mov r4, #0xffff0fff
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100645 str r3, [r4, #-15] @ TLS val at 0xffff0ff0
646#endif
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000647#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
Hyok S. Choiafeb90c2006-01-13 21:05:25 +0000649#endif
Russell Kingd6551e82006-06-21 13:31:52 +0100650 mov r5, r0
651 add r4, r2, #TI_CPU_SAVE
652 ldr r0, =thread_notify_head
653 mov r1, #THREAD_NOTIFY_SWITCH
654 bl atomic_notifier_call_chain
655 mov r0, r5
656 ldmia r4, {r4 - sl, fp, sp, pc} @ Load all regs saved previously
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657
658 __INIT
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100659
660/*
661 * User helpers.
662 *
663 * These are segment of kernel provided user code reachable from user space
664 * at a fixed address in kernel memory. This is used to provide user space
665 * with some operations which require kernel help because of unimplemented
666 * native feature and/or instructions in many ARM CPUs. The idea is for
667 * this code to be executed directly in user mode for best efficiency but
668 * which is too intimate with the kernel counter part to be left to user
669 * libraries. In fact this code might even differ from one CPU to another
670 * depending on the available instruction set and restrictions like on
671 * SMP systems. In other words, the kernel reserves the right to change
672 * this code as needed without warning. Only the entry points and their
673 * results are guaranteed to be stable.
674 *
675 * Each segment is 32-byte aligned and will be moved to the top of the high
676 * vector page. New segments (if ever needed) must be added in front of
677 * existing ones. This mechanism should be used only for things that are
678 * really small and justified, and not be abused freely.
679 *
680 * User space is expected to implement those things inline when optimizing
681 * for a processor that has the necessary native support, but only if such
682 * resulting binaries are already to be incompatible with earlier ARM
683 * processors due to the use of unsupported instructions other than what
684 * is provided here. In other words don't make binaries unable to run on
685 * earlier processors just for the sake of not using these kernel helpers
686 * if your compiled code is not going to use the new instructions for other
687 * purpose.
688 */
689
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100690 .macro usr_ret, reg
691#ifdef CONFIG_ARM_THUMB
692 bx \reg
693#else
694 mov pc, \reg
695#endif
696 .endm
697
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100698 .align 5
699 .globl __kuser_helper_start
700__kuser_helper_start:
701
702/*
703 * Reference prototype:
704 *
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000705 * void __kernel_memory_barrier(void)
706 *
707 * Input:
708 *
709 * lr = return address
710 *
711 * Output:
712 *
713 * none
714 *
715 * Clobbered:
716 *
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100717 * none
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000718 *
719 * Definition and user space usage example:
720 *
721 * typedef void (__kernel_dmb_t)(void);
722 * #define __kernel_dmb (*(__kernel_dmb_t *)0xffff0fa0)
723 *
724 * Apply any needed memory barrier to preserve consistency with data modified
725 * manually and __kuser_cmpxchg usage.
726 *
727 * This could be used as follows:
728 *
729 * #define __kernel_dmb() \
730 * asm volatile ( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #95" \
Paul Brook6896eec2006-03-28 22:19:29 +0100731 * : : : "r0", "lr","cc" )
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000732 */
733
734__kuser_memory_barrier: @ 0xffff0fa0
735
736#if __LINUX_ARM_ARCH__ >= 6 && defined(CONFIG_SMP)
737 mcr p15, 0, r0, c7, c10, 5 @ dmb
738#endif
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100739 usr_ret lr
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000740
741 .align 5
742
743/*
744 * Reference prototype:
745 *
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100746 * int __kernel_cmpxchg(int oldval, int newval, int *ptr)
747 *
748 * Input:
749 *
750 * r0 = oldval
751 * r1 = newval
752 * r2 = ptr
753 * lr = return address
754 *
755 * Output:
756 *
757 * r0 = returned value (zero or non-zero)
758 * C flag = set if r0 == 0, clear if r0 != 0
759 *
760 * Clobbered:
761 *
762 * r3, ip, flags
763 *
764 * Definition and user space usage example:
765 *
766 * typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
767 * #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
768 *
769 * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
770 * Return zero if *ptr was changed or non-zero if no exchange happened.
771 * The C flag is also set if *ptr was changed to allow for assembly
772 * optimization in the calling code.
773 *
Nicolas Pitre5964eae2006-02-08 21:19:37 +0000774 * Notes:
775 *
776 * - This routine already includes memory barriers as needed.
777 *
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100778 * For example, a user space atomic_add implementation could look like this:
779 *
780 * #define atomic_add(ptr, val) \
781 * ({ register unsigned int *__ptr asm("r2") = (ptr); \
782 * register unsigned int __result asm("r1"); \
783 * asm volatile ( \
784 * "1: @ atomic_add\n\t" \
785 * "ldr r0, [r2]\n\t" \
786 * "mov r3, #0xffff0fff\n\t" \
787 * "add lr, pc, #4\n\t" \
788 * "add r1, r0, %2\n\t" \
789 * "add pc, r3, #(0xffff0fc0 - 0xffff0fff)\n\t" \
790 * "bcc 1b" \
791 * : "=&r" (__result) \
792 * : "r" (__ptr), "rIL" (val) \
793 * : "r0","r3","ip","lr","cc","memory" ); \
794 * __result; })
795 */
796
797__kuser_cmpxchg: @ 0xffff0fc0
798
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100799#if defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100800
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100801 /*
802 * Poor you. No fast solution possible...
803 * The kernel itself must perform the operation.
804 * A special ghost syscall is used for that (see traps.c).
805 */
Nicolas Pitre5e097442006-01-18 22:38:49 +0000806 stmfd sp!, {r7, lr}
807 mov r7, #0xff00 @ 0xfff0 into r7 for EABI
808 orr r7, r7, #0xf0
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100809 swi #0x9ffff0
Nicolas Pitre5e097442006-01-18 22:38:49 +0000810 ldmfd sp!, {r7, pc}
Nicolas Pitredcef1f62005-06-08 19:00:47 +0100811
812#elif __LINUX_ARM_ARCH__ < 6
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100813
Nicolas Pitre49bca4c2006-02-08 21:19:37 +0000814#ifdef CONFIG_MMU
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100815
816 /*
817 * The only thing that can break atomicity in this cmpxchg
818 * implementation is either an IRQ or a data abort exception
819 * causing another process/thread to be scheduled in the middle
820 * of the critical sequence. To prevent this, code is added to
821 * the IRQ and data abort exception handlers to set the pc back
822 * to the beginning of the critical section if it is found to be
823 * within that critical section (see kuser_cmpxchg_fixup).
824 */
8251: ldr r3, [r2] @ load current val
826 subs r3, r3, r0 @ compare with oldval
8272: streq r1, [r2] @ store newval if eq
828 rsbs r0, r3, #0 @ set return val and C flag
829 usr_ret lr
830
831 .text
832kuser_cmpxchg_fixup:
833 @ Called from kuser_cmpxchg_check macro.
834 @ r2 = address of interrupted insn (must be preserved).
835 @ sp = saved regs. r7 and r8 are clobbered.
836 @ 1b = first critical insn, 2b = last critical insn.
837 @ If r2 >= 1b and r2 <= 2b then saved pc_usr is set to 1b.
838 mov r7, #0xffff0fff
839 sub r7, r7, #(0xffff0fff - (0xffff0fc0 + (1b - __kuser_cmpxchg)))
840 subs r8, r2, r7
841 rsbcss r8, r8, #(2b - 1b)
842 strcs r7, [sp, #S_PC]
843 mov pc, lr
844 .previous
845
Nicolas Pitre49bca4c2006-02-08 21:19:37 +0000846#else
847#warning "NPTL on non MMU needs fixing"
848 mov r0, #-1
849 adds r0, r0, #0
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100850 usr_ret lr
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100851#endif
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100852
853#else
854
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000855#ifdef CONFIG_SMP
856 mcr p15, 0, r0, c7, c10, 5 @ dmb
857#endif
Nicolas Pitreb49c0f22007-11-20 17:20:29 +01008581: ldrex r3, [r2]
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100859 subs r3, r3, r0
860 strexeq r3, r1, [r2]
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100861 teqeq r3, #1
862 beq 1b
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100863 rsbs r0, r3, #0
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100864 /* beware -- each __kuser slot must be 8 instructions max */
Nicolas Pitre7c612bf2005-12-19 22:20:51 +0000865#ifdef CONFIG_SMP
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100866 b __kuser_memory_barrier
867#else
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100868 usr_ret lr
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100869#endif
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100870
871#endif
872
873 .align 5
874
875/*
876 * Reference prototype:
877 *
878 * int __kernel_get_tls(void)
879 *
880 * Input:
881 *
882 * lr = return address
883 *
884 * Output:
885 *
886 * r0 = TLS value
887 *
888 * Clobbered:
889 *
Nicolas Pitreb49c0f22007-11-20 17:20:29 +0100890 * none
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100891 *
892 * Definition and user space usage example:
893 *
894 * typedef int (__kernel_get_tls_t)(void);
895 * #define __kernel_get_tls (*(__kernel_get_tls_t *)0xffff0fe0)
896 *
897 * Get the TLS value as previously set via the __ARM_NR_set_tls syscall.
898 *
899 * This could be used as follows:
900 *
901 * #define __kernel_get_tls() \
902 * ({ register unsigned int __val asm("r0"); \
903 * asm( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #31" \
904 * : "=r" (__val) : : "lr","cc" ); \
905 * __val; })
906 */
907
908__kuser_get_tls: @ 0xffff0fe0
909
Nicolas Pitre4b0e07a2005-05-05 23:24:45 +0100910#if !defined(CONFIG_HAS_TLS_REG) && !defined(CONFIG_TLS_REG_EMUL)
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100911 ldr r0, [pc, #(16 - 8)] @ TLS stored at 0xffff0ff0
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100912#else
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100913 mrc p15, 0, r0, c13, c0, 3 @ read TLS register
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100914#endif
Nicolas Pitreba9b5d72006-08-18 17:20:15 +0100915 usr_ret lr
Nicolas Pitre2d2669b2005-04-29 22:08:33 +0100916
917 .rep 5
918 .word 0 @ pad up to __kuser_helper_version
919 .endr
920
921/*
922 * Reference declaration:
923 *
924 * extern unsigned int __kernel_helper_version;
925 *
926 * Definition and user space usage example:
927 *
928 * #define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
929 *
930 * User space may read this to determine the curent number of helpers
931 * available.
932 */
933
934__kuser_helper_version: @ 0xffff0ffc
935 .word ((__kuser_helper_end - __kuser_helper_start) >> 5)
936
937 .globl __kuser_helper_end
938__kuser_helper_end:
939
940
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941/*
942 * Vector stubs.
943 *
Russell King79335232005-04-26 15:17:42 +0100944 * This code is copied to 0xffff0200 so we can use branches in the
945 * vectors, rather than ldr's. Note that this code must not
946 * exceed 0x300 bytes.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 *
948 * Common stub entry macro:
949 * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
Russell Kingccea7a12005-05-31 22:22:32 +0100950 *
951 * SP points to a minimal amount of processor-private memory, the address
952 * of which is copied into r0 for the mode specific abort handler.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000954 .macro vector_stub, name, mode, correction=0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 .align 5
956
957vector_\name:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 .if \correction
959 sub lr, lr, #\correction
960 .endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961
Russell Kingccea7a12005-05-31 22:22:32 +0100962 @
963 @ Save r0, lr_<exception> (parent PC) and spsr_<exception>
964 @ (parent CPSR)
965 @
966 stmia sp, {r0, lr} @ save r0, lr
967 mrs lr, spsr
968 str lr, [sp, #8] @ save spsr
969
970 @
971 @ Prepare for SVC32 mode. IRQs remain disabled.
972 @
973 mrs r0, cpsr
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000974 eor r0, r0, #(\mode ^ SVC_MODE)
Russell Kingccea7a12005-05-31 22:22:32 +0100975 msr spsr_cxsf, r0
976
977 @
978 @ the branch table must immediately follow this code
979 @
Russell Kingccea7a12005-05-31 22:22:32 +0100980 and lr, lr, #0x0f
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000981 mov r0, sp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982 ldr lr, [pc, lr, lsl #2]
Russell Kingccea7a12005-05-31 22:22:32 +0100983 movs pc, lr @ branch to handler in SVC mode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 .endm
985
Russell King79335232005-04-26 15:17:42 +0100986 .globl __stubs_start
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987__stubs_start:
988/*
989 * Interrupt dispatcher
990 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +0000991 vector_stub irq, IRQ_MODE, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992
993 .long __irq_usr @ 0 (USR_26 / USR_32)
994 .long __irq_invalid @ 1 (FIQ_26 / FIQ_32)
995 .long __irq_invalid @ 2 (IRQ_26 / IRQ_32)
996 .long __irq_svc @ 3 (SVC_26 / SVC_32)
997 .long __irq_invalid @ 4
998 .long __irq_invalid @ 5
999 .long __irq_invalid @ 6
1000 .long __irq_invalid @ 7
1001 .long __irq_invalid @ 8
1002 .long __irq_invalid @ 9
1003 .long __irq_invalid @ a
1004 .long __irq_invalid @ b
1005 .long __irq_invalid @ c
1006 .long __irq_invalid @ d
1007 .long __irq_invalid @ e
1008 .long __irq_invalid @ f
1009
1010/*
1011 * Data abort dispatcher
1012 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
1013 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001014 vector_stub dabt, ABT_MODE, 8
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015
1016 .long __dabt_usr @ 0 (USR_26 / USR_32)
1017 .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32)
1018 .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32)
1019 .long __dabt_svc @ 3 (SVC_26 / SVC_32)
1020 .long __dabt_invalid @ 4
1021 .long __dabt_invalid @ 5
1022 .long __dabt_invalid @ 6
1023 .long __dabt_invalid @ 7
1024 .long __dabt_invalid @ 8
1025 .long __dabt_invalid @ 9
1026 .long __dabt_invalid @ a
1027 .long __dabt_invalid @ b
1028 .long __dabt_invalid @ c
1029 .long __dabt_invalid @ d
1030 .long __dabt_invalid @ e
1031 .long __dabt_invalid @ f
1032
1033/*
1034 * Prefetch abort dispatcher
1035 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
1036 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001037 vector_stub pabt, ABT_MODE, 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038
1039 .long __pabt_usr @ 0 (USR_26 / USR_32)
1040 .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32)
1041 .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32)
1042 .long __pabt_svc @ 3 (SVC_26 / SVC_32)
1043 .long __pabt_invalid @ 4
1044 .long __pabt_invalid @ 5
1045 .long __pabt_invalid @ 6
1046 .long __pabt_invalid @ 7
1047 .long __pabt_invalid @ 8
1048 .long __pabt_invalid @ 9
1049 .long __pabt_invalid @ a
1050 .long __pabt_invalid @ b
1051 .long __pabt_invalid @ c
1052 .long __pabt_invalid @ d
1053 .long __pabt_invalid @ e
1054 .long __pabt_invalid @ f
1055
1056/*
1057 * Undef instr entry dispatcher
1058 * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
1059 */
Nicolas Pitreb7ec4792005-11-06 14:42:37 +00001060 vector_stub und, UND_MODE
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061
1062 .long __und_usr @ 0 (USR_26 / USR_32)
1063 .long __und_invalid @ 1 (FIQ_26 / FIQ_32)
1064 .long __und_invalid @ 2 (IRQ_26 / IRQ_32)
1065 .long __und_svc @ 3 (SVC_26 / SVC_32)
1066 .long __und_invalid @ 4
1067 .long __und_invalid @ 5
1068 .long __und_invalid @ 6
1069 .long __und_invalid @ 7
1070 .long __und_invalid @ 8
1071 .long __und_invalid @ 9
1072 .long __und_invalid @ a
1073 .long __und_invalid @ b
1074 .long __und_invalid @ c
1075 .long __und_invalid @ d
1076 .long __und_invalid @ e
1077 .long __und_invalid @ f
1078
1079 .align 5
1080
1081/*=============================================================================
1082 * Undefined FIQs
1083 *-----------------------------------------------------------------------------
1084 * Enter in FIQ mode, spsr = ANY CPSR, lr = ANY PC
1085 * MUST PRESERVE SVC SPSR, but need to switch to SVC mode to show our msg.
1086 * Basically to switch modes, we *HAVE* to clobber one register... brain
1087 * damage alert! I don't think that we can execute any code in here in any
1088 * other mode than FIQ... Ok you can switch to another mode, but you can't
1089 * get out of that mode without clobbering one register.
1090 */
1091vector_fiq:
1092 disable_fiq
1093 subs pc, lr, #4
1094
1095/*=============================================================================
1096 * Address exception handler
1097 *-----------------------------------------------------------------------------
1098 * These aren't too critical.
1099 * (they're not supposed to happen, and won't happen in 32-bit data mode).
1100 */
1101
1102vector_addrexcptn:
1103 b vector_addrexcptn
1104
1105/*
1106 * We group all the following data together to optimise
1107 * for CPUs with separate I & D caches.
1108 */
1109 .align 5
1110
1111.LCvswi:
1112 .word vector_swi
1113
Russell King79335232005-04-26 15:17:42 +01001114 .globl __stubs_end
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115__stubs_end:
1116
Russell King79335232005-04-26 15:17:42 +01001117 .equ stubs_offset, __vectors_start + 0x200 - __stubs_start
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118
Russell King79335232005-04-26 15:17:42 +01001119 .globl __vectors_start
1120__vectors_start:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 swi SYS_ERROR0
Russell King79335232005-04-26 15:17:42 +01001122 b vector_und + stubs_offset
1123 ldr pc, .LCvswi + stubs_offset
1124 b vector_pabt + stubs_offset
1125 b vector_dabt + stubs_offset
1126 b vector_addrexcptn + stubs_offset
1127 b vector_irq + stubs_offset
1128 b vector_fiq + stubs_offset
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129
Russell King79335232005-04-26 15:17:42 +01001130 .globl __vectors_end
1131__vectors_end:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132
1133 .data
1134
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 .globl cr_alignment
1136 .globl cr_no_alignment
1137cr_alignment:
1138 .space 4
1139cr_no_alignment:
1140 .space 4