1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef __ASSEMBLY__
20#error "Only include this from assembly code"
21#endif
22
23#ifndef __ASM_ASSEMBLER_H
24#define __ASM_ASSEMBLER_H
25
26#include <asm/ptrace.h>
27#include <asm/thread_info.h>
28
29
30
31
32
33 .macro push, xreg1, xreg2
34 stp \xreg1, \xreg2, [sp, #-16]!
35 .endm
36
37 .macro pop, xreg1, xreg2
38 ldp \xreg1, \xreg2, [sp], #16
39 .endm
40
41
42
43
44 .macro disable_irq
45 msr daifset, #2
46 .endm
47
48 .macro enable_irq
49 msr daifclr, #2
50 .endm
51
52
53
54
55 .macro disable_dbg
56 msr daifset, #8
57 .endm
58
59 .macro enable_dbg
60 msr daifclr, #8
61 .endm
62
63 .macro disable_step_tsk, flgs, tmp
64 tbz \flgs, #TIF_SINGLESTEP, 9990f
65 mrs \tmp, mdscr_el1
66 bic \tmp, \tmp, #1
67 msr mdscr_el1, \tmp
68 isb
699990:
70 .endm
71
72 .macro enable_step_tsk, flgs, tmp
73 tbz \flgs, #TIF_SINGLESTEP, 9990f
74 disable_dbg
75 mrs \tmp, mdscr_el1
76 orr \tmp, \tmp, #1
77 msr mdscr_el1, \tmp
789990:
79 .endm
80
81
82
83
84
85
86 .macro enable_dbg_and_irq
87 msr daifclr, #(8 | 2)
88 .endm
89
90
91
92
93 .macro smp_dmb, opt
94 dmb \opt
95 .endm
96
97
98
99
100 .macro _asm_extable, from, to
101 .pushsection __ex_table, "a"
102 .align 3
103 .long (\from - .), (\to - .)
104 .popsection
105 .endm
106
107#define USER(l, x...) \
1089999: x; \
109 _asm_extable 9999b, l
110
111
112
113
114lr .req x30
115
116
117
118
119 .macro ventry label
120 .align 7
121 b \label
122 .endm
123
124
125
126
127#ifdef CONFIG_CPU_BIG_ENDIAN
128#define CPU_BE(code...) code
129#else
130#define CPU_BE(code...)
131#endif
132
133
134
135
136#ifdef CONFIG_CPU_BIG_ENDIAN
137#define CPU_LE(code...)
138#else
139#define CPU_LE(code...) code
140#endif
141
142
143
144
145
146
147#ifndef CONFIG_CPU_BIG_ENDIAN
148 .macro regs_to_64, rd, lbits, hbits
149#else
150 .macro regs_to_64, rd, hbits, lbits
151#endif
152 orr \rd, \lbits, \hbits, lsl #32
153 .endm
154
155
156
157
158
159
160
161
162
163
164
165 .macro adr_l, dst, sym, tmp=
166 .ifb \tmp
167 adrp \dst, \sym
168 add \dst, \dst, :lo12:\sym
169 .else
170 adrp \tmp, \sym
171 add \dst, \tmp, :lo12:\sym
172 .endif
173 .endm
174
175
176
177
178
179
180
181
182 .macro ldr_l, dst, sym, tmp=
183 .ifb \tmp
184 adrp \dst, \sym
185 ldr \dst, [\dst, :lo12:\sym]
186 .else
187 adrp \tmp, \sym
188 ldr \dst, [\tmp, :lo12:\sym]
189 .endif
190 .endm
191
192
193
194
195
196
197
198 .macro str_l, src, sym, tmp
199 adrp \tmp, \sym
200 str \src, [\tmp, :lo12:\sym]
201 .endm
202
203
204
205
206
207
208 .macro this_cpu_ptr, sym, reg, tmp
209 adr_l \reg, \sym
210 mrs \tmp, tpidr_el1
211 add \reg, \reg, \tmp
212 .endm
213
214
215
216
217
218#define ENDPIPROC(x) \
219 .globl __pi_##x; \
220 .type __pi_##x, %function; \
221 .set __pi_##x, x; \
222 .size __pi_##x, . - x; \
223 ENDPROC(x)
224
225
226
227
228
229
230
231 .macro le64sym, sym
232 .long \sym\()_lo32
233 .long \sym\()_hi32
234 .endm
235
236#endif
237