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