scsireg.h revision 1.1 1 /*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: $Hdr: scsireg.h,v 4.300 91/06/09 06:38:12 root Rel41 $ SONY
37 *
38 * @(#)scsireg.h 8.1 (Berkeley) 6/11/93
39 */
40
41 /*
42 * scsireg.h
43 */
44
45 #ifndef __SCSIREG__
46 #define __SCSIREG__ 1
47
48 /*
49 * initiator status byte bit image
50 */
51 #define INST_EP 0x80 /* End of Process */
52 #define INST_WR 0x40 /* Waiting Reselection */
53 #define INST_IP 0x20 /* In Process */
54 #define INST_WAIT 0x10 /* Waiting Bus free */
55 #define INST_LB 0x8 /* Loss of BUSY */
56 #define INST_TO 0x4 /* Time Out */
57 #define INST_PRE 0x2 /* PaRameter Error */
58 #define INST_HE 0x1 /* Hard Error */
59
60 #define INSTERMASK 0x7
61
62
63 /*
64 * target status byte bit image
65 */
66 #define VENDOR 0x61
67 #define TGSTMASK 0x1e
68 #define TGST_RSVCFLCT 0x18
69 #define TGST_INTERMED 0x10
70 #define TGST_BUSY 0x8
71 #define TGST_CC 0x2
72 #define TGST_GOOD 0x0
73
74 #define TS_MAPPED_PIO 0x01 /* program I/O with map */
75 #define TS_CONTR_ON 0x02 /* contiguous transfer on */
76 #define TS_CONTR_OFF 0x04 /* contiguous transfer off */
77 #define TS_BYTE_DMA 0x08 /* DMA transfer(byte access) */
78 #define TS_LONG_DMA 0x10 /* DMA transfer(long access) */
79
80
81 /*
82 * message byte
83 */
84 #define MSG_IDENT 0x80
85 #define MSG_RESELEN 0x40
86 #define MSG_CCOMP 0
87 #define MSG_EXTND 1
88 #define MSG_SDP 2
89 #define MSG_RDP 3
90 #define MSG_DCNT 4
91 #define MSG_IDE 5
92 /*#define MSG_ABORT 6*/
93 #define MSG_MREJ 7
94 #define MSG_NOP 8
95 #define MSG_PERROR 9
96
97
98 /*
99 * message identify byte bit image
100 */
101 #define IDT_DISCON 0x40
102 #define IDT_DRMASK 0x7
103
104
105 /*
106 * scsi command opcodes
107 */
108 #define SCOP_TST 0x00
109 #define SCOP_REZERO 0x01
110 #define SCOP_REWIND 0x01
111 #define SCOP_RSENSE 0x03
112 #define SCOP_FMT 0x04
113 #define SCOP_RBLIM 0x05
114 #define SCOP_SPARAM 0x06
115 #define SCOP_RASBLK 0x07
116 #define SCOP_READ 0x08
117 #define SCOP_MOERASE 0x09
118 #define SCOP_WRITE 0x0a
119 #define SCOP_SEEK 0x0b
120 #define SCOP_MERASE 0x0e
121 #define SCOP_WFMARK 0x10
122 #define SCOP_SPACE 0x11
123 #define SCOP_INQUIRY 0x12
124 #define SCOP_SVERIFY 0x13
125 #define SCOP_RBDATA 0x14
126 #define SCOP_MSELECT 0x15
127 #define SCOP_ERASE 0x19
128 #define SCOP_MSENSE 0x1a
129 #define SCOP_STST 0x1b
130 #define SCOP_LOAD 0x1b
131 #define SCOP_RECDIAG 0x1c
132 #define SCOP_SNDDIAG 0x1d
133 #define SCOP_MEDRMV 0x1e
134 #define SCOP_RCAP 0x25
135 #define SCOP_EREAD 0x28
136 #define SCOP_EWRITE 0x2a
137 #define SCOP_BSSRCH 0x2c
138 #define SCOP_WSSRCH 0x2d
139 #define SCOP_WRTVRFY 0x2e
140 #define SCOP_VERIFY 0x2f
141 #define SCOP_RDL 0x37
142 #define SCOP_WBUF 0x3b
143 #define SCOP_RBUF 0x3c
144 #define SCOP_EJECT 0xc0
145 #define SCOP_EESENSE 0xc1
146 #define SCOP_READTOC 0xc1
147 #define SCOP_READID 0xc2
148 #define SCOP_ADP 0xc2
149 #define SCOP_READQ 0xc2
150 #define SCOP_BLANKS 0xc3
151 #define SCOP_READHEAD 0xc3
152 #define SCOP_PBSTS 0xc4
153 #define SCOP_RCVDISK 0xc4
154 #define SCOP_PAUSE 0xc5
155 #define SCOP_PLAYTRACK 0xc6
156 #define SCOP_PLAYMSF 0xc7
157 #define SCOP_PLAYAUDIO 0xc8
158 #define SCOP_ERASED 0xe7
159 #define SCOP_RESET 0xff
160
161
162 /*
163 * other definition
164 */
165 #define ON 1
166 #define OFF 0
167
168
169 /*
170 * scsi internal parameter block
171 */
172 struct scsi {
173 /*00*/ u_char sc_istatus;
174 /*01*/ u_char sc_tstatus;
175 /*02*/ u_char sc_identify;
176 /*03*/ u_char sc_message;
177 /*04*/ u_int sc_mpages;
178 /*08*/ u_int sc_bytesec;
179 /*0c*/ u_char *sc_cpoint;
180 /*10*/ u_int sc_ctrnscnt;
181 /*14*/ struct sc_map *sc_map;
182 union {
183 struct un_type0 {
184 /*18*/ u_int t0_opcode : 8;
185 /*19*/ u_int t0_lun : 3;
186 /*19*/ u_int t0_lad : 21;
187 /*1c*/ u_char t0_count;
188 /*1d*/ u_char t0_ctrl;
189 /*1e*/
190 } un_type0;
191 struct un_tuio {
192 /*18*/ u_char tu_opcode;
193 /*19*/ u_char tu_lun : 3;
194 /*19*/ u_char tu_resved : 3;
195 /*19*/ u_char tu_code : 2;
196 /*1a*/ u_char tu_count1;
197 /*1b*/ u_char tu_count2;
198 /*1c*/ u_char tu_count3;
199 /*1d*/ u_char tu_ctrl;
200 /*1e*/
201 } un_tuio;
202 struct un_mtio {
203 /*18*/ u_char mt_opcode;
204 /*19*/ u_char mt_lun : 3;
205 /*19*/ u_char mt_resvd : 2;
206 /*19*/ u_char mt_st : 1;
207 /*19*/ u_char mt_code : 2;
208 /*1a*/ u_char mt_len1;
209 /*1b*/ u_char mt_len2;
210 /*1c*/ u_char mt_len3;
211 /*1d*/ u_char mt_ctrl;
212 /*1e*/
213 } un_mtio;
214 struct un_type1 {
215 /*18*/ u_char t1_opcode;
216 /*19*/ u_char t1_lun : 3;
217 /*19*/ u_char t1_rsvd : 4;
218 /*19*/ u_char t1_relat : 1;
219 /*1a*/ u_short t1_ladhi;
220 /*1c*/ u_short t1_ladlo;
221 /*1e*/ u_char t1_p1;
222 /*1f*/ u_char t1_p2;
223 /*20*/ u_char t1_p3;
224 /*21*/ u_char t1_ctrl;
225 /*22*/
226 } un_type1;
227 /*18*/ u_char un_reserved[12];
228 /*24*/
229 } sc_cdb;
230 /*24*/ u_char sc_param[20];
231 /*38*/ int sc_hbinfo; /* Copy of the hb_ctlr->hm_hbinfo */
232 /*3c*/ u_int sc_ctag;
233 /*40*/ u_int sc_coffset;
234 /*44*/ void *sc_xs;
235 /*48*/
236 };
237
238
239 #define sc_opcode sc_cdb.un_type0.t0_opcode
240 #define sc_lun sc_cdb.un_type0.t0_lun
241 #define sc_lad sc_cdb.un_type0.t0_lad
242 #define sc_count sc_cdb.un_type0.t0_count
243 #define sc_nsect sc_cdb.un_type0.t0_count
244 #define sc_switch sc_cdb.un_type0.t0_count
245 #define sc_ctrl sc_cdb.un_type0.t0_ctrl
246
247 #define sc_tucode sc_cdb.un_tuio.tu_code
248 #define sc_tucount1 sc_cdb.un_tuio.tu_count1
249 #define sc_tucount2 sc_cdb.un_tuio.tu_count2
250 #define sc_tucount3 sc_cdb.un_tuio.tu_count3
251 #define sc_tunsect1 sc_cdb.un_tuio.tu_count1
252 #define sc_tunsect2 sc_cdb.un_tuio.tu_count2
253 #define sc_tunsect3 sc_cdb.un_tuio.tu_count3
254
255 #define sc_mtst sc_cdb.un_mtio.mt_st
256 #define sc_mtcode sc_cdb.un_mtio.mt_code
257 #define sc_mtlen1 sc_cdb.un_mtio.mt_len1
258 #define sc_mtlen2 sc_cdb.un_mtio.mt_len2
259 #define sc_mtlen3 sc_cdb.un_mtio.mt_len3
260 #define sc_mtcount1 sc_cdb.un_mtio.mt_len1
261 #define sc_mtcount2 sc_cdb.un_mtio.mt_len2
262 #define sc_mtcount3 sc_cdb.un_mtio.mt_len3
263 #define sc_mtnsect1 sc_cdb.un_mtio.mt_len1
264 #define sc_mtnsect2 sc_cdb.un_mtio.mt_len2
265 #define sc_mtnsect3 sc_cdb.un_mtio.mt_len3
266 #define sc_mtctrl sc_cdb.un_mtio.mt_ctrl
267 #define sc_mtfxd sc_mtcode
268 #define sc_mtimm sc_mtcode
269 #define sc_mtlng sc_mtcode
270
271 #define sc_ladhi sc_cdb.un_type1.t1_ladhi
272 #define sc_ladlo sc_cdb.un_type1.t1_ladlo
273 #define sc_pmi sc_cdb.un_type1.t1_p3
274
275 #define scop_load(a,b,c,d,e) scop_stst(a,b,c,d,e)
276
277
278 /*
279 * tape unit space operation code definitions
280 */
281 #define SCSC_DATA 0
282 #define SCSC_FM 1
283 #define SCSC_SQFM 2
284 #define SCSC_EOD 3
285
286
287 /*
288 * scsi map table format
289 */
290 #ifdef news3400
291 #define NSCMAP 120
292 #endif
293
294 #ifdef news3800
295 #define NSCMAP 129
296 #endif
297
298 struct sc_map {
299 /*000*/ unsigned mp_offset;
300 /*004*/ unsigned mp_pages;
301 /*008*/ unsigned mp_addr[NSCMAP];
302 };
303
304
305 /*
306 * scsi nonextended sense data
307 */
308 struct sc_nextnd {
309 /*00*/ u_int scn_advalid : 1;
310 /*00*/ u_int scn_ecode : 7;
311 /*01*/ u_int scn_resvd : 3;
312 /*01*/ u_int scn_secno : 21;
313 /*04*/
314 };
315
316
317 /*
318 * scsi extended sense data
319 */
320 struct sc_extnd {
321 /*00*/ u_char sce_advalid : 1;
322 /*00*/ u_char sce_extend : 7;
323 /*01*/ u_char sce_segno;
324 /*02*/ u_char sce_fm : 1;
325 /*02*/ u_char sce_eom : 1;
326 /*02*/ u_char sce_ili : 1;
327 /*02*/ u_char sce_resvd : 1;
328 /*02*/ u_char sce_skey : 4;
329 /*03*/ u_char sce_infob1;
330 /*04*/ u_char sce_infob2;
331 /*05*/ u_char sce_infob3;
332 /*06*/ u_char sce_infob4;
333 /*07*/ u_char sce_addlen;
334 union {
335 struct un_ehd {
336 /*08*/ u_short ehd_resvd1;
337 /*0a*/ u_short ehd_resvd2;
338 /*0c*/ u_char ehd_ecode;
339 /*0d*/ u_char ehd_resvd3;
340 /*0e*/ u_char ehd_fru;
341 /*0f*/ u_char ehd_fpv : 1;
342 /*0f*/ u_char ehd_cd : 1;
343 /*0f*/ u_char ehd_resvd4 : 2;
344 /*0f*/ u_char ehd_bpv : 1;
345 /*0f*/ u_char ehd_bitpnt : 3;
346 /*10*/ u_short ehd_fldpnt;
347 /*12*/
348 } un_ehd;
349 struct un_etu {
350 /*08*/ u_char etu_ecode;
351 /*09*/ u_char etu_nerrhi;
352 /*0a*/ u_char etu_nerrlo;
353 /*0b*/
354 } un_etu;
355 struct un_emt {
356 /*08*/ u_short emt_estat;
357 /*0a*/ u_char emt_resvd1;
358 /*0b*/ u_char emt_totlrtry;
359 /*0c*/ u_short emt_resvd2;
360 /*0e*/ u_short emt_resvd3;
361 /*10*/ u_char emt_resvd4;
362 /*11*/ u_char emt_ecode;
363 /*12*/
364 } un_emt;
365 struct un_ewo {
366 /*08*/ u_char ewo_resvd1;
367 /*09*/ u_char ewo_resvd2;
368 /*0a*/ u_char ewo_resvd3;
369 /*0b*/ u_char ewo_sadvalid : 1;
370 /*0b*/ u_char ewo_secode : 7;
371 /*0c*/ u_char ewo_saddr1;
372 /*0d*/ u_char ewo_saddr2;
373 /*0e*/ u_char ewo_saddr3;
374 /*0f*/ u_char ewo_saddr4;
375 /*10*/ u_char ewo_resvd4;
376 /*11*/ u_char ewo_dadvalid : 1;
377 /*11*/ u_char ewo_decode : 7;
378 /*12*/ u_char ewo_daddr1;
379 /*13*/ u_char ewo_daddr2;
380 /*14*/ u_char ewo_daddr3;
381 /*15*/ u_char ewo_daddr4;
382 /*16*/
383 } un_ewo;
384 struct un_eod {
385 /*08*/ u_char eod_resvd1;
386 /*09*/ u_char eod_resvd2;
387 /*0a*/ u_char eod_resvd3;
388 /*0b*/ u_char eod_resvd4;
389 /*0c*/ u_char eod_ecode;
390 /*0d*/ u_char eod_resvd5;
391 /*0e*/ u_char eod_resvd6;
392 /*0f*/ u_char eod_resvd7;
393 /*10*/ u_char eod_resvd8;
394 /*11*/ u_char eod_resvd9;
395 /*12*/
396 } un_eod;
397 /*08*/ u_char un_data[24];
398 /*20*/
399 } sce_add;
400 /*20*/
401 };
402
403 #define sce_hdecode sce_add.un_ehd.ehd_ecode
404
405 #define sce_tuecode sce_add.un_etu.etu_ecode
406 #define sce_tunerrhi sce_add.un_etu.etu_nerrhi
407 #define sce_tunerrlo sce_add.un_etu.etu_nerrlo
408
409 #define sce_mtestat sce_add.un_emt.emt_estat
410 #define sce_mtecode sce_add.un_emt.emt_ecode
411
412 #define sce_odecode sce_add.un_eod.eod_ecode
413
414 #define sce_ascq sce_add.un_ehd.ehd_resvd3
415 #define sce_sksv sce_add.un_ehd.ehd_fpv
416 #define sce_actretry sce_add.un_ehd.ehd_fldpnt
417
418 /*
419 * scsi inquiry response data
420 */
421 struct sc_inq {
422 /*00*/ u_char sci_devtype;
423 /*01*/ u_char sci_qual;
424 /*02*/ u_char sci_version;
425 /*03*/ u_char sci_resvd1;
426 /*04*/ u_char sci_ninfo;
427 /*05*/ u_char sci_drinfo;
428 /*06*/ u_char sci_firmrev;
429 /*07*/ u_char sci_ready;
430 /*08*/ u_char sci_vendid[8];
431 /*10*/ u_char sci_prodid[16];
432 /*20*/ u_char sci_revision[4];
433 /*24*/
434 };
435
436
437 /*
438 * scsi read capacity data
439 */
440 struct sc_rcap {
441 /*00*/ u_int scr_nblock;
442 /*04*/ u_int scr_blocklen;
443 /*08*/
444 };
445
446
447 /*
448 * scsi mode sense/select data
449 */
450 struct sc_mdata {
451 /*00*/ u_char scm_len;
452 /*01*/ u_char scm_type;
453 /*02*/ u_char scm_flags1;
454 /*03*/ u_char scm_dlen;
455 /*04*/ u_int scm_dens : 8;
456 /*05*/ u_int scm_nblock : 24;
457 /*08*/ u_int scm_resvd1 : 8;
458 /*09*/ u_int scm_bsize : 24;
459 /*0c*/ u_char scm_flags2;
460 /*0d*/ u_char scm_resvd2;
461 /*0e*/ u_char scm_resvd3;
462 /*0f*/ u_char scm_maxrtry;
463 /*10*/
464 };
465
466 #define scm_tdens scm_flags2
467
468
469 /*
470 * bits of scm_flags1
471 */
472 #define SCM1_WRP 0x80
473 #define SCM1_BUFM 0x10
474 #define SCM1_SPD90 0x02
475
476
477 /*
478 * scm_type
479 */
480 #define SCMT_DEFAULT 0x0
481 #define SCMT_150_600 0x80
482 #define SCMT_300_450 0x81
483
484
485 /*
486 * scm_dens
487 */
488 #define SCMD_QIC_24_9 0x0 /* This may be 0x5 */
489 #define SCMD_QIC_11_4 0x4
490 #define SCMD_QIC_11_9 0x84
491 #define SCMD_QIC_120_15 0xf
492 #define SCMD_QIC_150_18 0x10
493
494 #define SCMD_DEFAULT 0x00
495 #define SCMD_800_BPI 0x01
496 #define SCMD_1600_BPI 0x02
497 #define SCMD_6250_BPI 0x03
498 #define SCMD_3200_BPI 0x06
499 #define SCMD_NEWTAPE 0x80
500 #define SCMD_NOTAPE 0xff
501
502
503 /*
504 * bits of scm_flags2
505 */
506 #define SCM2_DEA 0x04
507 #define SCM2_AUI 0x02
508 #define SCM2_SEC 0x01
509
510
511 /*
512 * scsi reassign block perameter list
513 */
514 struct sc_rab {
515 /*00*/ u_short sca_resved;
516 /*02*/ u_short sca_dllen;
517 /*04*/ u_int sca_dlad[4];
518 /*14*/
519 };
520
521
522 #ifdef CPU_DOUBLE
523
524 # ifdef mips
525 # define ipc_phys(x) (caddr_t)K0_TT0(x)
526 # else
527 # define ipc_phys(x) (caddr_t)((int)(x) & ~0x80000000)
528 # endif
529
530 # ifdef news3800
531 # define splsc spl4
532 # define splscon spl3
533 # endif
534
535 #endif /* CPU_DOUBLE */
536
537 #ifdef CPU_SINGLE
538 # define ipc_phys(x) (caddr_t)(x)
539 # ifdef news3400
540 # define splsc cpu_spl0 /* Lite2 used spl3 */
541 # define splscon spl2 XXX not used
542 extern int cpu_spl0 __P((void));
543 # else
544 # define splsc spl4
545 # define splscon spl3
546 # endif
547 #endif /* CPU_SINGLE */
548
549 #define SCSI_INTEN 1
550 #define SCSI_INTDIS 0
551
552 struct scintsw {
553 /*00*/ int (*sci_inthandler)(); /* pointer to interrupt handler */
554 /*04*/ int sci_ctlr; /* controller number */
555 /*08*/
556 };
557
558 struct sc_data {
559 /*00*/ struct scsi *scd_scaddr; /* pointer to struct scsi */
560 /*04*/ vm_offset_t scd_vaddr; /* pointer to buffer address */
561 /*08*/ int scd_count; /* buffer size */
562 /*0c*/
563 };
564
565 #endif /* !__SCSIREG__ */
566