Merge branch 'for-3.18-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj...
[linux/fpc-iii.git] / arch / s390 / include / asm / ctl_reg.h
blob31ab9f346d7e37f1c7ce8048db783ba4a15d128c
1 /*
2 * Copyright IBM Corp. 1999, 2009
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 */
7 #ifndef __ASM_CTL_REG_H
8 #define __ASM_CTL_REG_H
10 #include <linux/bug.h>
12 #ifdef CONFIG_64BIT
13 # define __CTL_LOAD "lctlg"
14 # define __CTL_STORE "stctg"
15 #else
16 # define __CTL_LOAD "lctl"
17 # define __CTL_STORE "stctl"
18 #endif
20 #define __ctl_load(array, low, high) { \
21 typedef struct { char _[sizeof(array)]; } addrtype; \
23 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
24 asm volatile( \
25 __CTL_LOAD " %1,%2,%0\n" \
26 : : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high));\
29 #define __ctl_store(array, low, high) { \
30 typedef struct { char _[sizeof(array)]; } addrtype; \
32 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
33 asm volatile( \
34 __CTL_STORE " %1,%2,%0\n" \
35 : "=Q" (*(addrtype *)(&array)) \
36 : "i" (low), "i" (high)); \
39 static inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
41 unsigned long reg;
43 __ctl_store(reg, cr, cr);
44 reg |= 1UL << bit;
45 __ctl_load(reg, cr, cr);
48 static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit)
50 unsigned long reg;
52 __ctl_store(reg, cr, cr);
53 reg &= ~(1UL << bit);
54 __ctl_load(reg, cr, cr);
57 void smp_ctl_set_bit(int cr, int bit);
58 void smp_ctl_clear_bit(int cr, int bit);
60 union ctlreg0 {
61 unsigned long val;
62 struct {
63 #ifdef CONFIG_64BIT
64 unsigned long : 32;
65 #endif
66 unsigned long : 3;
67 unsigned long lap : 1; /* Low-address-protection control */
68 unsigned long : 4;
69 unsigned long edat : 1; /* Enhanced-DAT-enablement control */
70 unsigned long : 23;
74 #ifdef CONFIG_SMP
75 # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
76 # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
77 #else
78 # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
79 # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
80 #endif
82 #endif /* __ASM_CTL_REG_H */