1 /*
2 * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com>
3 * All rights reserved.
4 *
5 * Partially based on an autochanger driver written by Stefan Grefen
6 * and on an autochanger driver written by the Systems Programming Group
7 * at the University of Utah Computer Science Department.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgements:
19 * This product includes software developed by Jason R. Thorpe
20 * for And Communications, http://www.and.com/
21 * 4. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * 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 * $FreeBSD: src/sys/scsi/scsi_changer.h,v 1.7.10.2 1999/09/05 08:21:40 peter Exp $
37 */
38
39 /*
40 * SCSI changer interface description
41 */
42
43 /*
44 * Partially derived from software written by Stefan Grefen
45 * (grefen@goofy.zdv.uni-mainz.de soon grefen@convex.com)
46 * based on the SCSI System by written Julian Elischer (julian@tfs.com)
47 * for TRW Financial Systems.
48 *
49 * TRW Financial Systems, in accordance with their agreement with Carnegie
50 * Mellon University, makes this software available to CMU to distribute
51 * or use in any manner that they see fit as long as this message is kept with
52 * the software. For this reason TFS also grants any other persons or
53 * organisations permission to use or modify this software.
54 *
55 * TFS supplies this software to be publicly redistributed
56 * on the understanding that TFS is not responsible for the correct
57 * functioning of this software in any circumstances.
58 *
59 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
60 *
61 * $FreeBSD: src/sys/scsi/scsi_changer.h,v 1.7.10.2 1999/09/05 08:21:40 peter Exp $
62 */
63
64 #ifndef _SCSI_SCSI_CHANGER_H
65 #define _SCSI_SCSI_CHANGER_H 1
66
67 /*
68 * SCSI command format
69 */
70
71 /*
72 * Exchange the medium in the source element with the medium
73 * located at the destination element.
74 */
75 struct scsi_exchange_medium {
76 u_int8_t opcode;
77 #define EXCHANGE_MEDIUM 0xa6
78 u_int8_t byte2;
79 u_int8_t tea[2]; /* transport element address */
80 u_int8_t src[2]; /* source address */
81 u_int8_t fdst[2]; /* first destination address */
82 u_int8_t sdst[2]; /* second destination address */
83 u_int8_t flags;
84 #define EXCHANGE_MEDIUM_INV1 0x01
85 #define EXCHANGE_MEDIUM_INV2 0x02
86 u_int8_t control;
87 };
88
89 /*
90 * Cause the medium changer to check all elements for medium and any
91 * other status relevant to the element.
92 */
93 struct scsi_initialize_elememt_status {
94 u_int8_t opcode;
95 #define INITIALIZE_ELEMENT_STATUS 0x07
96 u_int8_t byte2;
97 u_int8_t reserved[3];
98 u_int8_t control;
99 };
100
101 /*
102 * Request the changer to move a unit of media from the source element
103 * to the destination element.
104 */
105 struct scsi_move_medium {
106 u_int8_t opcode;
107 #define MOVE_MEDIUM 0xa5
108 u_int8_t byte2;
109 u_int8_t tea[2]; /* transport element address */
110 u_int8_t src[2]; /* source element address */
111 u_int8_t dst[2]; /* destination element address */
112 u_int8_t reserved[2];
113 u_int8_t flags;
114 #define MOVE_MEDIUM_INVERT 0x01
115 u_int8_t control;
116 };
117
118 /*
119 * Position the specified transport element (picker) in front of
120 * the destination element specified.
121 */
122 struct scsi_position_to_element {
123 u_int8_t opcode;
124 #define POSITION_TO_ELEMENT 0x2b
125 u_int8_t byte2;
126 u_int8_t tea[2]; /* transport element address */
127 u_int8_t dst[2]; /* destination element address */
128 u_int8_t reserved[2];
129 u_int8_t flags;
130 #define POSITION_TO_ELEMENT_INVERT 0x01
131 u_int8_t control;
132 };
133
134 /*
135 * Request that the changer report the status of its internal elements.
136 */
137 struct scsi_read_element_status {
138 u_int8_t opcode;
139 #define READ_ELEMENT_STATUS 0xb8
140 u_int8_t byte2;
141 #define READ_ELEMENT_STATUS_VOLTAG 0x10 /* report volume tag info */
142 /* ...next 4 bits are an element type code... */
143 u_int8_t sea[2]; /* starting element address */
144 u_int8_t count[2]; /* number of elements */
145 u_int8_t reserved0;
146 u_int8_t len[3]; /* length of data buffer */
147 u_int8_t reserved1;
148 u_int8_t control;
149 };
150
151 struct scsi_request_volume_element_address {
152 u_int8_t opcode;
153 #define REQUEST_VOLUME_ELEMENT_ADDRESS 0xb5
154 u_int8_t byte2;
155 #define REQUEST_VOLUME_ELEMENT_ADDRESS_VOLTAG 0x10
156 /* ...next 4 bits are an element type code... */
157 u_int8_t eaddr[2]; /* element address */
158 u_int8_t count[2]; /* number of elements */
159 u_int8_t reserved0;
160 u_int8_t len[3]; /* length of data buffer */
161 u_int8_t reserved1;
162 u_int8_t control;
163 };
164
165 /* XXX scsi_release */
166
167 /*
168 * Data returned by READ ELEMENT STATUS consists of an 8-byte header
169 * followed by one or more read_element_status_pages.
170 */
171 struct read_element_status_header {
172 u_int8_t fear[2]; /* first element address reported */
173 u_int8_t count[2]; /* number of elements available */
174 u_int8_t reserved;
175 u_int8_t nbytes[3]; /* byte count of all pages */
176 };
177
178 struct read_element_status_page_header {
179 u_int8_t type; /* element type code; see type codes below */
180 u_int8_t flags;
181 #define READ_ELEMENT_STATUS_AVOLTAG 0x40
182 #define READ_ELEMENT_STATUS_PVOLTAG 0x80
183 u_int8_t edl[2]; /* element descriptor length */
184 u_int8_t reserved;
185 u_int8_t nbytes[3]; /* byte count of all descriptors */
186 };
187
188 struct read_element_status_descriptor {
189 u_int8_t eaddr[2]; /* element address */
190 u_int8_t flags1;
191
192 #define READ_ELEMENT_STATUS_FULL 0x01
193 #define READ_ELEMENT_STATUS_IMPEXP 0x02
194 #define READ_ELEMENT_STATUS_EXCEPT 0x04
195 #define READ_ELEMENT_STATUS_ACCESS 0x08
196 #define READ_ELEMENT_STATUS_EXENAB 0x10
197 #define READ_ELEMENT_STATUS_INENAB 0x20
198
199 #define READ_ELEMENT_STATUS_MT_MASK1 0x05
200 #define READ_ELEMENT_STATUS_ST_MASK1 0x0c
201 #define READ_ELEMENT_STATUS_IE_MASK1 0x3f
202 #define READ_ELEMENT_STATUS_DT_MASK1 0x0c
203
204 u_int8_t reserved0;
205 u_int8_t sense_code;
206 u_int8_t sense_qual;
207
208 /*
209 * dt_scsi_flags and dt_scsi_addr are valid only on data transport
210 * elements. These bytes are undefined for all other element types.
211 */
212 u_int8_t dt_scsi_flags;
213
214 #define READ_ELEMENT_STATUS_DT_LUNMASK 0x07
215 #define READ_ELEMENT_STATUS_DT_LUVALID 0x10
216 #define READ_ELEMENT_STATUS_DT_IDVALID 0x20
217 #define READ_ELEMENT_STATUS_DT_NOTBUS 0x80
218
219 u_int8_t dt_scsi_addr;
220
221 u_int8_t reserved1;
222
223 u_int8_t flags2;
224 #define READ_ELEMENT_STATUS_INVERT 0x40
225 #define READ_ELEMENT_STATUS_SVALID 0x80
226 u_int8_t ssea[2]; /* source storage element address */
227
228 /*
229 * bytes 12-47: Primary volume tag information.
230 * (field omitted if PVOLTAG = 0)
231 *
232 * bytes 48-83: Alternate volume tag information.
233 * (field omitted if AVOLTAG = 0)
234 *
235 * bytes 84-87: Reserved (moved up if either of the above fields
236 * are omitted)
237 *
238 * bytes 88-end: Vendor-specific: (moved up if either of the
239 * above fields are missing)
240 */
241 };
242
243 /* XXX add data returned by REQUEST VOLUME ELEMENT ADDRESS */
244
245 /* Element type codes */
246 #define ELEMENT_TYPE_MASK 0x0f /* Note: these aren't bits */
247 #define ELEMENT_TYPE_ALL 0x00
248 #define ELEMENT_TYPE_MT 0x01
249 #define ELEMENT_TYPE_ST 0x02
250 #define ELEMENT_TYPE_IE 0x03
251 #define ELEMENT_TYPE_DT 0x04
252
253 /*
254 * XXX The following definitions should be common to all SCSI device types.
255 */
256 #define PGCODE_MASK 0x3f /* valid page number bits in pg_code */
257 #define PGCODE_PS 0x80 /* indicates page is savable */
258
259 /*
260 * Device capabilities page.
261 *
262 * This page defines characteristics of the elemenet types in the
263 * medium changer device.
264 *
265 * Note in the definitions below, the following abbreviations are
266 * used:
267 * MT Medium transport element (picker)
268 * ST Storage transport element (slot)
269 * IE Import/export element (portal)
270 * DT Data tranfer element (tape/disk drive)
271 */
272 struct page_device_capabilities {
273 u_int8_t pg_code; /* page code (0x1f) */
274 u_int8_t pg_length; /* page length (0x12) */
275
276 /*
277 * The STOR_xx bits indicate that an element of a given
278 * type may provide independent storage for a unit of
279 * media. The top four bits of this value are reserved.
280 */
281 u_int8_t stor;
282 #define STOR_MT 0x01
283 #define STOR_ST 0x02
284 #define STOR_IE 0x04
285 #define STOR_DT 0x08
286
287 u_int8_t reserved0;
288
289 /*
290 * The MOVE_TO_yy bits indicate the changer supports
291 * moving a unit of medium from an element of a given type to an
292 * element of type yy. This is used to determine if a given
293 * MOVE MEDIUM command is legal. The top four bits of each
294 * of these values are reserved.
295 */
296 u_int8_t move_from_mt;
297 u_int8_t move_from_st;
298 u_int8_t move_from_ie;
299 u_int8_t move_from_dt;
300 #define MOVE_TO_MT 0x01
301 #define MOVE_TO_ST 0x02
302 #define MOVE_TO_IE 0x04
303 #define MOVE_TO_DT 0x08
304
305 u_int8_t reserved1[2];
306
307 /*
308 * Similar to above, but for EXCHANGE MEDIUM.
309 */
310 u_int8_t exchange_with_mt;
311 u_int8_t exchange_with_st;
312 u_int8_t exchange_with_ie;
313 u_int8_t exchange_with_dt;
314 #define EXCHANGE_WITH_MT 0x01
315 #define EXCHANGE_WITH_ST 0x02
316 #define EXCHANGE_WITH_IE 0x04
317 #define EXCHANGE_WITH_DT 0x08
318 };
319
320 /*
321 * Medium changer elemement address assignment page.
322 *
323 * Some of these fields can be a little confusing, so an explanation
324 * is in order.
325 *
326 * Each component within a a medium changer apparatus is called an
327 * "element".
328 *
329 * The "medium transport element address" is the address of the first
330 * picker (robotic arm). "Number of medium transport elements" tells
331 * us how many pickers exist in the changer.
332 *
333 * The "first storage element address" is the address of the first
334 * slot in the tape or disk magazine. "Number of storage elements" tells
335 * us how many slots exist in the changer.
336 *
337 * The "first import/export element address" is the address of the first
338 * medium portal accessible both by the medium changer and an outside
339 * human operator. This is where the changer might deposit tapes destined
340 * for some vault. The "number of import/export elements" tells us
341 * not many of these portals exist in the changer. NOTE: this number may
342 * be 0.
343 *
344 * The "first data transfer element address" is the address of the first
345 * tape or disk drive in the changer. "Number of data transfer elements"
346 * tells us how many drives exist in the changer.
347 */
348 struct page_element_address_assignment {
349 u_int8_t pg_code; /* page code (0x1d) */
350 u_int8_t pg_length; /* page length (0x12) */
351
352 /* Medium transport element address */
353 u_int8_t mtea[2];
354
355 /* Number of medium transport elements */
356 u_int8_t nmte[2];
357
358 /* First storage element address */
359 u_int8_t fsea[2];
360
361 /* Number of storage elements */
362 u_int8_t nse[2];
363
364 /* First import/export element address */
365 u_int8_t fieea[2];
366
367 /* Number of import/export elements */
368 u_int8_t niee[2];
369
370 /* First data transfer element address */
371 u_int8_t fdtea[2];
372
373 /* Number of data trafer elements */
374 u_int8_t ndte[2];
375
376 u_int8_t reserved[2];
377 };
378
379 /*
380 * Transport geometry parameters page.
381 *
382 * Defines whether each medium transport element is a member of a set of
383 * elements that share a common robotics subsystem and whether the element
384 * is capable of media rotation. One transport geometry descriptor is
385 * transferred for each medium transport element, beginning with the first
386 * medium transport element (other than the default transport element address
387 * of 0).
388 */
389 struct page_transport_geometry_parameters {
390 u_int8_t pg_code; /* page code (0x1e) */
391 u_int8_t pg_length; /* page length; variable */
392
393 /* Transport geometry descriptor(s) are here. */
394
395 u_int8_t misc;
396 #define CAN_ROTATE 0x01
397
398 /* Member number in transport element set. */
399 u_int8_t member;
400 };
401
402 #endif /* _SCSI_SCSI_CHANGER_H */
Cache object: 84a55225e61b1941a58d29a1ba6ed34e
|