18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 1999 Hewlett-Packard (Frank Rowand)
48c2ecf20Sopenharmony_ci * Copyright (C) 1999 Philipp Rumpf <prumpf@tux.org>
58c2ecf20Sopenharmony_ci * Copyright (C) 1999 SuSE GmbH
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _PARISC_ASSEMBLY_H
98c2ecf20Sopenharmony_ci#define _PARISC_ASSEMBLY_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define CALLEE_FLOAT_FRAME_SIZE	80
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
148c2ecf20Sopenharmony_ci#define LDREG	ldd
158c2ecf20Sopenharmony_ci#define STREG	std
168c2ecf20Sopenharmony_ci#define LDREGX  ldd,s
178c2ecf20Sopenharmony_ci#define LDREGM	ldd,mb
188c2ecf20Sopenharmony_ci#define STREGM	std,ma
198c2ecf20Sopenharmony_ci#define SHRREG	shrd
208c2ecf20Sopenharmony_ci#define SHLREG	shld
218c2ecf20Sopenharmony_ci#define ANDCM   andcm,*
228c2ecf20Sopenharmony_ci#define	COND(x)	* ## x
238c2ecf20Sopenharmony_ci#define RP_OFFSET	16
248c2ecf20Sopenharmony_ci#define FRAME_SIZE	128
258c2ecf20Sopenharmony_ci#define CALLEE_REG_FRAME_SIZE	144
268c2ecf20Sopenharmony_ci#define REG_SZ		8
278c2ecf20Sopenharmony_ci#define ASM_ULONG_INSN	.dword
288c2ecf20Sopenharmony_ci#else	/* CONFIG_64BIT */
298c2ecf20Sopenharmony_ci#define LDREG	ldw
308c2ecf20Sopenharmony_ci#define STREG	stw
318c2ecf20Sopenharmony_ci#define LDREGX  ldwx,s
328c2ecf20Sopenharmony_ci#define LDREGM	ldwm
338c2ecf20Sopenharmony_ci#define STREGM	stwm
348c2ecf20Sopenharmony_ci#define SHRREG	shr
358c2ecf20Sopenharmony_ci#define SHLREG	shlw
368c2ecf20Sopenharmony_ci#define ANDCM   andcm
378c2ecf20Sopenharmony_ci#define COND(x)	x
388c2ecf20Sopenharmony_ci#define RP_OFFSET	20
398c2ecf20Sopenharmony_ci#define FRAME_SIZE	64
408c2ecf20Sopenharmony_ci#define CALLEE_REG_FRAME_SIZE	128
418c2ecf20Sopenharmony_ci#define REG_SZ		4
428c2ecf20Sopenharmony_ci#define ASM_ULONG_INSN	.word
438c2ecf20Sopenharmony_ci#endif
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define CALLEE_SAVE_FRAME_SIZE (CALLEE_REG_FRAME_SIZE + CALLEE_FLOAT_FRAME_SIZE)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#ifdef CONFIG_PA20
488c2ecf20Sopenharmony_ci#define LDCW		ldcw,co
498c2ecf20Sopenharmony_ci#define BL		b,l
508c2ecf20Sopenharmony_ci# ifdef CONFIG_64BIT
518c2ecf20Sopenharmony_ci#  define PA_ASM_LEVEL	2.0w
528c2ecf20Sopenharmony_ci# else
538c2ecf20Sopenharmony_ci#  define PA_ASM_LEVEL	2.0
548c2ecf20Sopenharmony_ci# endif
558c2ecf20Sopenharmony_ci#else
568c2ecf20Sopenharmony_ci#define LDCW		ldcw
578c2ecf20Sopenharmony_ci#define BL		bl
588c2ecf20Sopenharmony_ci#define PA_ASM_LEVEL	1.1
598c2ecf20Sopenharmony_ci#endif
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#ifdef __ASSEMBLY__
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
648c2ecf20Sopenharmony_ci/* the 64-bit pa gnu assembler unfortunately defaults to .level 1.1 or 2.0 so
658c2ecf20Sopenharmony_ci * work around that for now... */
668c2ecf20Sopenharmony_ci	.level 2.0w
678c2ecf20Sopenharmony_ci#endif
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#include <asm/asm-offsets.h>
708c2ecf20Sopenharmony_ci#include <asm/page.h>
718c2ecf20Sopenharmony_ci#include <asm/types.h>
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#include <asm/asmregs.h>
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	sp	=	30
768c2ecf20Sopenharmony_ci	gp	=	27
778c2ecf20Sopenharmony_ci	ipsw	=	22
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	/*
808c2ecf20Sopenharmony_ci	 * We provide two versions of each macro to convert from physical
818c2ecf20Sopenharmony_ci	 * to virtual and vice versa. The "_r1" versions take one argument
828c2ecf20Sopenharmony_ci	 * register, but trashes r1 to do the conversion. The other
838c2ecf20Sopenharmony_ci	 * version takes two arguments: a src and destination register.
848c2ecf20Sopenharmony_ci	 * However, the source and destination registers can not be
858c2ecf20Sopenharmony_ci	 * the same register.
868c2ecf20Sopenharmony_ci	 */
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	.macro  tophys  grvirt, grphys
898c2ecf20Sopenharmony_ci	ldil    L%(__PAGE_OFFSET), \grphys
908c2ecf20Sopenharmony_ci	sub     \grvirt, \grphys, \grphys
918c2ecf20Sopenharmony_ci	.endm
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	.macro  tovirt  grphys, grvirt
948c2ecf20Sopenharmony_ci	ldil    L%(__PAGE_OFFSET), \grvirt
958c2ecf20Sopenharmony_ci	add     \grphys, \grvirt, \grvirt
968c2ecf20Sopenharmony_ci	.endm
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci	.macro  tophys_r1  gr
998c2ecf20Sopenharmony_ci	ldil    L%(__PAGE_OFFSET), %r1
1008c2ecf20Sopenharmony_ci	sub     \gr, %r1, \gr
1018c2ecf20Sopenharmony_ci	.endm
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	.macro  tovirt_r1  gr
1048c2ecf20Sopenharmony_ci	ldil    L%(__PAGE_OFFSET), %r1
1058c2ecf20Sopenharmony_ci	add     \gr, %r1, \gr
1068c2ecf20Sopenharmony_ci	.endm
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	.macro delay value
1098c2ecf20Sopenharmony_ci	ldil	L%\value, 1
1108c2ecf20Sopenharmony_ci	ldo	R%\value(1), 1
1118c2ecf20Sopenharmony_ci	addib,UV,n -1,1,.
1128c2ecf20Sopenharmony_ci	addib,NUV,n -1,1,.+8
1138c2ecf20Sopenharmony_ci	nop
1148c2ecf20Sopenharmony_ci	.endm
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci	.macro	debug value
1178c2ecf20Sopenharmony_ci	.endm
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci	.macro shlw r, sa, t
1208c2ecf20Sopenharmony_ci	zdep	\r, 31-(\sa), 32-(\sa), \t
1218c2ecf20Sopenharmony_ci	.endm
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	/* And the PA 2.0W shift left */
1248c2ecf20Sopenharmony_ci	.macro shld r, sa, t
1258c2ecf20Sopenharmony_ci	depd,z	\r, 63-(\sa), 64-(\sa), \t
1268c2ecf20Sopenharmony_ci	.endm
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	/* Shift Right - note the r and t can NOT be the same! */
1298c2ecf20Sopenharmony_ci	.macro shr r, sa, t
1308c2ecf20Sopenharmony_ci	extru \r, 31-(\sa), 32-(\sa), \t
1318c2ecf20Sopenharmony_ci	.endm
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	/* pa20w version of shift right */
1348c2ecf20Sopenharmony_ci	.macro shrd r, sa, t
1358c2ecf20Sopenharmony_ci	extrd,u \r, 63-(\sa), 64-(\sa), \t
1368c2ecf20Sopenharmony_ci	.endm
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci	/* load 32-bit 'value' into 'reg' compensating for the ldil
1398c2ecf20Sopenharmony_ci	 * sign-extension when running in wide mode.
1408c2ecf20Sopenharmony_ci	 * WARNING!! neither 'value' nor 'reg' can be expressions
1418c2ecf20Sopenharmony_ci	 * containing '.'!!!! */
1428c2ecf20Sopenharmony_ci	.macro	load32 value, reg
1438c2ecf20Sopenharmony_ci	ldil	L%\value, \reg
1448c2ecf20Sopenharmony_ci	ldo	R%\value(\reg), \reg
1458c2ecf20Sopenharmony_ci	.endm
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	.macro loadgp
1488c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
1498c2ecf20Sopenharmony_ci	ldil		L%__gp, %r27
1508c2ecf20Sopenharmony_ci	ldo		R%__gp(%r27), %r27
1518c2ecf20Sopenharmony_ci#else
1528c2ecf20Sopenharmony_ci	ldil		L%$global$, %r27
1538c2ecf20Sopenharmony_ci	ldo		R%$global$(%r27), %r27
1548c2ecf20Sopenharmony_ci#endif
1558c2ecf20Sopenharmony_ci	.endm
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci#define SAVE_SP(r, where) mfsp r, %r1 ! STREG %r1, where
1588c2ecf20Sopenharmony_ci#define REST_SP(r, where) LDREG where, %r1 ! mtsp %r1, r
1598c2ecf20Sopenharmony_ci#define SAVE_CR(r, where) mfctl r, %r1 ! STREG %r1, where
1608c2ecf20Sopenharmony_ci#define REST_CR(r, where) LDREG where, %r1 ! mtctl %r1, r
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	.macro	save_general	regs
1638c2ecf20Sopenharmony_ci	STREG %r1, PT_GR1 (\regs)
1648c2ecf20Sopenharmony_ci	STREG %r2, PT_GR2 (\regs)
1658c2ecf20Sopenharmony_ci	STREG %r3, PT_GR3 (\regs)
1668c2ecf20Sopenharmony_ci	STREG %r4, PT_GR4 (\regs)
1678c2ecf20Sopenharmony_ci	STREG %r5, PT_GR5 (\regs)
1688c2ecf20Sopenharmony_ci	STREG %r6, PT_GR6 (\regs)
1698c2ecf20Sopenharmony_ci	STREG %r7, PT_GR7 (\regs)
1708c2ecf20Sopenharmony_ci	STREG %r8, PT_GR8 (\regs)
1718c2ecf20Sopenharmony_ci	STREG %r9, PT_GR9 (\regs)
1728c2ecf20Sopenharmony_ci	STREG %r10, PT_GR10(\regs)
1738c2ecf20Sopenharmony_ci	STREG %r11, PT_GR11(\regs)
1748c2ecf20Sopenharmony_ci	STREG %r12, PT_GR12(\regs)
1758c2ecf20Sopenharmony_ci	STREG %r13, PT_GR13(\regs)
1768c2ecf20Sopenharmony_ci	STREG %r14, PT_GR14(\regs)
1778c2ecf20Sopenharmony_ci	STREG %r15, PT_GR15(\regs)
1788c2ecf20Sopenharmony_ci	STREG %r16, PT_GR16(\regs)
1798c2ecf20Sopenharmony_ci	STREG %r17, PT_GR17(\regs)
1808c2ecf20Sopenharmony_ci	STREG %r18, PT_GR18(\regs)
1818c2ecf20Sopenharmony_ci	STREG %r19, PT_GR19(\regs)
1828c2ecf20Sopenharmony_ci	STREG %r20, PT_GR20(\regs)
1838c2ecf20Sopenharmony_ci	STREG %r21, PT_GR21(\regs)
1848c2ecf20Sopenharmony_ci	STREG %r22, PT_GR22(\regs)
1858c2ecf20Sopenharmony_ci	STREG %r23, PT_GR23(\regs)
1868c2ecf20Sopenharmony_ci	STREG %r24, PT_GR24(\regs)
1878c2ecf20Sopenharmony_ci	STREG %r25, PT_GR25(\regs)
1888c2ecf20Sopenharmony_ci	/* r26 is saved in get_stack and used to preserve a value across virt_map */
1898c2ecf20Sopenharmony_ci	STREG %r27, PT_GR27(\regs)
1908c2ecf20Sopenharmony_ci	STREG %r28, PT_GR28(\regs)
1918c2ecf20Sopenharmony_ci	/* r29 is saved in get_stack and used to point to saved registers */
1928c2ecf20Sopenharmony_ci	/* r30 stack pointer saved in get_stack */
1938c2ecf20Sopenharmony_ci	STREG %r31, PT_GR31(\regs)
1948c2ecf20Sopenharmony_ci	.endm
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	.macro	rest_general	regs
1978c2ecf20Sopenharmony_ci	/* r1 used as a temp in rest_stack and is restored there */
1988c2ecf20Sopenharmony_ci	LDREG PT_GR2 (\regs), %r2
1998c2ecf20Sopenharmony_ci	LDREG PT_GR3 (\regs), %r3
2008c2ecf20Sopenharmony_ci	LDREG PT_GR4 (\regs), %r4
2018c2ecf20Sopenharmony_ci	LDREG PT_GR5 (\regs), %r5
2028c2ecf20Sopenharmony_ci	LDREG PT_GR6 (\regs), %r6
2038c2ecf20Sopenharmony_ci	LDREG PT_GR7 (\regs), %r7
2048c2ecf20Sopenharmony_ci	LDREG PT_GR8 (\regs), %r8
2058c2ecf20Sopenharmony_ci	LDREG PT_GR9 (\regs), %r9
2068c2ecf20Sopenharmony_ci	LDREG PT_GR10(\regs), %r10
2078c2ecf20Sopenharmony_ci	LDREG PT_GR11(\regs), %r11
2088c2ecf20Sopenharmony_ci	LDREG PT_GR12(\regs), %r12
2098c2ecf20Sopenharmony_ci	LDREG PT_GR13(\regs), %r13
2108c2ecf20Sopenharmony_ci	LDREG PT_GR14(\regs), %r14
2118c2ecf20Sopenharmony_ci	LDREG PT_GR15(\regs), %r15
2128c2ecf20Sopenharmony_ci	LDREG PT_GR16(\regs), %r16
2138c2ecf20Sopenharmony_ci	LDREG PT_GR17(\regs), %r17
2148c2ecf20Sopenharmony_ci	LDREG PT_GR18(\regs), %r18
2158c2ecf20Sopenharmony_ci	LDREG PT_GR19(\regs), %r19
2168c2ecf20Sopenharmony_ci	LDREG PT_GR20(\regs), %r20
2178c2ecf20Sopenharmony_ci	LDREG PT_GR21(\regs), %r21
2188c2ecf20Sopenharmony_ci	LDREG PT_GR22(\regs), %r22
2198c2ecf20Sopenharmony_ci	LDREG PT_GR23(\regs), %r23
2208c2ecf20Sopenharmony_ci	LDREG PT_GR24(\regs), %r24
2218c2ecf20Sopenharmony_ci	LDREG PT_GR25(\regs), %r25
2228c2ecf20Sopenharmony_ci	LDREG PT_GR26(\regs), %r26
2238c2ecf20Sopenharmony_ci	LDREG PT_GR27(\regs), %r27
2248c2ecf20Sopenharmony_ci	LDREG PT_GR28(\regs), %r28
2258c2ecf20Sopenharmony_ci	/* r29 points to register save area, and is restored in rest_stack */
2268c2ecf20Sopenharmony_ci	/* r30 stack pointer restored in rest_stack */
2278c2ecf20Sopenharmony_ci	LDREG PT_GR31(\regs), %r31
2288c2ecf20Sopenharmony_ci	.endm
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	.macro	save_fp 	regs
2318c2ecf20Sopenharmony_ci	fstd,ma  %fr0, 8(\regs)
2328c2ecf20Sopenharmony_ci	fstd,ma	 %fr1, 8(\regs)
2338c2ecf20Sopenharmony_ci	fstd,ma	 %fr2, 8(\regs)
2348c2ecf20Sopenharmony_ci	fstd,ma	 %fr3, 8(\regs)
2358c2ecf20Sopenharmony_ci	fstd,ma	 %fr4, 8(\regs)
2368c2ecf20Sopenharmony_ci	fstd,ma	 %fr5, 8(\regs)
2378c2ecf20Sopenharmony_ci	fstd,ma	 %fr6, 8(\regs)
2388c2ecf20Sopenharmony_ci	fstd,ma	 %fr7, 8(\regs)
2398c2ecf20Sopenharmony_ci	fstd,ma	 %fr8, 8(\regs)
2408c2ecf20Sopenharmony_ci	fstd,ma	 %fr9, 8(\regs)
2418c2ecf20Sopenharmony_ci	fstd,ma	%fr10, 8(\regs)
2428c2ecf20Sopenharmony_ci	fstd,ma	%fr11, 8(\regs)
2438c2ecf20Sopenharmony_ci	fstd,ma	%fr12, 8(\regs)
2448c2ecf20Sopenharmony_ci	fstd,ma	%fr13, 8(\regs)
2458c2ecf20Sopenharmony_ci	fstd,ma	%fr14, 8(\regs)
2468c2ecf20Sopenharmony_ci	fstd,ma	%fr15, 8(\regs)
2478c2ecf20Sopenharmony_ci	fstd,ma	%fr16, 8(\regs)
2488c2ecf20Sopenharmony_ci	fstd,ma	%fr17, 8(\regs)
2498c2ecf20Sopenharmony_ci	fstd,ma	%fr18, 8(\regs)
2508c2ecf20Sopenharmony_ci	fstd,ma	%fr19, 8(\regs)
2518c2ecf20Sopenharmony_ci	fstd,ma	%fr20, 8(\regs)
2528c2ecf20Sopenharmony_ci	fstd,ma	%fr21, 8(\regs)
2538c2ecf20Sopenharmony_ci	fstd,ma	%fr22, 8(\regs)
2548c2ecf20Sopenharmony_ci	fstd,ma	%fr23, 8(\regs)
2558c2ecf20Sopenharmony_ci	fstd,ma	%fr24, 8(\regs)
2568c2ecf20Sopenharmony_ci	fstd,ma	%fr25, 8(\regs)
2578c2ecf20Sopenharmony_ci	fstd,ma	%fr26, 8(\regs)
2588c2ecf20Sopenharmony_ci	fstd,ma	%fr27, 8(\regs)
2598c2ecf20Sopenharmony_ci	fstd,ma	%fr28, 8(\regs)
2608c2ecf20Sopenharmony_ci	fstd,ma	%fr29, 8(\regs)
2618c2ecf20Sopenharmony_ci	fstd,ma	%fr30, 8(\regs)
2628c2ecf20Sopenharmony_ci	fstd	%fr31, 0(\regs)
2638c2ecf20Sopenharmony_ci	.endm
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	.macro	rest_fp 	regs
2668c2ecf20Sopenharmony_ci	fldd	0(\regs),	 %fr31
2678c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr30
2688c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr29
2698c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr28
2708c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr27
2718c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr26
2728c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr25
2738c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr24
2748c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr23
2758c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr22
2768c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr21
2778c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr20
2788c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr19
2798c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr18
2808c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr17
2818c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr16
2828c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr15
2838c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr14
2848c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr13
2858c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr12
2868c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr11
2878c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr10
2888c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr9
2898c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr8
2908c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr7
2918c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr6
2928c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr5
2938c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr4
2948c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr3
2958c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr2
2968c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr1
2978c2ecf20Sopenharmony_ci	fldd,mb	-8(\regs),       %fr0
2988c2ecf20Sopenharmony_ci	.endm
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	.macro	callee_save_float
3018c2ecf20Sopenharmony_ci	fstd,ma	 %fr12,	8(%r30)
3028c2ecf20Sopenharmony_ci	fstd,ma	 %fr13,	8(%r30)
3038c2ecf20Sopenharmony_ci	fstd,ma	 %fr14,	8(%r30)
3048c2ecf20Sopenharmony_ci	fstd,ma	 %fr15,	8(%r30)
3058c2ecf20Sopenharmony_ci	fstd,ma	 %fr16,	8(%r30)
3068c2ecf20Sopenharmony_ci	fstd,ma	 %fr17,	8(%r30)
3078c2ecf20Sopenharmony_ci	fstd,ma	 %fr18,	8(%r30)
3088c2ecf20Sopenharmony_ci	fstd,ma	 %fr19,	8(%r30)
3098c2ecf20Sopenharmony_ci	fstd,ma	 %fr20,	8(%r30)
3108c2ecf20Sopenharmony_ci	fstd,ma	 %fr21,	8(%r30)
3118c2ecf20Sopenharmony_ci	.endm
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	.macro	callee_rest_float
3148c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr21
3158c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr20
3168c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr19
3178c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr18
3188c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr17
3198c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr16
3208c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr15
3218c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr14
3228c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr13
3238c2ecf20Sopenharmony_ci	fldd,mb	-8(%r30),   %fr12
3248c2ecf20Sopenharmony_ci	.endm
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
3278c2ecf20Sopenharmony_ci	.macro	callee_save
3288c2ecf20Sopenharmony_ci	std,ma	  %r3,	 CALLEE_REG_FRAME_SIZE(%r30)
3298c2ecf20Sopenharmony_ci	mfctl	  %cr27, %r3
3308c2ecf20Sopenharmony_ci	std	  %r4,	-136(%r30)
3318c2ecf20Sopenharmony_ci	std	  %r5,	-128(%r30)
3328c2ecf20Sopenharmony_ci	std	  %r6,	-120(%r30)
3338c2ecf20Sopenharmony_ci	std	  %r7,	-112(%r30)
3348c2ecf20Sopenharmony_ci	std	  %r8,	-104(%r30)
3358c2ecf20Sopenharmony_ci	std	  %r9,	 -96(%r30)
3368c2ecf20Sopenharmony_ci	std	 %r10,	 -88(%r30)
3378c2ecf20Sopenharmony_ci	std	 %r11,	 -80(%r30)
3388c2ecf20Sopenharmony_ci	std	 %r12,	 -72(%r30)
3398c2ecf20Sopenharmony_ci	std	 %r13,	 -64(%r30)
3408c2ecf20Sopenharmony_ci	std	 %r14,	 -56(%r30)
3418c2ecf20Sopenharmony_ci	std	 %r15,	 -48(%r30)
3428c2ecf20Sopenharmony_ci	std	 %r16,	 -40(%r30)
3438c2ecf20Sopenharmony_ci	std	 %r17,	 -32(%r30)
3448c2ecf20Sopenharmony_ci	std	 %r18,	 -24(%r30)
3458c2ecf20Sopenharmony_ci	std	  %r3,	 -16(%r30)
3468c2ecf20Sopenharmony_ci	.endm
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci	.macro	callee_rest
3498c2ecf20Sopenharmony_ci	ldd	 -16(%r30),    %r3
3508c2ecf20Sopenharmony_ci	ldd	 -24(%r30),   %r18
3518c2ecf20Sopenharmony_ci	ldd	 -32(%r30),   %r17
3528c2ecf20Sopenharmony_ci	ldd	 -40(%r30),   %r16
3538c2ecf20Sopenharmony_ci	ldd	 -48(%r30),   %r15
3548c2ecf20Sopenharmony_ci	ldd	 -56(%r30),   %r14
3558c2ecf20Sopenharmony_ci	ldd	 -64(%r30),   %r13
3568c2ecf20Sopenharmony_ci	ldd	 -72(%r30),   %r12
3578c2ecf20Sopenharmony_ci	ldd	 -80(%r30),   %r11
3588c2ecf20Sopenharmony_ci	ldd	 -88(%r30),   %r10
3598c2ecf20Sopenharmony_ci	ldd	 -96(%r30),    %r9
3608c2ecf20Sopenharmony_ci	ldd	-104(%r30),    %r8
3618c2ecf20Sopenharmony_ci	ldd	-112(%r30),    %r7
3628c2ecf20Sopenharmony_ci	ldd	-120(%r30),    %r6
3638c2ecf20Sopenharmony_ci	ldd	-128(%r30),    %r5
3648c2ecf20Sopenharmony_ci	ldd	-136(%r30),    %r4
3658c2ecf20Sopenharmony_ci	mtctl	%r3, %cr27
3668c2ecf20Sopenharmony_ci	ldd,mb	-CALLEE_REG_FRAME_SIZE(%r30),    %r3
3678c2ecf20Sopenharmony_ci	.endm
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci#else /* ! CONFIG_64BIT */
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci	.macro	callee_save
3728c2ecf20Sopenharmony_ci	stw,ma	 %r3,	CALLEE_REG_FRAME_SIZE(%r30)
3738c2ecf20Sopenharmony_ci	mfctl	 %cr27, %r3
3748c2ecf20Sopenharmony_ci	stw	 %r4,	-124(%r30)
3758c2ecf20Sopenharmony_ci	stw	 %r5,	-120(%r30)
3768c2ecf20Sopenharmony_ci	stw	 %r6,	-116(%r30)
3778c2ecf20Sopenharmony_ci	stw	 %r7,	-112(%r30)
3788c2ecf20Sopenharmony_ci	stw	 %r8,	-108(%r30)
3798c2ecf20Sopenharmony_ci	stw	 %r9,	-104(%r30)
3808c2ecf20Sopenharmony_ci	stw	 %r10,	-100(%r30)
3818c2ecf20Sopenharmony_ci	stw	 %r11,	 -96(%r30)
3828c2ecf20Sopenharmony_ci	stw	 %r12,	 -92(%r30)
3838c2ecf20Sopenharmony_ci	stw	 %r13,	 -88(%r30)
3848c2ecf20Sopenharmony_ci	stw	 %r14,	 -84(%r30)
3858c2ecf20Sopenharmony_ci	stw	 %r15,	 -80(%r30)
3868c2ecf20Sopenharmony_ci	stw	 %r16,	 -76(%r30)
3878c2ecf20Sopenharmony_ci	stw	 %r17,	 -72(%r30)
3888c2ecf20Sopenharmony_ci	stw	 %r18,	 -68(%r30)
3898c2ecf20Sopenharmony_ci	stw	  %r3,	 -64(%r30)
3908c2ecf20Sopenharmony_ci	.endm
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci	.macro	callee_rest
3938c2ecf20Sopenharmony_ci	ldw	 -64(%r30),    %r3
3948c2ecf20Sopenharmony_ci	ldw	 -68(%r30),   %r18
3958c2ecf20Sopenharmony_ci	ldw	 -72(%r30),   %r17
3968c2ecf20Sopenharmony_ci	ldw	 -76(%r30),   %r16
3978c2ecf20Sopenharmony_ci	ldw	 -80(%r30),   %r15
3988c2ecf20Sopenharmony_ci	ldw	 -84(%r30),   %r14
3998c2ecf20Sopenharmony_ci	ldw	 -88(%r30),   %r13
4008c2ecf20Sopenharmony_ci	ldw	 -92(%r30),   %r12
4018c2ecf20Sopenharmony_ci	ldw	 -96(%r30),   %r11
4028c2ecf20Sopenharmony_ci	ldw	-100(%r30),   %r10
4038c2ecf20Sopenharmony_ci	ldw	-104(%r30),   %r9
4048c2ecf20Sopenharmony_ci	ldw	-108(%r30),   %r8
4058c2ecf20Sopenharmony_ci	ldw	-112(%r30),   %r7
4068c2ecf20Sopenharmony_ci	ldw	-116(%r30),   %r6
4078c2ecf20Sopenharmony_ci	ldw	-120(%r30),   %r5
4088c2ecf20Sopenharmony_ci	ldw	-124(%r30),   %r4
4098c2ecf20Sopenharmony_ci	mtctl	%r3, %cr27
4108c2ecf20Sopenharmony_ci	ldw,mb	-CALLEE_REG_FRAME_SIZE(%r30),   %r3
4118c2ecf20Sopenharmony_ci	.endm
4128c2ecf20Sopenharmony_ci#endif /* ! CONFIG_64BIT */
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	.macro	save_specials	regs
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci	SAVE_SP  (%sr0, PT_SR0 (\regs))
4178c2ecf20Sopenharmony_ci	SAVE_SP  (%sr1, PT_SR1 (\regs))
4188c2ecf20Sopenharmony_ci	SAVE_SP  (%sr2, PT_SR2 (\regs))
4198c2ecf20Sopenharmony_ci	SAVE_SP  (%sr3, PT_SR3 (\regs))
4208c2ecf20Sopenharmony_ci	SAVE_SP  (%sr4, PT_SR4 (\regs))
4218c2ecf20Sopenharmony_ci	SAVE_SP  (%sr5, PT_SR5 (\regs))
4228c2ecf20Sopenharmony_ci	SAVE_SP  (%sr6, PT_SR6 (\regs))
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci	SAVE_CR  (%cr17, PT_IASQ0(\regs))
4258c2ecf20Sopenharmony_ci	mtctl	 %r0,	%cr17
4268c2ecf20Sopenharmony_ci	SAVE_CR  (%cr17, PT_IASQ1(\regs))
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci	SAVE_CR  (%cr18, PT_IAOQ0(\regs))
4298c2ecf20Sopenharmony_ci	mtctl	 %r0,	%cr18
4308c2ecf20Sopenharmony_ci	SAVE_CR  (%cr18, PT_IAOQ1(\regs))
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci#ifdef CONFIG_64BIT
4338c2ecf20Sopenharmony_ci	/* cr11 (sar) is a funny one.  5 bits on PA1.1 and 6 bit on PA2.0
4348c2ecf20Sopenharmony_ci	 * For PA2.0 mtsar or mtctl always write 6 bits, but mfctl only
4358c2ecf20Sopenharmony_ci	 * reads 5 bits.  Use mfctl,w to read all six bits.  Otherwise
4368c2ecf20Sopenharmony_ci	 * we lose the 6th bit on a save/restore over interrupt.
4378c2ecf20Sopenharmony_ci	 */
4388c2ecf20Sopenharmony_ci	mfctl,w  %cr11, %r1
4398c2ecf20Sopenharmony_ci	STREG    %r1, PT_SAR (\regs)
4408c2ecf20Sopenharmony_ci#else
4418c2ecf20Sopenharmony_ci	SAVE_CR  (%cr11, PT_SAR  (\regs))
4428c2ecf20Sopenharmony_ci#endif
4438c2ecf20Sopenharmony_ci	SAVE_CR  (%cr19, PT_IIR  (\regs))
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci	/*
4468c2ecf20Sopenharmony_ci	 * Code immediately following this macro (in intr_save) relies
4478c2ecf20Sopenharmony_ci	 * on r8 containing ipsw.
4488c2ecf20Sopenharmony_ci	 */
4498c2ecf20Sopenharmony_ci	mfctl    %cr22, %r8
4508c2ecf20Sopenharmony_ci	STREG    %r8,   PT_PSW(\regs)
4518c2ecf20Sopenharmony_ci	.endm
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci	.macro	rest_specials	regs
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci	REST_SP  (%sr0, PT_SR0 (\regs))
4568c2ecf20Sopenharmony_ci	REST_SP  (%sr1, PT_SR1 (\regs))
4578c2ecf20Sopenharmony_ci	REST_SP  (%sr2, PT_SR2 (\regs))
4588c2ecf20Sopenharmony_ci	REST_SP  (%sr3, PT_SR3 (\regs))
4598c2ecf20Sopenharmony_ci	REST_SP  (%sr4, PT_SR4 (\regs))
4608c2ecf20Sopenharmony_ci	REST_SP  (%sr5, PT_SR5 (\regs))
4618c2ecf20Sopenharmony_ci	REST_SP  (%sr6, PT_SR6 (\regs))
4628c2ecf20Sopenharmony_ci	REST_SP  (%sr7, PT_SR7 (\regs))
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci	REST_CR	(%cr17, PT_IASQ0(\regs))
4658c2ecf20Sopenharmony_ci	REST_CR	(%cr17, PT_IASQ1(\regs))
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci	REST_CR	(%cr18, PT_IAOQ0(\regs))
4688c2ecf20Sopenharmony_ci	REST_CR	(%cr18, PT_IAOQ1(\regs))
4698c2ecf20Sopenharmony_ci
4708c2ecf20Sopenharmony_ci	REST_CR (%cr11, PT_SAR	(\regs))
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci	REST_CR	(%cr22, PT_PSW	(\regs))
4738c2ecf20Sopenharmony_ci	.endm
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	/* First step to create a "relied upon translation"
4778c2ecf20Sopenharmony_ci	 * See PA 2.0 Arch. page F-4 and F-5.
4788c2ecf20Sopenharmony_ci	 *
4798c2ecf20Sopenharmony_ci	 * The ssm was originally necessary due to a "PCxT bug".
4808c2ecf20Sopenharmony_ci	 * But someone decided it needed to be added to the architecture
4818c2ecf20Sopenharmony_ci	 * and this "feature" went into rev3 of PA-RISC 1.1 Arch Manual.
4828c2ecf20Sopenharmony_ci	 * It's been carried forward into PA 2.0 Arch as well. :^(
4838c2ecf20Sopenharmony_ci	 *
4848c2ecf20Sopenharmony_ci	 * "ssm 0,%r0" is a NOP with side effects (prefetch barrier).
4858c2ecf20Sopenharmony_ci	 * rsm/ssm prevents the ifetch unit from speculatively fetching
4868c2ecf20Sopenharmony_ci	 * instructions past this line in the code stream.
4878c2ecf20Sopenharmony_ci	 * PA 2.0 processor will single step all insn in the same QUAD (4 insn).
4888c2ecf20Sopenharmony_ci	 */
4898c2ecf20Sopenharmony_ci	.macro	pcxt_ssm_bug
4908c2ecf20Sopenharmony_ci	rsm	PSW_SM_I,%r0
4918c2ecf20Sopenharmony_ci	nop	/* 1 */
4928c2ecf20Sopenharmony_ci	nop	/* 2 */
4938c2ecf20Sopenharmony_ci	nop	/* 3 */
4948c2ecf20Sopenharmony_ci	nop	/* 4 */
4958c2ecf20Sopenharmony_ci	nop	/* 5 */
4968c2ecf20Sopenharmony_ci	nop	/* 6 */
4978c2ecf20Sopenharmony_ci	nop	/* 7 */
4988c2ecf20Sopenharmony_ci	.endm
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci	/*
5018c2ecf20Sopenharmony_ci	 * ASM_EXCEPTIONTABLE_ENTRY
5028c2ecf20Sopenharmony_ci	 *
5038c2ecf20Sopenharmony_ci	 * Creates an exception table entry.
5048c2ecf20Sopenharmony_ci	 * Do not convert to a assembler macro. This won't work.
5058c2ecf20Sopenharmony_ci	 */
5068c2ecf20Sopenharmony_ci#define ASM_EXCEPTIONTABLE_ENTRY(fault_addr, except_addr)	\
5078c2ecf20Sopenharmony_ci	.section __ex_table,"aw"			!	\
5088c2ecf20Sopenharmony_ci	.word (fault_addr - .), (except_addr - .)	!	\
5098c2ecf20Sopenharmony_ci	.previous
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
5138c2ecf20Sopenharmony_ci#endif
514