xref: /openbmc/linux/arch/parisc/include/asm/special_insns.h (revision c595db6d7c8bcf87ef42204391fa890e5950e566)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2527dcdccSDavid Howells #ifndef __PARISC_SPECIAL_INSNS_H
3527dcdccSDavid Howells #define __PARISC_SPECIAL_INSNS_H
4527dcdccSDavid Howells 
5116d7533SJohn David Anglin #define lpa(va)	({					\
6116d7533SJohn David Anglin 	unsigned long pa;				\
7116d7533SJohn David Anglin 	__asm__ __volatile__(				\
8db19c6f1SJohn David Anglin 		"copy %%r0,%0\n"			\
9db19c6f1SJohn David Anglin 		"8:\tlpa %%r0(%1),%0\n"			\
10db19c6f1SJohn David Anglin 		"9:\n"					\
11*fa69a806SHelge Deller 		ASM_EXCEPTIONTABLE_ENTRY(8b, 9b,	\
12*fa69a806SHelge Deller 				"or %%r0,%%r0,%%r0")	\
13db19c6f1SJohn David Anglin 		: "=&r" (pa)				\
14116d7533SJohn David Anglin 		: "r" (va)				\
15116d7533SJohn David Anglin 		: "memory"				\
16116d7533SJohn David Anglin 	);						\
17116d7533SJohn David Anglin 	pa;						\
18116d7533SJohn David Anglin })
19116d7533SJohn David Anglin 
20116d7533SJohn David Anglin #define lpa_user(va)	({				\
21116d7533SJohn David Anglin 	unsigned long pa;				\
22116d7533SJohn David Anglin 	__asm__ __volatile__(				\
23db19c6f1SJohn David Anglin 		"copy %%r0,%0\n"			\
24db19c6f1SJohn David Anglin 		"8:\tlpa %%r0(%%sr3,%1),%0\n"		\
25db19c6f1SJohn David Anglin 		"9:\n"					\
26*fa69a806SHelge Deller 		ASM_EXCEPTIONTABLE_ENTRY(8b, 9b,	\
27*fa69a806SHelge Deller 				"or %%r0,%%r0,%%r0")	\
28db19c6f1SJohn David Anglin 		: "=&r" (pa)				\
29116d7533SJohn David Anglin 		: "r" (va)				\
30116d7533SJohn David Anglin 		: "memory"				\
31116d7533SJohn David Anglin 	);						\
32116d7533SJohn David Anglin 	pa;						\
33116d7533SJohn David Anglin })
34116d7533SJohn David Anglin 
357e0b2be9SHelge Deller #define CR_EIEM 15	/* External Interrupt Enable Mask */
367e0b2be9SHelge Deller #define CR_CR16 16	/* CR16 Interval Timer */
377e0b2be9SHelge Deller #define CR_EIRR 23	/* External Interrupt Request Register */
387e0b2be9SHelge Deller 
39527dcdccSDavid Howells #define mfctl(reg)	({		\
40527dcdccSDavid Howells 	unsigned long cr;		\
41527dcdccSDavid Howells 	__asm__ __volatile__(		\
427e0b2be9SHelge Deller 		"mfctl %1,%0" :		\
437e0b2be9SHelge Deller 		 "=r" (cr) : "i" (reg)	\
44527dcdccSDavid Howells 	);				\
45527dcdccSDavid Howells 	cr;				\
46527dcdccSDavid Howells })
47527dcdccSDavid Howells 
48527dcdccSDavid Howells #define mtctl(gr, cr) \
49527dcdccSDavid Howells 	__asm__ __volatile__("mtctl %0,%1" \
50527dcdccSDavid Howells 		: /* no outputs */ \
51527dcdccSDavid Howells 		: "r" (gr), "i" (cr) : "memory")
52527dcdccSDavid Howells 
537e0b2be9SHelge Deller #define get_eiem()	mfctl(CR_EIEM)
547e0b2be9SHelge Deller #define set_eiem(val)	mtctl(val, CR_EIEM)
55527dcdccSDavid Howells 
56527dcdccSDavid Howells #define mfsp(reg)	({		\
57527dcdccSDavid Howells 	unsigned long cr;		\
58527dcdccSDavid Howells 	__asm__ __volatile__(		\
59360bd6c6SHelge Deller 		"mfsp %%sr%1,%0"	\
60360bd6c6SHelge Deller 		: "=r" (cr) : "i"(reg)	\
61527dcdccSDavid Howells 	);				\
62527dcdccSDavid Howells 	cr;				\
63527dcdccSDavid Howells })
64527dcdccSDavid Howells 
6592b59929SHelge Deller #define mtsp(val, cr) \
6692b59929SHelge Deller 	{ if (__builtin_constant_p(val) && ((val) == 0)) \
6792b59929SHelge Deller 	 __asm__ __volatile__("mtsp %%r0,%0" : : "i" (cr) : "memory"); \
6892b59929SHelge Deller 	else \
69527dcdccSDavid Howells 	 __asm__ __volatile__("mtsp %0,%1" \
70527dcdccSDavid Howells 		: /* no outputs */ \
7192b59929SHelge Deller 		: "r" (val), "i" (cr) : "memory"); }
72527dcdccSDavid Howells 
73527dcdccSDavid Howells #endif /* __PARISC_SPECIAL_INSNS_H */
74