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