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