This source file includes following definitions.
- _lto2b
- _lto3b
- _lto4b
- _lto8b
- _2btol
- _3btol
- _4btol
- _5btol
- _8btol
- _lto2l
- _lto3l
- _lto4l
- _2ltol
- _3ltol
- _4ltol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #ifndef SCSI_SCSICONF_H
51 #define SCSI_SCSICONF_H 1
52
53 #include <sys/queue.h>
54 #include <sys/timeout.h>
55 #include <sys/workq.h>
56 #include <machine/cpu.h>
57 #include <scsi/scsi_debug.h>
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 struct buf;
89 struct scsi_xfer;
90 struct scsi_link;
91
92
93
94
95 extern int scsi_autoconf;
96
97
98
99
100
101
102 struct scsi_adapter {
103 int (*scsi_cmd)(struct scsi_xfer *);
104 void (*scsi_minphys)(struct buf *);
105 int (*open_target_lu)(void);
106 int (*close_target_lu)(void);
107 int (*ioctl)(struct scsi_link *, u_long, caddr_t, int,
108 struct proc *);
109 };
110
111
112
113
114 #define SUCCESSFULLY_QUEUED 0
115 #define TRY_AGAIN_LATER 1
116 #define COMPLETE 2
117 #define ESCAPE_NOT_SUPPORTED 3
118 #define NO_CCB 4
119
120
121
122
123
124
125 struct scsi_device {
126 int (*err_handler)(struct scsi_xfer *);
127
128 void (*start)(void *);
129
130 int (*async)(void);
131 void (*done)(struct scsi_xfer *);
132 };
133
134
135
136
137
138
139
140 struct scsi_link {
141 u_int8_t scsibus;
142 u_int8_t luns;
143 u_int16_t target;
144 u_int16_t lun;
145 u_int16_t openings;
146 u_int64_t port_wwn;
147 u_int64_t node_wwn;
148 u_int16_t adapter_target;
149 u_int16_t adapter_buswidth;
150 u_int16_t active;
151 u_int16_t flags;
152 #define SDEV_REMOVABLE 0x0001
153 #define SDEV_MEDIA_LOADED 0x0002
154 #define SDEV_WAITING 0x0004
155 #define SDEV_OPEN 0x0008
156 #define SDEV_DBX 0x00f0
157 #define SDEV_EJECTING 0x0100
158 #define SDEV_ATAPI 0x0200
159 #define SDEV_2NDBUS 0x0400
160 #define SDEV_UMASS 0x0800
161 #define SDEV_VIRTUAL 0x1000
162 u_int16_t quirks;
163 #define SDEV_AUTOSAVE 0x0001
164 #define SDEV_NOSYNC 0x0002
165 #define SDEV_NOWIDE 0x0004
166 #define SDEV_NOTAGS 0x0008
167 #define SDEV_NOSYNCCACHE 0x0100
168 #define ADEV_NOSENSE 0x0200
169 #define ADEV_LITTLETOC 0x0400
170 #define ADEV_NOCAPACITY 0x0800
171 #define ADEV_NOTUR 0x1000
172 #define ADEV_NODOORLOCK 0x2000
173 #define SDEV_ONLYBIG 0x4000
174 struct scsi_device *device;
175 void *device_softc;
176 struct scsi_adapter *adapter;
177 void *adapter_softc;
178 struct scsi_inquiry_data inqdata;
179 };
180
181 int scsiprint(void *, const char *);
182
183
184
185
186
187 struct scsi_inquiry_pattern {
188 u_int8_t type;
189 int removable;
190 char *vendor;
191 char *product;
192 char *revision;
193 };
194
195 struct scsibus_attach_args {
196 struct scsi_link *saa_sc_link;
197 };
198
199
200
201
202
203
204
205
206
207 struct scsibus_softc {
208 struct device sc_dev;
209 struct scsi_link *adapter_link;
210 struct scsi_link ***sc_link;
211 u_int16_t sc_buswidth;
212 };
213
214
215
216
217
218 struct scsi_attach_args {
219 struct scsi_link *sa_sc_link;
220 struct scsi_inquiry_data *sa_inqbuf;
221 };
222
223
224
225
226
227
228
229 struct scsi_xfer {
230 LIST_ENTRY(scsi_xfer) free_list;
231 int flags;
232 struct scsi_link *sc_link;
233 int retries;
234 int timeout;
235 struct scsi_generic *cmd;
236 int cmdlen;
237 u_char *data;
238 int datalen;
239 size_t resid;
240 int error;
241 struct buf *bp;
242 struct scsi_sense_data sense;
243
244
245
246
247 int req_sense_length;
248 u_int8_t status;
249 struct scsi_generic cmdstore;
250
251
252
253 struct timeout stimeout;
254 };
255
256
257
258
259 #define SCSI_NOSLEEP 0x00001
260 #define SCSI_POLL 0x00002
261 #define SCSI_AUTOCONF 0x00003
262 #define SCSI_USER 0x00004
263 #define ITSDONE 0x00008
264 #define SCSI_SILENT 0x00020
265 #define SCSI_IGNORE_NOT_READY 0x00040
266 #define SCSI_IGNORE_MEDIA_CHANGE 0x00080
267 #define SCSI_IGNORE_ILLEGAL_REQUEST 0x00100
268 #define SCSI_RESET 0x00200
269 #define SCSI_DATA_UIO 0x00400
270 #define SCSI_DATA_IN 0x00800
271 #define SCSI_DATA_OUT 0x01000
272 #define SCSI_TARGET 0x02000
273 #define SCSI_ESCAPE 0x04000
274 #define SCSI_URGENT 0x08000
275 #define SCSI_PRIVATE 0xf0000
276
277
278
279
280
281
282 #define SCSI_OP_TARGET 0x0001
283 #define SCSI_OP_RESET 0x0002
284 #define SCSI_OP_BDINFO 0x0003
285
286
287
288
289 #define XS_NOERROR 0
290 #define XS_SENSE 1
291 #define XS_DRIVER_STUFFUP 2
292 #define XS_SELTIMEOUT 3
293 #define XS_TIMEOUT 4
294 #define XS_BUSY 5
295 #define XS_SHORTSENSE 6
296 #define XS_RESET 8
297
298
299
300
301 #define TEST_READY_RETRIES 5
302
303 const void *scsi_inqmatch(struct scsi_inquiry_data *, const void *, int,
304 int, int *);
305
306 #define scsi_task(_f, _a1, _a2, _fl) \
307 workq_add_task(NULL, (_fl), (_f), (_a1), (_a2))
308
309 void scsi_init(void);
310 void scsi_deinit(void);
311 struct scsi_xfer *
312 scsi_get_xs(struct scsi_link *, int);
313 void scsi_free_xs(struct scsi_xfer *, int);
314 int scsi_execute_xs(struct scsi_xfer *);
315 daddr64_t scsi_size(struct scsi_link *, int, u_int32_t *);
316 int scsi_test_unit_ready(struct scsi_link *, int, int);
317 int scsi_inquire(struct scsi_link *, struct scsi_inquiry_data *, int);
318 int scsi_inquire_vpd(struct scsi_link *, void *, u_int, u_int8_t, int);
319 int scsi_prevent(struct scsi_link *, int, int);
320 int scsi_start(struct scsi_link *, int, int);
321 int scsi_mode_sense(struct scsi_link *, int, int, struct scsi_mode_header *,
322 size_t, int, int);
323 int scsi_mode_sense_big(struct scsi_link *, int, int,
324 struct scsi_mode_header_big *, size_t, int, int);
325 void * scsi_mode_sense_page(struct scsi_mode_header *, int);
326 void * scsi_mode_sense_big_page(struct scsi_mode_header_big *, int);
327 int scsi_do_mode_sense(struct scsi_link *, int,
328 union scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *,
329 u_int32_t *, int, int, int *);
330 int scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
331 int, int);
332 int scsi_mode_select_big(struct scsi_link *, int,
333 struct scsi_mode_header_big *, int, int);
334 void scsi_done(struct scsi_xfer *);
335 void scsi_user_done(struct scsi_xfer *);
336 int scsi_scsi_cmd(struct scsi_link *, struct scsi_generic *,
337 int cmdlen, u_char *data_addr, int datalen, int retries,
338 int timeout, struct buf *bp, int flags);
339 int scsi_do_ioctl(struct scsi_link *, dev_t, u_long, caddr_t,
340 int, struct proc *);
341 void sc_print_addr(struct scsi_link *);
342 int scsi_report_luns(struct scsi_link *, int,
343 struct scsi_report_luns_data *, u_int32_t, int, int);
344
345 void show_scsi_xs(struct scsi_xfer *);
346 void scsi_print_sense(struct scsi_xfer *);
347 void show_scsi_cmd(struct scsi_xfer *);
348 void show_mem(u_char *, int);
349 void scsi_strvis(u_char *, u_char *, int);
350 int scsi_delay(struct scsi_xfer *, int);
351
352 int scsi_probe_bus(struct scsibus_softc *);
353 int scsi_probe_target(struct scsibus_softc *, int);
354 int scsi_probe_lun(struct scsibus_softc *, int, int);
355
356 int scsi_detach_bus(struct scsibus_softc *, int);
357 int scsi_detach_target(struct scsibus_softc *, int, int);
358 int scsi_detach_lun(struct scsibus_softc *, int, int, int);
359
360 static __inline void _lto2b(u_int32_t val, u_int8_t *bytes);
361 static __inline void _lto3b(u_int32_t val, u_int8_t *bytes);
362 static __inline void _lto4b(u_int32_t val, u_int8_t *bytes);
363 static __inline void _lto8b(u_int64_t val, u_int8_t *bytes);
364 static __inline u_int32_t _2btol(u_int8_t *bytes);
365 static __inline u_int32_t _3btol(u_int8_t *bytes);
366 static __inline u_int32_t _4btol(u_int8_t *bytes);
367 static __inline u_int64_t _5btol(u_int8_t *bytes);
368 static __inline u_int64_t _8btol(u_int8_t *bytes);
369
370 static __inline void _lto2l(u_int32_t val, u_int8_t *bytes);
371 static __inline void _lto3l(u_int32_t val, u_int8_t *bytes);
372 static __inline void _lto4l(u_int32_t val, u_int8_t *bytes);
373 static __inline u_int32_t _2ltol(u_int8_t *bytes);
374 static __inline u_int32_t _3ltol(u_int8_t *bytes);
375 static __inline u_int32_t _4ltol(u_int8_t *bytes);
376
377 static __inline void
378 _lto2b(val, bytes)
379 u_int32_t val;
380 u_int8_t *bytes;
381 {
382
383 bytes[0] = (val >> 8) & 0xff;
384 bytes[1] = val & 0xff;
385 }
386
387 static __inline void
388 _lto3b(val, bytes)
389 u_int32_t val;
390 u_int8_t *bytes;
391 {
392
393 bytes[0] = (val >> 16) & 0xff;
394 bytes[1] = (val >> 8) & 0xff;
395 bytes[2] = val & 0xff;
396 }
397
398 static __inline void
399 _lto4b(val, bytes)
400 u_int32_t val;
401 u_int8_t *bytes;
402 {
403
404 bytes[0] = (val >> 24) & 0xff;
405 bytes[1] = (val >> 16) & 0xff;
406 bytes[2] = (val >> 8) & 0xff;
407 bytes[3] = val & 0xff;
408 }
409
410 static __inline void
411 _lto8b(val, bytes)
412 u_int64_t val;
413 u_int8_t *bytes;
414 {
415
416 bytes[0] = (val >> 56) & 0xff;
417 bytes[1] = (val >> 48) & 0xff;
418 bytes[2] = (val >> 40) & 0xff;
419 bytes[3] = (val >> 32) & 0xff;
420 bytes[4] = (val >> 24) & 0xff;
421 bytes[5] = (val >> 16) & 0xff;
422 bytes[6] = (val >> 8) & 0xff;
423 bytes[7] = val & 0xff;
424 }
425
426 static __inline u_int32_t
427 _2btol(bytes)
428 u_int8_t *bytes;
429 {
430 u_int32_t rv;
431
432 rv = (bytes[0] << 8) | bytes[1];
433 return (rv);
434 }
435
436 static __inline u_int32_t
437 _3btol(bytes)
438 u_int8_t *bytes;
439 {
440 u_int32_t rv;
441
442 rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2];
443 return (rv);
444 }
445
446 static __inline u_int32_t
447 _4btol(bytes)
448 u_int8_t *bytes;
449 {
450 u_int32_t rv;
451
452 rv = (bytes[0] << 24) | (bytes[1] << 16) |
453 (bytes[2] << 8) | bytes[3];
454 return (rv);
455 }
456
457 static __inline u_int64_t
458 _5btol(bytes)
459 u_int8_t *bytes;
460 {
461 u_int64_t rv;
462
463 rv = ((u_int64_t)bytes[0] << 32) |
464 ((u_int64_t)bytes[1] << 24) |
465 ((u_int64_t)bytes[2] << 16) |
466 ((u_int64_t)bytes[3] << 8) |
467 (u_int64_t)bytes[4];
468 return (rv);
469 }
470
471 static __inline u_int64_t
472 _8btol(bytes)
473 u_int8_t *bytes;
474 {
475 u_int64_t rv;
476
477 rv = (((u_int64_t)bytes[0]) << 56) |
478 (((u_int64_t)bytes[1]) << 48) |
479 (((u_int64_t)bytes[2]) << 40) |
480 (((u_int64_t)bytes[3]) << 32) |
481 (((u_int64_t)bytes[4]) << 24) |
482 (((u_int64_t)bytes[5]) << 16) |
483 (((u_int64_t)bytes[6]) << 8) |
484 ((u_int64_t)bytes[7]);
485 return (rv);
486 }
487
488 static __inline void
489 _lto2l(val, bytes)
490 u_int32_t val;
491 u_int8_t *bytes;
492 {
493
494 bytes[0] = val & 0xff;
495 bytes[1] = (val >> 8) & 0xff;
496 }
497
498 static __inline void
499 _lto3l(val, bytes)
500 u_int32_t val;
501 u_int8_t *bytes;
502 {
503
504 bytes[0] = val & 0xff;
505 bytes[1] = (val >> 8) & 0xff;
506 bytes[2] = (val >> 16) & 0xff;
507 }
508
509 static __inline void
510 _lto4l(val, bytes)
511 u_int32_t val;
512 u_int8_t *bytes;
513 {
514
515 bytes[0] = val & 0xff;
516 bytes[1] = (val >> 8) & 0xff;
517 bytes[2] = (val >> 16) & 0xff;
518 bytes[3] = (val >> 24) & 0xff;
519 }
520
521 static __inline u_int32_t
522 _2ltol(bytes)
523 u_int8_t *bytes;
524 {
525 u_int32_t rv;
526
527 rv = bytes[0] | (bytes[1] << 8);
528 return (rv);
529 }
530
531 static __inline u_int32_t
532 _3ltol(bytes)
533 u_int8_t *bytes;
534 {
535 u_int32_t rv;
536
537 rv = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16);
538 return (rv);
539 }
540
541 static __inline u_int32_t
542 _4ltol(bytes)
543 u_int8_t *bytes;
544 {
545 u_int32_t rv;
546
547 rv = bytes[0] | (bytes[1] << 8) |
548 (bytes[2] << 16) | (bytes[3] << 24);
549 return (rv);
550 }
551
552 extern const u_int8_t version_to_spc [];
553 #define SCSISPC(x)(version_to_spc[(x) & SID_ANSII])
554
555 #endif