blob: fb283f239ea4c8f99a08e9d6487dbd42f5a49037 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Alexey Brodkin23d1b352015-02-24 17:08:44 +03002/*
3 * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved.
Alexey Brodkin23d1b352015-02-24 17:08:44 +03004 */
5
6#include <linux/linkage.h>
7
8/*
9 * Note on the LD/ST addressing modes with address register write-back
10 *
11 * LD.a same as LD.aw
12 *
13 * LD.a reg1, [reg2, x] => Pre Incr
14 * Eff Addr for load = [reg2 + x]
15 *
16 * LD.ab reg1, [reg2, x] => Post Incr
17 * Eff Addr for load = [reg2]
18 */
19
20.macro PUSH reg
21 st.a \reg, [%sp, -4]
22.endm
23
24.macro PUSHAX aux
25 lr %r9, [\aux]
26 PUSH %r9
27.endm
28
29.macro SAVE_R1_TO_R24
30 PUSH %r1
31 PUSH %r2
32 PUSH %r3
33 PUSH %r4
34 PUSH %r5
35 PUSH %r6
36 PUSH %r7
37 PUSH %r8
38 PUSH %r9
39 PUSH %r10
40 PUSH %r11
41 PUSH %r12
42 PUSH %r13
43 PUSH %r14
44 PUSH %r15
45 PUSH %r16
46 PUSH %r17
47 PUSH %r18
48 PUSH %r19
49 PUSH %r20
50 PUSH %r21
51 PUSH %r22
52 PUSH %r23
53 PUSH %r24
54.endm
55
56.macro SAVE_ALL_SYS
57 /* saving %r0 to reg->r0 in advance since we read %ecr into it */
58 st %r0, [%sp, -8]
59 lr %r0, [%ecr] /* all stack addressing is manual so far */
60 st %r0, [%sp]
61 st %sp, [%sp, -4]
62 /* now move %sp to reg->r0 position so we can do "push" automatically */
63 sub %sp, %sp, 8
64
65 SAVE_R1_TO_R24
66 PUSH %r25
67 PUSH %gp
68 PUSH %fp
69 PUSH %blink
70 PUSHAX %eret
71 PUSHAX %erstatus
72 PUSH %lp_count
73 PUSHAX %lp_end
74 PUSHAX %lp_start
75 PUSHAX %erbta
76.endm
77
78.macro SAVE_EXCEPTION_SOURCE
Alexey Brodkin23d1b352015-02-24 17:08:44 +030079 /* Otherwise in ERET (exception return) reg */
80 lr %r0, [%eret]
Alexey Brodkin23d1b352015-02-24 17:08:44 +030081.endm
82
83ENTRY(memory_error)
84 SAVE_ALL_SYS
85 SAVE_EXCEPTION_SOURCE
86 mov %r1, %sp
87 j do_memory_error
88ENDPROC(memory_error)
89
90ENTRY(instruction_error)
91 SAVE_ALL_SYS
92 SAVE_EXCEPTION_SOURCE
93 mov %r1, %sp
94 j do_instruction_error
95ENDPROC(instruction_error)
96
97ENTRY(interrupt_handler)
98 /* Todo - save and restore CPU context when interrupts will be in use */
99 bl do_interrupt_handler
100 rtie
101ENDPROC(interrupt_handler)
102
103ENTRY(EV_MachineCheck)
104 SAVE_ALL_SYS
105 SAVE_EXCEPTION_SOURCE
106 mov %r1, %sp
107 j do_machine_check_fault
108ENDPROC(EV_MachineCheck)
109
110ENTRY(EV_TLBMissI)
111 SAVE_ALL_SYS
112 mov %r0, %sp
113 j do_itlb_miss
114ENDPROC(EV_TLBMissI)
115
116ENTRY(EV_TLBMissD)
117 SAVE_ALL_SYS
118 mov %r0, %sp
119 j do_dtlb_miss
120ENDPROC(EV_TLBMissD)
121
122ENTRY(EV_TLBProtV)
123 SAVE_ALL_SYS
124 SAVE_EXCEPTION_SOURCE
125 mov %r1, %sp
126 j do_tlb_prot_violation
127ENDPROC(EV_TLBProtV)
128
129ENTRY(EV_PrivilegeV)
130 SAVE_ALL_SYS
131 mov %r0, %sp
132 j do_privilege_violation
133ENDPROC(EV_PrivilegeV)
134
135ENTRY(EV_Trap)
136 SAVE_ALL_SYS
137 mov %r0, %sp
138 j do_trap
139ENDPROC(EV_Trap)
140
141ENTRY(EV_Extension)
142 SAVE_ALL_SYS
143 mov %r0, %sp
144 j do_extension
145ENDPROC(EV_Extension)
Alexey Brodkine20c2892016-08-04 09:21:50 +0300146
147#ifdef CONFIG_ISA_ARCV2
148ENTRY(EV_SWI)
149 SAVE_ALL_SYS
150 mov %r0, %sp
151 j do_swi
152ENDPROC(EV_SWI)
153
154ENTRY(EV_DivZero)
155 SAVE_ALL_SYS
156 SAVE_EXCEPTION_SOURCE
157 mov %r1, %sp
158 j do_divzero
159ENDPROC(EV_DivZero)
160
161ENTRY(EV_DCError)
162 SAVE_ALL_SYS
163 mov %r0, %sp
164 j do_dcerror
165ENDPROC(EV_DCError)
166
167ENTRY(EV_Maligned)
168 SAVE_ALL_SYS
169 SAVE_EXCEPTION_SOURCE
170 mov %r1, %sp
171 j do_maligned
172ENDPROC(EV_Maligned)
173#endif