1 /* 2 * Copyright IBM Corp. 1999, 2009 3 * 4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 5 */ 6 7 #ifndef __ASM_CTL_REG_H 8 #define __ASM_CTL_REG_H 9 10 #include <linux/bug.h> 11 12 #define __ctl_load(array, low, high) do { \ 13 typedef struct { char _[sizeof(array)]; } addrtype; \ 14 \ 15 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\ 16 asm volatile( \ 17 " lctlg %1,%2,%0\n" \ 18 : \ 19 : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high) \ 20 : "memory"); \ 21 } while (0) 22 23 #define __ctl_store(array, low, high) do { \ 24 typedef struct { char _[sizeof(array)]; } addrtype; \ 25 \ 26 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\ 27 asm volatile( \ 28 " stctg %1,%2,%0\n" \ 29 : "=Q" (*(addrtype *)(&array)) \ 30 : "i" (low), "i" (high)); \ 31 } while (0) 32 33 static inline void __ctl_set_bit(unsigned int cr, unsigned int bit) 34 { 35 unsigned long reg; 36 37 __ctl_store(reg, cr, cr); 38 reg |= 1UL << bit; 39 __ctl_load(reg, cr, cr); 40 } 41 42 static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit) 43 { 44 unsigned long reg; 45 46 __ctl_store(reg, cr, cr); 47 reg &= ~(1UL << bit); 48 __ctl_load(reg, cr, cr); 49 } 50 51 void smp_ctl_set_bit(int cr, int bit); 52 void smp_ctl_clear_bit(int cr, int bit); 53 54 union ctlreg0 { 55 unsigned long val; 56 struct { 57 unsigned long : 32; 58 unsigned long : 3; 59 unsigned long lap : 1; /* Low-address-protection control */ 60 unsigned long : 4; 61 unsigned long edat : 1; /* Enhanced-DAT-enablement control */ 62 unsigned long : 4; 63 unsigned long afp : 1; /* AFP-register control */ 64 unsigned long vx : 1; /* Vector enablement control */ 65 unsigned long : 7; 66 unsigned long sssm : 1; /* Service signal subclass mask */ 67 unsigned long : 9; 68 }; 69 }; 70 71 #ifdef CONFIG_SMP 72 # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit) 73 # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit) 74 #else 75 # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit) 76 # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit) 77 #endif 78 79 #endif /* __ASM_CTL_REG_H */ 80