xref: /openbmc/linux/arch/arm/kernel/entry-header.S (revision f4dc9a4cf26278f5b608d6e4bd16e7b27ddcf1a5)
1#include <linux/config.h> /* for CONFIG_ARCH_xxxx */
2#include <linux/linkage.h>
3
4#include <asm/assembler.h>
5#include <asm/constants.h>
6#include <asm/errno.h>
7#include <asm/hardware.h>
8#include <asm/arch/irqs.h>
9#include <asm/arch/entry-macro.S>
10
11	.macro	zero_fp
12#ifdef CONFIG_FRAME_POINTER
13	mov	fp, #0
14#endif
15	.endm
16
17	.text
18
19@ Bad Abort numbers
20@ -----------------
21@
22#define BAD_PREFETCH	0
23#define BAD_DATA	1
24#define BAD_ADDREXCPTN	2
25#define BAD_IRQ		3
26#define BAD_UNDEFINSTR	4
27
28@
29@ Most of the stack format comes from struct pt_regs, but with
30@ the addition of 8 bytes for storing syscall args 5 and 6.
31@
32#define S_OFF		8
33
34/*
35 * The SWI code relies on the fact that R0 is at the bottom of the stack
36 * (due to slow/fast restore user regs).
37 */
38#if S_R0 != 0
39#error "Please fix"
40#endif
41
42#if __LINUX_ARM_ARCH__ >= 6
43	.macro	disable_irq
44	cpsid	i
45	.endm
46
47	.macro	enable_irq
48	cpsie	i
49	.endm
50#else
51	.macro	disable_irq
52	msr	cpsr_c, #PSR_I_BIT | SVC_MODE
53	.endm
54
55	.macro	enable_irq
56	msr	cpsr_c, #SVC_MODE
57	.endm
58#endif
59
60	.macro	get_thread_info, rd
61	mov	\rd, sp, lsr #13
62	mov	\rd, \rd, lsl #13
63	.endm
64
65	.macro	alignment_trap, rbase, rtemp, sym
66#ifdef CONFIG_ALIGNMENT_TRAP
67#define OFF_CR_ALIGNMENT(x)	cr_alignment - x
68
69	ldr	\rtemp, [\rbase, #OFF_CR_ALIGNMENT(\sym)]
70	mcr	p15, 0, \rtemp, c1, c0
71#endif
72	.endm
73
74
75/*
76 * These are the registers used in the syscall handler, and allow us to
77 * have in theory up to 7 arguments to a function - r0 to r6.
78 *
79 * r7 is reserved for the system call number for thumb mode.
80 *
81 * Note that tbl == why is intentional.
82 *
83 * We must set at least "tsk" and "why" when calling ret_with_reschedule.
84 */
85scno	.req	r7		@ syscall number
86tbl	.req	r8		@ syscall table pointer
87why	.req	r8		@ Linux syscall (!= 0)
88tsk	.req	r9		@ current thread_info
89