2 * Copyright (c) 2007-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * PSW and PSW handling
31 r
:1, /* PER Mask (R) */
33 t
:1, /* DAT Mode (T) */
34 io
:1, /* I/O Mask (IO) */
35 ex
:1; /* External Mask (EX) */
38 fmt
:1, /* 1 on 390, 0 on z */
39 m
:1, /* Machine-Check Mask (M) */
40 w
:1, /* Wait State (W) */
41 p
:1; /* Problem State (P) */
43 u8 as
:2, /* Address-Space Control (AS) */
44 cc
:2, /* Condition Code (CC) */
45 prog_mask
:4; /* Program Mask */
48 ea
:1; /* Extended Addressing (EA) */
50 u32 ba
:1, /* Basic Addressing (BA) */
54 } __attribute__((packed
,aligned(8)));
56 static inline void lpswe(struct psw
*psw
)
69 * NOTE: We don't care about not clobbering registers as when this
70 * code executes, the CPU will be stopped.
72 * TODO: mark this with a no-return attribute
74 static inline void sigp_stop(void)
77 "SR %r1, %r1 # not used, but should be zero\n"
78 "SR %r3, %r3 # CPU Address\n"
79 "SIGP %r1, %r3, 0x05 # order 0x05 = stop\n"
83 * Just in case SIGP fails
90 * Control Register handling
92 #define set_cr(cr, val) \
119 * Machine Check Interrupt related structs & locations
121 struct mch_int_code
{
122 u8 sd
:1, /* System Damage */
123 pd
:1, /* Instruction-processing damage */
124 sr
:1, /* System recovery */
126 cd
:1, /* Timing-facility damage */
127 ed
:1, /* External damage */
129 dg
:1; /* Degradation */
130 u8 w
:1, /* Warning */
131 cp
:1, /* Channel report pending */
132 sp
:1, /* Service-processor damage */
133 ck
:1, /* Channel-subsystem damage */
137 u8 se
:1, /* Storage error uncorrected */
138 sc
:1, /* Storage error corrected */
139 ke
:1, /* Storage-key error uncorrected */
140 ds
:1, /* Storage degradation */
141 wp
:1, /* PSW-MWP validity */
142 ms
:1, /* PSW mask and key validity */
143 pm
:1, /* PSW program-mask and condition-code validity */
144 ia
:1; /* PSW-instruction-address validity */
145 u8 fa
:1, /* Failing-storage-address validity */
147 ec
:1, /* External-damage-code */
148 fp
:1, /* Floating-point-register validity */
149 gr
:1, /* General-register validity */
150 cr
:1, /* Control-register validity */
152 st
:1; /* Storage logical validity */
153 u8 ie
:1, /* Indirect storage error */
154 ar
:1, /* Access-register validity */
155 da
:1, /* Delayed-access exception */
158 pr
:1, /* TOD-programable-register validity */
159 fc
:1, /* Floating-point-control-register validity */
160 ap
:1, /* Ancilary report */
162 ct
:1, /* CPU-timer validity */
163 cc
:1; /* Clock-comparator validity */
166 } __attribute__((packed
));
168 #define MCH_INT_OLD_PSW ((void*) 0x160)
169 #define MCH_INT_NEW_PSW ((void*) 0x1e0)
170 #define MCH_INT_CODE ((struct mch_int_code*) 0xe8)