1
2
3
4
5
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
34static 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
43static 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
52void smp_ctl_set_bit(int cr, int bit);
53void smp_ctl_clear_bit(int cr, int bit);
54
55union ctlreg0 {
56 unsigned long val;
57 struct {
58 unsigned long : 32;
59 unsigned long : 3;
60 unsigned long lap : 1;
61 unsigned long : 4;
62 unsigned long edat : 1;
63 unsigned long : 2;
64 unsigned long iep : 1;
65 unsigned long : 1;
66 unsigned long afp : 1;
67 unsigned long vx : 1;
68 unsigned long : 7;
69 unsigned long sssm : 1;
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
83