1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 1999 Hewlett-Packard (Frank Rowand)
4 * Copyright (C) 1999 Philipp Rumpf <prumpf@tux.org>
5 * Copyright (C) 1999 SuSE GmbH
8 #ifndef _PARISC_ASSEMBLY_H
9 #define _PARISC_ASSEMBLY_H
11 #define CALLEE_FLOAT_FRAME_SIZE 80
22 #define COND(x) * ## x
24 #define FRAME_SIZE 128
25 #define CALLEE_REG_FRAME_SIZE 144
27 #define ASM_ULONG_INSN .dword
28 #else /* CONFIG_64BIT */
40 #define CALLEE_REG_FRAME_SIZE 128
42 #define ASM_ULONG_INSN .word
45 #define CALLEE_SAVE_FRAME_SIZE (CALLEE_REG_FRAME_SIZE + CALLEE_FLOAT_FRAME_SIZE)
51 # define PA_ASM_LEVEL 2.0w
53 # define PA_ASM_LEVEL 2.0
58 #define PA_ASM_LEVEL 1.1
64 /* the 64-bit pa gnu assembler unfortunately defaults to .level 1.1 or 2.0 so
65 * work around that for now... */
69 #include <asm/asm-offsets.h>
71 #include <asm/types.h>
73 #include <asm/asmregs.h>
80 * We provide two versions of each macro to convert from physical
81 * to virtual and vice versa. The "_r1" versions take one argument
82 * register, but trashes r1 to do the conversion. The other
83 * version takes two arguments: a src and destination register.
84 * However, the source and destination registers can not be
88 .macro tophys grvirt
, grphys
89 ldil L
%(__PAGE_OFFSET
), \grphys
90 sub \grvirt
, \grphys
, \grphys
93 .macro tovirt grphys
, grvirt
94 ldil L
%(__PAGE_OFFSET
), \grvirt
95 add \grphys
, \grvirt
, \grvirt
99 ldil L
%(__PAGE_OFFSET
), %r1
104 ldil L
%(__PAGE_OFFSET
), %r1
120 zdep
\r, 31-(\sa
), 32-(\sa
), \t
123 /* And the PA 2.0W shift left */
125 depd
,z
\r, 63-(\sa
), 64-(\sa
), \t
128 /* Shift Right - note the r and t can NOT be the same! */
130 extru
\r, 31-(\sa
), 32-(\sa
), \t
133 /* pa20w version of shift right */
135 extrd
,u
\r, 63-(\sa
), 64-(\sa
), \t
138 /* load 32-bit 'value' into 'reg' compensating for the ldil
139 * sign-extension when running in wide mode.
140 * WARNING!! neither 'value' nor 'reg' can be expressions
141 * containing '.'!!!! */
142 .macro load32 value
, reg
144 ldo R
%\value
(\reg
), \reg
150 ldo R
%__gp(%r27
), %r27
152 ldil L
%$global$
, %r27
153 ldo R
%$global$
(%r27
), %r27
157 #define SAVE_SP(r, where) mfsp r, %r1 ! STREG %r1, where
158 #define REST_SP(r, where) LDREG where, %r1 ! mtsp %r1, r
159 #define SAVE_CR(r, where) mfctl r, %r1 ! STREG %r1, where
160 #define REST_CR(r, where) LDREG where, %r1 ! mtctl %r1, r
162 .macro save_general regs
163 STREG
%r1
, PT_GR1 (\regs
)
164 STREG
%r2
, PT_GR2 (\regs
)
165 STREG
%r3
, PT_GR3 (\regs
)
166 STREG
%r4
, PT_GR4 (\regs
)
167 STREG
%r5
, PT_GR5 (\regs
)
168 STREG
%r6
, PT_GR6 (\regs
)
169 STREG
%r7
, PT_GR7 (\regs
)
170 STREG
%r8
, PT_GR8 (\regs
)
171 STREG
%r9
, PT_GR9 (\regs
)
172 STREG
%r10
, PT_GR10(\regs
)
173 STREG
%r11
, PT_GR11(\regs
)
174 STREG
%r12
, PT_GR12(\regs
)
175 STREG
%r13
, PT_GR13(\regs
)
176 STREG
%r14
, PT_GR14(\regs
)
177 STREG
%r15
, PT_GR15(\regs
)
178 STREG
%r16
, PT_GR16(\regs
)
179 STREG
%r17
, PT_GR17(\regs
)
180 STREG
%r18
, PT_GR18(\regs
)
181 STREG
%r19
, PT_GR19(\regs
)
182 STREG
%r20
, PT_GR20(\regs
)
183 STREG
%r21
, PT_GR21(\regs
)
184 STREG
%r22
, PT_GR22(\regs
)
185 STREG
%r23
, PT_GR23(\regs
)
186 STREG
%r24
, PT_GR24(\regs
)
187 STREG
%r25
, PT_GR25(\regs
)
188 /* r26 is saved in get_stack and used to preserve a value across virt_map */
189 STREG
%r27
, PT_GR27(\regs
)
190 STREG
%r28
, PT_GR28(\regs
)
191 /* r29 is saved in get_stack and used to point to saved registers */
192 /* r30 stack pointer saved in get_stack */
193 STREG
%r31
, PT_GR31(\regs
)
196 .macro rest_general regs
197 /* r1 used as a temp in rest_stack and is restored there */
198 LDREG
PT_GR2 (\regs
), %r2
199 LDREG
PT_GR3 (\regs
), %r3
200 LDREG
PT_GR4 (\regs
), %r4
201 LDREG
PT_GR5 (\regs
), %r5
202 LDREG
PT_GR6 (\regs
), %r6
203 LDREG
PT_GR7 (\regs
), %r7
204 LDREG
PT_GR8 (\regs
), %r8
205 LDREG
PT_GR9 (\regs
), %r9
206 LDREG
PT_GR10(\regs
), %r10
207 LDREG
PT_GR11(\regs
), %r11
208 LDREG
PT_GR12(\regs
), %r12
209 LDREG
PT_GR13(\regs
), %r13
210 LDREG
PT_GR14(\regs
), %r14
211 LDREG
PT_GR15(\regs
), %r15
212 LDREG
PT_GR16(\regs
), %r16
213 LDREG
PT_GR17(\regs
), %r17
214 LDREG
PT_GR18(\regs
), %r18
215 LDREG
PT_GR19(\regs
), %r19
216 LDREG
PT_GR20(\regs
), %r20
217 LDREG
PT_GR21(\regs
), %r21
218 LDREG
PT_GR22(\regs
), %r22
219 LDREG
PT_GR23(\regs
), %r23
220 LDREG
PT_GR24(\regs
), %r24
221 LDREG
PT_GR25(\regs
), %r25
222 LDREG
PT_GR26(\regs
), %r26
223 LDREG
PT_GR27(\regs
), %r27
224 LDREG
PT_GR28(\regs
), %r28
225 /* r29 points to register save area, and is restored in rest_stack */
226 /* r30 stack pointer restored in rest_stack */
227 LDREG
PT_GR31(\regs
), %r31
231 fstd
,ma
%fr0
, 8(\regs
)
232 fstd
,ma
%fr1
, 8(\regs
)
233 fstd
,ma
%fr2
, 8(\regs
)
234 fstd
,ma
%fr3
, 8(\regs
)
235 fstd
,ma
%fr4
, 8(\regs
)
236 fstd
,ma
%fr5
, 8(\regs
)
237 fstd
,ma
%fr6
, 8(\regs
)
238 fstd
,ma
%fr7
, 8(\regs
)
239 fstd
,ma
%fr8
, 8(\regs
)
240 fstd
,ma
%fr9
, 8(\regs
)
241 fstd
,ma
%fr10
, 8(\regs
)
242 fstd
,ma
%fr11
, 8(\regs
)
243 fstd
,ma
%fr12
, 8(\regs
)
244 fstd
,ma
%fr13
, 8(\regs
)
245 fstd
,ma
%fr14
, 8(\regs
)
246 fstd
,ma
%fr15
, 8(\regs
)
247 fstd
,ma
%fr16
, 8(\regs
)
248 fstd
,ma
%fr17
, 8(\regs
)
249 fstd
,ma
%fr18
, 8(\regs
)
250 fstd
,ma
%fr19
, 8(\regs
)
251 fstd
,ma
%fr20
, 8(\regs
)
252 fstd
,ma
%fr21
, 8(\regs
)
253 fstd
,ma
%fr22
, 8(\regs
)
254 fstd
,ma
%fr23
, 8(\regs
)
255 fstd
,ma
%fr24
, 8(\regs
)
256 fstd
,ma
%fr25
, 8(\regs
)
257 fstd
,ma
%fr26
, 8(\regs
)
258 fstd
,ma
%fr27
, 8(\regs
)
259 fstd
,ma
%fr28
, 8(\regs
)
260 fstd
,ma
%fr29
, 8(\regs
)
261 fstd
,ma
%fr30
, 8(\regs
)
267 fldd
,mb
-8(\regs
), %fr30
268 fldd
,mb
-8(\regs
), %fr29
269 fldd
,mb
-8(\regs
), %fr28
270 fldd
,mb
-8(\regs
), %fr27
271 fldd
,mb
-8(\regs
), %fr26
272 fldd
,mb
-8(\regs
), %fr25
273 fldd
,mb
-8(\regs
), %fr24
274 fldd
,mb
-8(\regs
), %fr23
275 fldd
,mb
-8(\regs
), %fr22
276 fldd
,mb
-8(\regs
), %fr21
277 fldd
,mb
-8(\regs
), %fr20
278 fldd
,mb
-8(\regs
), %fr19
279 fldd
,mb
-8(\regs
), %fr18
280 fldd
,mb
-8(\regs
), %fr17
281 fldd
,mb
-8(\regs
), %fr16
282 fldd
,mb
-8(\regs
), %fr15
283 fldd
,mb
-8(\regs
), %fr14
284 fldd
,mb
-8(\regs
), %fr13
285 fldd
,mb
-8(\regs
), %fr12
286 fldd
,mb
-8(\regs
), %fr11
287 fldd
,mb
-8(\regs
), %fr10
288 fldd
,mb
-8(\regs
), %fr9
289 fldd
,mb
-8(\regs
), %fr8
290 fldd
,mb
-8(\regs
), %fr7
291 fldd
,mb
-8(\regs
), %fr6
292 fldd
,mb
-8(\regs
), %fr5
293 fldd
,mb
-8(\regs
), %fr4
294 fldd
,mb
-8(\regs
), %fr3
295 fldd
,mb
-8(\regs
), %fr2
296 fldd
,mb
-8(\regs
), %fr1
297 fldd
,mb
-8(\regs
), %fr0
300 .macro callee_save_float
301 fstd
,ma
%fr12
, 8(%r30
)
302 fstd
,ma
%fr13
, 8(%r30
)
303 fstd
,ma
%fr14
, 8(%r30
)
304 fstd
,ma
%fr15
, 8(%r30
)
305 fstd
,ma
%fr16
, 8(%r30
)
306 fstd
,ma
%fr17
, 8(%r30
)
307 fstd
,ma
%fr18
, 8(%r30
)
308 fstd
,ma
%fr19
, 8(%r30
)
309 fstd
,ma
%fr20
, 8(%r30
)
310 fstd
,ma
%fr21
, 8(%r30
)
313 .macro callee_rest_float
314 fldd
,mb
-8(%r30
), %fr21
315 fldd
,mb
-8(%r30
), %fr20
316 fldd
,mb
-8(%r30
), %fr19
317 fldd
,mb
-8(%r30
), %fr18
318 fldd
,mb
-8(%r30
), %fr17
319 fldd
,mb
-8(%r30
), %fr16
320 fldd
,mb
-8(%r30
), %fr15
321 fldd
,mb
-8(%r30
), %fr14
322 fldd
,mb
-8(%r30
), %fr13
323 fldd
,mb
-8(%r30
), %fr12
328 std
,ma
%r3
, CALLEE_REG_FRAME_SIZE(%r30
)
366 ldd
,mb
-CALLEE_REG_FRAME_SIZE(%r30
), %r3
369 #else /* ! CONFIG_64BIT */
372 stw
,ma
%r3
, CALLEE_REG_FRAME_SIZE(%r30
)
410 ldw
,mb
-CALLEE_REG_FRAME_SIZE(%r30
), %r3
412 #endif /* ! CONFIG_64BIT */
414 .macro save_specials regs
416 SAVE_SP (%sr0
, PT_SR0 (\regs
))
417 SAVE_SP (%sr1
, PT_SR1 (\regs
))
418 SAVE_SP (%sr2
, PT_SR2 (\regs
))
419 SAVE_SP (%sr3
, PT_SR3 (\regs
))
420 SAVE_SP (%sr4
, PT_SR4 (\regs
))
421 SAVE_SP (%sr5
, PT_SR5 (\regs
))
422 SAVE_SP (%sr6
, PT_SR6 (\regs
))
424 SAVE_CR (%cr17
, PT_IASQ0(\regs
))
426 SAVE_CR (%cr17
, PT_IASQ1(\regs
))
428 SAVE_CR (%cr18
, PT_IAOQ0(\regs
))
430 SAVE_CR (%cr18
, PT_IAOQ1(\regs
))
433 /* cr11 (sar) is a funny one. 5 bits on PA1.1 and 6 bit on PA2.0
434 * For PA2.0 mtsar or mtctl always write 6 bits, but mfctl only
435 * reads 5 bits. Use mfctl,w to read all six bits. Otherwise
436 * we lose the 6th bit on a save/restore over interrupt.
439 STREG
%r1
, PT_SAR (\regs
)
441 SAVE_CR (%cr11
, PT_SAR (\regs
))
443 SAVE_CR (%cr19
, PT_IIR (\regs
))
446 * Code immediately following this macro (in intr_save) relies
447 * on r8 containing ipsw.
450 STREG
%r8
, PT_PSW(\regs
)
453 .macro rest_specials regs
455 REST_SP (%sr0
, PT_SR0 (\regs
))
456 REST_SP (%sr1
, PT_SR1 (\regs
))
457 REST_SP (%sr2
, PT_SR2 (\regs
))
458 REST_SP (%sr3
, PT_SR3 (\regs
))
459 REST_SP (%sr4
, PT_SR4 (\regs
))
460 REST_SP (%sr5
, PT_SR5 (\regs
))
461 REST_SP (%sr6
, PT_SR6 (\regs
))
462 REST_SP (%sr7
, PT_SR7 (\regs
))
464 REST_CR (%cr17
, PT_IASQ0(\regs
))
465 REST_CR (%cr17
, PT_IASQ1(\regs
))
467 REST_CR (%cr18
, PT_IAOQ0(\regs
))
468 REST_CR (%cr18
, PT_IAOQ1(\regs
))
470 REST_CR (%cr11
, PT_SAR (\regs
))
472 REST_CR (%cr22
, PT_PSW (\regs
))
476 /* First step to create a "relied upon translation"
477 * See PA 2.0 Arch. page F-4 and F-5.
479 * The ssm was originally necessary due to a "PCxT bug".
480 * But someone decided it needed to be added to the architecture
481 * and this "feature" went into rev3 of PA-RISC 1.1 Arch Manual.
482 * It's been carried forward into PA 2.0 Arch as well. :^(
484 * "ssm 0,%r0" is a NOP with side effects (prefetch barrier).
485 * rsm/ssm prevents the ifetch unit from speculatively fetching
486 * instructions past this line in the code stream.
487 * PA 2.0 processor will single step all insn in the same QUAD (4 insn).
501 * ASM_EXCEPTIONTABLE_ENTRY
503 * Creates an exception table entry.
504 * Do not convert to a assembler macro. This won't work.
506 #define ASM_EXCEPTIONTABLE_ENTRY(fault_addr, except_addr) \
507 .section __ex_table,"aw" ! \
508 .word (fault_addr - .), (except_addr - .) ! \
512 #endif /* __ASSEMBLY__ */