Linux-libre 3.5.4-gnu1
[librecmc/linux-libre.git] / arch / s390 / include / asm / ctl_reg.h
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 #ifdef CONFIG_64BIT
11
12 #define __ctl_load(array, low, high) ({                         \
13         typedef struct { char _[sizeof(array)]; } addrtype;     \
14         asm volatile(                                           \
15                 "       lctlg   %1,%2,%0\n"                     \
16                 : : "Q" (*(addrtype *)(&array)),                \
17                     "i" (low), "i" (high));                     \
18         })
19
20 #define __ctl_store(array, low, high) ({                        \
21         typedef struct { char _[sizeof(array)]; } addrtype;     \
22         asm volatile(                                           \
23                 "       stctg   %1,%2,%0\n"                     \
24                 : "=Q" (*(addrtype *)(&array))                  \
25                 : "i" (low), "i" (high));                       \
26         })
27
28 #else /* CONFIG_64BIT */
29
30 #define __ctl_load(array, low, high) ({                         \
31         typedef struct { char _[sizeof(array)]; } addrtype;     \
32         asm volatile(                                           \
33                 "       lctl    %1,%2,%0\n"                     \
34                 : : "Q" (*(addrtype *)(&array)),                \
35                     "i" (low), "i" (high));                     \
36 })
37
38 #define __ctl_store(array, low, high) ({                        \
39         typedef struct { char _[sizeof(array)]; } addrtype;     \
40         asm volatile(                                           \
41                 "       stctl   %1,%2,%0\n"                     \
42                 : "=Q" (*(addrtype *)(&array))                  \
43                 : "i" (low), "i" (high));                       \
44         })
45
46 #endif /* CONFIG_64BIT */
47
48 #define __ctl_set_bit(cr, bit) ({       \
49         unsigned long __dummy;          \
50         __ctl_store(__dummy, cr, cr);   \
51         __dummy |= 1UL << (bit);        \
52         __ctl_load(__dummy, cr, cr);    \
53 })
54
55 #define __ctl_clear_bit(cr, bit) ({     \
56         unsigned long __dummy;          \
57         __ctl_store(__dummy, cr, cr);   \
58         __dummy &= ~(1UL << (bit));     \
59         __ctl_load(__dummy, cr, cr);    \
60 })
61
62 #ifdef CONFIG_SMP
63
64 extern void smp_ctl_set_bit(int cr, int bit);
65 extern void smp_ctl_clear_bit(int cr, int bit);
66 #define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit)
67 #define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit)
68
69 #else
70
71 #define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit)
72 #define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit)
73
74 #endif /* CONFIG_SMP */
75
76 #endif /* __ASM_CTL_REG_H */