include: {get,set}_cr and BIT*() are generic
[hvf.git] / include / arch.h
blob376d178e96f5f12d9ed588b6cf37b1008865d549
1 /*
2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
5 * details.
6 */
8 #ifndef __ARCH_H
9 #define __ARCH_H
11 struct psw {
12 u8 _zero0:1,
13 r:1, /* PER Mask (R) */
14 _zero1:3,
15 t:1, /* DAT Mode (T) */
16 io:1, /* I/O Mask (IO) */
17 ex:1; /* External Mask (EX) */
19 u8 key:4, /* Key */
20 fmt:1, /* 1 on 390, 0 on z */
21 m:1, /* Machine-Check Mask (M) */
22 w:1, /* Wait State (W) */
23 p:1; /* Problem State (P) */
25 u8 as:2, /* Address-Space Control (AS) */
26 cc:2, /* Condition Code (CC) */
27 prog_mask:4; /* Program Mask */
29 u8 _zero2:7,
30 ea:1; /* Extended Addressing (EA) */
32 u32 ba:1, /* Basic Addressing (BA) */
33 ptr31:31;
35 u64 ptr;
38 #define set_cr(cr, val) \
39 do { \
40 u64 lval = (val); \
41 asm volatile( \
42 "lctlg %1,%1,%0\n" \
43 : /* output */ \
44 : /* input */ \
45 "m" (lval), \
46 "i" (cr) \
47 ); \
48 } while(0)
50 #define get_cr(cr) \
51 ({ \
52 u64 reg; \
54 asm volatile( \
55 "stctg %1,%1,%0\n" \
56 : /* output */ \
57 "=m" (reg) \
58 : /* input */ \
59 "i" (cr) \
60 ); \
61 reg; \
64 #endif