summaryrefslogtreecommitdiff
path: root/arch/arc/lib/ints_low.S
blob: 38c45c60a955163557133ab80cf40013e392565b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved.
 */

#include <linux/linkage.h>

/*
 * Note on the LD/ST addressing modes with address register write-back
 *
 * LD.a same as LD.aw
 *
 * LD.a    reg1, [reg2, x]  => Pre Incr
 *      Eff Addr for load = [reg2 + x]
 *
 * LD.ab   reg1, [reg2, x]  => Post Incr
 *      Eff Addr for load = [reg2]
 */

.macro PUSH reg
	st.a	\reg, [%sp, -4]
.endm

.macro PUSHAX aux
	lr	%r9, [\aux]
	PUSH	%r9
.endm

.macro  SAVE_R1_TO_R24
	PUSH	%r1
	PUSH	%r2
	PUSH	%r3
	PUSH	%r4
	PUSH	%r5
	PUSH	%r6
	PUSH	%r7
	PUSH	%r8
	PUSH	%r9
	PUSH	%r10
	PUSH	%r11
	PUSH	%r12
	PUSH	%r13
	PUSH	%r14
	PUSH	%r15
	PUSH	%r16
	PUSH	%r17
	PUSH	%r18
	PUSH	%r19
	PUSH	%r20
	PUSH	%r21
	PUSH	%r22
	PUSH	%r23
	PUSH	%r24
.endm

.macro SAVE_ALL_SYS
	/* saving %r0 to reg->r0 in advance since we read %ecr into it */
	st	%r0, [%sp, -8]
	lr	%r0, [%ecr]	/* all stack addressing is manual so far */
	st	%r0, [%sp]
	st	%sp, [%sp, -4]
	/* now move %sp to reg->r0 position so we can do "push" automatically */
	sub	%sp, %sp, 8

	SAVE_R1_TO_R24
	PUSH	%r25
	PUSH	%gp
	PUSH	%fp
	PUSH	%blink
	PUSHAX	%eret
	PUSHAX	%erstatus
	PUSH	%lp_count
	PUSHAX	%lp_end
	PUSHAX	%lp_start
	PUSHAX	%erbta
.endm

.macro SAVE_EXCEPTION_SOURCE
#ifdef CONFIG_MMU
	/* If MMU exists exception faulting address is loaded in EFA reg */
	lr	%r0, [%efa]
#else
	/* Otherwise in ERET (exception return) reg */
	lr	%r0, [%eret]
#endif
.endm

ENTRY(memory_error)
	SAVE_ALL_SYS
	SAVE_EXCEPTION_SOURCE
	mov	%r1, %sp
	j	do_memory_error
ENDPROC(memory_error)

ENTRY(instruction_error)
	SAVE_ALL_SYS
	SAVE_EXCEPTION_SOURCE
	mov	%r1, %sp
	j	do_instruction_error
ENDPROC(instruction_error)

ENTRY(interrupt_handler)
	/* Todo - save and restore CPU context when interrupts will be in use */
	bl	do_interrupt_handler
	rtie
ENDPROC(interrupt_handler)

ENTRY(EV_MachineCheck)
	SAVE_ALL_SYS
	SAVE_EXCEPTION_SOURCE
	mov	%r1, %sp
	j	do_machine_check_fault
ENDPROC(EV_MachineCheck)

ENTRY(EV_TLBMissI)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_itlb_miss
ENDPROC(EV_TLBMissI)

ENTRY(EV_TLBMissD)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_dtlb_miss
ENDPROC(EV_TLBMissD)

ENTRY(EV_TLBProtV)
	SAVE_ALL_SYS
	SAVE_EXCEPTION_SOURCE
	mov	%r1, %sp
	j	do_tlb_prot_violation
ENDPROC(EV_TLBProtV)

ENTRY(EV_PrivilegeV)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_privilege_violation
ENDPROC(EV_PrivilegeV)

ENTRY(EV_Trap)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_trap
ENDPROC(EV_Trap)

ENTRY(EV_Extension)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_extension
ENDPROC(EV_Extension)

#ifdef CONFIG_ISA_ARCV2
ENTRY(EV_SWI)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_swi
ENDPROC(EV_SWI)

ENTRY(EV_DivZero)
	SAVE_ALL_SYS
	SAVE_EXCEPTION_SOURCE
	mov	%r1, %sp
	j	do_divzero
ENDPROC(EV_DivZero)

ENTRY(EV_DCError)
	SAVE_ALL_SYS
	mov	%r0, %sp
	j	do_dcerror
ENDPROC(EV_DCError)

ENTRY(EV_Maligned)
	SAVE_ALL_SYS
	SAVE_EXCEPTION_SOURCE
	mov	%r1, %sp
	j	do_maligned
ENDPROC(EV_Maligned)
#endif