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