1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef CIO_H
14#define CIO_H
15
16
17
18
19struct pmcw {
20 __u32 intparm;
21 __u32 qf : 1;
22 __u32 w : 1;
23 __u32 isc : 3;
24 __u32 res5 : 3;
25 __u32 ena : 1;
26 __u32 lm : 2;
27 __u32 mme : 2;
28 __u32 mp : 1;
29 __u32 tf : 1;
30 __u32 dnv : 1;
31 __u32 dev : 16;
32 __u8 lpm;
33 __u8 pnom;
34 __u8 lpum;
35 __u8 pim;
36 __u16 mbi;
37 __u8 pom;
38 __u8 pam;
39 __u8 chpid[8];
40 __u32 unused1 : 8;
41 __u32 st : 3;
42 __u32 unused2 : 18;
43 __u32 mbfc : 1;
44 __u32 xmwme : 1;
45 __u32 csense : 1;
46
47
48
49} __attribute__ ((packed));
50
51
52struct schib_config {
53 __u64 mba;
54 __u32 intparm;
55 __u16 mbi;
56 __u32 isc:3;
57 __u32 ena:1;
58 __u32 mme:2;
59 __u32 mp:1;
60 __u32 csense:1;
61 __u32 mbfc:1;
62} __attribute__ ((packed));
63
64struct scsw {
65 __u16 flags;
66 __u16 ctrl;
67 __u32 cpa;
68 __u8 dstat;
69 __u8 cstat;
70 __u16 count;
71} __attribute__ ((packed));
72
73#define SCSW_FCTL_CLEAR_FUNC 0x1000
74#define SCSW_FCTL_HALT_FUNC 0x2000
75#define SCSW_FCTL_START_FUNC 0x4000
76
77
78
79
80struct schib {
81 struct pmcw pmcw;
82 struct scsw scsw;
83 __u64 mba;
84 __u8 mda[4];
85} __attribute__ ((packed,aligned(4)));
86
87struct subchannel_id {
88 __u32 cssid : 8;
89 __u32 : 4;
90 __u32 m : 1;
91 __u32 ssid : 2;
92 __u32 one : 1;
93 __u32 sch_no : 16;
94} __attribute__ ((packed, aligned(4)));
95
96struct chsc_header {
97 __u16 length;
98 __u16 code;
99} __attribute__((packed));
100
101struct chsc_area_sda {
102 struct chsc_header request;
103 __u8 reserved1:4;
104 __u8 format:4;
105 __u8 reserved2;
106 __u16 operation_code;
107 __u32 reserved3;
108 __u32 reserved4;
109 __u32 operation_data_area[252];
110 struct chsc_header response;
111 __u32 reserved5:4;
112 __u32 format2:4;
113 __u32 reserved6:24;
114} __attribute__((packed));
115
116
117
118
119struct tpi_info {
120 struct subchannel_id schid;
121 __u32 intparm;
122 __u32 adapter_IO : 1;
123 __u32 reserved2 : 1;
124 __u32 isc : 3;
125 __u32 reserved3 : 12;
126 __u32 int_type : 3;
127 __u32 reserved4 : 12;
128} __attribute__ ((packed));
129
130
131struct ccw1 {
132 __u8 cmd_code;
133 __u8 flags;
134 __u16 count;
135 __u32 cda;
136} __attribute__ ((packed, aligned(8)));
137
138#define CCW_FLAG_DC 0x80
139#define CCW_FLAG_CC 0x40
140#define CCW_FLAG_SLI 0x20
141#define CCW_FLAG_SKIP 0x10
142#define CCW_FLAG_PCI 0x08
143#define CCW_FLAG_IDA 0x04
144#define CCW_FLAG_SUSPEND 0x02
145
146#define CCW_CMD_NOOP 0x03
147#define CCW_CMD_BASIC_SENSE 0x04
148#define CCW_CMD_TIC 0x08
149#define CCW_CMD_SENSE_ID 0xe4
150
151#define CCW_CMD_SET_VQ 0x13
152#define CCW_CMD_VDEV_RESET 0x33
153#define CCW_CMD_READ_FEAT 0x12
154#define CCW_CMD_WRITE_FEAT 0x11
155#define CCW_CMD_READ_CONF 0x22
156#define CCW_CMD_WRITE_CONF 0x21
157#define CCW_CMD_WRITE_STATUS 0x31
158#define CCW_CMD_SET_IND 0x43
159#define CCW_CMD_SET_CONF_IND 0x53
160#define CCW_CMD_READ_VQ_CONF 0x32
161
162
163
164
165struct cmd_orb {
166 __u32 intparm;
167 __u32 key:4;
168 __u32 spnd:1;
169 __u32 res1:1;
170 __u32 mod:1;
171 __u32 sync:1;
172 __u32 fmt:1;
173 __u32 pfch:1;
174 __u32 isic:1;
175 __u32 alcc:1;
176 __u32 ssic:1;
177 __u32 res2:1;
178 __u32 c64:1;
179 __u32 i2k:1;
180 __u32 lpm:8;
181 __u32 ils:1;
182 __u32 zero:6;
183 __u32 orbx:1;
184 __u32 cpa;
185} __attribute__ ((packed, aligned(4)));
186
187struct ciw {
188 __u8 type;
189 __u8 command;
190 __u16 count;
191};
192
193
194
195
196struct senseid {
197
198 __u8 reserved;
199 __u16 cu_type;
200 __u8 cu_model;
201 __u16 dev_type;
202 __u8 dev_model;
203 __u8 unused;
204
205 struct ciw ciw[62];
206} __attribute__ ((packed, aligned(4)));
207
208
209struct irb {
210 struct scsw scsw;
211 __u32 esw[5];
212 __u32 ecw[8];
213 __u32 emw[8];
214} __attribute__ ((packed, aligned(4)));
215
216
217
218
219
220static inline int stsch_err(struct subchannel_id schid, struct schib *addr)
221{
222 register struct subchannel_id reg1 asm ("1") = schid;
223 int ccode = -EIO;
224
225 asm volatile(
226 " stsch 0(%3)\n"
227 "0: ipm %0\n"
228 " srl %0,28\n"
229 "1:\n"
230 : "+d" (ccode), "=m" (*addr)
231 : "d" (reg1), "a" (addr)
232 : "cc");
233 return ccode;
234}
235
236static inline int msch(struct subchannel_id schid, struct schib *addr)
237{
238 register struct subchannel_id reg1 asm ("1") = schid;
239 int ccode;
240
241 asm volatile(
242 " msch 0(%2)\n"
243 " ipm %0\n"
244 " srl %0,28"
245 : "=d" (ccode)
246 : "d" (reg1), "a" (addr), "m" (*addr)
247 : "cc");
248 return ccode;
249}
250
251static inline int msch_err(struct subchannel_id schid, struct schib *addr)
252{
253 register struct subchannel_id reg1 asm ("1") = schid;
254 int ccode = -EIO;
255
256 asm volatile(
257 " msch 0(%2)\n"
258 "0: ipm %0\n"
259 " srl %0,28\n"
260 "1:\n"
261 : "+d" (ccode)
262 : "d" (reg1), "a" (addr), "m" (*addr)
263 : "cc");
264 return ccode;
265}
266
267static inline int tsch(struct subchannel_id schid, struct irb *addr)
268{
269 register struct subchannel_id reg1 asm ("1") = schid;
270 int ccode;
271
272 asm volatile(
273 " tsch 0(%3)\n"
274 " ipm %0\n"
275 " srl %0,28"
276 : "=d" (ccode), "=m" (*addr)
277 : "d" (reg1), "a" (addr)
278 : "cc");
279 return ccode;
280}
281
282static inline int ssch(struct subchannel_id schid, struct cmd_orb *addr)
283{
284 register struct subchannel_id reg1 asm("1") = schid;
285 int ccode = -EIO;
286
287 asm volatile(
288 " ssch 0(%2)\n"
289 "0: ipm %0\n"
290 " srl %0,28\n"
291 "1:\n"
292 : "+d" (ccode)
293 : "d" (reg1), "a" (addr), "m" (*addr)
294 : "cc", "memory");
295 return ccode;
296}
297
298static inline int csch(struct subchannel_id schid)
299{
300 register struct subchannel_id reg1 asm("1") = schid;
301 int ccode;
302
303 asm volatile(
304 " csch\n"
305 " ipm %0\n"
306 " srl %0,28"
307 : "=d" (ccode)
308 : "d" (reg1)
309 : "cc");
310 return ccode;
311}
312
313static inline int tpi(struct tpi_info *addr)
314{
315 int ccode;
316
317 asm volatile(
318 " tpi 0(%2)\n"
319 " ipm %0\n"
320 " srl %0,28"
321 : "=d" (ccode), "=m" (*addr)
322 : "a" (addr)
323 : "cc");
324 return ccode;
325}
326
327static inline int chsc(void *chsc_area)
328{
329 typedef struct { char _[4096]; } addr_type;
330 int cc;
331
332 asm volatile(
333 " .insn rre,0xb25f0000,%2,0\n"
334 " ipm %0\n"
335 " srl %0,28\n"
336 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
337 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
338 : "cc");
339 return cc;
340}
341
342#endif
343