1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __PARISC_SPECIAL_INSNS_H 3 #define __PARISC_SPECIAL_INSNS_H 4 5 #define lpa(va) ({ \ 6 unsigned long pa; \ 7 __asm__ __volatile__( \ 8 "copy %%r0,%0\n" \ 9 "8:\tlpa %%r0(%1),%0\n" \ 10 "9:\n" \ 11 ASM_EXCEPTIONTABLE_ENTRY(8b, 9b) \ 12 : "=&r" (pa) \ 13 : "r" (va) \ 14 : "memory" \ 15 ); \ 16 pa; \ 17 }) 18 19 #define lpa_user(va) ({ \ 20 unsigned long pa; \ 21 __asm__ __volatile__( \ 22 "copy %%r0,%0\n" \ 23 "8:\tlpa %%r0(%%sr3,%1),%0\n" \ 24 "9:\n" \ 25 ASM_EXCEPTIONTABLE_ENTRY(8b, 9b) \ 26 : "=&r" (pa) \ 27 : "r" (va) \ 28 : "memory" \ 29 ); \ 30 pa; \ 31 }) 32 33 #define mfctl(reg) ({ \ 34 unsigned long cr; \ 35 __asm__ __volatile__( \ 36 "mfctl " #reg ",%0" : \ 37 "=r" (cr) \ 38 ); \ 39 cr; \ 40 }) 41 42 #define mtctl(gr, cr) \ 43 __asm__ __volatile__("mtctl %0,%1" \ 44 : /* no outputs */ \ 45 : "r" (gr), "i" (cr) : "memory") 46 47 /* these are here to de-mystefy the calling code, and to provide hooks */ 48 /* which I needed for debugging EIEM problems -PB */ 49 #define get_eiem() mfctl(15) 50 static inline void set_eiem(unsigned long val) 51 { 52 mtctl(val, 15); 53 } 54 55 #define mfsp(reg) ({ \ 56 unsigned long cr; \ 57 __asm__ __volatile__( \ 58 "mfsp " #reg ",%0" : \ 59 "=r" (cr) \ 60 ); \ 61 cr; \ 62 }) 63 64 #define mtsp(val, cr) \ 65 { if (__builtin_constant_p(val) && ((val) == 0)) \ 66 __asm__ __volatile__("mtsp %%r0,%0" : : "i" (cr) : "memory"); \ 67 else \ 68 __asm__ __volatile__("mtsp %0,%1" \ 69 : /* no outputs */ \ 70 : "r" (val), "i" (cr) : "memory"); } 71 72 #endif /* __PARISC_SPECIAL_INSNS_H */ 73