1 /* 2 * Copyright (c) 1998,1999,2000 3 * Traakan, Inc., Los Altos, CA 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice unmodified, this list of conditions, and the following 11 * disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 /* 30 * Project: NDMJOB 31 * Ident: $Id: $ 32 * 33 * Description: 34 * 35 */ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* 42 * 17.1 Medium-changer device model 43 * 44 * Medium changer devices mechanize the movement of media to and from 45 * primary devices (such as disk or tape drives) and other locations 46 * within the range of the medium changer. The medium changer command set 47 * is based on a physical model of this functionality. 48 * 49 * This command set supports varied physical implementations of the medium 50 * changer function. Most of these variations are hidden from the 51 * initiator by the high level of function provided by the MOVE MEDIUM and 52 * EXCHANGE MEDIUM commands and by the generalized nature of the element 53 * addressing scheme. However, initiators may need to be aware of the 54 * capabilities of the particular medium changer device. These 55 * characteristics and capabilities are conveyed via MODE SENSE pages. 56 * 57 * 17.1.1 Medium-changer elements 58 * 59 * The medium-changer command set uses as its address space the set of 60 * physical locations and mechanisms within the scope of a medium changer 61 * device. The term element is used throughout this clause to refer to one 62 * member of the medium changer address space. Each element is a discrete 63 * physical entity that may hold zero or one physical unit of media - one 64 * disk cartridge, one spool of tape, etc. Element addresses do not extend 65 * across multiple physical units of media. Likewise, element addresses 66 * are independent of any logical partitioning that the primary device may 67 * support within a physical unit of media. 68 * 69 * A medium changer is viewed as a set of addressable elements, each of 70 * which may contain a unit of media or be used to move a unit of media. 71 * Each medium changer element has a unique 16 bit element address. Each 72 * element is an instance of one of four classes or element types. 73 * 74 * a) MEDIUM TRANSPORT ELEMENT 75 * b) STORAGE ELEMENT 76 * c) IMPORT EXPORT ELEMENT 77 * d) DATA TRANSFER ELEMENT 78 * 79 * Units of media (cartridges, cassettes, caddies, etc.) are referred to 80 * only indirectly by this device model. Units of media can be moved to 81 * or from any of the elements of the medium changer device. The presence 82 * of media at the various elements in a medium changer can be sensed. In 83 * order to ensure exclusive access to a unit of media, the element where 84 * the unit of media is located (the element address) must be reserved. 85 * 86 * Elements of the medium transport, import export and (rarely) data 87 * transport types may not provide independent storage for medium. The 88 * capabilities of a particular medium changer in this respect can be 89 * sensed via the device capabilities page of the mode sense data. The 90 * following hypothetical medium changer implementation illustrates one 91 * case of an element not providing independent storage for medium. 92 * Consider a medium changer which has a carousel style storage for 93 * medium. The import export function could be provided by a port which 94 * allows operator access to one of the storage elements. In such a 95 * device, the MOVE ELEMENT command from storage element to import export 96 * element would rotate the carousel to align the addressed storage 97 * element to the import export position. In this case the import export 98 * element does not provide independent storage but rather access to one 99 * of the storage elements. 100 * 101 * 17.1.1.1 Medium transport elements 102 * 103 * Medium transport elements address the functions of the medium changer 104 * device that perform the movement of units of media. Where a medium 105 * transport element can serve (even temporarily) as a storage location 106 * for medium, the location of each unit of media must have a separate 107 * element address. 108 * 109 * In larger medium changer devices, the medium movement functions may be 110 * performed by multiple independent robotics subsystems. Each of these 111 * may have a number of medium transport element addresses. The element 112 * addresses within each subsystem shall be contiguous. Any of the element 113 * addresses within a subsystem may be used interchangeably in the medium 114 * transport element address field of MOVE MEDIUM and EXCHANGE MEDIUM 115 * commands. An initiator may determine the capabilities of the medium 116 * movement facilities of a medium changer device via the transport 117 * geometry MODE SENSE page, see 17.3.3.3. 118 * 119 * Element address zero is reserved for use in the medium transport 120 * element address field of MOVE MEDIUM and EXCHANGE MEDIUM commands to 121 * direct the medium changer to use a default or medium changer selected 122 * medium transport element. 123 * 124 * In some implementations, medium transport elements may be source and/or 125 * destination addresses in MOVE MEDIUM and EXCHANGE MEDIUM commands. 126 * They may or may not provide independent storage of a unit of media. 127 * See the device capabilities MODE SENSE page, see 17.3.3. 128 * 129 * 17.1.1.2 Storage elements 130 * 131 * Storage elements are locations of units of media while not in some 132 * other element type. Medium in storage elements is available for access 133 * by medium transport elements. 134 * 135 * Storage elements may be source and/or destination addresses in MOVE 136 * MEDIUM and EXCHANGE MEDIUM commands. 137 * 138 * 17.1.1.3 Import export elements 139 * 140 * Import export elements are locations of units of media which are being 141 * inserted into or withdrawn from the medium changer device. Medium in 142 * these elements is accessible by both medium transport elements, by the 143 * operator, or by another independent medium changer device. 144 * 145 * Import export elements may be source and/or destination addresses in 146 * MOVE MEDIUM and EXCHANGE MEDIUM commands. They may or may not provide 147 * independent storage of a unit of media, see the device capabilities 148 * MODE SENSE page, see 17.3.3. 149 * 150 * Particular import export elements may be capable of either import 151 * actions, export actions, both or neither (if an element is not 152 * present). 153 * 154 * 17.1.1.4 Data transfer element 155 * 156 * Data transfer elements are locations of the primary devices which are 157 * capable of reading or writing the medium. Data transfer elements may 158 * also be viewed as medium changer element addresses of units of media 159 * loaded in or available for loading in or removal from primary devices 160 * such as disk or tape drives. Note that the medium changer function 161 * specified in this clause does not control the primary device. That is 162 * the responsibility of the system. 163 * 164 * Data transfer elements may be source and/or destination addresses in 165 * MOVE MEDIUM and EXCHANGE MEDIUM commands. They may or may not provide 166 * independent storage of a unit of media, see the device capabilities 167 * MODE SENSE page, see 17.3.3. 168 */ 169 170 /* 171 * Table 333 - Element type code 172 * +=============-===================================================+ 173 * | Code | Description | 174 * |-------------+---------------------------------------------------| 175 * | 0h | All element types reported, (valid in CDB only) | 176 * | 1h | Medium transport element | 177 * | 2h | Storage element | 178 * | 3h | Import export element | 179 * | 4h | Data transfer element | 180 * | 5h - Fh | Reserved | 181 * +=================================================================+ 182 */ 183 184 #define SMC_ELEM_TYPE_ALL 0 185 #define SMC_ELEM_TYPE_MTE 1 186 #define SMC_ELEM_TYPE_SE 2 187 #define SMC_ELEM_TYPE_IEE 3 188 #define SMC_ELEM_TYPE_DTE 4 189 190 191 192 /* 193 * 17.1.5 Volume tags 194 * 195 * The read element status descriptor format for all element types 196 * includes two sets of fields that contain volume tag information. These 197 * optional fields are used to report media identification information 198 * that the medium changer has acquired either by reading an external 199 * label (e.g. bar code labels), by a SEND VOLUME TAG command or by other 200 * means which may be vendor unique. The same volume tag information shall 201 * be available to all initiators whether assigned by that initiator, by 202 * some other initiator or by the media changer itself. 203 * 204 * Volume tag information provides a means to confirm the identity of a 205 * unit of media that resides in a medium changer element. This command 206 * set does not define any direct addressing of units of media based on 207 * these fields. However, commands are defined that provide translation 208 * between volume tag information and the element address where that unit 209 * of media currently resides. 210 * 211 * The medium changer command set definition does not impose the 212 * requirement that volume tag information be unique over the units of 213 * media within the scope of the changer device. 214 * 215 * The following commands support the optional volume tag functionality: 216 * a) SEND VOLUME TAG - either as a translation request or to associate 217 * a volume tag with the unit of media currently residing at an 218 * element address. 219 * b) REQUEST VOLUME ELEMENT ADDRESS - return the element address 220 * currently associated with the volume tag information transferred 221 * with the last send volume tag command. 222 * c) READ ELEMENT STATUS - optionally reports volume tag information 223 * for all element types. 224 * d) MOVE MEDIUM and EXCHANGE MEDIUM commands - if volume tags are 225 * implemented, these commands must retain the association between 226 * volume tag information and units of media as they are moved from 227 * element to element. 228 * 229 * 17.1.5.1 Volume tag format 230 * 231 * Volume tag information consists of a volume identifier field of 32 232 * bytes plus a volume sequence number field of 2 bytes. The volume 233 * identifier shall consist of a left justified sequence of ASCII 234 * characters. Unused positions shall be blank (20h) filled. In order for 235 * the SEND VOLUME TAG translate with template to work the characters '*' 236 * and'?' (2Ah and 3Fh) must not appear in volume identification data and 237 * there must be no blanks (20h) within the significant part of the volume 238 * identifier. If volume tag information for a particular element is 239 * undefined, the volume identifier field shall be zero. 240 * 241 * The volume sequence number is a 2 byte integer field. If the volume 242 * sequence number is not used this field shall be zero. The volume tag 243 * contents are independent of the volume identification information 244 * recorded on the media. 245 * 246 * NOTE 199 For compatibility with the volume identifier defined by volume 247 * and file structure standards, it is recommended that the characters in the 248 * significant non-blank portion of the volume identifier field be restricted 249 * to the set: '0'..'9', 'A'..'Z', and '_' (30h .. 39h, 41h .. 5Ah, 5Fh). 250 * Specific systems may have differing requirements that may take precedence 251 * over this recommendation. 252 * 253 * Table 326 defines the fields within the 36 byte primary and alternate 254 * volume tag information fields found in READ ELEMENT STATUS descriptors 255 * and in the data format for the SEND VOLUME TAG command. 256 * 257 * Table 326 - Volume tag information format 258 * +=====-=======-=======-=======-========-========-========-=======-========+ 259 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 260 * |Byte | | | | | | | | | 261 * |=====+===================================================================| 262 * | 0 | | 263 * |- - -+--- Volume identification field ---| 264 * | 31 | | 265 * |-----+-------------------------------------------------------------------| 266 * | 32 | | 267 * |- - -+--- Reserved ---| 268 * | 33 | | 269 * |-----+-------------------------------------------------------------------| 270 * | 34 | (MSB) | 271 * |-----+--- Volume sequence number ---| 272 * | 35 | (LSB) | 273 * +=========================================================================+ 274 * 275 * 276 * 17.1.5.2 Primary and alternate volume tag information 277 * 278 * Element status descriptors as reported by the READ ELEMENT STATUS 279 * command define a primary volume tag and an alternate volume tag. 280 * Alternate volume tag information provides a means for a system to use 281 * different volume identification information for each side of double 282 * sided media. In such a system, the primary volume tag information 283 * refers to the logical medium accessible via a MOVE MEDIUM command 284 * without the invert bit set. The alternate volume tag information refers 285 * to the other side of the media, i.e. the side that would be accessed 286 * via a MOVE MEDIUM command with the invert bit set. 287 */ 288 289 #define SMC_VOL_TAG_LEN 36 290 291 struct smc_raw_volume_tag { 292 unsigned char volume_id[32]; 293 unsigned char resv32[2]; 294 unsigned char volume_seq[2]; 295 }; 296 297 298 299 300 /* 301 * 17.1.4 Element status maintenance requirements 302 * 303 * If the medium changer device chooses to implement the READ ELEMENT 304 * STATUS command, the medium changer device must be capable of reporting 305 * the various data (i.e. full, error, etc.) required by each page type. 306 * The medium changer may maintain this information at all times or 307 * regenerate it in response to the READ ELEMENT STATUS command. The 308 * INITIALIZE ELEMENT STATUS command can be used to force regeneration of 309 * this information. 310 */ 311 312 /* 313 * 17.2.5 READ ELEMENT STATUS command 314 * 315 * The READ ELEMENT STATUS command (see table 332) requests that the 316 * target report the status of its internal elements to the initiator. 317 * 318 * Table 332 - READ ELEMENT STATUS command 319 * +====-=======-========-========-========-========-========-========-=======+ 320 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 321 * |Byte| | | | | | | | | 322 * |====+=====================================================================| 323 * | 0 | Operation code (B8h) | 324 * |----+---------------------------------------------------------------------| 325 * | 1 |Logical unit number | VolTag | Element type code | 326 * |----+---------------------------------------------------------------------| 327 * | 2 |(MSB) | 328 * |----+-- Starting element address --| 329 * | 3 | (LSB)| 330 * |----+---------------------------------------------------------------------| 331 * | 4 |(MSB) | 332 * |----+-- Number of elements --| 333 * | 5 | (LSB)| 334 * |----+---------------------------------------------------------------------| 335 * | 6 | Reserved | 336 * |----+---------------------------------------------------------------------| 337 * | 7 |(MSB) | 338 * |----+-- --| 339 * | 8 | Allocation length | 340 * |----+-- --| 341 * | 9 | (LSB)| 342 * |----+---------------------------------------------------------------------| 343 * |10 | Reserved | 344 * |----+---------------------------------------------------------------------| 345 * |11 | Control | 346 * +==========================================================================+ 347 * 348 * 349 * A volume tag (VolTag) bit of one indicates that the target shall report 350 * volume tag information if this feature is supported. A value of zero 351 * indicates that volume tag information shall not be reported. If the 352 * volume tag feature is not supported this field shall be treated as 353 * reserved. 354 * 355 * The element type code field specifies the particular element type(s) 356 * selected for reporting by this command. A value of zero specifies that 357 * status for all element types shall be reported. The element type codes 358 * are defined in table 333. 359 * 360 * Table 333 - Element type code 361 * (SEE ABOVE) 362 * 363 * The starting element address specifies the minimum element address to 364 * report. Only elements with an element type code permitted by the 365 * element type code specification, and an element address greater than or 366 * equal to the starting element address shall be reported. Element 367 * descriptor blocks are not generated for undefined element addresses. 368 * 369 * The number of elements specifies the maximum number of element 370 * descriptors to be created by the target for this command. The value 371 * specified by this field is not the range of element addresses to be 372 * considered for reporting but rather the number of defined elements to 373 * report. If the allocation length is not sufficient to transfer all the 374 * element descriptors, the target shall transfer all those descriptors 375 * that can be completely transferred and this shall not be considered an 376 * error. 377 * 378 * 17.2.5.1 Element status data 379 * 380 * The data returned by the READ ELEMENT STATUS command is defined in 381 * table 334 and 17.2.5.3 through 17.2.5.6. Element status data consists 382 * of an eight-byte header, (see table 334) followed by one or more 383 * element status pages. 384 * 385 * Table 334 - Element status data 386 * +====-=======-========-========-========-========-========-========-=======+ 387 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 388 * |Byte| | | | | | | | | 389 * |====+=====================================================================| 390 * | 0 |(MSB) | 391 * |----+-- First element address reported --| 392 * | 1 | (LSB)| 393 * |----+---------------------------------------------------------------------| 394 * | 2 |(MSB) | 395 * |----+-- Number of elements available --| 396 * | 3 | (LSB)| 397 * |----+---------------------------------------------------------------------| 398 * | 4 | Reserved | 399 * |----+---------------------------------------------------------------------| 400 * | 5 |(MSB) | 401 * |----+-- --| 402 * | 6 | Byte count of report available | 403 * |----+-- (all pages, n - 7 ) --| 404 * | 7 | (LSB)| 405 * |====+=====================================================================| 406 * | 8 | | 407 * |- - +-- Element status page(s) --| 408 * | n | | 409 * +==========================================================================+ 410 * 411 * 412 * The first element address reported field indicates the element address 413 * of the element with the smallest element address found to meet the CDB 414 * request. 415 * 416 * The number of elements available field indicates the number of elements 417 * meeting the request in the command descriptor block. The status for 418 * these elements is returned if sufficient allocation length was 419 * specified. 420 * 421 * The byte count of report available field indicates the number of bytes 422 * of element status page data available for all elements meeting the 423 * request in the command descriptor block. This value shall not be 424 * adjusted to match the allocation length available. 425 * 426 * NOTE 202 - The READ ELEMENT STATUS command can be issued with an 427 * allocation length of eight bytes in order to determine the allocation 428 * length required to transfer all the element status data specified by the 429 * command. 430 * 431 * Figure 28 provides an illustration of the element status data 432 * structure. 433 * 434 * Figure 28 - Illustration of element status data structure 435 * 436 * 437 * 17.2.5.2 Element status page 438 * 439 * The element status page is defined in table 335. Each element status 440 * page includes an eight-byte header followed by one or more element 441 * descriptor blocks. The header includes the element type code, the 442 * length of each descriptor block and the number of bytes of element 443 * descriptor information that follow the header for this element type. 444 * 445 * Table 335 - Element status page 446 * +====-=======-========-========-========-========-========-========-=======+ 447 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 448 * |Byte| | | | | | | | | 449 * |====+=====================================================================| 450 * | 0 | Element type code | 451 * |----+---------------------------------------------------------------------| 452 * | 1 |PVolTag| AVolTag| Reserved | 453 * |----+---------------------------------------------------------------------| 454 * | 2 |(MSB) | 455 * |----+-- Element descriptor length --| 456 * | 3 | (LSB)| 457 * |----+---------------------------------------------------------------------| 458 * | 4 | Reserved | 459 * |----+---------------------------------------------------------------------| 460 * | 5 |(MSB) | 461 * |----+-- --| 462 * | 6 | Byte count of descriptor data available | 463 * |----+-- (this page, n - 7) --| 464 * | 7 | (LSB)| 465 * |====+=====================================================================| 466 * | 8 | | 467 * |- - +-- Element descriptor(s) --| 468 * | n | | 469 * +==========================================================================+ 470 * 471 * 472 * The element type code field indicates the element type reported by this 473 * page. 474 * 475 * A primary volume tag (PVolTag) bit of one indicates that the primary 476 * volume tag information field is present in each of the following 477 * element descriptor blocks. A value of zero indicates that these bytes 478 * are omitted from the element descriptors that follow. 479 * 480 * An alternate volume tag (AVolTag) bit of one indicates that the 481 * alternate volume tag information field is present in each of the 482 * following element descriptor blocks. A value of zero indicates that 483 * these bytes are omitted from the element descriptors that follow. 484 * 485 * The element descriptor length field indicates the number of bytes in 486 * each element descriptor. 487 * 488 * The byte count of descriptor data available field indicates the number 489 * of bytes of element descriptor data available for elements of this 490 * element type meeting the request in the CDB. This value shall not be 491 * adjusted to match the allocation length available. 492 * 493 * Each element descriptor includes the element address and status flags; 494 * it may also contain sense code information as well as other information 495 * depending on the element type (see 17.2.5.3 through 17.2.5.6). 496 * 497 * 17.2.5.3 Medium transport element descriptor 498 * 499 * Table 336 defines the medium transport element descriptor. 500 * 501 * Table 336 - Medium transport element descriptor 502 * +====-======-========-========-========-========-========-========-=======+ 503 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 504 * |Byte| | | | | | | | | 505 * |====+====================================================================| 506 * | 0 |(MSB) | 507 * |----+-- Element address --| 508 * | 1 | (LSB)| 509 * |----+--------------------------------------------------------------------| 510 * | 2 | Reserved | Except |Reserved| Full | 511 * |----+--------------------------------------------------------------------| 512 * | 3 | Reserved | 513 * |----+--------------------------------------------------------------------| 514 * | 4 | Additional sense code | 515 * |----+--------------------------------------------------------------------| 516 * | 5 | Additional sense code qualifier | 517 * |----+--------------------------------------------------------------------| 518 * | 6 | | 519 * | - -+-- Reserved --| 520 * | 8 | | 521 * |----+--------------------------------------------------------------------| 522 * | 9 |SValid| Invert | Reserved | 523 * |----+--------------------------------------------------------------------| 524 * |10 |(MSB) | 525 * |----+-- Source storage element address --| 526 * |11 | (LSB) | 527 * |----+--------------------------------------------------------------------| 528 * |12 | | 529 * | - -+-- Primary volume tag information --| 530 * |47 | (Field omitted if PVolTag = 0) | 531 * |----+--------------------------------------------------------------------| 532 * |48 | | 533 * | - -+-- Alternate volume tag information --| 534 * |83 | (Field omitted if AVolTag = 0) | 535 * |----+--------------------------------------------------------------------| 536 * |84 | | 537 * | - -+-- Reserved --| 538 * |87 | (Field moved up if volume tag information field(s) are omitted.) | 539 * |----+--------------------------------------------------------------------| 540 * |88 | | 541 * | - -+-- Vendor-specific --| 542 * |z-1 | (Field moved up if volume tag information field(s) are omitted.) | 543 * +=========================================================================+ 544 * 545 * 546 * The element address field gives the address of the medium changer 547 * element whose status is reported by this element descriptor block. 548 * 549 * An exception (Except) bit of one indicates the element is in an 550 * abnormal state. An exception bit of zero indicates the element is in a 551 * normal state. If this bit is one, information on the abnormal state 552 * may be available in the additional sense code and additional sense code 553 * qualifier bytes. 554 * 555 * A full bit value of one indicates that the element contains a unit of 556 * media. A value of zero indicates that the element does not contain a 557 * unit of media. 558 * 559 * The additional sense code field may provide specific information on an 560 * abnormal element state. The values in this field are as defined for 561 * the additional sense code of the REQUEST SENSE data (see 8.2.14.3). 562 * 563 * The additional sense code qualifier field may provide more detailed 564 * information on an abnormal element state. The values in this field are 565 * as defined for the additional sense code qualifier of the REQUEST SENSE 566 * data (see 8.2.14.4). 567 * 568 * A source valid (SValid) bit value of one indicates that the source 569 * storage element address field and the invert bit information are valid. 570 * A value of zero indicates that the values in these fields are not 571 * valid. 572 * 573 * An invert bit value of one indicates that the unit of media now in this 574 * element was inverted by MOVE MEDIUM or EXCHANGE MEDIUM operations since 575 * it was last in the source storage element. A value of zero indicates 576 * that no inversion occurred during the operation. 577 * 578 * The source storage element address field provides the address of the 579 * last storage element this unit of media was moved. This field is valid 580 * only if the SValid bit is one. 581 * 582 * The primary and alternate volume tag information fields provide for 583 * identifying the unit of media residing in this element (see 17.1.5.). 584 * Either or both of these fields may be omitted for all the element 585 * descriptor blocks that comprise an element status page as indicated by 586 * the PVolTag and AVolTag bits in the element status page header. 587 * 588 * 17.2.5.4 Storage element descriptor 589 * 590 * Table 337 defines the storage element descriptor. 591 * 592 * Table 337 - Storage element descriptor 593 * +=====-======-========-========-========-========-========-========-=======+ 594 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 595 * |Byte| | | | | | | | | 596 * |====+====================================================================| 597 * | 0 |(MSB) | 598 * |----+-- Element address --| 599 * | 1 | (LSB)| 600 * |----+--------------------------------------------------------------------| 601 * | 2 | Reserved | Access | Except |Reserved| Full | 602 * |----+--------------------------------------------------------------------| 603 * | 3 | Reserved | 604 * |----+--------------------------------------------------------------------| 605 * | 4 | Additional sense code | 606 * |----+--------------------------------------------------------------------| 607 * | 5 | Additional sense code qualifier | 608 * |----+--------------------------------------------------------------------| 609 * | 6 | | 610 * | - -+-- Reserved --| 611 * | 8 | | 612 * |----+--------------------------------------------------------------------| 613 * | 9 |SValid| Invert | Reserved | 614 * |----+--------------------------------------------------------------------| 615 * |10 |(MSB) | 616 * |----+-- Source element address --| 617 * |11 | (LSB) | 618 * |----+--------------------------------------------------------------------| 619 * |12 | | 620 * | - -+-- Primary volume tag information --| 621 * |47 | (Field omitted if PVolTag = 0) | 622 * |----+--------------------------------------------------------------------| 623 * |48 | | 624 * | - -+-- Alternate volume tag information --| 625 * |83 | (Field omitted if PVolTag = 0) | 626 * |----+--------------------------------------------------------------------| 627 * |84 | | 628 * | - -+-- Reserved --| 629 * |87 | (Field moved up if volume tag information field(s) are omitted.) | 630 * |----+--------------------------------------------------------------------| 631 * |88 | | 632 * | - -+-- Vendor unique --| 633 * |z-1 | (Field moved up if volume tag information field(s) are omitted.) | 634 * +=========================================================================+ 635 * 636 * 637 * An access bit value of one indicates that access to the element by a 638 * medium transport element is allowed. An access bit of zero indicates 639 * that access to the element by the medium transport element is denied. 640 * 641 * The source storage element address field provides the address of the 642 * last storage element this unit of media was moved from. This element 643 * address value may or may not be the same as this element. This field is 644 * valid only if the SValid bit is one. 645 * 646 * For fields not defined in this subclause, see 17.2.5.3. 647 * 648 * 17.2.5.5 Import export element descriptor 649 * 650 * Table 338 defines the import export element descriptor. 651 * 652 * Table 338 - Import export element descriptor 653 * +====-======-========-========-========-========-========-========-=======+ 654 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 655 * |Byte| | | | | | | | | 656 * |====+====================================================================| 657 * | 0 |(MSB) | 658 * |----+-- Element address --| 659 * | 1 | (LSB)| 660 * |----+--------------------------------------------------------------------| 661 * | 2 | Reserved | InEnab | ExEnab | Access | Except | ImpExp | Full | 662 * |----+--------------------------------------------------------------------| 663 * | 3 | Reserved | 664 * |----+--------------------------------------------------------------------| 665 * | 4 | Additional sense code | 666 * |----+--------------------------------------------------------------------| 667 * | 5 | Additional sense code qualifier | 668 * |----+--------------------------------------------------------------------| 669 * | 6 | | 670 * |----+-- Reserved --| 671 * | 8 | | 672 * |----+--------------------------------------------------------------------| 673 * | 9 |SValid| Invert | Reserved | 674 * |----+--------------------------------------------------------------------| 675 * |10 |(MSB) | 676 * |----+-- Source storage element address --| 677 * |11 | (LSB) | 678 * |----+--------------------------------------------------------------------| 679 * |12 | | 680 * | - -+-- Primary volume tag information --| 681 * |47 | (Field omitted if PVolTag = 0) | 682 * |----+--------------------------------------------------------------------| 683 * |48 | | 684 * | - -+-- Alternate volume tag information --| 685 * |83 | (Field omitted if PVolTag = 0) | 686 * |----+--------------------------------------------------------------------| 687 * |84 | | 688 * | - -+-- Reserved --| 689 * |87 | (Field moved up if volume tag information field(s) are omitted.) | 690 * |----+--------------------------------------------------------------------| 691 * |88 | | 692 * | - -+-- Vendor unique --| 693 * |z-1 | (Field moved up if volume tag information field(s) are omitted.) | 694 * +=========================================================================+ 695 * 696 * 697 * An import enable (InEnab) bit of one indicates that the import export 698 * element supports movement of media into the scope of the medium changer 699 * device. An InEnab bit of zero indicates that this element does not 700 * support import actions. 701 * 702 * An export enable (ExEnab) bit of one indicates that the import export 703 * element supports movement of media out of the scope of the medium 704 * changer device. An ExEnab bit of zero indicates that this element does 705 * not support export actions. 706 * 707 * An access bit of one indicates that access to the import export element 708 * by a medium transport element is allowed. An access bit of zero 709 * indicates access to the import export element by medium transport 710 * elements is denied. 711 * 712 * NOTE 203 An example of when access would be denied is when the operator 713 * has exclusive access to the import export element. 714 * 715 * An import export (ImpExp) bit of one indicates the unit of media in the 716 * import export element was placed there by an operator. An ImpExp bit 717 * of zero indicates the unit of media in the import export element was 718 * placed there by the medium transport element. 719 * 720 * For fields not defined in this clause, see 17.2.5.3. 721 * 722 * 17.2.5.6 Data transfer element descriptor 723 * 724 * Table 339 defines the data transfer element descriptor. 725 * 726 * Table 339 - Data transfer element descriptor 727 * +====-=======-========-========-========-========-========-========-=======+ 728 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 729 * |Byte| | | | | | | | | 730 * |====+=====================================================================| 731 * | 0 |(MSB) | 732 * |----+-- Element address --| 733 * | 1 | (LSB)| 734 * |----+---------------------------------------------------------------------| 735 * | 2 | Reserved | Access | Except |Reserved| Full | 736 * |----+---------------------------------------------------------------------| 737 * | 3 | Reserved | 738 * |----+---------------------------------------------------------------------| 739 * | 4 | Additional sense code | 740 * |----+---------------------------------------------------------------------| 741 * | 5 | Additional sense code qualifier | 742 * |----+---------------------------------------------------------------------| 743 * | 6 Not bus|Reserved|ID valid|LU valid|Reserved| Logical unit number | 744 * |----+---------------------------------------------------------------------| 745 * | 7 | SCSI bus address | 746 * |----+---------------------------------------------------------------------| 747 * | 8 | Reserved | 748 * |----+---------------------------------------------------------------------| 749 * | 9 |SValid | Invert | Reserved | 750 * |----+---------------------------------------------------------------------| 751 * |10 |(MSB) | 752 * |----+-- Source storage element address --| 753 * |11 | (LSB) | 754 * |----+---------------------------------------------------------------------| 755 * |12 | | 756 * | - -+-- Primary volume tag information --| 757 * |47 | (Field omitted if PVolTag = 0) | 758 * |----+---------------------------------------------------------------------| 759 * |48 | | 760 * | - -+-- Alternate volume tag information --| 761 * |83 | (Field omitted if PVolTag = 0) | 762 * |----+---------------------------------------------------------------------| 763 * |84 | | 764 * | - -+-- Reserved --| 765 * |87 | (Field moved up if volume tag information field(s) are omitted.) | 766 * |----+---------------------------------------------------------------------| 767 * |88 | | 768 * | - -+-- Vendor unique --| 769 * |z-1 | (Field moved up if volume tag information field(s) are omitted.) | 770 * +==========================================================================+ 771 * 772 * 773 * An access bit value of one indicates access to the data transfer 774 * element by the medium transport element is allowed. A value of zero 775 * indicates access to the data transfer element by a medium transport 776 * element is denied. 777 * 778 * NOTE 204 Access to the data transfer element by medium transport elements 779 * might be denied if a data transfer operation was under way. Note that a 780 * one value in this bit may not be sufficient to ensure a successful 781 * operation. This bit can only reflect the best information available to the 782 * medium changer device, which may not accurately reflect the state of the 783 * primary (data transfer) device. 784 * 785 * A not this bus (not bus) bit value of one indicates that the SCSI bus 786 * address and logical unit number values are not valid for the SCSI bus 787 * used to select the medium changer device. A not bus bit value of zero 788 * indicates that the SCSI address and logical unit values, if valid, are 789 * on the same bus as the medium changer device. 790 * 791 * An ID Valid bit value of one indicates that the SCSI bus address field 792 * contains valid information. An LU Valid bit value of one indicates that 793 * the logical unit number field contains valid information. 794 * 795 * The SCSI bus address field, if valid, provides the SCSI address (binary 796 * representation) of the primary device served by the medium changer at 797 * this element address. 798 * 799 * The logical unit number field, if valid, provides the logical unit 800 * number within the SCSI bus device of the primary device served by the 801 * medium changer at this element address. 802 * 803 * For fields not defined in this clause, see 17.2.5.3. 804 */ 805 806 struct smc_raw_element_status_data_header { 807 unsigned char first_elem[2]; 808 unsigned char n_elem[2]; 809 unsigned char resv4; 810 unsigned char byte_count[3]; 811 }; 812 813 struct smc_raw_element_status_page_header { 814 unsigned char element_type; 815 unsigned char flag1; 816 #define SMC_RAW_ESP_F1_PVolTag 0x80 817 #define SMC_RAW_ESP_F1_AVolTag 0x40 818 unsigned char elem_desc_len[2]; 819 unsigned char resv4; 820 unsigned char byte_count[3]; 821 }; 822 823 struct smc_raw_element_descriptor { 824 unsigned char element_address[2]; 825 unsigned char flags2; 826 #define SMC_RAW_ED_F2_Full 0x01 827 #define SMC_RAW_ED_F2_ImpExp 0x02 828 #define SMC_RAW_ED_F2_Except 0x04 829 #define SMC_RAW_ED_F2_Access 0x08 830 #define SMC_RAW_ED_F2_ExEnab 0x10 831 #define SMC_RAW_ED_F2_InEnab 0x20 832 833 unsigned char resv3; 834 unsigned char asc; 835 unsigned char ascq; 836 unsigned char flags6; 837 #define SMC_RAW_ED_F6_LUN 0x07 838 #define SMC_RAW_ED_F6_LU_valid 0x10 839 #define SMC_RAW_ED_F6_ID_valid 0x20 840 #define SMC_RAW_ED_F6_Not_bus 0x80 841 842 unsigned char scsi_sid; 843 844 unsigned char resv8; 845 846 unsigned char flags9; 847 #define SMC_RAW_ED_F9_Invert 0x40 848 #define SMC_RAW_ED_F9_SValid 0x80 849 850 unsigned char src_se_addr[2]; 851 852 /* 853 * primary_vol_tag (optional) 854 * alternate_vol_tag (optional) 855 * resv84 856 * vendor_specific 857 */ 858 unsigned char data[SMC_VOL_TAG_LEN + 859 SMC_VOL_TAG_LEN + 860 4 + 4]; 861 }; 862 863 864 /* 865 * 17.3.3.2 Element address assignment page 866 * 867 * The element address assignment page (see table 352) is used to assign 868 * addresses to the elements of the medium changer (MODE SELECT) and to 869 * report those assignments (MODE SENSE). This page also defines the 870 * number of each type of element present. 871 * 872 * Table 352 - Element address assignment page 873 * +====-=======-========-========-========-========-========-========-=======+ 874 * | Bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 875 * |Byte| | | | | | | | | 876 * |====+=======+========+====================================================| 877 * | 0 | PS |Reserved| Page code (1Dh) | 878 * |----+---------------------------------------------------------------------| 879 * | 1 | Parameter length (12h) | 880 * |----+---------------------------------------------------------------------| 881 * | 2 |(MSB) | 882 * |----+-- Medium transport element address --| 883 * | 3 | (LSB)| 884 * |----+---------------------------------------------------------------------| 885 * | 4 |(MSB) | 886 * |----+-- Number of medium transport elements --| 887 * | 5 | (LSB)| 888 * |----+---------------------------------------------------------------------| 889 * | 6 |(MSB) | 890 * |----+-- First storage element address --| 891 * | 7 | (LSB)| 892 * |----+---------------------------------------------------------------------| 893 * | 8 |(MSB) | 894 * |----+-- Number of storage elements --| 895 * | 9 | (LSB)| 896 * |----+---------------------------------------------------------------------| 897 * | 10 |(MSB) | 898 * |----+-- First import export element address --| 899 * | 11 | (LSB)| 900 * |----+---------------------------------------------------------------------| 901 * | 12 |(MSB) | 902 * |----+-- Number of import export elements --| 903 * | 13 | (LSB)| 904 * |----+---------------------------------------------------------------------| 905 * | 14 |(MSB) | 906 * |----+-- First data transfer element address --| 907 * | 15 | (LSB)| 908 * |----+---------------------------------------------------------------------| 909 * | 16 |(MSB) | 910 * |----+-- Number of data transfer elements --| 911 * | 17 | (LSB)| 912 * |----+---------------------------------------------------------------------| 913 * | 18 | | 914 * |----+-- Reserved --| 915 * | 19 | | 916 * +==========================================================================+ 917 * 918 * 919 * The parameters savable (PS) bit is only used with the MODE SENSE 920 * command. This bit is reserved with the MODE SELECT command. A PS bit 921 * of one indicates that the target is capable of saving the page in a 922 * non-volatile vendor-specific location. 923 * 924 * The first medium transport element address field identifies the first 925 * medium transport element contained in the medium changer (other than 926 * the default medium transport address of zero). The number of medium 927 * transport elements field defines the total number of medium transport 928 * elements contained in the medium changer. If the number of medium 929 * transport elements field in a MODE SELECT command is greater than the 930 * default value returned in the MODE SENSE parameter data, the target 931 * shall return CHECK CONDITION status and set the sense key to ILLEGAL 932 * REQUEST. 933 * 934 * The first storage element address field identifies the first medium 935 * storage element contained in the medium changer. The number of storage 936 * elements field defines the total number of medium storage elements 937 * contained in the medium changer. If the number of medium storage 938 * elements field in a MODE SELECT command is greater than the default 939 * value returned in the MODE SENSE parameter data, the target shall 940 * return CHECK CONDITION status and set the sense key to ILLEGAL REQUEST. 941 * 942 * The first import export element address field identifies the first 943 * medium portal that is accessible both by the medium transport devices 944 * and also by an operator from outside the medium changer. The number of 945 * import export elements field defines the total number of import export 946 * elements contained in the medium changer and accessible to the medium 947 * transport elements. If the number of import export elements field in a 948 * MODE SELECT command is greater than the default value returned in the 949 * MODE SENSE parameter data, the target shall return CHECK CONDITION 950 * status and set the sense key to ILLEGAL REQUEST . 951 * 952 * NOTE 207 The number of import export elements may be zero. 953 * 954 * The first data transfer element address field identifies the first data 955 * transfer element contained in the medium changer. The data transfer 956 * elements may be either read/write or read-only devices. The number of 957 * data transfer field defines the total number of data transfer elements 958 * contained within the medium changer and accessible to the medium 959 * transport elements. If the number of data transfer elements field in a 960 * MODE SELECT command is greater than the default value returned in the 961 * MODE SENSE parameter data, the target shall return CHECK CONDITION 962 * status and set the sense key to ILLEGAL REQUEST . 963 * 964 * Each element in the medium changer must have a unique address. If the 965 * address ranges defined for any of the element types overlap, the target 966 * shall return CHECK CONDITION status and set the sense key to ILLEGAL 967 * REQUEST. 968 */ 969 970 struct smc_raw_element_address_assignment_page { 971 unsigned char page_code; /* 0x1D */ 972 #define SMC_RAW_EA_PC_PS 0x80 973 unsigned char param_length; /* 0x12 */ 974 unsigned char mte_addr[2]; 975 unsigned char mte_count[2]; 976 unsigned char se_addr[2]; 977 unsigned char se_count[2]; 978 unsigned char iee_addr[2]; 979 unsigned char iee_count[2]; 980 unsigned char dte_addr[2]; 981 unsigned char dte_count[2]; 982 unsigned char resv18[2]; 983 }; 984 985 986 987 988 #define SMC_GET2(VEC) \ 989 (uint16_t) \ 990 ( (((unsigned char)(VEC)[0] << 8)) \ 991 + (((unsigned char)(VEC)[1]))) 992 993 #define SMC_PUT2(VEC,VAL) \ 994 ((VEC)[0] = (unsigned char)((VAL)>>8), \ 995 (VEC)[1] = (unsigned char)((VAL))) 996 997 #define SMC_GET3(VEC) \ 998 (uint32_t) \ 999 ( (((unsigned char)(VEC)[0] << 16)) \ 1000 + (((unsigned char)(VEC)[1] << 8)) \ 1001 + ((unsigned char)(VEC)[2])) 1002 1003 #define SMC_PUT3(VEC,VAL) \ 1004 ((VEC)[0] = (unsigned char)((VAL)>>16), \ 1005 (VEC)[1] = (unsigned char)((VAL)>>8), \ 1006 (VEC)[2] = (unsigned char)((VAL))) 1007 1008 #define SMC_GET4(VEC) \ 1009 (uint32_t) \ 1010 ( (((unsigned char)(VEC)[0] << 24)) \ 1011 + (((unsigned char)(VEC)[1] << 16)) \ 1012 + (((unsigned char)(VEC)[2] << 8)) \ 1013 + ((unsigned char)(VEC)[3])) 1014 1015 #define SMC_PUT4(VEC,VAL) \ 1016 ((VEC)[0] = (unsigned char)((VAL)>>24), \ 1017 (VEC)[1] = (unsigned char)((VAL)>>16), \ 1018 (VEC)[2] = (unsigned char)((VAL)>>8), \ 1019 (VEC)[3] = (unsigned char)((VAL))) 1020 1021 #ifdef __cplusplus 1022 } 1023 #endif 1024