xref: /original-bsd/sys/dev/scsi/disktape.h (revision da6ea800)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratories.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)disktape.h	8.1 (Berkeley) 06/10/93
17  *
18  * from: $Header: disktape.h,v 1.4 93/04/30 00:02:16 torek Exp $ (LBL)
19  */
20 
21 /*
22  * Commands common to disk and tape devices, but not other SCSI devices.
23  */
24 #define	CMD_MODE_SELECT6	0x15	/* mode select (6 byte cdb) */
25 #define	CMD_MODE_SENSE6		0x1a	/* mode sense (6 byte cdb) */
26 
27 #define	CMD_MODE_SELECT10	0x55	/* mode select (10 byte cdb) */
28 #define	CMD_MODE_SENSE10	0x5a	/* mode sense (10 byte cdb) */
29 
30 /*
31  * Structure of MODE SELECT commands (i.e., the cdb; 6 & 10 byte flavors).
32  * The only difference is that the 10-byte version can give more parameter
33  * bytes.
34  */
35 struct scsi_cdb_modeselect6 {
36 	u_char	cdb_cmd,	/* 0x15 */
37 		cdb_lun_flags,	/* LUN + flags */
38 		cdb_xxx[2],	/* reserved */
39 		cdb_len,	/* parameter list length */
40 		cdb_ctrl;	/* control byte */
41 };
42 struct scsi_cdb_modeselect10 {
43 	u_char	cdb_cmd,	/* 0x55 */
44 		cdb_lun_flags,	/* LUN + flags */
45 		cdb_xxx[5],	/* reserved */
46 		cdb_lenh,	/* parameter list length (MSB) */
47 		cdb_lenl,	/* parameter list length (LSB) */
48 		cdb_ctrl;	/* control byte */
49 };
50 /* flags in SCSI_MODESELECT commands */
51 #define	SCSI_MSEL_SCSI1_DATA	0x00	/* SCSI-1 data format */
52 #define	SCSI_MSEL_SCSI2_DATA	0x10	/* SCSI-2 data format */
53 #define	SCSI_MSEL_DONTSAVE	0x00	/* don't save pages */
54 #define	SCSI_MSEL_SAVEPAGES	0x01	/* save mode pages */
55 
56 /*
57  * Structure of MODE SENSE command (i.e., the cdb; 6 & 10 byte flavors).
58  * Again, the 10-byte version merely allows more parameter bytes.
59  * Note that these lengths include the MODE SENSE headers, while those
60  * for individual mode pages do not.  (Consistency?  What's that?)
61  */
62 struct scsi_cdb_modesense6 {
63 	u_char	cdb_cmd,	/* 0x1a */
64 		cdb_lun_flags,	/* logical unit number + flags */
65 		cdb_pcc,	/* page control & code */
66 		cdb_xxx,	/* reserved */
67 		cdb_len,	/* allocation length */
68 		cdb_ctrl;	/* control byte */
69 };
70 struct scsi_cdb_modesense10 {
71 	u_char	cdb_cmd,	/* 0x5a */
72 		cdb_lun_flags,	/* logical unit number + flags */
73 		cdb_pcc,	/* page control & code */
74 		cdb_xxx[4],	/* reserved */
75 		cdb_lenh,	/* allocation length (MSB) */
76 		cdb_lenl,	/* allocation length (MSB) */
77 		cdb_ctrl;	/* control byte */
78 };
79 /* flags in SCSI_MODESENSE commands */
80 #define	SCSI_MSENSE_DBD		0x08	/* device returns db descriptors */
81 
82 /* page controls */
83 #define	SCSI_MSENSE_PCTL_CUR	0x00	/* return current parameters */
84 #define	SCSI_MSENSE_PCTL_VAR	0x40	/* return variable parameters */
85 #define	SCSI_MSENSE_PCTL_DFLT	0x80	/* return default parameters */
86 #define	SCSI_MSENSE_PCTL_SAVED	0xc0	/* return saved parameters */
87 
88 /*
89  * Both MODE_SENSE and MODE_SELECT use a Mode Parameter Header,
90  * followed by an array of Block Descriptors, followed by an array
91  * of Pages.  We define structures for the Block Descriptor and Page
92  * header first, then the two (6 and 10 byte) Mode Parameter headers
93  * (not including the Block Descriptor(s) and any mode pages themselves).
94  */
95 struct scsi_ms_bd {		/* mode sense/select block descriptor */
96 	u_char	bd_dc,		/* density code (tapes only) */
97 		bd_nbh,		/* number of blocks (MSB) */
98 		bd_nbm,		/* number of blocks */
99 		bd_nbl,		/* number of blocks (LSB) */
100 		bd_xxx,		/* reserved */
101 		bd_blh,		/* block length (MSB) */
102 		bd_blm,		/* block length */
103 		bd_bll;		/* block length (LSB) */
104 };
105 struct scsi_ms_page_hdr {	/* mode sense/select page header */
106 	u_char	mp_psc,		/* saveable flag + code */
107 		mp_len;		/* parameter length (excludes this header) */
108 		/* followed by parameters */
109 };
110 #define	SCSI_MS_MP_SAVEABLE	0x80	/* page can be saved */
111 /*				0x40	   reserved */
112 #define	SCSI_MS_PC_MASK		0x3f	/* page code mask */
113 
114 /*
115  * Structure of returned mode sense6 / mode select6 (hence "ms6") data.
116  */
117 struct scsi_ms6 {
118 	u_char	ms_len,		/* total sense data length */
119 		ms_mt,		/* medium type (disks only?) */
120 		ms_dsp,		/* device specific parameter */
121 		ms_bdl;		/* block descriptor length (bytes) */
122 	/* followed by block descriptors, if any */
123 	/* followed by pages, if any */
124 };
125 /*
126  * Same, but for ms10.
127  */
128 struct scsi_ms10 {
129 	u_char	ms_lenh,	/* total sense length (MSB) */
130 		ms_lenl,	/* total sense length (LSB) */
131 		ms_mt,		/* medium type (disks only?) */
132 		ms_dsp,		/* device specific parameter */
133 		ms_xxx[2],	/* reserved */
134 		ms_bdlh,	/* block descriptor length (bytes) (MSB) */
135 		ms_bdll;	/* block descriptor length (bytes) (LSB) */
136 	/* followed by block descriptors, if any */
137 	/* followed by pages, if any */
138 };
139 
140 /* values for the Medium Type field - disks */
141 #define	SCSI_MS_MT_DEFAULT	0x00	/* whatever is current */
142 #define	SCSI_MS_MT_SS		0x01	/* single sided, unspecified medium */
143 #define	SCSI_MS_MT_DS		0x02	/* double sided, unspecified medium */
144 #define	SCSI_MS_MT_8SSSD	0x05	/* 8" floppy, SSSD (X3.73-1980) */
145 #define	SCSI_MS_MT_8DSSD	0x06	/* 8" floppy, DSSD (X3B8-140) */
146 #define	SCSI_MS_MT_8SSDD	0x09	/* 8" floppy, SSDD (X3B8/78-139) */
147 #define	SCSI_MS_MT_8DSDD	0x0a	/* 8" floppy, DSDD (X3.121-1984) */
148 #define	SCSI_MS_MT_5SSSD	0x0d	/* 5.25" floppy, SSSD (X3.82-1980) */
149 #define	SCSI_MS_MT_5DSDD	0x12	/* 5.25" floppy, DSDD (X3.125-1984) */
150 #define	SCSI_MS_MT_5DSDD96	0x16	/* 5.25", DSDD, 96tpi (X3.126-198X) */
151 #define	SCSI_MS_MT_5DSQD	0x1a	/* 5.25", DSQD, 96tpi (DIS 8630) */
152 #define	SCSI_MS_MT_3DS		0x1e	/* 3.5", double sided (X3.137-198X) */
153 
154 /* values for the Medium Type field - tapes */
155 #define	SCSI_MS_MT_QIC_12T	0x40	/* 0.25", 12 tracks */
156 #define	SCSI_MS_MT_QIC_24T	0x44	/* 0.25", 24 tracks */
157 
158 /* values for the Device Specific Parameter field */
159 #define	SCSI_MS_DSP_WP		0x80	/* write protect (both disk & tape) */
160 
161 	/* if disk */
162 #define	SCSI_MS_DSP_DPO_FUA	0x10	/* cache flags DPO, FUA supported */
163 
164 	/* if tape */
165 #define	SCSI_MS_DSP_UNBUFFERED	0x00	/* unbuffered writes */
166 #define	SCSI_MS_DSP_BUFFERED	0x10	/* buffered writes */
167 #define	SCSI_MS_DSP_BUF2	0x20	/* buffered, for shared tapes */
168 /*				0x30..0x70 reserved */
169 #define	SCSI_MS_DSP_SPEED_DFLT	0x00	/* use device default speed */
170 #define	SCSI_MS_DSP_SPEED_MASK	0x0f	/* mask for non-default speeds */
171 
172 /* values for the Density Code field - tapes */
173 #define	SCSI_MS_DC_DEFAULT	0	/* use device default density */
174 #define	SCSI_MS_DC_9T_800BPI	1	/* 9 track, 800 bpi */
175 #define	SCSI_MS_DC_9T_1600BPI	2	/* 9 track, 1600 bpi */
176 #define	SCSI_MS_DC_9T_6250BPI	3	/* 9 track, 6250 bpi */
177 #define	SCSI_MS_DC_QIC_XX1	4	/* QIC-11? 4 or 9 track, 8000 bpi */
178 #define	SCSI_MS_DC_QIC_XX2	5	/* QIC-11? 4 or 9 track, 8000 bpi */
179 #define	SCSI_MS_DC_9T_3200BPI	6	/* 9 track, 3200 bpi */
180 #define	SCSI_MS_DC_QIC_XX3	7	/* QIC, 4 track, 6400 bpi */
181 #define	SCSI_MS_DC_CS_XX4	8	/* cassette 4 track, 8000 bpi */
182 #define	SCSI_MS_DC_HIC_XX5	9	/* half inch cartridge, 18 track */
183 #define	SCSI_MS_DC_HIC_XX6	10	/* HIC, 22 track, 6667 bpi */
184 #define	SCSI_MS_DC_QIC_XX7	11	/* QIC, 4 track, 1600 bpi */
185 #define	SCSI_MS_DC_HIC_XX8	12	/* HIC, 24 track, 12690 bpi */
186 #define	SCSI_MS_DC_HIC_XX9	13	/* HIC, 24 track, 25380 bpi */
187 
188 /*
189  * Common page codes.
190  */
191 /*				0x01	   device specific */
192 #define	SCSI_MS_PC_DR		0x02	/* disconnect/reconnect control */
193 /*				0x03..0x08 device specific */
194 #define	SCSI_MS_PC_PDEV		0x09	/* peripheral device page */
195 #define	SCSI_MS_PC_CTLMODE	0x0a	/* control mode page */
196 /*				0x0b..0x1f device specific */
197 /*				0x20..0x3e vendor specific */
198 #define	SCSI_MS_PC_ALL		0x3f	/* all pages */
199 
200 /*
201  * Structure of a Disconnect/Reconnect Control mode page.
202  */
203 struct scsi_page_dr {
204 	u_char	dr_full,	/* buffer full ratio */
205 		dr_empty,	/* buffer empty ratio */
206 		dr_inacth,	/* bus inactivity timeout (MSB) */
207 		dr_inactl,	/* bus inactivity timeout (LSB) */
208 		dr_disconh,	/* disconnect time limit (MSB) */
209 		dr_disconl,	/* disconnect time limit (LSB) */
210 		dr_conh,	/* connect time limit (MSB) */
211 		dr_conl,	/* connect time limit (LSB) */
212 		dr_bursth,	/* maximum burst size (MSB) */
213 		dr_burstl,	/* maximum burst size (LSB) */
214 		dr_dtdc,	/* Data Transfer Disconnect Control (below) */
215 		dr_xxx[3];	/* reserved */
216 };
217 /* Data Transfer Disconnect Control */
218 #define	SCSI_DR_DTDC_MASK	0x03	/* mask for valid bits */
219 #define	SCSI_DR_DTDC_NONE	0x00	/* no control */
220 #define	SCSI_DR_DTDC_NOTDATA	0x01	/* never during data transfer */
221 #define	SCSI_DR_DTDC_RSVD	0x02	/* reserved */
222 #define	SCSI_DR_DTDC_NOTD2	0x03	/* never during/after data transfer */
223 
224 /*
225  * Structure of a PREVENT/ALLOW MEDIUM REMOVAL command.
226  */
227 struct scsi_cdb_pamr {
228 	u_char	cdb_cmd,	/* 0x1e */
229 		cdb_lun_xxx,	/* logical unit number + reserved */
230 		cdb_xxx1,	/* reserved */
231 		cdb_xxx2,	/* reserved */
232 		cdb_prevent,	/* 1=prevent, 0=allow */
233 		cdb_ctrl;
234 };
235