xref: /openbmc/u-boot/arch/arc/lib/ints_low.S (revision f77d4410)
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (C) 2013-2015 Synopsys, Inc. All rights reserved.
4 */
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
79#ifdef CONFIG_MMU
80	/* If MMU exists exception faulting address is loaded in EFA reg */
81	lr	%r0, [%efa]
82#else
83	/* Otherwise in ERET (exception return) reg */
84	lr	%r0, [%eret]
85#endif
86.endm
87
88ENTRY(memory_error)
89	SAVE_ALL_SYS
90	SAVE_EXCEPTION_SOURCE
91	mov	%r1, %sp
92	j	do_memory_error
93ENDPROC(memory_error)
94
95ENTRY(instruction_error)
96	SAVE_ALL_SYS
97	SAVE_EXCEPTION_SOURCE
98	mov	%r1, %sp
99	j	do_instruction_error
100ENDPROC(instruction_error)
101
102ENTRY(interrupt_handler)
103	/* Todo - save and restore CPU context when interrupts will be in use */
104	bl	do_interrupt_handler
105	rtie
106ENDPROC(interrupt_handler)
107
108ENTRY(EV_MachineCheck)
109	SAVE_ALL_SYS
110	SAVE_EXCEPTION_SOURCE
111	mov	%r1, %sp
112	j	do_machine_check_fault
113ENDPROC(EV_MachineCheck)
114
115ENTRY(EV_TLBMissI)
116	SAVE_ALL_SYS
117	mov	%r0, %sp
118	j	do_itlb_miss
119ENDPROC(EV_TLBMissI)
120
121ENTRY(EV_TLBMissD)
122	SAVE_ALL_SYS
123	mov	%r0, %sp
124	j	do_dtlb_miss
125ENDPROC(EV_TLBMissD)
126
127ENTRY(EV_TLBProtV)
128	SAVE_ALL_SYS
129	SAVE_EXCEPTION_SOURCE
130	mov	%r1, %sp
131	j	do_tlb_prot_violation
132ENDPROC(EV_TLBProtV)
133
134ENTRY(EV_PrivilegeV)
135	SAVE_ALL_SYS
136	mov	%r0, %sp
137	j	do_privilege_violation
138ENDPROC(EV_PrivilegeV)
139
140ENTRY(EV_Trap)
141	SAVE_ALL_SYS
142	mov	%r0, %sp
143	j	do_trap
144ENDPROC(EV_Trap)
145
146ENTRY(EV_Extension)
147	SAVE_ALL_SYS
148	mov	%r0, %sp
149	j	do_extension
150ENDPROC(EV_Extension)
151
152#ifdef CONFIG_ISA_ARCV2
153ENTRY(EV_SWI)
154	SAVE_ALL_SYS
155	mov	%r0, %sp
156	j	do_swi
157ENDPROC(EV_SWI)
158
159ENTRY(EV_DivZero)
160	SAVE_ALL_SYS
161	SAVE_EXCEPTION_SOURCE
162	mov	%r1, %sp
163	j	do_divzero
164ENDPROC(EV_DivZero)
165
166ENTRY(EV_DCError)
167	SAVE_ALL_SYS
168	mov	%r0, %sp
169	j	do_dcerror
170ENDPROC(EV_DCError)
171
172ENTRY(EV_Maligned)
173	SAVE_ALL_SYS
174	SAVE_EXCEPTION_SOURCE
175	mov	%r1, %sp
176	j	do_maligned
177ENDPROC(EV_Maligned)
178#endif
179