The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/chio.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: chio.h,v 1.10 1999/09/09 23:24:11 thorpej Exp $        */
    2 
    3 /*-
    4  * Copyright (c) 1996, 1999 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *      This product includes software developed by the NetBSD
   22  *      Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 #ifndef _SYS_CHIO_H_
   41 #define _SYS_CHIO_H_
   42 
   43 /*
   44  * Element types.  Used as "to" and "from" type indicators in move
   45  * and exchange operations.
   46  *
   47  * Note that code in sys/dev/scsipi/ch.c relies on these values (uses
   48  * them as offsets in an array, and other evil), so don't muck with them
   49  * unless you know what you're doing.
   50  */
   51 #define CHET_MT         0       /* medium transport (picker) */
   52 #define CHET_ST         1       /* storage transport (slot) */
   53 #define CHET_IE         2       /* import/export (portal) */
   54 #define CHET_DT         3       /* data transfer (drive) */
   55 
   56 /*
   57  * Structure used to execute a MOVE MEDIUM command.
   58  */
   59 struct changer_move_request {
   60         int     cm_fromtype;    /* element type to move from */
   61         int     cm_fromunit;    /* logical unit of from element */
   62         int     cm_totype;      /* element type to move to */
   63         int     cm_tounit;      /* logical unit of to element */
   64         int     cm_flags;       /* misc. flags */
   65 };
   66 
   67 /* cm_flags */
   68 #define CM_INVERT       0x01    /* invert media */
   69 
   70 /*
   71  * Structure used to execute an EXCHANGE MEDIUM command.  In an
   72  * exchange operation, the following steps occur:
   73  *
   74  *      - media from source is moved to first destination.
   75  *
   76  *      - media previously occupying first destination is moved
   77  *        to the second destination.
   78  *
   79  * The second destination may or may not be the same as the source.
   80  * In the case of a simple exchange, the source and second destination
   81  * are the same.
   82  */
   83 struct changer_exchange_request {
   84         int     ce_srctype;     /* element type of source */
   85         int     ce_srcunit;     /* logical unit of source */
   86         int     ce_fdsttype;    /* element type of first destination */
   87         int     ce_fdstunit;    /* logical unit of first destination */
   88         int     ce_sdsttype;    /* element type of second destination */
   89         int     ce_sdstunit;    /* logical unit of second destination */
   90         int     ce_flags;       /* misc. flags */
   91 };
   92 
   93 /* ce_flags */
   94 #define CE_INVERT1      0x01    /* invert media 1 */
   95 #define CE_INVERT2      0x02    /* invert media 2 */
   96 
   97 /*
   98  * Structure used to execute a POSITION TO ELEMENT command.  This
   99  * moves the current picker in front of the specified element.
  100  */
  101 struct changer_position_request {
  102         int     cp_type;        /* element type */
  103         int     cp_unit;        /* logical unit of element */
  104         int     cp_flags;       /* misc. flags */
  105 };
  106 
  107 /* cp_flags */
  108 #define CP_INVERT       0x01    /* invert picker */
  109 
  110 /*
  111  * Data returned by CHIOGPARAMS.
  112  */
  113 struct changer_params {
  114         int     cp_curpicker;   /* current picker */
  115         int     cp_npickers;    /* number of pickers */
  116         int     cp_nslots;      /* number of slots */
  117         int     cp_nportals;    /* number of import/export portals */
  118         int     cp_ndrives;     /* number of drives */
  119 };
  120 
  121 /*
  122  * Old-style command used to get element status.
  123  */
  124 struct ochanger_element_status_request {
  125         int     cesr_type;      /* element type */
  126         u_int8_t *cesr_data;    /* pre-allocated data storage */
  127 };
  128 
  129 /*
  130  * Structure of a changer volume tag.
  131  */
  132 #define CHANGER_VOLTAG_SIZE     32      /* same as SCSI voltag size */
  133 struct changer_voltag {
  134         char    cv_tag[CHANGER_VOLTAG_SIZE + 1];        /* ASCII tag */
  135         u_int16_t cv_serial;                            /* serial number */
  136 };
  137 
  138 /*
  139  * Data returned by CHIOGSTATUS.
  140  */
  141 struct changer_element_status {
  142         int     ces_flags;      /* CESTATUS_* flags; see below */
  143 
  144         /*
  145          * The following is only valid on Data Transport elements (drives).
  146          */
  147         char    ces_xname[16];  /* external name of drive device */
  148 
  149         /*
  150          * The following fieds indicate the element the medium was
  151          * moved from in order to arrive in this element.
  152          */
  153         int     ces_from_type;  /* type of element */
  154         int     ces_from_unit;  /* logical unit of element */
  155 
  156         /*
  157          * Volume tag information.
  158          */
  159         struct changer_voltag ces_pvoltag;      /* primary volume tag */
  160         struct changer_voltag ces_avoltag;      /* alternate volume tag */
  161 
  162         size_t  ces_vendor_len; /* length of any vendor-specific data */
  163 
  164         /*
  165          * These two fields are only valid if CESTATUS_EXCEPT is
  166          * set in ces_flags, and are only valid on SCSI changers.
  167          */
  168         u_int8_t ces_asc;       /* Additional Sense Code */
  169         u_int8_t ces_ascq;      /* Additional Sense Code Qualifier */
  170 
  171         /*
  172          * These two fields may be useful if ces_xname is not valid.
  173          * They indicate the target and lun of a drive element.  These
  174          * are only valid on SCSI changers.
  175          */
  176         u_int8_t ces_target;    /* SCSI target of drive */
  177         u_int8_t ces_lun;       /* SCSI LUN of drive */
  178 };
  179 
  180 /*
  181  * Flags for changer_element_status.  These are flags that are returned
  182  * by hardware.  Not all flags have meaning for all element types.
  183  */
  184 #define CESTATUS_FULL           0x0001  /* element is full */
  185 #define CESTATUS_IMPEXP         0x0002  /* media deposited by operator */
  186 #define CESTATUS_EXCEPT         0x0004  /* element in abnormal state */
  187 #define CESTATUS_ACCESS         0x0008  /* media accessible by picker */
  188 #define CESTATUS_EXENAB         0x0010  /* element supports exporting */
  189 #define CESTATUS_INENAB         0x0020  /* element supports importing */
  190 
  191 #define CESTATUS_PICKER_MASK    0x0005  /* flags valid for pickers */
  192 #define CESTATUS_SLOT_MASK      0x000c  /* flags valid for slots */
  193 #define CESTATUS_PORTAL_MASK    0x003f  /* flags valid for portals */
  194 #define CESTATUS_DRIVE_MASK     0x000c  /* flags valid for drives */
  195 
  196 #define CESTATUS_INVERTED       0x0040  /* medium inverted from storage */
  197 #define CESTATUS_NOTBUS         0x0080  /* drive not on same bus as changer */
  198 
  199 /*
  200  * These changer_element_status flags indicate the validity of fields
  201  * in the returned data.
  202  */
  203 #define CESTATUS_STATUS_VALID   0x0100  /* entire structure valid */
  204 #define CESTATUS_XNAME_VALID    0x0200  /* ces_xname valid */
  205 #define CESTATUS_FROM_VALID     0x0400  /* ces_from_* valid */
  206 #define CESTATUS_PVOL_VALID     0x0800  /* ces_pvoltag valid */
  207 #define CESTATUS_AVOL_VALID     0x1000  /* ces_avoltag valid */
  208 #define CESTATUS_TARGET_VALID   0x2000  /* ces_target valid */
  209 #define CESTATUS_LUN_VALID      0x4000  /* ces_lun valid */
  210 
  211 #define CESTATUS_BITS   \
  212         "\2\6INEAB\5EXENAB\4ACCESS\3EXCEPT\2IMPEXP\1FULL"
  213 
  214 /*
  215  * Command used to get element status.
  216  */
  217 struct changer_element_status_request {
  218         int     cesr_type;      /* element type */
  219         int     cesr_unit;      /* start at this unit */
  220         int     cesr_count;     /* for this many units */
  221         int     cesr_flags;     /* flags; see below */
  222                                 /* pre-allocated data storage */
  223         /*
  224          * These fields point to the data to be returned to the
  225          * user:
  226          *
  227          *      cesr_deta: pointer to array of cesr_count status descriptors
  228          *
  229          *      cesr_vendor_data: pointer to array of void *'s which point
  230          *      to pre-allocated areas for vendor-specific data.  Optional.
  231          */
  232         struct changer_element_status *cesr_data;
  233         void    **cesr_vendor_data;
  234 };
  235 
  236 #define CESR_VOLTAGS            0x01    /* request volume tags */
  237 
  238 /*
  239  * Command used to modify a media element's volume tag.
  240  */
  241 struct changer_set_voltag_request {
  242         int     csvr_type;      /* element type */
  243         int     csvr_unit;      /* unit to modify */
  244         int     csvr_flags;     /* flags; see below */
  245                                 /* the actual volume tag; ignored if clearing
  246                                    the tag */
  247         struct changer_voltag csvr_voltag;
  248 };
  249 
  250 #define CSVR_MODE_SET           0x00    /* set volume tag if not set */
  251 #define CSVR_MODE_REPLACE       0x01    /* unconditionally replace volume tag */
  252 #define CSVR_MODE_CLEAR         0x02    /* clear volume tag */
  253 #define CSVR_MODE_MASK          0x0f
  254 #define CSVR_ALTERNATE          0x10    /* modify alternate volume tag */
  255 
  256 /*
  257  * Changer events.
  258  *
  259  * When certain events occur, the kernel can indicate this by setting
  260  * a bit in a bitmask.
  261  *
  262  * When a read is issued to the changer, the kernel returns this event
  263  * bitmask.  The read never blocks; if no events are pending, the bitmask
  264  * will be all-clear.
  265  *
  266  * A process may select for read to wait for an event to occur.
  267  *
  268  * The event mask is cleared when the changer is closed.
  269  */
  270 #define CHANGER_EVENT_SIZE              sizeof(u_int)
  271 #define CHEV_ELEMENT_STATUS_CHANGED     0x00000001
  272 
  273 /*
  274  * ioctls applicable to changers.
  275  */
  276 #define CHIOMOVE        _IOW('c', 0x01, struct changer_move_request)
  277 #define CHIOEXCHANGE    _IOW('c', 0x02, struct changer_exchange_request)
  278 #define CHIOPOSITION    _IOW('c', 0x03, struct changer_position_request)
  279 #define CHIOGPICKER     _IOR('c', 0x04, int)
  280 #define CHIOSPICKER     _IOW('c', 0x05, int)
  281 #define CHIOGPARAMS     _IOR('c', 0x06, struct changer_params)
  282 #define CHIOIELEM        _IO('c', 0x07)
  283 #define OCHIOGSTATUS    _IOW('c', 0x08, struct ochanger_element_status_request)
  284 #define CHIOGSTATUS     _IOW('c', 0x09, struct changer_element_status_request)
  285 #define CHIOSVOLTAG     _IOW('c', 0x0a, struct changer_set_voltag_request)
  286 
  287 #endif /* _SYS_CHIO_H_ */

Cache object: 291a1879816a69c1813c914d54e0186f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.