Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * SCSI general interface description | |
3 | */ | |
4 | ||
15637ed4 RG |
5 | /* |
6 | * Largely written by Julian Elischer (julian@tfs.com) | |
7 | * for TRW Financial Systems. | |
8 | * | |
9 | * TRW Financial Systems, in accordance with their agreement with Carnegie | |
10 | * Mellon University, makes this software available to CMU to distribute | |
11 | * or use in any manner that they see fit as long as this message is kept with | |
12 | * the software. For this reason TFS also grants any other persons or | |
13 | * organisations permission to use or modify this software. | |
14 | * | |
15 | * TFS supplies this software to be publicly redistributed | |
16 | * on the understanding that TFS is not responsible for the correct | |
17 | * functioning of this software in any circumstances. | |
18 | * | |
15637ed4 | 19 | * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 |
98639498 | 20 | * |
519fb2b7 | 21 | * $Id: scsi_all.h,v 2.0 93/10/06 21:10:28 julian Exp Locker: julian $ |
15637ed4 RG |
22 | */ |
23 | ||
519fb2b7 RG |
24 | #ifndef _SCSI_SCSI_ALL_H |
25 | #define _SCSI_SCSI_ALL_H 1 | |
15637ed4 RG |
26 | /* |
27 | * SCSI command format | |
28 | */ | |
29 | ||
869c4419 RG |
30 | /* |
31 | * Define dome bits that are in ALL (or a lot of) scsi commands | |
32 | */ | |
519fb2b7 RG |
33 | #define SCSI_CTL_LINK 0x01 |
34 | #define SCSI_CTL_FLAG 0x02 | |
35 | #define SCSI_CTL_VENDOR 0xC0 | |
36 | #define SCSI_CMD_LUN 0xA0 /* these two should not be needed */ | |
869c4419 RG |
37 | #define SCSI_CMD_LUN_SHIFT 5 /* LUN in the cmd is no longer SCSI */ |
38 | ||
15637ed4 RG |
39 | |
40 | struct scsi_generic | |
41 | { | |
42 | u_char opcode; | |
43 | u_char bytes[11]; | |
44 | }; | |
45 | ||
46 | struct scsi_test_unit_ready | |
47 | { | |
48 | u_char op_code; | |
869c4419 | 49 | u_char byte2; |
15637ed4 | 50 | u_char unused[3]; |
869c4419 | 51 | u_char control; |
15637ed4 RG |
52 | }; |
53 | ||
54 | struct scsi_send_diag | |
55 | { | |
56 | u_char op_code; | |
869c4419 RG |
57 | u_char byte2; |
58 | #define SSD_UOL 0x01 | |
59 | #define SSD_DOL 0x02 | |
60 | #define SSD_SELFTEST 0x04 | |
61 | #define SSD_PF 0x10 | |
15637ed4 RG |
62 | u_char unused[1]; |
63 | u_char paramlen[2]; | |
869c4419 | 64 | u_char control; |
15637ed4 RG |
65 | }; |
66 | ||
67 | struct scsi_sense | |
68 | { | |
69 | u_char op_code; | |
869c4419 | 70 | u_char byte2; |
15637ed4 RG |
71 | u_char unused[2]; |
72 | u_char length; | |
869c4419 | 73 | u_char control; |
15637ed4 RG |
74 | }; |
75 | ||
76 | struct scsi_inquiry | |
77 | { | |
78 | u_char op_code; | |
869c4419 | 79 | u_char byte2; |
15637ed4 RG |
80 | u_char unused[2]; |
81 | u_char length; | |
869c4419 | 82 | u_char control; |
15637ed4 RG |
83 | }; |
84 | ||
85 | struct scsi_mode_sense | |
86 | { | |
87 | u_char op_code; | |
869c4419 RG |
88 | u_char byte2; |
89 | #define SMS_DBD 0x08 | |
90 | u_char page; | |
91 | #define SMS_PAGE_CODE 0x3F | |
92 | #define SMS_PAGE_CTRL 0xC0 | |
93 | #define SMS_PAGE_CTRL_CURRENT 0x00 | |
94 | #define SMS_PAGE_CTRL_CHANGEABLE 0x40 | |
95 | #define SMS_PAGE_CTRL_DEFAULT 0x80 | |
96 | #define SMS_PAGE_CTRL_SAVED 0xC0 | |
15637ed4 RG |
97 | u_char unused; |
98 | u_char length; | |
869c4419 | 99 | u_char control; |
15637ed4 RG |
100 | }; |
101 | ||
102 | struct scsi_mode_sense_big | |
103 | { | |
104 | u_char op_code; | |
519fb2b7 | 105 | u_char byte2; /* same bits as small version */ |
869c4419 | 106 | u_char page; /* same bits as small version */ |
15637ed4 RG |
107 | u_char unused[4]; |
108 | u_char length[2]; | |
869c4419 | 109 | u_char control; |
15637ed4 RG |
110 | }; |
111 | ||
112 | struct scsi_mode_select | |
113 | { | |
114 | u_char op_code; | |
869c4419 RG |
115 | u_char byte2; |
116 | #define SMS_SP 0x01 | |
117 | #define SMS_PF 0x10 | |
15637ed4 RG |
118 | u_char unused[2]; |
119 | u_char length; | |
869c4419 | 120 | u_char control; |
15637ed4 RG |
121 | }; |
122 | ||
123 | struct scsi_mode_select_big | |
124 | { | |
125 | u_char op_code; | |
519fb2b7 | 126 | u_char byte2; /* same bits as small version */ |
15637ed4 RG |
127 | u_char unused[5]; |
128 | u_char length[2]; | |
869c4419 | 129 | u_char control; |
15637ed4 RG |
130 | }; |
131 | ||
132 | struct scsi_reserve | |
133 | { | |
134 | u_char op_code; | |
869c4419 | 135 | u_char byte2; |
15637ed4 RG |
136 | u_char unused[2]; |
137 | u_char length; | |
869c4419 | 138 | u_char control; |
15637ed4 RG |
139 | }; |
140 | ||
141 | struct scsi_release | |
142 | { | |
143 | u_char op_code; | |
869c4419 | 144 | u_char byte2; |
15637ed4 RG |
145 | u_char unused[2]; |
146 | u_char length; | |
869c4419 | 147 | u_char control; |
15637ed4 RG |
148 | }; |
149 | ||
150 | struct scsi_prevent | |
151 | { | |
152 | u_char op_code; | |
869c4419 | 153 | u_char byte2; |
15637ed4 | 154 | u_char unused[2]; |
869c4419 RG |
155 | u_char how; |
156 | u_char control; | |
15637ed4 | 157 | }; |
869c4419 RG |
158 | #define PR_PREVENT 0x01 |
159 | #define PR_ALLOW 0x00 | |
15637ed4 | 160 | |
519fb2b7 RG |
161 | struct scsi_changedef |
162 | { | |
163 | u_char op_code; | |
164 | u_char byte2; | |
165 | u_char unused1; | |
166 | u_char how; | |
167 | u_char unused[4]; | |
168 | u_char datalen; | |
169 | u_char control; | |
170 | }; | |
171 | #define SC_SCSI_1 0x01 | |
172 | #define SC_SCSI_2 0x03 | |
173 | ||
15637ed4 RG |
174 | /* |
175 | * Opcodes | |
176 | */ | |
177 | ||
178 | #define TEST_UNIT_READY 0x00 | |
179 | #define REQUEST_SENSE 0x03 | |
180 | #define INQUIRY 0x12 | |
181 | #define MODE_SELECT 0x15 | |
182 | #define MODE_SENSE 0x1a | |
183 | #define START_STOP 0x1b | |
184 | #define RESERVE 0x16 | |
185 | #define RELEASE 0x17 | |
186 | #define PREVENT_ALLOW 0x1e | |
187 | #define POSITION_TO_ELEMENT 0x2b | |
519fb2b7 | 188 | #define CHANGE_DEFINITION 0x40 |
15637ed4 RG |
189 | #define MODE_SENSE_BIG 0x54 |
190 | #define MODE_SELECT_BIG 0x55 | |
191 | #define MOVE_MEDIUM 0xa5 | |
192 | #define READ_ELEMENT_STATUS 0xb8 | |
193 | ||
194 | ||
195 | /* | |
196 | * sense data format | |
197 | */ | |
198 | #define T_DIRECT 0 | |
199 | #define T_SEQUENTIAL 1 | |
200 | #define T_PRINTER 2 | |
201 | #define T_PROCESSOR 3 | |
202 | #define T_WORM 4 | |
203 | #define T_READONLY 5 | |
204 | #define T_SCANNER 6 | |
205 | #define T_OPTICAL 7 | |
206 | #define T_NODEVICE 0x1F | |
207 | ||
208 | #define T_CHANGER 8 | |
209 | #define T_COMM 9 | |
210 | ||
211 | #define T_REMOV 1 | |
212 | #define T_FIXED 0 | |
213 | ||
214 | struct scsi_inquiry_data | |
215 | { | |
869c4419 RG |
216 | u_char device; |
217 | #define SID_TYPE 0x1F | |
218 | #define SID_QUAL 0xE0 | |
219 | #define SID_QUAL_LU_OK 0x00 | |
220 | #define SID_QUAL_LU_OFFLINE 0x20 | |
221 | #define SID_QUAL_RSVD 0x40 | |
222 | #define SID_QUAL_BAD_LU 0x60 | |
223 | u_char dev_qual2; | |
224 | #define SID_QUAL2 0x7F | |
225 | #define SID_REMOVABLE 0x80 | |
226 | u_char version; | |
227 | #define SID_ANSII 0x07 | |
228 | #define SID_ECMA 0x38 | |
229 | #define SID_ISO 0xC0 | |
15637ed4 RG |
230 | u_char response_format; |
231 | u_char additional_length; | |
232 | u_char unused[2]; | |
869c4419 RG |
233 | u_char flags; |
234 | #define SID_SftRe 0x01 | |
235 | #define SID_CmdQue 0x02 | |
236 | #define SID_Linked 0x08 | |
237 | #define SID_Sync 0x10 | |
238 | #define SID_WBus16 0x20 | |
239 | #define SID_WBus32 0x40 | |
240 | #define SID_RelAdr 0x80 | |
15637ed4 RG |
241 | char vendor[8]; |
242 | char product[16]; | |
243 | char revision[4]; | |
244 | u_char extra[8]; | |
245 | }; | |
246 | ||
247 | ||
248 | struct scsi_sense_data | |
249 | { | |
519fb2b7 | 250 | /* 1*/ u_char error_code; /* same bits as new version */ |
15637ed4 RG |
251 | union |
252 | { | |
253 | struct | |
254 | { | |
519fb2b7 RG |
255 | /* 2*/ u_char blockhi; |
256 | /* 3*/ u_char blockmed; | |
257 | /* 4*/ u_char blocklow; | |
15637ed4 RG |
258 | } unextended; |
259 | struct | |
260 | { | |
519fb2b7 RG |
261 | /* 2*/ u_char segment; |
262 | /* 3*/ u_char flags; /* same bits as new version */ | |
263 | /* 7*/ u_char info[4]; | |
264 | /* 8*/ u_char extra_len; | |
15637ed4 | 265 | /* allocate enough room to hold new stuff |
519fb2b7 RG |
266 | ( by increasing 16 to 24 below) */ |
267 | /*32*/ u_char extra_bytes[24]; | |
15637ed4 RG |
268 | } extended; |
269 | }ext; | |
519fb2b7 | 270 | }; /* total of 32 bytes */ |
15637ed4 RG |
271 | struct scsi_sense_data_new |
272 | { | |
519fb2b7 | 273 | /* 1*/ u_char error_code; |
869c4419 RG |
274 | #define SSD_ERRCODE 0x7F |
275 | #define SSD_ERRCODE_VALID 0x80 | |
15637ed4 RG |
276 | union |
277 | { | |
519fb2b7 | 278 | struct /* this is deprecated, the standard says "DON'T"*/ |
15637ed4 | 279 | { |
519fb2b7 RG |
280 | /* 2*/ u_char blockhi; |
281 | /* 3*/ u_char blockmed; | |
282 | /* 4*/ u_char blocklow; | |
15637ed4 RG |
283 | } unextended; |
284 | struct | |
285 | { | |
519fb2b7 RG |
286 | /* 2*/ u_char segment; |
287 | /* 3*/ u_char flags; | |
869c4419 RG |
288 | #define SSD_KEY 0x0F |
289 | #define SSD_ILI 0x20 | |
290 | #define SSD_EOM 0x40 | |
291 | #define SSD_FILEMARK 0x80 | |
519fb2b7 RG |
292 | /* 7*/ u_char info[4]; |
293 | /* 8*/ u_char extra_len; | |
294 | /*12*/ u_char cmd_spec_info[4]; | |
295 | /*13*/ u_char add_sense_code; | |
296 | /*14*/ u_char add_sense_code_qual; | |
297 | /*15*/ u_char fru; | |
298 | /*16*/ u_char sense_key_spec_1; | |
869c4419 | 299 | #define SSD_SCS_VALID 0x80 |
519fb2b7 RG |
300 | /*17*/ u_char sense_key_spec_2; |
301 | /*18*/ u_char sense_key_spec_3; | |
302 | /*32*/ u_char extra_bytes[14]; | |
15637ed4 RG |
303 | } extended; |
304 | }ext; | |
519fb2b7 | 305 | }; /* total of 32 bytes */ |
15637ed4 RG |
306 | |
307 | struct blk_desc | |
308 | { | |
309 | u_char density; | |
310 | u_char nblocks[3]; | |
311 | u_char reserved; | |
312 | u_char blklen[3]; | |
313 | }; | |
314 | ||
315 | struct scsi_mode_header | |
316 | { | |
317 | u_char data_length; /* Sense data length */ | |
318 | u_char medium_type; | |
319 | u_char dev_spec; | |
320 | u_char blk_desc_len; | |
321 | }; | |
322 | ||
323 | struct scsi_mode_header_big | |
324 | { | |
325 | u_char data_length[2]; /* Sense data length */ | |
326 | u_char medium_type; | |
327 | u_char dev_spec; | |
328 | u_char unused[2]; | |
329 | u_char blk_desc_len[2]; | |
330 | }; | |
331 | ||
332 | ||
333 | /* | |
334 | * Status Byte | |
335 | */ | |
336 | #define SCSI_OK 0x00 | |
337 | #define SCSI_CHECK 0x02 | |
338 | #define SCSI_BUSY 0x08 | |
339 | #define SCSI_INTERM 0x10 | |
519fb2b7 | 340 | #endif /*_SCSI_SCSI_ALL_H*/ |