cp: fairly simplistic Machine Check Interruption handler
[hvf.git] / cp / include / interrupt.h
blob09ff61a4a717855c8c3035ba8fb763a85aef443e
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 __INTERRUPT_H
9 #define __INTERRUPT_H
12 * I/O interruptions specific constants & structures
14 struct io_int_code {
15 u32 ssid;
16 u32 param;
17 } __attribute__((packed));
19 struct mch_int_code {
20 u8 sd:1, /* System Damage */
21 pd:1, /* Instruction-processing damage */
22 sr:1, /* System recovery */
23 _pad0:1,
24 cd:1, /* Timing-facility damage */
25 ed:1, /* External damage */
26 _pad1:1,
27 dg:1; /* Degradation */
28 u8 w:1, /* Warning */
29 cp:1, /* Channel report pending */
30 sp:1, /* Service-processor damage */
31 ck:1, /* Channel-subsystem damage */
32 _pad2:2,
33 b:1, /* Backed up */
34 _pad3:1;
35 u8 se:1, /* Storage error uncorrected */
36 sc:1, /* Storage error corrected */
37 ke:1, /* Storage-key error uncorrected */
38 ds:1, /* Storage degradation */
39 wp:1, /* PSW-MWP validity */
40 ms:1, /* PSW mask and key validity */
41 pm:1, /* PSW program-mask and condition-code validity */
42 ia:1; /* PSW-instruction-address validity */
43 u8 fa:1, /* Failing-storage-address validity */
44 _pad4:1,
45 ec:1, /* External-damage-code */
46 fp:1, /* Floating-point-register validity */
47 gr:1, /* General-register validity */
48 cr:1, /* Control-register validity */
49 _pad5:1,
50 st:1; /* Storage logical validity */
51 u8 ie:1, /* Indirect storage error */
52 ar:1, /* Access-register validity */
53 da:1, /* Delayed-access exception */
54 _pad6:5;
55 u8 _pad7:2,
56 pr:1, /* TOD-programable-register validity */
57 fc:1, /* Floating-point-control-register validity */
58 ap:1, /* Ancilary report */
59 _pad8:1,
60 ct:1, /* CPU-timer validity */
61 cc:1; /* Clock-comparator validity */
62 u8 _pad9;
63 u8 _pad10;
64 } __attribute__((packed));
66 #define PSA_INT_GPR ((u64*) 0x200)
67 #define PSA_TMP_PSW ((struct psw*) 0x280)
69 #define IO_INT_OLD_PSW ((void*) 0x170)
70 #define IO_INT_NEW_PSW ((void*) 0x1f0)
71 #define IO_INT_CODE ((struct io_int_code*) 0xb8)
73 #define EXT_INT_OLD_PSW ((void*) 0x130)
74 #define EXT_INT_NEW_PSW ((void*) 0x1b0)
75 #define EXT_INT_CODE ((u16*) 0x86)
77 #define SVC_INT_OLD_PSW ((void*) 0x140)
78 #define SVC_INT_NEW_PSW ((void*) 0x1c0)
79 #define SVC_INT_CODE ((u16*) 0x8a)
81 #define PGM_INT_OLD_PSW ((void*) 0x150)
82 #define PGM_INT_NEW_PSW ((void*) 0x1d0)
83 #define PGM_INT_ILC ((u8*) 0x8d)
84 #define PGM_INT_CODE ((u16*) 0x8e)
86 #define MCH_INT_OLD_PSW ((void*) 0x160)
87 #define MCH_INT_NEW_PSW ((void*) 0x1e0)
88 #define MCH_INT_CODE ((struct mch_int_code*) 232)
91 * Assembly stubs to call the C-handlers
93 extern void IO_INT(void);
94 extern void EXT_INT(void);
95 extern void SVC_INT(void);
96 extern void PGM_INT(void);
97 extern void MCH_INT(void);
99 /**
100 * local_int_disable - disable interruptions & return old mask
102 #define local_int_disable() ({ \
103 unsigned long __flags; \
104 __asm__ __volatile__ ( \
105 "stnsm 0(%1),0xfc" : "=m" (__flags) : "a" (&__flags) ); \
106 __flags; \
110 * local_int_restore - restore interrupt mask
111 * x: mask to restore
113 #define local_int_restore(x) \
114 __asm__ __volatile__("ssm 0(%0)" : : "a" (&x), "m" (x) : "memory")
117 * local_int_restore - restore interrupt mask
118 * x: mask to restore
120 static inline int interruptable()
122 u8 x;
124 __asm__ __volatile__(
125 "stosm 0(%0),0x00"
126 : /* out */
127 : /* in */
128 "a" (&x),
129 "m" (x)
130 : /* clobber */
131 "memory"
134 return (x & 0x43) != 0;
137 extern void set_timer(void);
140 * The Supervisor-Service call table
142 #define SVC_SCHEDULE 0
143 #define SVC_SCHEDULE_BLOCKED 1
144 #define SVC_SCHEDULE_EXIT 2
145 #define NR_SVC 3
146 extern u64 svc_table[NR_SVC];
148 /* Interrupt handlers */
149 extern void __pgm_int_handler(void);
150 extern void __ext_int_handler(void);
151 extern void __io_int_handler(void);
153 /* Interrupt handler stack pointer */
154 extern u8 *int_stack_ptr;
156 #endif