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