blob: 55c99cdab7d64f430f1e3063343111cfdf9dfce9 [file] [log] [blame]
Russell Kingbce495d2005-04-26 15:21:02 +01001#include <linux/config.h>
2#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003#include <linux/linkage.h>
4
5#include <asm/assembler.h>
Sam Ravnborge6ae7442005-09-09 21:08:59 +02006#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm/errno.h>
Russell Kingbce495d2005-04-26 15:21:02 +01008#include <asm/thread_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10@ Bad Abort numbers
11@ -----------------
12@
13#define BAD_PREFETCH 0
14#define BAD_DATA 1
15#define BAD_ADDREXCPTN 2
16#define BAD_IRQ 3
17#define BAD_UNDEFINSTR 4
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019@
Russell King925c8a12005-04-26 15:18:59 +010020@ Most of the stack format comes from struct pt_regs, but with
21@ the addition of 8 bytes for storing syscall args 5 and 6.
Nicolas Pitre2dede2d2006-01-14 16:18:08 +000022@ This _must_ remain a multiple of 8 for EABI.
Linus Torvalds1da177e2005-04-16 15:20:36 -070023@
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#define S_OFF 8
25
Russell King925c8a12005-04-26 15:18:59 +010026/*
27 * The SWI code relies on the fact that R0 is at the bottom of the stack
28 * (due to slow/fast restore user regs).
29 */
30#if S_R0 != 0
31#error "Please fix"
32#endif
33
Russell Kingbce495d2005-04-26 15:21:02 +010034 .macro zero_fp
35#ifdef CONFIG_FRAME_POINTER
36 mov fp, #0
37#endif
38 .endm
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#if __LINUX_ARM_ARCH__ >= 6
Russell King1ec42c02005-04-26 15:18:26 +010041 .macro disable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 cpsid i
43 .endm
44
Russell King1ec42c02005-04-26 15:18:26 +010045 .macro enable_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 cpsie i
47 .endm
48#else
Russell King1ec42c02005-04-26 15:18:26 +010049 .macro disable_irq
50 msr cpsr_c, #PSR_I_BIT | SVC_MODE
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 .endm
52
Russell King1ec42c02005-04-26 15:18:26 +010053 .macro enable_irq
54 msr cpsr_c, #SVC_MODE
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 .endm
56#endif
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 .macro get_thread_info, rd
59 mov \rd, sp, lsr #13
60 mov \rd, \rd, lsl #13
61 .endm
62
Russell King49f680e2005-05-31 18:02:00 +010063 .macro alignment_trap, rtemp
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#ifdef CONFIG_ALIGNMENT_TRAP
Russell King49f680e2005-05-31 18:02:00 +010065 ldr \rtemp, .LCcralign
66 ldr \rtemp, [\rtemp]
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 mcr p15, 0, \rtemp, c1, c0
68#endif
69 .endm
70
71
72/*
73 * These are the registers used in the syscall handler, and allow us to
74 * have in theory up to 7 arguments to a function - r0 to r6.
75 *
76 * r7 is reserved for the system call number for thumb mode.
77 *
78 * Note that tbl == why is intentional.
79 *
80 * We must set at least "tsk" and "why" when calling ret_with_reschedule.
81 */
82scno .req r7 @ syscall number
83tbl .req r8 @ syscall table pointer
84why .req r8 @ Linux syscall (!= 0)
85tsk .req r9 @ current thread_info