chio.h revision 55205
14Srgrimes/* 223452Sjoerg * Copyright (c) 1996 Jason R. Thorpe <thorpej@and.com> 323452Sjoerg * All rights reserved. 4624Srgrimes * 523452Sjoerg * Redistribution and use in source and binary forms, with or without 623452Sjoerg * modification, are permitted provided that the following conditions 723452Sjoerg * are met: 823452Sjoerg * 1. Redistributions of source code must retain the above copyright 923452Sjoerg * notice, this list of conditions and the following disclaimer. 1023452Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 1123452Sjoerg * notice, this list of conditions and the following disclaimer in the 1223452Sjoerg * documentation and/or other materials provided with the distribution. 1323452Sjoerg * 3. All advertising materials mentioning features or use of this software 1423452Sjoerg * must display the following acknowledgements: 1523452Sjoerg * This product includes software developed by Jason R. Thorpe 1623452Sjoerg * for And Communications, http://www.and.com/ 1723452Sjoerg * 4. The name of the author may not be used to endorse or promote products 1823452Sjoerg * derived from this software without specific prior written permission. 1923452Sjoerg * 2023452Sjoerg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2123452Sjoerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2223452Sjoerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2323452Sjoerg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2423452Sjoerg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2523452Sjoerg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 2623452Sjoerg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2723452Sjoerg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2823452Sjoerg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2923452Sjoerg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3023452Sjoerg * SUCH DAMAGE. 3123452Sjoerg * 3250477Speter * $FreeBSD: head/sys/sys/chio.h 55205 1999-12-29 04:46:21Z peter $ 334Srgrimes */ 344Srgrimes 3523736Sjoerg#ifndef _SYS_CHIO_H_ 3623736Sjoerg#define _SYS_CHIO_H_ 3723452Sjoerg 3855205Speter#ifndef _KERNEL 3923736Sjoerg#include <sys/types.h> 4023736Sjoerg#endif 4123736Sjoerg#include <sys/ioccom.h> 4223736Sjoerg 4323452Sjoerg/* 4423452Sjoerg * Element types. Used as "to" and "from" type indicators in move 4523452Sjoerg * and exchange operations. 4623452Sjoerg * 4723452Sjoerg * Note that code in sys/scsi/ch.c relies on these values (uses them 4823452Sjoerg * as offsets in an array, and other evil), so don't muck with them 4923452Sjoerg * unless you know what you're doing. 504Srgrimes */ 5123452Sjoerg#define CHET_MT 0 /* medium transport (picker) */ 5223452Sjoerg#define CHET_ST 1 /* storage transport (slot) */ 5323452Sjoerg#define CHET_IE 2 /* import/export (portal) */ 5423452Sjoerg#define CHET_DT 3 /* data transfer (drive) */ 554Srgrimes 564Srgrimes/* 5739248Sgibbs * Maximum length of a volume identification string 5839248Sgibbs */ 5939248Sgibbs#define CH_VOLTAG_MAXLEN 32 6039248Sgibbs 6139248Sgibbs/* 6223452Sjoerg * Structure used to execute a MOVE MEDIUM command. 634Srgrimes */ 6423452Sjoergstruct changer_move { 6539248Sgibbs u_int16_t cm_fromtype; /* element type to move from */ 6639248Sgibbs u_int16_t cm_fromunit; /* logical unit of from element */ 6739248Sgibbs u_int16_t cm_totype; /* element type to move to */ 6839248Sgibbs u_int16_t cm_tounit; /* logical unit of to element */ 6939248Sgibbs u_int16_t cm_flags; /* misc. flags */ 7023452Sjoerg}; 714Srgrimes 7223452Sjoerg/* cm_flags */ 7323452Sjoerg#define CM_INVERT 0x01 /* invert media */ 7418444Sbde 7523452Sjoerg/* 7623452Sjoerg * Structure used to execute an EXCHANGE MEDIUM command. In an 7723452Sjoerg * exchange operation, the following steps occur: 7823452Sjoerg * 7923452Sjoerg * - media from source is moved to first destination. 8023452Sjoerg * 8123452Sjoerg * - media previously occupying first destination is moved 8223452Sjoerg * to the second destination. 8323452Sjoerg * 8423452Sjoerg * The second destination may or may not be the same as the source. 8523452Sjoerg * In the case of a simple exchange, the source and second destination 8623452Sjoerg * are the same. 8723452Sjoerg */ 8823452Sjoergstruct changer_exchange { 8939248Sgibbs u_int16_t ce_srctype; /* element type of source */ 9039248Sgibbs u_int16_t ce_srcunit; /* logical unit of source */ 9139248Sgibbs u_int16_t ce_fdsttype; /* element type of first destination */ 9239248Sgibbs u_int16_t ce_fdstunit; /* logical unit of first destination */ 9339248Sgibbs u_int16_t ce_sdsttype; /* element type of second destination */ 9439248Sgibbs u_int16_t ce_sdstunit; /* logical unit of second destination */ 9539248Sgibbs u_int16_t ce_flags; /* misc. flags */ 9623452Sjoerg}; 9718444Sbde 9823452Sjoerg/* ce_flags */ 9923452Sjoerg#define CE_INVERT1 0x01 /* invert media 1 */ 10023452Sjoerg#define CE_INVERT2 0x02 /* invert media 2 */ 1014Srgrimes 10223452Sjoerg/* 10323452Sjoerg * Structure used to execute a POSITION TO ELEMENT command. This 10423452Sjoerg * moves the current picker in front of the specified element. 10523452Sjoerg */ 10623452Sjoergstruct changer_position { 10739248Sgibbs u_int16_t cp_type; /* element type */ 10839248Sgibbs u_int16_t cp_unit; /* logical unit of element */ 10939248Sgibbs u_int16_t cp_flags; /* misc. flags */ 1104Srgrimes}; 1114Srgrimes 11223452Sjoerg/* cp_flags */ 11323452Sjoerg#define CP_INVERT 0x01 /* invert picker */ 1144Srgrimes 11523452Sjoerg/* 11623452Sjoerg * Data returned by CHIOGPARAMS. 11723452Sjoerg */ 11823452Sjoergstruct changer_params { 11939248Sgibbs u_int16_t cp_npickers; /* number of pickers */ 12039248Sgibbs u_int16_t cp_nslots; /* number of slots */ 12139248Sgibbs u_int16_t cp_nportals; /* number of import/export portals */ 12239248Sgibbs u_int16_t cp_ndrives; /* number of drives */ 12323452Sjoerg}; 1244Srgrimes 12523452Sjoerg/* 12623452Sjoerg * Command used to get element status. 12723452Sjoerg */ 12839248Sgibbs 12939248Sgibbsstruct changer_voltag { 13039248Sgibbs u_char cv_volid[CH_VOLTAG_MAXLEN+1]; 13139248Sgibbs u_int16_t cv_serial; 13223452Sjoerg}; 133785Srgrimes 13439248Sgibbstypedef struct changer_voltag changer_voltag_t; 13539248Sgibbs 13623452Sjoerg/* 13739248Sgibbs * Flags definitions for ces_status 13823452Sjoerg * Not all flags have meaning for all element types. 13923452Sjoerg */ 14039248Sgibbstypedef enum { 14139248Sgibbs CES_STATUS_FULL = 0x001, /* element is full */ 14239248Sgibbs CES_STATUS_IMPEXP = 0x002, /* media deposited by operator */ 14339248Sgibbs CES_STATUS_EXCEPT = 0x004, /* element in abnormal state */ 14439248Sgibbs CES_PICKER_MASK = 0x005, /* flags valid for pickers */ 14539248Sgibbs CES_STATUS_ACCESS = 0x008, /* media accessible by picker */ 14639248Sgibbs CES_SLOT_MASK = 0x00c, /* flags valid for slots */ 14739248Sgibbs CES_DRIVE_MASK = 0x00c, /* flags valid for drives */ 14839248Sgibbs CES_STATUS_EXENAB = 0x010, /* element supports exporting */ 14939248Sgibbs CES_STATUS_INENAB = 0x020, /* element supports importing */ 15039248Sgibbs CES_PORTAL_MASK = 0x03f, /* flags valid for portals */ 15139248Sgibbs CES_INVERT = 0x040, /* invert bit */ 15239248Sgibbs CES_SOURCE_VALID = 0x080, /* source address (ces_source) valid */ 15339248Sgibbs CES_SCSIID_VALID = 0x100, /* ces_scsi_id is valid */ 15444516Sbde CES_LUN_VALID = 0x200 /* ces_scsi_lun is valid */ 15539248Sgibbs} ces_status_flags; 15623452Sjoerg 15739248Sgibbsstruct changer_element_status { 15839248Sgibbs u_int8_t ces_type; /* element type */ 15939248Sgibbs u_int16_t ces_addr; /* logical element address */ 16039248Sgibbs u_int16_t ces_int_addr; /* changer element address */ 16139248Sgibbs ces_status_flags ces_flags; /* 16239248Sgibbs * see CESTATUS definitions 16339248Sgibbs * below 16439248Sgibbs */ 16539248Sgibbs u_int8_t ces_sensecode; /* 16639248Sgibbs * additional sense 16739248Sgibbs * code for element */ 16839248Sgibbs u_int8_t ces_sensequal; /* 16939248Sgibbs * additional sense 17039248Sgibbs * code qualifier 17139248Sgibbs */ 17239248Sgibbs u_int8_t ces_source_type; /* 17339248Sgibbs * element type of 17439248Sgibbs * source address 17539248Sgibbs */ 17639248Sgibbs u_int16_t ces_source_addr; /* 17739248Sgibbs * source address of medium 17839248Sgibbs */ 17939248Sgibbs changer_voltag_t ces_pvoltag; /* primary volume tag */ 18039248Sgibbs changer_voltag_t ces_avoltag; /* alternate volume tag */ 18139248Sgibbs u_int8_t ces_scsi_id; /* SCSI id of element */ 18239248Sgibbs u_int8_t ces_scsi_lun; /* SCSI lun of element */ 18339248Sgibbs}; 18423452Sjoerg 18539248Sgibbsstruct changer_element_status_request { 18639248Sgibbs u_int16_t cesr_element_type; 18739248Sgibbs u_int16_t cesr_element_base; 18839248Sgibbs u_int16_t cesr_element_count; 18939248Sgibbs 19039248Sgibbs u_int16_t cesr_flags; 19139248Sgibbs#define CESR_VOLTAGS 0x01 19239248Sgibbs 19339248Sgibbs struct changer_element_status *cesr_element_status; 19439248Sgibbs}; 19539248Sgibbs 19639248Sgibbs 19739248Sgibbsstruct changer_set_voltag_request { 19839248Sgibbs u_int16_t csvr_type; 19939248Sgibbs u_int16_t csvr_addr; 20039248Sgibbs 20139248Sgibbs u_int16_t csvr_flags; 20239248Sgibbs#define CSVR_MODE_MASK 0x0f /* mode mask, acceptable modes below: */ 20339248Sgibbs#define CSVR_MODE_SET 0x00 /* set volume tag if not set */ 20439248Sgibbs#define CSVR_MODE_REPLACE 0x01 /* unconditionally replace volume tag */ 20539248Sgibbs#define CSVR_MODE_CLEAR 0x02 /* clear volume tag */ 20639248Sgibbs 20739248Sgibbs#define CSVR_ALTERNATE 0x10 /* set to work with alternate voltag */ 20839248Sgibbs 20939248Sgibbs changer_voltag_t csvr_voltag; 21039248Sgibbs}; 21139248Sgibbs 21239248Sgibbs 21323452Sjoerg#define CESTATUS_BITS \ 21423452Sjoerg "\20\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL" 21523452Sjoerg 21623452Sjoerg#define CHIOMOVE _IOW('c', 0x01, struct changer_move) 21723452Sjoerg#define CHIOEXCHANGE _IOW('c', 0x02, struct changer_exchange) 21823452Sjoerg#define CHIOPOSITION _IOW('c', 0x03, struct changer_position) 21923452Sjoerg#define CHIOGPICKER _IOR('c', 0x04, int) 22023452Sjoerg#define CHIOSPICKER _IOW('c', 0x05, int) 22123452Sjoerg#define CHIOGPARAMS _IOR('c', 0x06, struct changer_params) 22239248Sgibbs#define CHIOIELEM _IOW('c', 0x07, u_int32_t) 22339248Sgibbs#define CHIOGSTATUS _IOW('c', 0x08, struct changer_element_status_request) 22439248Sgibbs#define CHIOSETVOLTAG _IOW('c', 0x09, struct changer_set_voltag_request) 22523452Sjoerg 22623736Sjoerg#endif /* !_SYS_CHIO_H_ */ 227