xref: /netbsd/sys/dev/scsipi/scsi_tape.h (revision bf9ec67e)
1 /*	$NetBSD: scsi_tape.h,v 1.20 2001/04/25 17:53:39 bouyer Exp $	*/
2 
3 /*-
4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Charles M. Hannum.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Originally written by Julian Elischer (julian@tfs.com)
41  * for TRW Financial Systems.
42  *
43  * TRW Financial Systems, in accordance with their agreement with Carnegie
44  * Mellon University, makes this software available to CMU to distribute
45  * or use in any manner that they see fit as long as this message is kept with
46  * the software. For this reason TFS also grants any other persons or
47  * organisations permission to use or modify this software.
48  *
49  * TFS supplies this software to be publicly redistributed
50  * on the understanding that TFS is not responsible for the correct
51  * functioning of this software in any circumstances.
52  *
53  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
54  */
55 
56 /*
57  * SCSI tape interface description
58  */
59 
60 /*
61  * SCSI command formats
62  */
63 
64 #define	READ			0x08
65 #define WRITE			0x0a
66 struct scsi_rw_tape {
67 	u_int8_t opcode;
68 	u_int8_t byte2;
69 #define	SRW_FIXED		0x01
70 	u_int8_t len[3];
71 	u_int8_t control;
72 };
73 
74 #define	SPACE			0x11
75 struct scsi_space {
76 	u_int8_t opcode;
77 	u_int8_t byte2;
78 #define	SS_CODE			0x03
79 #define SP_BLKS			0x00
80 #define SP_FILEMARKS		0x01
81 #define SP_SEQ_FILEMARKS	0x02
82 #define	SP_EOM			0x03
83 	u_int8_t number[3];
84 	u_int8_t control;
85 };
86 
87 #define	WRITE_FILEMARKS		0x10
88 struct scsi_write_filemarks {
89 	u_int8_t opcode;
90 	u_int8_t byte2;
91 	u_int8_t number[3];
92 	u_int8_t control;
93 };
94 
95 #define REWIND			0x01
96 struct scsi_rewind {
97 	u_int8_t opcode;
98 	u_int8_t byte2;
99 #define	SR_IMMED		0x01
100 	u_int8_t unused[3];
101 	u_int8_t control;
102 };
103 
104 #define LOAD			0x1b
105 struct scsi_load {
106 	u_int8_t opcode;
107 	u_int8_t byte2;
108 #define	SL_IMMED		0x01
109 	u_int8_t unused[2];
110 	u_int8_t how;
111 #define LD_UNLOAD		0x00
112 #define LD_LOAD			0x01
113 #define LD_RETENSION		0x02
114 	u_int8_t control;
115 };
116 
117 #define	ERASE			0x19
118 struct scsi_erase {
119 	u_int8_t opcode;
120 	u_int8_t byte2;
121 #define	SE_LONG			0x01
122 #define	SE_IMMED		0x02
123 	u_int8_t unused[3];
124 	u_int8_t control;
125 };
126 
127 #define	READ_BLOCK_LIMITS	0x05
128 struct scsi_block_limits {
129 	u_int8_t opcode;
130 	u_int8_t byte2;
131 	u_int8_t unused[3];
132 	u_int8_t control;
133 };
134 
135 struct scsi_block_limits_data {
136 	u_int8_t reserved;
137 	u_int8_t max_length[3];		/* Most significant */
138 	u_int8_t min_length[2];		/* Most significant */
139 };
140 
141 /* See SCSI-II spec 9.3.3.1 */
142 struct scsi_tape_dev_conf_page {
143 	u_int8_t pagecode;	/* 0x10 */
144 	u_int8_t pagelength;	/* 0x0e */
145 	u_int8_t byte2;
146 #define	SMT_CAP			0x40	/* change active partition */
147 #define	SMT_CAF			0x20	/* change active format */
148 #define	SMT_AFMASK		0x1f	/* active format mask */
149 	u_int8_t active_partition;
150 	u_int8_t wb_full_ratio;
151 	u_int8_t rb_empty_ratio;
152 	u_int8_t wrdelay_time[2];
153 	u_int8_t byte8;
154 #define	SMT_DBR			0x80	/* data buffer recovery */
155 #define	SMT_BIS			0x40	/* block identifiers supported */
156 #define	SMT_RSMK		0x20	/* report setmarks */
157 #define	SMT_AVC			0x10	/* automatic velocity control */
158 #define SMT_SOCF_MASK		0xc0	/* stop on consecutive formats */
159 #define	SMT_RBO			0x20	/* recover buffer order */
160 #define	SMT_REW			0x10	/* report early warning */
161 	u_int8_t gap_size;
162 	u_int8_t byte10;
163 #define	SMT_EODDEFINED		0xe0	/* EOD defined */
164 #define	SMT_EEG			0x10	/* enable EOD generation */
165 #define	SMT_SEW			0x80	/* synchronize at early warning */
166 	u_int8_t ew_bufsize[3];
167 	u_int8_t sel_comp_alg;
168 #define	SMT_COMP_NONE		0x00
169 #define	SMT_COMP_DEFAULT	0x01
170 	u_int8_t reserved;
171 };
172 
173 /* from SCSI-3: SSC-Rev10 (6/97) */
174 struct scsi_tape_dev_compression_page {
175 	u_int8_t pagecode;	/* 0x0f */
176 	u_int8_t pagelength;	/* 0x0e */
177 	u_int8_t dce_dcc;
178 #define	DCP_DCE			0x80	/* enable compression */
179 #define	DCP_DCC			0x40	/* compression capable */
180 	u_int8_t dde_red;
181 #define	DCP_DDE			0x80	/* enable decompression */
182 /* There's a lot of gup about bits 5,6 for reporting exceptions */
183 /* in transitions between compressed and uncompressed data- but */
184 /* mostly we want the default (0), which is to report a MEDIUM	*/
185 /* ERROR when a read transitions into data that can't be de-	*/
186 /* compressed */
187 	u_int8_t comp_alg[4];		/* compression algorithm */
188 	u_int8_t decomp_alg[4];		/* de-"" */
189 	u_int8_t reserved[4];
190 };
191 
192 /* defines for the device specific byte in the mode select/sense header */
193 #define	SMH_DSP_SPEED		0x0F
194 #define	SMH_DSP_BUFF_MODE	0x70
195 #define	SMH_DSP_BUFF_MODE_OFF	0x00
196 #define	SMH_DSP_BUFF_MODE_ON	0x10
197 #define	SMH_DSP_BUFF_MODE_MLTI	0x20
198 #define	SMH_DSP_WRITE_PROT	0x80
199 
200 /* A special for the CIPHER ST150S(old drive) */
201 struct block_desc_cipher {
202 	u_int8_t density;
203 	u_int8_t nblocks[3];
204 	u_int8_t reserved;
205 	u_int8_t blklen[3];
206 	u_int8_t other;
207 #define ST150_SEC		0x01	/* soft error count */
208 #define	SR150_AUI		0x02	/* autoload inhibit */
209 };
210 
211 
212 #define	READ_POSITION	0x34
213 struct scsi_tape_read_position {
214 	u_int8_t opcode;		/* READ_POSITION */
215 	u_int8_t byte1;			/* set LSB to read hardware block pos */
216 	u_int8_t reserved[8];
217 };
218 
219 #define	LOCATE		0x2B
220 struct scsi_tape_locate {
221 	u_int8_t opcode;
222 	u_int8_t byte2;
223 	u_int8_t reserved1;
224 	u_int8_t blkaddr[4];
225 	u_int8_t reserved2;
226 	u_int8_t partition;
227 	u_int8_t control;
228 };
229 
230 #define	HALFINCH_800	0x01
231 #define	HALFINCH_1600	0x02
232 #define	HALFINCH_6250	0x03
233 #define	QIC_11		0x04	/* from Archive 150S Theory of Op. XXX	*/
234 #define QIC_24		0x05	/* may be bad, works for CIPHER ST150S XXX */
235 #define QIC_120		0x0f
236 #define QIC_150		0x10
237 #define QIC_320		0x11
238 #define QIC_525		0x11
239 #define QIC_1320	0x12
240 #define DDS		0x13
241 #define DAT_1		0x13
242 #define QIC_3095	0x45
243 #define QIC_3220	0x47
244