cp: fairly simplistic Machine Check Interruption handler
[hvf.git] / cp / include / cpu.h
blob1ec065f2673cf42f14c7980238e742d6d63efbfe
1 /*
2 * (C) Copyright 2007-2010 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 __CPU_H
9 #define __CPU_H
11 static inline u64 getcpuid()
13 u64 cpuid = ~0;
15 asm("stidp 0(%1)\n"
16 : /* output */
17 "=m" (cpuid)
18 : /* input */
19 "a" (&cpuid)
22 return cpuid;
25 static inline u16 getcpuaddr()
27 u16 cpuaddr = ~0;
29 asm("stap 0(%1)\n"
30 : /* output */
31 "=m" (cpuaddr)
32 : /* input */
33 "a" (&cpuaddr)
36 return cpuaddr;
39 #define BIT64(x) (1u << (63-(x)))
40 #define BIT32(x) (1u << (31-(x)))
42 #define set_cr(cr, val) \
43 do { \
44 u64 lval = (val); \
45 asm volatile( \
46 "lctlg %1,%1,%0\n" \
47 : /* output */ \
48 : /* input */ \
49 "m" (lval), \
50 "i" (cr) \
51 ); \
52 } while(0)
54 #define get_cr(cr) \
55 ({ \
56 u64 reg; \
58 asm volatile( \
59 "stctg %1,%1,%0\n" \
60 : /* output */ \
61 "=m" (reg) \
62 : /* input */ \
63 "i" (cr) \
64 ); \
65 reg; \
68 #endif