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
14 * We only care about format-1 CCWs
17 u8 cmd
; /* Command code */
19 u16 count
; /* Count */
20 u32 addr
; /* Data Address */
21 } __attribute__((packed
,aligned(8)));
23 #define CCW0_ADDR(c) ((((u64)((c)->addr_hi)) << 16) | (((u64)((c)->addr_lo))))
26 u8 cmd
; /* Command code */
27 u8 addr_hi
; /* Data Address (bits 8-15) */
28 u16 addr_lo
; /* Data Address (bits 16-31) */
31 u16 count
; /* Count */
32 } __attribute__((packed
,aligned(8)));
34 #define CCW_CMD_INVAL 0x00
35 #define CCW_CMD_IPL_READ 0x02
36 #define CCW_CMD_NOP 0x03
37 #define CCW_CMD_BASIC_SENSE 0x04
38 #define CCW_CMD_SENSE_ID 0xe4
39 #define CCW_CMD_TIC 0x08
41 #define IS_CCW_WRITE(op) (((op)&0x03)==0x01)
42 #define IS_CCW_READ(op) (((op)&0x03)==0x02)
43 #define IS_CCW_CONTROL(op) (((op)&0x03)==0x03)
45 #define CCW_FLAG_CD 0x80 /* Chain-Data */
46 #define CCW_FLAG_CC 0x40 /* Chain-Command */
47 #define CCW_FLAG_SLI 0x20 /* Suppress-Length-Indication */
48 #define CCW_FLAG_SKP 0x10 /* Skip */
49 #define CCW_FLAG_PCI 0x08 /* Program-Controlled-Interruption */
50 #define CCW_FLAG_IDA 0x04 /* Indirect-Data-Address */
51 #define CCW_FLAG_S 0x02 /* Suspend */
52 #define CCW_FLAG_MIDA 0x01 /* Modified-Indirect-Data-Address */
54 static inline void ccw0_to_ccw1(struct ccw
*out
, struct ccw0
*in
)
56 /* 0x08 is TIC; format-0 CCWs allow upper nibble to be non-zero */
57 out
->cmd
= ((in
->cmd
& 0x0f) == CCW_CMD_TIC
) ?
58 CCW_CMD_TIC
: in
->cmd
;
59 out
->flags
= in
->flags
;
60 out
->count
= in
->count
;
61 out
->addr
= CCW0_ADDR(in
);
69 u32 param
; /* Interruption Parameter */
72 u8 key
:4, /* Subchannel Key */
74 c
:1, /* Streaming-Mode Control */
75 m
:1, /* Modification Control */
76 y
:1; /* Synchronization Control */
77 u8 f
:1, /* Format Control */
78 p
:1, /* Prefetch Control */
79 i
:1, /* Initial-Status-Interruption Control */
80 a
:1, /* Address-Limit-Checking control */
81 u
:1, /* Suppress-Suspend-Interruption Control */
82 b
:1, /* Channel-Program Type Control */
83 h
:1, /* Format-2-IDAW Control */
84 t
:1; /* 2K-IDAW Control */
85 u8 lpm
; /* Logical-Path Mask */
86 u8 l
:1, /* Incorrect-Length-Suppression Mode */
87 d
:1, /* Modified-CCW-Indirect-Data-Addressing Control */
89 x
:1; /* ORB-Extension Control */
92 u32 addr
; /* Channel-Program Address */
95 u8 css_prio
; /* Channel-Subsystem Priority */
97 u8 cu_prio
; /* Control-Unit Priority */
105 } __attribute__((packed
,aligned(4)));
133 u16 key
:4, /* Subchannel key */
134 s
:1, /* Suspend control */
135 l
:1, /* ESW format */
136 cc
:2, /* Deferred condition code */
139 i
:1, /* Initial-status interruption control */
140 a
:1, /* Address-limit-checking control */
141 u
:1, /* Supress-suspended interruption */
142 z
:1, /* Zero condition code */
143 e
:1, /* Extended control */
144 n
:1; /* Path no operational */
146 fc
:3, /* Function control */
147 ac
:7, /* Activity control */
148 sc
:5; /* Status control */
151 u32 addr
; /* CCW Address */
154 u8 dev_status
; /* Device status */
155 u8 sch_status
; /* Subchannel status */
156 u16 count
; /* Count */
157 } __attribute__((packed
));
160 struct irb_ext_status
{
161 /* TODO: not implemented */
162 u32 w0
, w1
, w2
, w3
, w4
;
163 } __attribute__((packed
));
166 struct irb_ext_control
{
167 /* TODO: not implemented */
168 u32 w0
, w1
, w2
, w3
, w4
, w5
, w6
, w7
;
169 } __attribute__((packed
));
172 struct irb_ext_measurement
{
173 /* TODO: not implemented */
174 u32 w0
, w1
, w2
, w3
, w4
, w5
, w6
, w7
;
175 } __attribute__((packed
));
178 struct scsw scsw
; /* Subchannel-Status */
179 struct irb_ext_status ext_status
; /* Extended-Status */
180 struct irb_ext_control ext_control
; /* Extended-Control */
181 struct irb_ext_measurement ext_measure
; /* Extended-Measurement */
182 } __attribute__((packed
,aligned(4)));
184 /* Path Management Control Word */
187 u32 interrupt_param
; /* Interruption Parameter */
191 isc
:3, /* I/O-Interruption-Subclass Code */
193 u8 e
:1, /* Enabled */
194 lm
:2, /* Limit Mode */
195 mm
:2, /* Measurement-Mode Enable */
196 d
:1, /* Multipath Mode */
197 t
:1, /* Timing Facility */
198 v
:1; /* Device Number Valid */
199 u16 dev_num
; /* Device Number */
202 u8 lpm
; /* Logical-Path Mask */
203 u8 pnom
; /* Path-Not-Operational Mask */
204 u8 lpum
; /* Last-Path-Used Mask */
205 u8 pim
; /* Path-Installed Mask */
208 u16 mbi
; /* Measurement-Block Index */
209 u8 pom
; /* Path-Operational Mask */
210 u8 pam
; /* Path-Available Mask */
213 u8 chpid
[8]; /* Channel-Path Identifiers */
218 f
:1, /* Measurement Block Format Control */
219 x
:1, /* Extended Measurement Word Mode Enable */
220 s
:1; /* Concurrent Sense */
223 /* needed by schib */
224 struct schib_measurement_block
{
225 /* TODO: not implemented */
230 struct pmcw pmcw
; /* Path Management Control Word */
231 struct scsw scsw
; /* Subchannel Status Word */
233 struct schib_measurement_block measure_block
;
236 } __attribute__((packed
,aligned(4)));
238 struct senseid_struct
{
244 } __attribute__((packed
));
247 SC_STATUS_ATTN
= 0x80, /* Attention */
248 SC_STATUS_MOD
= 0x40, /* Status Modifier */
249 SC_STATUS_CUE
= 0x20, /* Control-Unit End */
250 SC_STATUS_BUSY
= 0x10, /* Busy */
251 SC_STATUS_CE
= 0x08, /* Channel End */
252 SC_STATUS_DE
= 0x04, /* Device End */
253 SC_STATUS_UC
= 0x02, /* Unit-check */
254 SC_STATUS_UE
= 0x01, /* Unit-exception */
258 SC_PROG_CI
= 0x80, /* Program-Controlled Interruption */
259 SC_INC_LEN
= 0x40, /* Incorrect Length */
260 SC_PROG_CHK
= 0x20, /* Program Check */
261 SC_PROT_CHK
= 0x10, /* Protection Check */
262 SC_CHD_CHK
= 0x08, /* Channel-Data Check */
263 SC_CHC_CHK
= 0x04, /* Channel-Control Check */
264 SC_IC_CHK
= 0x02, /* Interface-Control Check */
265 SC_CHAIN_CHK
= 0x01, /* Chaining Check */
272 static inline int store_sch(u32 sch
, struct schib
*schib
)
295 static inline int modify_sch(u32 sch
, struct schib
*schib
)
313 if (cc
== 1 || cc
== 2)
320 static inline int start_sch(u32 sch
, struct orb
*orb
)
338 if (cc
== 1 || cc
== 2)
346 static inline int test_sch(u32 sch
, struct irb
*irb
)
380 } __attribute__((packed
));
383 * store_crw - stores the Channel Report Word
384 * @crw: pointer to CRW
385 * @return: 0 on success, 1 if zeros were stored
387 static inline int store_crw(struct crw
*crw
)