[PATCH] ARM SMP: add IPI support
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / kernel / entry-armv.S
CommitLineData
1da177e4
LT
1/*
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)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Low-level vector interface routines
12 *
13 * Note: there is a StrongARM bug in the STMIA rn, {regs}^ instruction that causes
14 * it to save wrong values... Be aware!
15 */
16#include <linux/config.h>
1da177e4 17
1da177e4 18#include <asm/glue.h>
1da177e4 19#include <asm/vfpmacros.h>
41e46d6a
NP
20#include <asm/hardware.h> /* should be moved into entry-macro.S */
21#include <asm/arch/irqs.h> /* should be moved into entry-macro.S */
bce495d8 22#include <asm/arch/entry-macro.S>
1da177e4
LT
23
24#include "entry-header.S"
25
187a51ad
RK
26/*
27 * Interrupt handling. Preserves r7, r8, r9
28 */
29 .macro irq_handler
301: get_irqnr_and_base r0, r6, r5, lr
31 movne r1, sp
32 @
33 @ routine called with r0 = irq number, r1 = struct pt_regs *
34 @
35 adrne lr, 1b
36 bne asm_do_IRQ
791be9b9
RK
37
38#ifdef CONFIG_SMP
39 /*
40 * XXX
41 *
42 * this macro assumes that irqstat (r6) and base (r5) are
43 * preserved from get_irqnr_and_base above
44 */
45 test_for_ipi r0, r6, r5, lr
46 movne r0, sp
47 adrne lr, 1b
48 bne do_IPI
49#endif
50
187a51ad
RK
51 .endm
52
1da177e4
LT
53/*
54 * Invalid mode handlers
55 */
56 .macro inv_entry, sym, reason
57 sub sp, sp, #S_FRAME_SIZE @ Allocate frame size in one go
58 stmia sp, {r0 - lr} @ Save XXX r0 - lr
59 ldr r4, .LC\sym
60 mov r1, #\reason
61 .endm
62
63__pabt_invalid:
64 inv_entry abt, BAD_PREFETCH
65 b 1f
66
67__dabt_invalid:
68 inv_entry abt, BAD_DATA
69 b 1f
70
71__irq_invalid:
72 inv_entry irq, BAD_IRQ
73 b 1f
74
75__und_invalid:
76 inv_entry und, BAD_UNDEFINSTR
77
781: zero_fp
79 ldmia r4, {r5 - r7} @ Get XXX pc, cpsr, old_r0
80 add r4, sp, #S_PC
81 stmia r4, {r5 - r7} @ Save XXX pc, cpsr, old_r0
82 mov r0, sp
83 and r2, r6, #31 @ int mode
84 b bad_mode
85
86/*
87 * SVC mode handlers
88 */
89 .macro svc_entry, sym
90 sub sp, sp, #S_FRAME_SIZE
91 stmia sp, {r0 - r12} @ save r0 - r12
92 ldr r2, .LC\sym
93 add r0, sp, #S_FRAME_SIZE
94 ldmia r2, {r2 - r4} @ get pc, cpsr
95 add r5, sp, #S_SP
96 mov r1, lr
97
98 @
99 @ We are now ready to fill in the remaining blanks on the stack:
100 @
101 @ r0 - sp_svc
102 @ r1 - lr_svc
103 @ r2 - lr_<exception>, already fixed up for correct return/restart
104 @ r3 - spsr_<exception>
105 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
106 @
107 stmia r5, {r0 - r4}
108 .endm
109
110 .align 5
111__dabt_svc:
112 svc_entry abt
113
114 @
115 @ get ready to re-enable interrupts if appropriate
116 @
117 mrs r9, cpsr
118 tst r3, #PSR_I_BIT
119 biceq r9, r9, #PSR_I_BIT
120
121 @
122 @ Call the processor-specific abort handler:
123 @
124 @ r2 - aborted context pc
125 @ r3 - aborted context cpsr
126 @
127 @ The abort handler must return the aborted address in r0, and
128 @ the fault status register in r1. r9 must be preserved.
129 @
130#ifdef MULTI_ABORT
131 ldr r4, .LCprocfns
132 mov lr, pc
133 ldr pc, [r4]
134#else
135 bl CPU_ABORT_HANDLER
136#endif
137
138 @
139 @ set desired IRQ state, then call main handler
140 @
141 msr cpsr_c, r9
142 mov r2, sp
143 bl do_DataAbort
144
145 @
146 @ IRQs off again before pulling preserved data off the stack
147 @
1ec42c0c 148 disable_irq
1da177e4
LT
149
150 @
151 @ restore SPSR and restart the instruction
152 @
153 ldr r0, [sp, #S_PSR]
154 msr spsr_cxsf, r0
155 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
156
157 .align 5
158__irq_svc:
159 svc_entry irq
160#ifdef CONFIG_PREEMPT
706fdd9f
RK
161 get_thread_info tsk
162 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
163 add r7, r8, #1 @ increment it
164 str r7, [tsk, #TI_PREEMPT]
1da177e4 165#endif
187a51ad 166 irq_handler
1da177e4 167#ifdef CONFIG_PREEMPT
706fdd9f 168 ldr r0, [tsk, #TI_FLAGS] @ get flags
1da177e4
LT
169 tst r0, #_TIF_NEED_RESCHED
170 blne svc_preempt
171preempt_return:
706fdd9f
RK
172 ldr r0, [tsk, #TI_PREEMPT] @ read preempt value
173 str r8, [tsk, #TI_PREEMPT] @ restore preempt count
1da177e4 174 teq r0, r7
1da177e4
LT
175 strne r0, [r0, -r0] @ bug()
176#endif
177 ldr r0, [sp, #S_PSR] @ irqs are already disabled
178 msr spsr_cxsf, r0
179 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
180
181 .ltorg
182
183#ifdef CONFIG_PREEMPT
184svc_preempt:
706fdd9f 185 teq r8, #0 @ was preempt count = 0
1da177e4
LT
186 ldreq r6, .LCirq_stat
187 movne pc, lr @ no
188 ldr r0, [r6, #4] @ local_irq_count
189 ldr r1, [r6, #8] @ local_bh_count
190 adds r0, r0, r1
191 movne pc, lr
192 mov r7, #0 @ preempt_schedule_irq
706fdd9f 193 str r7, [tsk, #TI_PREEMPT] @ expects preempt_count == 0
1da177e4 1941: bl preempt_schedule_irq @ irq en/disable is done inside
706fdd9f 195 ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS
1da177e4
LT
196 tst r0, #_TIF_NEED_RESCHED
197 beq preempt_return @ go again
198 b 1b
199#endif
200
201 .align 5
202__und_svc:
203 svc_entry und
204
205 @
206 @ call emulation code, which returns using r9 if it has emulated
207 @ the instruction, or the more conventional lr if we are to treat
208 @ this as a real undefined instruction
209 @
210 @ r0 - instruction
211 @
212 ldr r0, [r2, #-4]
213 adr r9, 1f
214 bl call_fpe
215
216 mov r0, sp @ struct pt_regs *regs
217 bl do_undefinstr
218
219 @
220 @ IRQs off again before pulling preserved data off the stack
221 @
1ec42c0c 2221: disable_irq
1da177e4
LT
223
224 @
225 @ restore SPSR and restart the instruction
226 @
227 ldr lr, [sp, #S_PSR] @ Get SVC cpsr
228 msr spsr_cxsf, lr
229 ldmia sp, {r0 - pc}^ @ Restore SVC registers
230
231 .align 5
232__pabt_svc:
233 svc_entry abt
234
235 @
236 @ re-enable interrupts if appropriate
237 @
238 mrs r9, cpsr
239 tst r3, #PSR_I_BIT
240 biceq r9, r9, #PSR_I_BIT
241 msr cpsr_c, r9
242
243 @
244 @ set args, then call main handler
245 @
246 @ r0 - address of faulting instruction
247 @ r1 - pointer to registers on stack
248 @
249 mov r0, r2 @ address (pc)
250 mov r1, sp @ regs
251 bl do_PrefetchAbort @ call abort handler
252
253 @
254 @ IRQs off again before pulling preserved data off the stack
255 @
1ec42c0c 256 disable_irq
1da177e4
LT
257
258 @
259 @ restore SPSR and restart the instruction
260 @
261 ldr r0, [sp, #S_PSR]
262 msr spsr_cxsf, r0
263 ldmia sp, {r0 - pc}^ @ load r0 - pc, cpsr
264
265 .align 5
266.LCirq:
267 .word __temp_irq
268.LCund:
269 .word __temp_und
270.LCabt:
271 .word __temp_abt
272#ifdef MULTI_ABORT
273.LCprocfns:
274 .word processor
275#endif
276.LCfp:
277 .word fp_enter
278#ifdef CONFIG_PREEMPT
279.LCirq_stat:
280 .word irq_stat
281#endif
282
283/*
284 * User mode handlers
285 */
286 .macro usr_entry, sym
287 sub sp, sp, #S_FRAME_SIZE @ Allocate frame size in one go
288 stmia sp, {r0 - r12} @ save r0 - r12
289 ldr r7, .LC\sym
290 add r5, sp, #S_PC
291 ldmia r7, {r2 - r4} @ Get USR pc, cpsr
292
2d2669b6
NP
293#if __LINUX_ARM_ARCH__ < 6
294 @ make sure our user space atomic helper is aborted
295 cmp r2, #VIRT_OFFSET
296 bichs r3, r3, #PSR_Z_BIT
297#endif
298
1da177e4
LT
299 @
300 @ We are now ready to fill in the remaining blanks on the stack:
301 @
302 @ r2 - lr_<exception>, already fixed up for correct return/restart
303 @ r3 - spsr_<exception>
304 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
305 @
306 @ Also, separately save sp_usr and lr_usr
307 @
308 stmia r5, {r2 - r4}
309 stmdb r5, {sp, lr}^
310
311 @
312 @ Enable the alignment trap while in kernel mode
313 @
314 alignment_trap r7, r0, __temp_\sym
315
316 @
317 @ Clear FP to mark the first stack frame
318 @
319 zero_fp
320 .endm
321
322 .align 5
323__dabt_usr:
324 usr_entry abt
325
326 @
327 @ Call the processor-specific abort handler:
328 @
329 @ r2 - aborted context pc
330 @ r3 - aborted context cpsr
331 @
332 @ The abort handler must return the aborted address in r0, and
333 @ the fault status register in r1.
334 @
335#ifdef MULTI_ABORT
336 ldr r4, .LCprocfns
337 mov lr, pc
338 ldr pc, [r4]
339#else
340 bl CPU_ABORT_HANDLER
341#endif
342
343 @
344 @ IRQs on, then call the main handler
345 @
1ec42c0c 346 enable_irq
1da177e4
LT
347 mov r2, sp
348 adr lr, ret_from_exception
349 b do_DataAbort
350
351 .align 5
352__irq_usr:
353 usr_entry irq
354
706fdd9f 355 get_thread_info tsk
1da177e4 356#ifdef CONFIG_PREEMPT
706fdd9f
RK
357 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
358 add r7, r8, #1 @ increment it
359 str r7, [tsk, #TI_PREEMPT]
1da177e4 360#endif
187a51ad 361 irq_handler
1da177e4 362#ifdef CONFIG_PREEMPT
706fdd9f
RK
363 ldr r0, [tsk, #TI_PREEMPT]
364 str r8, [tsk, #TI_PREEMPT]
1da177e4 365 teq r0, r7
1da177e4 366 strne r0, [r0, -r0]
1da177e4
LT
367#endif
368 mov why, #0
369 b ret_to_user
370
371 .ltorg
372
373 .align 5
374__und_usr:
375 usr_entry und
376
377 tst r3, #PSR_T_BIT @ Thumb mode?
378 bne fpundefinstr @ ignore FP
379 sub r4, r2, #4
380
381 @
382 @ fall through to the emulation code, which returns using r9 if
383 @ it has emulated the instruction, or the more conventional lr
384 @ if we are to treat this as a real undefined instruction
385 @
386 @ r0 - instruction
387 @
3881: ldrt r0, [r4]
389 adr r9, ret_from_exception
390 adr lr, fpundefinstr
391 @
392 @ fallthrough to call_fpe
393 @
394
395/*
396 * The out of line fixup for the ldrt above.
397 */
398 .section .fixup, "ax"
3992: mov pc, r9
400 .previous
401 .section __ex_table,"a"
402 .long 1b, 2b
403 .previous
404
405/*
406 * Check whether the instruction is a co-processor instruction.
407 * If yes, we need to call the relevant co-processor handler.
408 *
409 * Note that we don't do a full check here for the co-processor
410 * instructions; all instructions with bit 27 set are well
411 * defined. The only instructions that should fault are the
412 * co-processor instructions. However, we have to watch out
413 * for the ARM6/ARM7 SWI bug.
414 *
415 * Emulators may wish to make use of the following registers:
416 * r0 = instruction opcode.
417 * r2 = PC+4
418 * r10 = this threads thread_info structure.
419 */
420call_fpe:
421 tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27
422#if defined(CONFIG_CPU_ARM610) || defined(CONFIG_CPU_ARM710)
423 and r8, r0, #0x0f000000 @ mask out op-code bits
424 teqne r8, #0x0f000000 @ SWI (ARM6/7 bug)?
425#endif
426 moveq pc, lr
427 get_thread_info r10 @ get current thread
428 and r8, r0, #0x00000f00 @ mask out CP number
429 mov r7, #1
430 add r6, r10, #TI_USED_CP
431 strb r7, [r6, r8, lsr #8] @ set appropriate used_cp[]
432#ifdef CONFIG_IWMMXT
433 @ Test if we need to give access to iWMMXt coprocessors
434 ldr r5, [r10, #TI_FLAGS]
435 rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only
436 movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
437 bcs iwmmxt_task_enable
438#endif
1ec42c0c 439 enable_irq
1da177e4
LT
440 add pc, pc, r8, lsr #6
441 mov r0, r0
442
443 mov pc, lr @ CP#0
444 b do_fpe @ CP#1 (FPE)
445 b do_fpe @ CP#2 (FPE)
446 mov pc, lr @ CP#3
447 mov pc, lr @ CP#4
448 mov pc, lr @ CP#5
449 mov pc, lr @ CP#6
450 mov pc, lr @ CP#7
451 mov pc, lr @ CP#8
452 mov pc, lr @ CP#9
453#ifdef CONFIG_VFP
454 b do_vfp @ CP#10 (VFP)
455 b do_vfp @ CP#11 (VFP)
456#else
457 mov pc, lr @ CP#10 (VFP)
458 mov pc, lr @ CP#11 (VFP)
459#endif
460 mov pc, lr @ CP#12
461 mov pc, lr @ CP#13
462 mov pc, lr @ CP#14 (Debug)
463 mov pc, lr @ CP#15 (Control)
464
465do_fpe:
466 ldr r4, .LCfp
467 add r10, r10, #TI_FPSTATE @ r10 = workspace
468 ldr pc, [r4] @ Call FP module USR entry point
469
470/*
471 * The FP module is called with these registers set:
472 * r0 = instruction
473 * r2 = PC+4
474 * r9 = normal "successful" return address
475 * r10 = FP workspace
476 * lr = unrecognised FP instruction return address
477 */
478
479 .data
480ENTRY(fp_enter)
481 .word fpundefinstr
482 .text
483
484fpundefinstr:
485 mov r0, sp
486 adr lr, ret_from_exception
487 b do_undefinstr
488
489 .align 5
490__pabt_usr:
491 usr_entry abt
492
1ec42c0c 493 enable_irq @ Enable interrupts
1da177e4
LT
494 mov r0, r2 @ address (pc)
495 mov r1, sp @ regs
496 bl do_PrefetchAbort @ call abort handler
497 /* fall through */
498/*
499 * This is the return code to user mode for abort handlers
500 */
501ENTRY(ret_from_exception)
502 get_thread_info tsk
503 mov why, #0
504 b ret_to_user
505
506/*
507 * Register switch for ARMv3 and ARMv4 processors
508 * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
509 * previous and next are guaranteed not to be the same.
510 */
511ENTRY(__switch_to)
512 add ip, r1, #TI_CPU_SAVE
513 ldr r3, [r2, #TI_TP_VALUE]
514 stmia ip!, {r4 - sl, fp, sp, lr} @ Store most regs on stack
515 ldr r6, [r2, #TI_CPU_DOMAIN]!
516#if defined(CONFIG_CPU_XSCALE) && !defined(CONFIG_IWMMXT)
517 mra r4, r5, acc0
518 stmia ip, {r4, r5}
519#endif
4b0e07a5 520#if defined(CONFIG_HAS_TLS_REG)
2d2669b6 521 mcr p15, 0, r3, c13, c0, 3 @ set TLS register
4b0e07a5 522#elif !defined(CONFIG_TLS_REG_EMUL)
1da177e4 523 mov r4, #0xffff0fff
2d2669b6
NP
524 str r3, [r4, #-15] @ TLS val at 0xffff0ff0
525#endif
1da177e4
LT
526 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
527#ifdef CONFIG_VFP
528 @ Always disable VFP so we can lazily save/restore the old
529 @ state. This occurs in the context of the previous thread.
530 VFPFMRX r4, FPEXC
531 bic r4, r4, #FPEXC_ENABLE
532 VFPFMXR FPEXC, r4
533#endif
534#if defined(CONFIG_IWMMXT)
535 bl iwmmxt_task_switch
536#elif defined(CONFIG_CPU_XSCALE)
537 add r4, r2, #40 @ cpu_context_save->extra
538 ldmib r4, {r4, r5}
539 mar acc0, r4, r5
540#endif
541 ldmib r2, {r4 - sl, fp, sp, pc} @ Load all regs saved previously
542
543 __INIT
2d2669b6
NP
544
545/*
546 * User helpers.
547 *
548 * These are segment of kernel provided user code reachable from user space
549 * at a fixed address in kernel memory. This is used to provide user space
550 * with some operations which require kernel help because of unimplemented
551 * native feature and/or instructions in many ARM CPUs. The idea is for
552 * this code to be executed directly in user mode for best efficiency but
553 * which is too intimate with the kernel counter part to be left to user
554 * libraries. In fact this code might even differ from one CPU to another
555 * depending on the available instruction set and restrictions like on
556 * SMP systems. In other words, the kernel reserves the right to change
557 * this code as needed without warning. Only the entry points and their
558 * results are guaranteed to be stable.
559 *
560 * Each segment is 32-byte aligned and will be moved to the top of the high
561 * vector page. New segments (if ever needed) must be added in front of
562 * existing ones. This mechanism should be used only for things that are
563 * really small and justified, and not be abused freely.
564 *
565 * User space is expected to implement those things inline when optimizing
566 * for a processor that has the necessary native support, but only if such
567 * resulting binaries are already to be incompatible with earlier ARM
568 * processors due to the use of unsupported instructions other than what
569 * is provided here. In other words don't make binaries unable to run on
570 * earlier processors just for the sake of not using these kernel helpers
571 * if your compiled code is not going to use the new instructions for other
572 * purpose.
573 */
574
575 .align 5
576 .globl __kuser_helper_start
577__kuser_helper_start:
578
579/*
580 * Reference prototype:
581 *
582 * int __kernel_cmpxchg(int oldval, int newval, int *ptr)
583 *
584 * Input:
585 *
586 * r0 = oldval
587 * r1 = newval
588 * r2 = ptr
589 * lr = return address
590 *
591 * Output:
592 *
593 * r0 = returned value (zero or non-zero)
594 * C flag = set if r0 == 0, clear if r0 != 0
595 *
596 * Clobbered:
597 *
598 * r3, ip, flags
599 *
600 * Definition and user space usage example:
601 *
602 * typedef int (__kernel_cmpxchg_t)(int oldval, int newval, int *ptr);
603 * #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
604 *
605 * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
606 * Return zero if *ptr was changed or non-zero if no exchange happened.
607 * The C flag is also set if *ptr was changed to allow for assembly
608 * optimization in the calling code.
609 *
610 * For example, a user space atomic_add implementation could look like this:
611 *
612 * #define atomic_add(ptr, val) \
613 * ({ register unsigned int *__ptr asm("r2") = (ptr); \
614 * register unsigned int __result asm("r1"); \
615 * asm volatile ( \
616 * "1: @ atomic_add\n\t" \
617 * "ldr r0, [r2]\n\t" \
618 * "mov r3, #0xffff0fff\n\t" \
619 * "add lr, pc, #4\n\t" \
620 * "add r1, r0, %2\n\t" \
621 * "add pc, r3, #(0xffff0fc0 - 0xffff0fff)\n\t" \
622 * "bcc 1b" \
623 * : "=&r" (__result) \
624 * : "r" (__ptr), "rIL" (val) \
625 * : "r0","r3","ip","lr","cc","memory" ); \
626 * __result; })
627 */
628
629__kuser_cmpxchg: @ 0xffff0fc0
630
631#if __LINUX_ARM_ARCH__ < 6
632
633#ifdef CONFIG_SMP /* sanity check */
634#error "CONFIG_SMP on a machine supporting pre-ARMv6 processors?"
635#endif
636
637 /*
638 * Theory of operation:
639 *
640 * We set the Z flag before loading oldval. If ever an exception
641 * occurs we can not be sure the loaded value will still be the same
642 * when the exception returns, therefore the user exception handler
643 * will clear the Z flag whenever the interrupted user code was
644 * actually from the kernel address space (see the usr_entry macro).
645 *
646 * The post-increment on the str is used to prevent a race with an
647 * exception happening just after the str instruction which would
648 * clear the Z flag although the exchange was done.
649 */
650 teq ip, ip @ set Z flag
651 ldr ip, [r2] @ load current val
652 add r3, r2, #1 @ prepare store ptr
653 teqeq ip, r0 @ compare with oldval if still allowed
654 streq r1, [r3, #-1]! @ store newval if still allowed
655 subs r0, r2, r3 @ if r2 == r3 the str occured
656 mov pc, lr
657
658#else
659
660 ldrex r3, [r2]
661 subs r3, r3, r0
662 strexeq r3, r1, [r2]
663 rsbs r0, r3, #0
664 mov pc, lr
665
666#endif
667
668 .align 5
669
670/*
671 * Reference prototype:
672 *
673 * int __kernel_get_tls(void)
674 *
675 * Input:
676 *
677 * lr = return address
678 *
679 * Output:
680 *
681 * r0 = TLS value
682 *
683 * Clobbered:
684 *
685 * the Z flag might be lost
686 *
687 * Definition and user space usage example:
688 *
689 * typedef int (__kernel_get_tls_t)(void);
690 * #define __kernel_get_tls (*(__kernel_get_tls_t *)0xffff0fe0)
691 *
692 * Get the TLS value as previously set via the __ARM_NR_set_tls syscall.
693 *
694 * This could be used as follows:
695 *
696 * #define __kernel_get_tls() \
697 * ({ register unsigned int __val asm("r0"); \
698 * asm( "mov r0, #0xffff0fff; mov lr, pc; sub pc, r0, #31" \
699 * : "=r" (__val) : : "lr","cc" ); \
700 * __val; })
701 */
702
703__kuser_get_tls: @ 0xffff0fe0
704
4b0e07a5 705#if !defined(CONFIG_HAS_TLS_REG) && !defined(CONFIG_TLS_REG_EMUL)
2d2669b6
NP
706
707 ldr r0, [pc, #(16 - 8)] @ TLS stored at 0xffff0ff0
708 mov pc, lr
709
710#else
711
712 mrc p15, 0, r0, c13, c0, 3 @ read TLS register
713 mov pc, lr
714
715#endif
716
717 .rep 5
718 .word 0 @ pad up to __kuser_helper_version
719 .endr
720
721/*
722 * Reference declaration:
723 *
724 * extern unsigned int __kernel_helper_version;
725 *
726 * Definition and user space usage example:
727 *
728 * #define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
729 *
730 * User space may read this to determine the curent number of helpers
731 * available.
732 */
733
734__kuser_helper_version: @ 0xffff0ffc
735 .word ((__kuser_helper_end - __kuser_helper_start) >> 5)
736
737 .globl __kuser_helper_end
738__kuser_helper_end:
739
740
1da177e4
LT
741/*
742 * Vector stubs.
743 *
7933523d
RK
744 * This code is copied to 0xffff0200 so we can use branches in the
745 * vectors, rather than ldr's. Note that this code must not
746 * exceed 0x300 bytes.
1da177e4
LT
747 *
748 * Common stub entry macro:
749 * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
750 */
751 .macro vector_stub, name, sym, correction=0
752 .align 5
753
754vector_\name:
755 ldr r13, .LCs\sym
756 .if \correction
757 sub lr, lr, #\correction
758 .endif
759 str lr, [r13] @ save lr_IRQ
760 mrs lr, spsr
761 str lr, [r13, #4] @ save spsr_IRQ
762 @
763 @ now branch to the relevant MODE handling routine
764 @
765 mrs r13, cpsr
766 bic r13, r13, #MODE_MASK
acaca3c9 767 orr r13, r13, #SVC_MODE
1da177e4
LT
768 msr spsr_cxsf, r13 @ switch to SVC_32 mode
769
770 and lr, lr, #15
771 ldr lr, [pc, lr, lsl #2]
772 movs pc, lr @ Changes mode and branches
773 .endm
774
7933523d 775 .globl __stubs_start
1da177e4
LT
776__stubs_start:
777/*
778 * Interrupt dispatcher
779 */
780 vector_stub irq, irq, 4
781
782 .long __irq_usr @ 0 (USR_26 / USR_32)
783 .long __irq_invalid @ 1 (FIQ_26 / FIQ_32)
784 .long __irq_invalid @ 2 (IRQ_26 / IRQ_32)
785 .long __irq_svc @ 3 (SVC_26 / SVC_32)
786 .long __irq_invalid @ 4
787 .long __irq_invalid @ 5
788 .long __irq_invalid @ 6
789 .long __irq_invalid @ 7
790 .long __irq_invalid @ 8
791 .long __irq_invalid @ 9
792 .long __irq_invalid @ a
793 .long __irq_invalid @ b
794 .long __irq_invalid @ c
795 .long __irq_invalid @ d
796 .long __irq_invalid @ e
797 .long __irq_invalid @ f
798
799/*
800 * Data abort dispatcher
801 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
802 */
803 vector_stub dabt, abt, 8
804
805 .long __dabt_usr @ 0 (USR_26 / USR_32)
806 .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32)
807 .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32)
808 .long __dabt_svc @ 3 (SVC_26 / SVC_32)
809 .long __dabt_invalid @ 4
810 .long __dabt_invalid @ 5
811 .long __dabt_invalid @ 6
812 .long __dabt_invalid @ 7
813 .long __dabt_invalid @ 8
814 .long __dabt_invalid @ 9
815 .long __dabt_invalid @ a
816 .long __dabt_invalid @ b
817 .long __dabt_invalid @ c
818 .long __dabt_invalid @ d
819 .long __dabt_invalid @ e
820 .long __dabt_invalid @ f
821
822/*
823 * Prefetch abort dispatcher
824 * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
825 */
826 vector_stub pabt, abt, 4
827
828 .long __pabt_usr @ 0 (USR_26 / USR_32)
829 .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32)
830 .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32)
831 .long __pabt_svc @ 3 (SVC_26 / SVC_32)
832 .long __pabt_invalid @ 4
833 .long __pabt_invalid @ 5
834 .long __pabt_invalid @ 6
835 .long __pabt_invalid @ 7
836 .long __pabt_invalid @ 8
837 .long __pabt_invalid @ 9
838 .long __pabt_invalid @ a
839 .long __pabt_invalid @ b
840 .long __pabt_invalid @ c
841 .long __pabt_invalid @ d
842 .long __pabt_invalid @ e
843 .long __pabt_invalid @ f
844
845/*
846 * Undef instr entry dispatcher
847 * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
848 */
849 vector_stub und, und
850
851 .long __und_usr @ 0 (USR_26 / USR_32)
852 .long __und_invalid @ 1 (FIQ_26 / FIQ_32)
853 .long __und_invalid @ 2 (IRQ_26 / IRQ_32)
854 .long __und_svc @ 3 (SVC_26 / SVC_32)
855 .long __und_invalid @ 4
856 .long __und_invalid @ 5
857 .long __und_invalid @ 6
858 .long __und_invalid @ 7
859 .long __und_invalid @ 8
860 .long __und_invalid @ 9
861 .long __und_invalid @ a
862 .long __und_invalid @ b
863 .long __und_invalid @ c
864 .long __und_invalid @ d
865 .long __und_invalid @ e
866 .long __und_invalid @ f
867
868 .align 5
869
870/*=============================================================================
871 * Undefined FIQs
872 *-----------------------------------------------------------------------------
873 * Enter in FIQ mode, spsr = ANY CPSR, lr = ANY PC
874 * MUST PRESERVE SVC SPSR, but need to switch to SVC mode to show our msg.
875 * Basically to switch modes, we *HAVE* to clobber one register... brain
876 * damage alert! I don't think that we can execute any code in here in any
877 * other mode than FIQ... Ok you can switch to another mode, but you can't
878 * get out of that mode without clobbering one register.
879 */
880vector_fiq:
881 disable_fiq
882 subs pc, lr, #4
883
884/*=============================================================================
885 * Address exception handler
886 *-----------------------------------------------------------------------------
887 * These aren't too critical.
888 * (they're not supposed to happen, and won't happen in 32-bit data mode).
889 */
890
891vector_addrexcptn:
892 b vector_addrexcptn
893
894/*
895 * We group all the following data together to optimise
896 * for CPUs with separate I & D caches.
897 */
898 .align 5
899
900.LCvswi:
901 .word vector_swi
902
903.LCsirq:
904 .word __temp_irq
905.LCsund:
906 .word __temp_und
907.LCsabt:
908 .word __temp_abt
909
7933523d 910 .globl __stubs_end
1da177e4
LT
911__stubs_end:
912
7933523d 913 .equ stubs_offset, __vectors_start + 0x200 - __stubs_start
1da177e4 914
7933523d
RK
915 .globl __vectors_start
916__vectors_start:
1da177e4 917 swi SYS_ERROR0
7933523d
RK
918 b vector_und + stubs_offset
919 ldr pc, .LCvswi + stubs_offset
920 b vector_pabt + stubs_offset
921 b vector_dabt + stubs_offset
922 b vector_addrexcptn + stubs_offset
923 b vector_irq + stubs_offset
924 b vector_fiq + stubs_offset
925
926 .globl __vectors_end
927__vectors_end:
1da177e4
LT
928
929 .data
930
931/*
932 * Do not reorder these, and do not insert extra data between...
933 */
934
935__temp_irq:
936 .word 0 @ saved lr_irq
937 .word 0 @ saved spsr_irq
938 .word -1 @ old_r0
939__temp_und:
940 .word 0 @ Saved lr_und
941 .word 0 @ Saved spsr_und
942 .word -1 @ old_r0
943__temp_abt:
944 .word 0 @ Saved lr_abt
945 .word 0 @ Saved spsr_abt
946 .word -1 @ old_r0
947
948 .globl cr_alignment
949 .globl cr_no_alignment
950cr_alignment:
951 .space 4
952cr_no_alignment:
953 .space 4