Annotation of kernel/bsd/dev/scsireg.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: /*     @(#)scsireg.h   1.0     10/23/89        (c) 1989 NeXT   */
                     26: /*
                     27:  * scsireg.h -- generic SCSI definitions
                     28:  * KERNEL VERSION
                     29:  *
                     30:  * HISTORY
                     31:  * 15-Jan-98   Martin Minow at Apple
                     32:  *             Radar 2178255: Fix 12-byte command length field
                     33:  * 13-Jun-95   dmitch at NeXT
                     34:  *     Added SCSI-3 types.
                     35:  * 10-Feb-93           dmitch
                     36:  *     Added generic endian/alignment #ifdef's.
                     37:  * 17-May-90   dmitch
                     38:  *     Added SDIOCGETCAP
                     39:  * 30-Apr-90   dmitch
                     40:  *     Added C6S_SS_START, C6S_SS_STOP, C6S_SS_EJECT, SR_IOST_VOLNA
                     41:  * 30-Oct-89   dmitch
                     42:  *     Deleted private #defines (--> scsivar.h)
                     43:  * 25-Sep-89   dmitch at NeXT
                     44:  *     Added scsi_req, support for sg and st drivers
                     45:  * 10-Sept-87          Mike DeMoney (mike) at NeXT
                     46:  *     Created.
                     47:  */
                     48: 
                     49: #ifndef _BSD_DEV_SCSIREG_
                     50: #define        _BSD_DEV_SCSIREG_
                     51: 
                     52: #import <sys/ioctl.h>
                     53: #import <sys/time.h>
                     54: #import <kern/queue.h>
                     55: #import <sys/types.h>
                     56: 
                     57: /*
                     58:  * status byte definitions
                     59:  */
                     60: #define        STAT_GOOD               0x00    /* cmd successfully completed */
                     61: #define        STAT_CHECK              0x02    /* abnormal condition occurred */
                     62: #define        STAT_CONDMET            0x04    /* condition met / good */
                     63: #define        STAT_BUSY               0x08    /* target busy */
                     64: #define        STAT_INTMGOOD           0x10    /* intermediate / good */
                     65: #define        STAT_INTMCONDMET        0x14    /* intermediate / cond met / good */
                     66: #define        STAT_RESERVED           0x18    /* reservation conflict */
                     67: 
                     68: #define        STAT_MASK               0x1e    /* clears vendor unique bits */
                     69: 
                     70: 
                     71: /*
                     72:  * SCSI command descriptor blocks
                     73:  * (Any device level driver doing fancy things will probably define
                     74:  * these locally and cast a pointer on top of the sd_cdb.  We define
                     75:  * them here to reserve the appropriate space, driver level routines
                     76:  * can use them if they want.)
                     77:  *
                     78:  * 6 byte command descriptor block, random device
                     79:  */
                     80: typedef struct cdb_6 {
                     81: #if    __BIG_ENDIAN__
                     82:        u_int   c6_opcode:8,            /* device command */
                     83:                c6_lun:3,               /* logical unit */
                     84:                c6_lba:21;              /* logical block number */
                     85:        u_char  c6_len;                 /* transfer length */
                     86:        u_char  c6_ctrl;                /* control byte */
                     87: 
                     88: #elif  __LITTLE_ENDIAN__
                     89:        u_char  c6_opcode;
                     90:        u_char  c6_lba2         :5,
                     91:                c6_lun          :3;
                     92:        u_char  c6_lba1;
                     93:        u_char  c6_lba0;
                     94:        u_char  c6_len;
                     95:        u_char  c6_ctrl;
                     96: 
                     97: #else
                     98: #error SCSI command / data structures are compiler sensitive
                     99: #endif
                    100: } cdb_6_t;
                    101: 
                    102: #define CDB_6_MAX_LENGTH        (255)           /* max block count */
                    103: #define CDB_6_MAX_LBA           ((1 << 21) - 1) /* max block address */
                    104: 
                    105: /*
                    106:  * 6 byte command descriptor block, sequential device
                    107:  */
                    108: typedef struct cdb_6s {
                    109: #if    __BIG_ENDIAN__
                    110: #if    __NATURAL_ALIGNMENT__
                    111: 
                    112:        u_char  c6s_opcode:8;           /* device command */
                    113:        u_char  c6s_lun:3,              /* logical unit */
                    114:                c6s_spare:3,            /* reserved */
                    115:                c6s_opt:2;              /* bits 1..0 - space type, fixed, 
                    116:                                         *    etc. */ 
                    117:        /*
                    118:         * Careful, natural alignment...
                    119:         */
                    120:        u_char  c6s_len[3];             /* transfer length */
                    121:        u_char  c6s_ctrl;               /* control byte */
                    122: 
                    123: #else  /* __NATURAL_ALIGNMENT__ */
                    124: 
                    125: 
                    126:        u_char  c6s_opcode:8;           /* device command */
                    127:        u_char  c6s_lun:3,              /* logical unit */
                    128:                c6s_spare:3,            /* reserved */
                    129:                c6s_opt:2;              /* bits 1..0 - space type, fixed, 
                    130:                                         *    etc. */ 
                    131:        u_int   c6s_len:24,             /* transfer length */
                    132:                c6s_ctrl:8;             /* control byte */
                    133: #endif /* __NATURAL_ALIGNMENT__ */
                    134: 
                    135: 
                    136: #elif  __LITTLE_ENDIAN__
                    137:        u_char  c6s_opcode;
                    138:        u_char  c6s_opt         :2,
                    139:                c6s_spare       :3,
                    140:                c6s_lun         :3;
                    141:        u_char  c6s_len2;
                    142:        u_char  c6s_len1;
                    143:        u_char  c6s_len0;
                    144:        u_char  c6s_ctrl;
                    145: 
                    146: #else  
                    147: #error SCSI command / data structures are compiler sensitive
                    148: #endif
                    149: } cdb_6s_t;
                    150: 
                    151: 
                    152: /*
                    153:  * 10 byte command descriptor block
                    154:  * This definition is machine dependent due to an int on a short boundary.
                    155:  */
                    156: typedef struct cdb_10 {
                    157: #if    __BIG_ENDIAN__
                    158: #if    __NATURAL_ALIGNMENT__
                    159:         u_char  c10_opcode;             /* device command */
                    160:         u_char  c10_lun:3,              /* logical unit */
                    161:                 c10_dp0:1,              /* disable page out */
                    162:                 c10_fua:1,              /* force unit access */
                    163:                 c10_mbz1:2,             /* reserved: must be zero */
                    164:                 c10_reladr:1;           /* addr relative to prev 
                    165:                                         * linked cmd */
                    166:        /*
                    167:         * Careful, this can't be an int due to natural alignment...
                    168:         */
                    169:         u_char c10_lba[4];             /* logical block number */
                    170:         u_char c10_mbz2:8;             /* reserved: must be zero */
                    171:        u_char  c10_len[2];             /* transfer length */
                    172:        u_char  c10_ctrl;               /* control byte */
                    173: 
                    174: #else  /* __NATURAL_ALIGNMENT__ */
                    175: 
                    176:        u_char  c10_opcode;             /* device command */
                    177:        u_char  c10_lun:3,              /* logical unit */
                    178:                c10_dp0:1,              /* disable page out (cache control) */
                    179:                c10_fua:1,              /* force unit access (cache control) */
                    180:                c10_mbz1:2,             /* reserved: must be zero */
                    181:                c10_reladr:1;           /* addr relative to prev linked cmd */
                    182:        u_int   c10_lba;                /* logical block number */
                    183:        u_int   c10_mbz2:8,             /* reserved: must be zero */
                    184:                c10_len:16,             /* transfer length */
                    185:                c10_ctrl:8;             /* control byte */
                    186:                
                    187: #endif /* __NATURAL_ALIGNMENT__ */
                    188: #elif    __LITTLE_ENDIAN__
                    189: 
                    190:        u_char  c10_opcode;
                    191:        u_char  c10_reladr      :1,
                    192:                c10_mbz1        :2,
                    193:                c10_fua         :1,
                    194:                c10_dp0         :1,
                    195:                c10_lun         :3;
                    196:        u_char  c10_lba3;
                    197:        u_char  c10_lba2;
                    198:        u_char  c10_lba1;
                    199:        u_char  c10_lba0;
                    200:        u_char  c10_mbz2;
                    201:        u_char  c10_len1;
                    202:        u_char  c10_len0;
                    203:        u_char  c10_ctrl;
                    204: 
                    205: #else
                    206: #error SCSI command / data structures are compiler sensitive
                    207: #endif
                    208: } cdb_10_t;
                    209: 
                    210: /*
                    211:  * 12 byte command descriptor block
                    212:  * This definition is machine dependent due to an int on a short boundary.
                    213:  */
                    214: typedef struct cdb_12 {
                    215: #if    __BIG_ENDIAN__
                    216: #if    __NATURAL_ALIGNMENT__
                    217: 
                    218:         u_char c12_opcode;             /* device command */
                    219:         u_char c12_lun:3,              /* logical unit */
                    220:                c12_dp0:1,              /* disable page out */
                    221:                c12_fua:1,              /* force unit access */
                    222:                c12_mbz1:2,             /* reserved: must be zero */
                    223:                c12_reladr:1;           /* addr relative to prev 
                    224:                                         * linked cmd */
                    225:         u_char c12_lba[4];             /* logical block number */
                    226: /* Radar 2178255: need 4-byte length field */
                    227:         u_char c12_len[4];             /* transfer length */
                    228:        u_char  c12_mbz2;               /* Reserved: must be zero */
                    229:         u_char c12_ctrl:8;             /* control byte */
                    230: 
                    231: #else  /* __NATURAL_ALIGNMENT__ */
                    232: 
                    233:        u_char  c12_opcode;             /* device command */
                    234:        u_char  c12_lun:3,              /* logical unit */
                    235:                c12_dp0:1,              /* disable page out (cache control) */
                    236:                c12_fua:1,              /* force unit access (cache control) */
                    237:                c12_mbz1:2,             /* reserved: must be zero */
                    238:                c12_reladr:1;           /* addr relative to prev linked cmd */
                    239:        u_int   c12_lba;                /* logical block number */
                    240: /* Radar 2178255: need 4-byte length field */
                    241:         u_char c12_len[4];             /* transfer length */
                    242:        u_char  c12_mbz2;               /* Reserved: must be zero */
                    243:        u_char  c12_ctrl:8;             /* control byte */
                    244: 
                    245: #endif /* __NATURAL_ALIGNMENT__ */
                    246: #elif   __LITTLE_ENDIAN__ 
                    247: 
                    248:        u_char  c12_opcode;
                    249:        u_char  c12_reladr      :1,
                    250:                c12_mbz1        :2,
                    251:                c12_fua         :1,
                    252:                c12_dp0         :1,
                    253:                c12_lun         :3;
                    254:        u_char  c12_lba3;
                    255:        u_char  c12_lba2;
                    256:        u_char  c12_lba1;
                    257:        u_char  c12_lba0;
                    258: /* Radar 2178255: need 4-byte length field */
                    259:        u_char  c12_len3;
                    260:        u_char  c12_len2;
                    261:        u_char  c12_len1;
                    262:        u_char  c12_len0;
                    263:        u_char  c12_mbz2;
                    264:        u_char  c12_ctrl;
                    265: 
                    266: #else
                    267: #error SCSI command / data structures are compiler sensitive
                    268: #endif
                    269: } cdb_12_t;
                    270: 
                    271: /*
                    272:  * 16 byte command descriptor block (SCSI-3 only)
                    273:  * This definition is machine dependent due to an int on a short boundary.
                    274:  */
                    275: typedef struct cdb_16 {
                    276: #if    __BIG_ENDIAN__
                    277: #if    __NATURAL_ALIGNMENT__
                    278: 
                    279:         u_char c16_opcode;             /* device command */
                    280:         u_char c16_mbz1;               /* reserved: must be zero */
                    281:         u_char c16_lba[4];             /* logical block number */
                    282:        u_char  c16_addl0;
                    283:        u_char  c16_addl1;
                    284:        u_char  c16_addl2;
                    285:        u_char  c16_addl3;
                    286:         u_char c16_len[4];             /* transfer length */
                    287:         u_char c16_mbz2;               /* reserved: must be zero */
                    288:         u_char c16_ctrl;               /* control byte */
                    289: 
                    290: #else  /* __NATURAL_ALIGNMENT__ */
                    291: 
                    292:        u_char  c16_opcode;             /* device command */
                    293:         u_char c16_mbz1;               /* reserved: must be zero */
                    294:        u_int   c16_lba;                /* logical block number */
                    295:        u_char  c16_addl0;
                    296:        u_char  c16_addl1;
                    297:        u_char  c16_addl2;
                    298:        u_char  c16_addl3;
                    299:        u_int   c16_len;                /* transfer length */
                    300:         u_char c16_mbz2;               /* reserved: must be zero */
                    301:         u_char c16_ctrl;               /* control byte */
                    302: 
                    303: #endif /* __NATURAL_ALIGNMENT__ */
                    304: #elif  __LITTLE_ENDIAN__
                    305: 
                    306:        u_char  c16_opcode;
                    307:         u_char c16_mbz1;               /* reserved: must be zero */
                    308:        u_char  c16_lba3;
                    309:        u_char  c16_lba2;
                    310:        u_char  c16_lba1;
                    311:        u_char  c16_lba0;
                    312:        u_char  c16_addl0;
                    313:        u_char  c16_addl1;
                    314:        u_char  c16_addl2;
                    315:        u_char  c16_addl3;
                    316:        u_char  c16_len3;
                    317:        u_char  c16_len2;
                    318:        u_char  c16_len1;
                    319:        u_char  c16_len0;
                    320:         u_char c16_mbz2;               /* reserved: must be zero */
                    321:         u_char c16_ctrl;               /* control byte */
                    322: 
                    323: #else
                    324: #error SCSI command / data structures are compiler sensitive
                    325: #endif
                    326: } cdb_16_t;
                    327: 
                    328: 
                    329: typedef union cdb {
                    330:        struct  cdb_6   cdb_c6;
                    331:        struct  cdb_6s  cdb_c6s;
                    332:        struct  cdb_10  cdb_c10;
                    333:        struct  cdb_12  cdb_c12;
                    334: } cdb_t;
                    335: 
                    336: /*
                    337:  * SCSI-3 CDB union.
                    338:  */
                    339: typedef union scsi3_cdb {
                    340:        struct  cdb_6   cdb_c6;
                    341:        struct  cdb_6s  cdb_c6s;
                    342:        struct  cdb_10  cdb_c10;
                    343:        struct  cdb_12  cdb_c12;
                    344:        struct  cdb_16  cdb_c16;
                    345: } scsi3_cdb_t;
                    346: 
                    347: 
                    348: #define        cdb_opcode      cdb_c6.c6_opcode        /* all opcodes in same place */
                    349: 
                    350: /*
                    351:  * control byte values
                    352:  */
                    353: #define        CTRL_LINKFLAG           0x03    /* link and flag bits */
                    354: #define        CTRL_LINK               0x01    /* link only */
                    355: #define        CTRL_NOLINK             0x00    /* no command linking */
                    356: 
                    357: /*
                    358:  * six byte cdb opcodes
                    359:  * (Optional commands should only be used by formatters)
                    360:  */
                    361: #define        C6OP_TESTRDY            0x00    /* test unit ready */
                    362: #define C6OP_REWIND            0x01    /* rewind */
                    363: #define        C6OP_REQSENSE           0x03    /* request sense */
                    364: #define        C6OP_FORMAT             0x04    /* format unit */
                    365: #define        C6OP_REASSIGNBLK        0x07    /* OPT: reassign block */
                    366: #define        C6OP_READ               0x08    /* read data */
                    367: #define        C6OP_WRITE              0x0a    /* write data */
                    368: #define        C6OP_SEEK               0x0b    /* seek */
                    369: #define C6OP_READREV           0x0F    /* read reverse */
                    370: #define C6OP_WRTFM             0x10    /* write filemarks */
                    371: #define C6OP_SPACE             0x11    /* space records/filemarks */
                    372: #define        C6OP_INQUIRY            0x12    /* get device specific info */
                    373: #define C6OP_VERIFY            0x13    /* sequential verify */
                    374: #define        C6OP_MODESELECT         0x15    /* OPT: set device parameters */
                    375: #define        C6OP_MODESENSE          0x1a    /* OPT: get device parameters */
                    376: #define        C6OP_STARTSTOP          0x1b    /* OPT: start or stop device */
                    377: #define        C6OP_SENDDIAG           0x1d    /* send diagnostic */
                    378: #define        C60P_PREVENTALLOW       0x1e    /* prevent/allow medium removal */
                    379: 
                    380: /*
                    381:  * ten byte cdb opcodes
                    382:  */
                    383: #define        C10OP_READCAPACITY      0x25    /* read capacity */
                    384: #define        C10OP_READEXTENDED      0x28    /* read extended */
                    385: #define        C10OP_WRITEEXTENDED     0x2a    /* write extended */
                    386: #define        C10OP_READDEFECTDATA    0x37    /* OPT: read media defect info */
                    387: 
                    388: 
                    389: /*
                    390:  *     c6s_opt - options for 6-byte sequential device commands 
                    391:  */
                    392:  
                    393: #define C6OPT_FIXED            0x01    /* fixed block transfer */
                    394: #define C6OPT_LONG             0x01    /* 1 = erase to EOT */
                    395: #define C6OPT_IMMED            0x01    /* immediate (for rewind, retension) */
                    396: #define C6OPT_BYTECMP          0x02    /* byte compare for C6OP_VERIFY */
                    397: #define C6OPT_SIL              0x02    /* suppress illegal length (Exabyte) */
                    398: #define C6OPT_SPACE_LB         0x00    /* space logical blocks */
                    399: #define C6OPT_SPACE_FM         0x01    /* space filemarks */
                    400: #define C6OPT_SPACE_SFM                0x02    /* space sequential filemarks */
                    401: #define C6OPT_SPACE_PEOD       0x03    /* space to physical end of data */     
                    402: 
                    403: /*     
                    404:  *     other 6-byte sequential command constants
                    405:  */
                    406:  
                    407: #define C6S_MAXLEN             0xFFFFFF        
                    408: #define C6S_RETEN              0x02    /* byte 4 of load/unload - retension */
                    409: #define C6S_LOAD               0x01    /* byte 4 of load/unload - load */
                    410: 
                    411: /*
                    412:  * these go in the c6_len fields of start/stop command
                    413:  */
                    414: #define C6S_SS_START           0x01    /* start unit */
                    415: #define C6S_SS_STOP            0x00    /* stop unit */
                    416: #define C6S_SS_EJECT           0x02    /* eject disk */
                    417: 
                    418: /*
                    419:  * extended sense data
                    420:  * returned by C6OP_REQSENSE
                    421:  */
                    422: typedef struct esense_reply {
                    423: #if    __BIG_ENDIAN__
                    424: 
                    425:        u_char  er_ibvalid:1,           /* information bytes valid */
                    426:                er_class:3,             /* error class */
                    427:                er_code:4;              /* error code */
                    428:        u_char  er_segment;             /* segment number for copy cmd */
                    429:        u_char  er_filemark:1,          /* file mark */
                    430:                er_endofmedium:1,       /* end-of-medium */
                    431:                er_badlen:1,            /* incorrect length */
                    432:                er_rsvd2:1,             /* reserved */
                    433:                er_sensekey:4;          /* sense key */
                    434:        u_char  er_infomsb;             /* MSB of information byte */
                    435:        u_int   er_info:24,             /* bits 23 - 0 of info "byte" */
                    436:                er_addsenselen:8;       /* additional sense length */
                    437:        u_int   er_rsvd8;               /* copy status (unused) */
                    438:        u_char  er_addsensecode;        /* additional sense code */
                    439:        
                    440:        /* the following are used for tape only as of 27-Feb-89 */
                    441:        
                    442:        u_char  er_qualifier;           /* sense code qualifier */
                    443:        u_char  er_rsvd_e;
                    444:        u_char  er_rsvd_f;
                    445:        u_int   er_err_count:24,        /* three bytes of data error counter */
                    446:                er_stat_13:8;           /* byte 0x13 - discrete status bits */
                    447:        u_char  er_stat_14;             /* byte 0x14 - discrete status bits */
                    448:        u_char  er_stat_15;             /* byte 0x15 - discrete status bits */
                    449:        
                    450: #if    __NATURAL_ALIGNMENT__
                    451: 
                    452:        u_char  er_rsvd_16;
                    453:        u_char  er_remaining[3];        /* bytes 0x17..0x19 - remaining tape */
                    454: 
                    455: #else  /* __NATURAL_ALIGNMENT__ */
                    456: 
                    457:        u_int   er_rsvd_16:8,
                    458:                er_remaining:24;        /* bytes 0x17..0x19 - remaining tape */
                    459: 
                    460: #endif /* __NATURAL_ALIGNMENT__ */
                    461: 
                    462: #elif  __LITTLE_ENDIAN__
                    463: 
                    464:        u_char  er_code         :4,
                    465:                er_class        :3,
                    466:                er_ibvalid      :1;
                    467:        u_char  er_segment;
                    468:        u_char  er_sensekey     :4,
                    469:                er_rsvd2        :1,
                    470:                er_badlen       :1,
                    471:                er_endofmedium  :1,
                    472:                er_filemark     :1;
                    473:        u_char  er_info3;
                    474:        u_char  er_info2;
                    475:        u_char  er_info1;
                    476:        u_char  er_info0;
                    477:        u_char  er_addsenselen;
                    478:        u_char  er_rsvd8[4];
                    479:        u_char  er_addsensecode;
                    480: 
                    481:        u_char  er_qualifier;
                    482:        u_char  er_rsvd_e;
                    483:        u_char  er_rsvd_f;
                    484:        u_char  er_err_count2;
                    485:        u_char  er_err_count1;
                    486:        u_char  er_err_count0;
                    487:        u_char  er_stat_13;
                    488:        u_char  er_stat_14;
                    489:        u_char  er_stat_15;
                    490:        u_char  er_rsvd_16;
                    491:        u_char  er_remaining2;
                    492:        u_char  er_remaining1;
                    493:        u_char  er_remaining0;
                    494: 
                    495: #else
                    496: #error SCSI command / data structures are compiler sensitive
                    497: #endif
                    498:                
                    499:        /* technically, there can be additional bytes of sense info
                    500:         * here, but we don't check them, so we don't define them
                    501:         */
                    502: } esense_reply_t;
                    503: 
                    504: /*
                    505:  * sense keys
                    506:  */
                    507: #define        SENSE_NOSENSE           0x0     /* no error to report */
                    508: #define        SENSE_RECOVERED         0x1     /* recovered error */
                    509: #define        SENSE_NOTREADY          0x2     /* target not ready */
                    510: #define        SENSE_MEDIA             0x3     /* media flaw */
                    511: #define        SENSE_HARDWARE          0x4     /* hardware failure */
                    512: #define        SENSE_ILLEGALREQUEST    0x5     /* illegal request */
                    513: #define        SENSE_UNITATTENTION     0x6     /* drive attention */
                    514: #define        SENSE_DATAPROTECT       0x7     /* drive access protected */
                    515: #define        SENSE_ABORTEDCOMMAND    0xb     /* target aborted command */
                    516: #define        SENSE_VOLUMEOVERFLOW    0xd     /* eom, some data not transfered */
                    517: #define        SENSE_MISCOMPARE        0xe     /* source/media data mismatch */
                    518: 
                    519: /*
                    520:  * inquiry data
                    521:  */
                    522: typedef struct inquiry_reply {
                    523: 
                    524: #if    __BIG_ENDIAN__
                    525: 
                    526:        u_char  ir_qual:3,              /* qualifier */
                    527:                ir_devicetype:5;        /* device type, see below */
                    528:        u_char  ir_removable:1,         /* removable media */
                    529:                ir_typequalifier:7;     /* device type qualifier */
                    530:        u_char  ir_isoversion:2,        /* ISO  version number */
                    531:                ir_ecmaversion:3,       /* ECMA version number */
                    532:                ir_ansiversion:3;       /* ANSI version number */
                    533:        u_char  ir_aerc:1,              /* Async event reporting capability */
                    534:                ir_trmtsk:1,            /* Terminate Task */
                    535:                ir_normaca:1,           /* Normal ACA supported */
                    536:                ir_zero2:1,             /* reserved */
                    537:                ir_rspdatafmt:4;        /* response data format */
                    538:        u_char  ir_addlistlen;          /* additional list length */
                    539:        u_char  ir_zero3;               /* reserved */
                    540:        u_char  ir_zero4:2,             /* reserved */
                    541:                ir_port:1,              /* port A/B */
                    542:                ir_dualPort:1,          /* dual port supported */
                    543:                ir_mchngr:1,            /* medium changer */
                    544:                ir_ackqreqq:1,          /* Q cable (SIP only) */
                    545:                ir_addr32:1,            /* 32-bit addressing (SIP only) */
                    546:                ir_addr16:1;            /* 16-bit addressing (SIP only) */
                    547:        u_char  ir_reladr:1,            /* relative addressing */
                    548:                ir_wbus32:1,            /* 32-bit wide data transfers */
                    549:                ir_wbus16:1,            /* 16-bit wide data transfers */
                    550:                ir_sync:1,              /* synchronous data transfers */
                    551:                ir_linked:1,            /* linked commands */
                    552:                ir_trandis:1,           /* transfer disable */
                    553:                ir_cmdque:1,            /* tagged command queuing */
                    554:                ir_sftre:1;             /* soft reset */
                    555:        char    ir_vendorid[8];         /* vendor name in ascii */
                    556:        char    ir_productid[16];       /* product name in ascii */
                    557:        char    ir_revision[4];         /* revision level info in ascii */
                    558:        char    ir_misc[28];            /* misc info */
                    559:        char    ir_endofid[1];          /* just a handle for end of id info */
                    560: 
                    561: #elif  __LITTLE_ENDIAN__
                    562: 
                    563:        u_char  ir_devicetype   :5,
                    564:                ir_qual         :3;
                    565:        u_char  ir_typequalifier:7,
                    566:                ir_removable    :1;
                    567:        u_char  ir_ansiversion  :3,
                    568:                ir_ecmaversion  :3,
                    569:                ir_isoversion   :2;
                    570:        u_char  ir_rspdatafmt   :4,
                    571:                ir_zero2:1,             /* reserved */
                    572:                ir_normaca:1,           /* Normal ACA supported */
                    573:                ir_trmtsk:1,            /* Terminate Task */
                    574:                ir_aerc:1;              /* Async event reporting capability */
                    575:        u_char  ir_addlistlen;
                    576:        u_char  ir_zero3;
                    577:        u_char  ir_addr16:1,            /* 16-bit addressing (SIP only) */
                    578:                ir_addr32:1,            /* 32-bit addressing (SIP only) */
                    579:                ir_ackqreqq:1,          /* Q cable (SIP only) */
                    580:                ir_mchngr:1,            /* medium changer */
                    581:                ir_dualPort:1,          /* dual port supported */
                    582:                ir_port:1,              /* port A/B */
                    583:                ir_zero4:2;             /* reserved */
                    584:        u_char  ir_sftre:1,
                    585:                ir_cmdque:1,
                    586:                ir_trandis:1,           /* transfer disable */
                    587:                ir_linked:1,
                    588:                ir_sync:1,
                    589:                ir_wbus16:1,
                    590:                ir_wbus32:1,
                    591:                ir_reladr:1;
                    592:        u_char  ir_vendorid[8];
                    593:        u_char  ir_productid[16];
                    594:        u_char  ir_revision[4];
                    595:        u_char  ir_misc[28];
                    596:        u_char  ir_endofid[1];
                    597: 
                    598: #else
                    599: #error SCSI command / data structures are compiler sensitive
                    600: #endif
                    601: } inquiry_reply_t;
                    602: 
                    603: #define        DEVQUAL_OK              0x00    /* device is connected to this lun */
                    604: #define        DEVQUAL_MIA             0x01    /* device not connected to lun */
                    605: #define        DEVQUAL_RSVD            0x02    /* reserved */
                    606: #define        DEVQUAL_NODEV           0x03    /* target doesn't support dev on lun */
                    607: #define        DEVQUAL_VUMASK          0x04    /* 1XXb is vendor specific */
                    608: 
                    609: 
                    610: #define        DEVTYPE_DISK            0x00    /* read/write disks */
                    611: #define        DEVTYPE_TAPE            0x01    /* tapes and other sequential devices*/
                    612: #define        DEVTYPE_PRINTER         0x02    /* printers */
                    613: #define        DEVTYPE_PROCESSOR       0x03    /* cpu's */
                    614: #define        DEVTYPE_WORM            0x04    /* write-once optical disks */
                    615: #define        DEVTYPE_CDROM           0x05    /* cd rom's, etc */
                    616: #define DEVTYPE_SCANNER                0x06
                    617: #define DEVTYPE_OPTICAL                0x07    /* other optical storage */
                    618: #define DEVTYPE_CHANGER                0x08    /* jukebox */
                    619: #define DEVTYPE_COMM           0x09    /* communication device */
                    620: #define DEVTYPE_GRAPH_A                0x0a    /* ASC IT8 graphics */
                    621: #define DEVTYPE_GRAPH_B                0x0b    /* ASC IT8 graphics */
                    622: #define DEVTYPE_RAID           0x0c    /* RAID controller */
                    623: #define DEVTYPE_NOTPRESENT      0x1f    /* logical unit not present */
                    624: 
                    625: /*
                    626:  * read capacity reply
                    627:  */
                    628: typedef struct capacity_reply {
                    629: 
                    630: #if    __BIG_ENDIAN__
                    631: 
                    632:        u_int   cr_lastlba;             /* last logical block address */
                    633:        u_int   cr_blklen;              /* block length */
                    634: 
                    635: #elif  __LITTLE_ENDIAN__
                    636: 
                    637:        u_char  cr_lastlba3;
                    638:        u_char  cr_lastlba2;
                    639:        u_char  cr_lastlba1;
                    640:        u_char  cr_lastlba0;
                    641: 
                    642:        u_char  cr_blklen3;
                    643:        u_char  cr_blklen2;
                    644:        u_char  cr_blklen1;
                    645:        u_char  cr_blklen0;
                    646: 
                    647: #else
                    648: #error SCSI command / data structures are compiler sensitive
                    649: #endif
                    650: } capacity_reply_t;
                    651: 
                    652: /*
                    653:  * Standard Mode Select/Mode Sense data structures
                    654:  */
                    655:  
                    656: typedef struct mode_sel_hdr {
                    657: 
                    658: #if    __BIG_ENDIAN__
                    659: 
                    660:        u_char          msh_sd_length_0;        /* byte 0 - length (mode sense
                    661:                                                 *    only)  */
                    662:        u_char          msh_med_type;           /* medium type - random access
                    663:                                                 *   devices only */
                    664:        u_char          msh_wp:1,               /* byte 2 bit 7 - write protect
                    665:                                                 *   mode sense only) */
                    666:                        msh_bufmode:3,          /* buffered mode - sequential
                    667:                                                 *   access devices only */
                    668:                        msh_speed:4;            /* speed - sequential access
                    669:                                                 *   devices only */
                    670:        u_char          msh_bd_length;          /* block descriptor length */
                    671: 
                    672: #elif  __LITTLE_ENDIAN__
                    673: 
                    674:        u_char          msh_sd_length_0;
                    675:        u_char          msh_med_type;
                    676:        u_char          msh_speed       :4,
                    677:                        msh_bufmode     :3,
                    678:                        msh_wp          :1;
                    679:        u_char          msh_bd_length;
                    680: 
                    681: #else
                    682: #error SCSI command / data structures are compiler sensitive
                    683: #endif
                    684: } mode_sel_hdr_t;
                    685: 
                    686: typedef struct mode_sel_bd {                           /* block descriptor */
                    687: 
                    688: #if    __BIG_ENDIAN__
                    689: 
                    690:        u_int           msbd_density:8,
                    691:                        msbd_numblocks:24;
                    692:        u_int           msbd_rsvd_0:8,          /* byte 4 - reserved */
                    693:                        msbd_blocklength:24;
                    694: 
                    695: #elif  __LITTLE_ENDIAN__
                    696: 
                    697:        u_char          msbd_density;
                    698:        u_char          msbd_numblocks2;
                    699:        u_char          msbd_numblocks1;
                    700:        u_char          msbd_numblocks0;
                    701:        u_char          msbd_rsvd_0;
                    702:        u_char          msbd_blocklength2;
                    703:        u_char          msbd_blocklength1;
                    704:        u_char          msbd_blocklength0;
                    705: 
                    706: #else
                    707: #error SCSI command / data structures are compiler sensitive
                    708: #endif
                    709: } mode_sel_bd_t;
                    710: 
                    711: #define MODSEL_DATA_LEN        0x30
                    712: 
                    713: typedef struct mode_sel_data {
                    714: 
                    715:        /* transferred to/from target during mode select/mode sense */
                    716:        struct mode_sel_hdr msd_header;
                    717:        struct mode_sel_bd  msd_blockdescript;
                    718:        u_char msd_vudata[MODSEL_DATA_LEN];     /* for vendor unique data */
                    719: } mode_sel_data_t;
                    720: 
                    721: /* 
                    722:  * struct for MTIOCMODSEL/ MTIOCMODSEN
                    723:  */
                    724: typedef struct modesel_parms {
                    725:        struct mode_sel_data    msp_data;
                    726:        int                     msp_bcount;     /* # of bytes to DMA */
                    727: } modesel_parms_t;
                    728: 
                    729: /*
                    730:  * Day-to-day constants in the SCSI world
                    731:  */
                    732: #define        SCSI_NTARGETS   8               /* 0 - 7 for target numbers */
                    733: #define        SCSI_NLUNS      8               /* 0 - 7 luns for each target */
                    734: 
                    735: /*
                    736:  * For SCSI-3 Wide.
                    737:  */
                    738: #define        SCSI3_NTARGETS  32
                    739: 
                    740: /*
                    741:  * Defect list header
                    742:  * Used by FORMAT and REASSIGN BLOCK commands
                    743:  */
                    744: struct defect_header {
                    745: 
                    746: #if    __BIG_ENDIAN__
                    747: 
                    748:        u_char  dh_mbz1;
                    749:        u_char  dh_fov:1,               /* format options valid */
                    750:                dh_dpry:1,              /* disable primary */
                    751:                dh_dcrt:1,              /* disable certification */
                    752:                dh_stpf:1,              /* stop format */
                    753:                dh_mbz2:4;
                    754:        u_short dh_len;                 /* items in defect list */
                    755: 
                    756: #elif  __LITTLE_ENDIAN__
                    757: 
                    758:        u_char  dh_mbz1;
                    759:        u_char  dh_mbz2         :4,
                    760:                dh_stpf         :1,
                    761:                dh_dcrt         :1,
                    762:                dh_dpry         :1,
                    763:                dh_fov          :1;
                    764:        u_char  dh_len1;
                    765:        u_char  dh_len0;
                    766: 
                    767: #else
                    768: #error SCSI command / data structures are compiler sensitive
                    769: #endif
                    770: };
                    771: 
                    772: /*
                    773:  * Status for scsi_req (see below).
                    774:  */
                    775: typedef enum {
                    776:        
                    777:        SR_IOST_GOOD    = 0,            /* successful */
                    778:        SR_IOST_SELTO   = 1,            /* selection timeout */
                    779:        SR_IOST_CHKSV   = 2,            /* check status, sr_esense */
                    780:                                        /*    valid */
                    781:        SR_IOST_CHKSNV  = 3,            /* check status, sr_esense */
                    782:                                        /*    not valid */
                    783:        SR_IOST_DMAOR   = 4,            /* target attempted to move */
                    784:                                        /*    more than sr_dma_max */
                    785:                                        /*    bytes */
                    786:        SR_IOST_IOTO    = 5,            /* sr_ioto exceeded */
                    787:        SR_IOST_BV      = 6,            /* SCSI Bus violation */
                    788:        SR_IOST_CMDREJ  = 7,            /* command reject (by 
                    789:                                         *    driver) */
                    790:        SR_IOST_MEMALL  = 8,            /* memory allocation failure */
                    791:        SR_IOST_MEMF    = 9,            /* memory fault */
                    792:        SR_IOST_PERM    = 10,           /* not super user */
                    793:        SR_IOST_NOPEN   = 11,           /* device not open */
                    794:        SR_IOST_TABT    = 12,           /* target aborted command */
                    795:        ST_IOST_BADST   = 13,           /* bad SCSI status byte  */
                    796:                                        /*  (other than check status)*/
                    797: #define        SR_IOST_BADST   ST_IOST_BADST
                    798:        ST_IOST_INT     = 14,           /* internal driver error */
                    799: #define        SR_IOST_INT     ST_IOST_INT
                    800:        SR_IOST_BCOUNT  = 15,           /* unexpected byte count */
                    801:                                        /* seen on SCSI bus */ 
                    802:        SR_IOST_VOLNA   = 16,           /* desired volume not available */
                    803:        SR_IOST_WP      = 17,           /* Media Write Protected */
                    804:        SR_IOST_ALIGN   = 18,           /* DMA alignment error */
                    805:        SR_IOST_IPCFAIL = 19,           /* Mach IPC failure */
                    806:        SR_IOST_RESET   = 20,           /* bus was reset during 
                    807:                                         * processing of command */
                    808:        SR_IOST_PARITY  = 21,           /* SCSI Bus Parity Error */
                    809:        SR_IOST_HW      = 22,           /* Gross Hardware Failure */
                    810:        SR_IOST_DMA     = 23,           /* DMA error */
                    811:        SR_IOST_INVALID = 100,          /* should never be seen */
                    812: } sc_status_t;
                    813: 
                    814: /*
                    815:  * DMA Direction.
                    816:  */
                    817: typedef enum {
                    818:        SR_DMA_RD = 0,                  /* DMA from device to host */
                    819:        SR_DMA_WR = 1,                  /* DMA from host to device */
                    820: } sc_dma_dir_t;
                    821: 
                    822: /*
                    823:  * SCSI Request used by sg driver via SGIOCREQ and internally in st driver
                    824:  */
                    825: 
                    826: typedef struct scsi_req {
                    827: 
                    828:        /*** inputs ***/
                    829:        
                    830:        cdb_t                   sr_cdb;         /* command descriptor block - 
                    831:                                                 * one of four formats */
                    832:        sc_dma_dir_t            sr_dma_dir;     /* DMA direction */
                    833:        caddr_t                 sr_addr;        /* memory addr for data 
                    834:                                                 * transfers */
                    835:        int                     sr_dma_max;     /* maximum number of bytes to
                    836:                                                 * transfer */
                    837:        int                     sr_ioto;        /* I/O timeout in seconds */
                    838:                                                 
                    839:        /*** outputs ***/
                    840:        
                    841:        int                     sr_io_status;   /* driver status */
                    842:        u_char                  sr_scsi_status; /* SCSI status byte */
                    843:        esense_reply_t          sr_esense;      /* extended sense in case of
                    844:                                                 * check status */
                    845:        int                     sr_dma_xfr;     /* actual number of bytes 
                    846:                                                 * transferred by DMA */
                    847:        struct  timeval         sr_exec_time;   /* execution time in 
                    848:                                                 * microseconds */
                    849:                                                 
                    850: #if    m68k
                    851: 
                    852:        /*** for driver's internal use ***/
                    853:        
                    854:        u_char                  sr_flags;
                    855:        queue_chain_t           sr_io_q;        /* for linking onto sgdp->
                    856:                                                 *    sdg_io_q */
                    857: #else  /* m68k */
                    858: 
                    859:        u_char                  sr_cdb_length;  /* length of CDB bytes 
                    860:                                                 *    (optional) */
                    861: 
                    862:        /*
                    863:         * Flags to disable disconnect, command queueing, synchronous 
                    864:         * transfer negotiation. Add one bit to allow chk. cond. to be 
                    865:         * ignored. 
                    866:         */
                    867: 
                    868:        u_char                  sr_discon_disable:1,
                    869:                                sr_cmd_queue_disable:1,
                    870:                                sr_sync_disable:1,
                    871:                                sr_ignore_chkcond:1,    /* to disable issuing 
                    872:                                                           of chk.cond. cmd  - 
                    873:                                                           specifically used 
                    874:                                                           for MTIOCSRQ 
                    875:                                                           requests. */
                    876:                                
                    877:                                sr_pad1:4;      
                    878: 
                    879:        u_char                  sr_pad2;
                    880:                                    
                    881:        u_char                  sr_flags;       /* driver private */
                    882:        queue_chain_t           sr_io_q;
                    883:        
                    884: #endif /* m68k */
                    885: 
                    886: } scsi_req_t;
                    887: 
                    888: /*
                    889:  * SCSI Request, with capability of 16-byte CDB
                    890:  */
                    891: 
                    892: typedef struct scsi3_req {
                    893: 
                    894:        /*** inputs ***/
                    895:        
                    896:        scsi3_cdb_t             s3r_cdb;        /* command descriptor block -                                            
                    897:                                                 * one of five formats */
                    898:        sc_dma_dir_t            s3r_dma_dir;    /* DMA direction */
                    899:        caddr_t                 s3r_addr;       /* memory addr for data 
                    900:                                                 * transfers */
                    901:        int                     s3r_dma_max;    /* maximum number of bytes to
                    902:                                                 * transfer */
                    903:        int                     s3r_ioto;       /* I/O timeout in seconds */
                    904:                                                 
                    905:        /*** outputs ***/
                    906:        
                    907:        int                     s3r_io_status;  /* driver status */
                    908:        u_char                  s3r_scsi_status; /* SCSI status byte */
                    909:        esense_reply_t          s3r_esense;     /* extended sense in case of
                    910:                                                 * check status */
                    911:        int                     s3r_dma_xfr;    /* actual number of bytes 
                    912:                                                 * transferred by DMA */
                    913:        struct  timeval         s3r_exec_time;  /* execution time in 
                    914:                                                 * microseconds */
                    915:                                                 
                    916: #if    m68k
                    917: 
                    918:        /*** for driver's internal use ***/
                    919:        
                    920:        u_char                  s3r_flags;
                    921:        queue_chain_t           s3r_io_q;       /* for linking onto sgdp->
                    922:                                                 *    sdg_io_q */
                    923: #else  /* m68k */
                    924: 
                    925:        u_char                  s3r_cdb_length; /* length of CDB bytes 
                    926:                                                 *    (optional) */
                    927: 
                    928:        /*
                    929:         * Flags to disable disconnect, command queueing, synchronous transfer
                    930:         * negotiation.
                    931:         */
                    932:        u_char                  s3r_discon_disable:1,
                    933:                                s3r_cmd_queue_disable:1,
                    934:                                s3r_sync_disable:1,
                    935:                                s3r_pad1:5;
                    936:        u_char                  s3r_pad2;
                    937:                                    
                    938:        u_char                  s3r_flags;      /* driver private */
                    939:        queue_chain_t           s3r_io_q;
                    940:        
                    941: #endif /* m68k */
                    942: 
                    943: } scsi3_req_t;
                    944: 
                    945: /*
                    946:  * SCSI-2 address specifier.
                    947:  */
                    948: typedef struct scsi_adr {
                    949: 
                    950:        u_char                  sa_target;
                    951:        u_char                  sa_lun;
                    952:        
                    953: } scsi_adr_t;
                    954: 
                    955: /*
                    956:  * SCSI-3 address specifier.
                    957:  */
                    958: typedef struct scsi3_adr {
                    959: 
                    960:        unsigned long long      s3a_target;
                    961:        unsigned long long      s3a_lun;
                    962:        
                    963: } scsi3_adr_t;
                    964: 
                    965: 
                    966: /*
                    967:  *     Generic SCSI ioctl requests
                    968:  */
                    969:  
                    970: #define SGIOCSTL       _IOW ('s', 0, struct scsi_adr)  /* set target/lun */
                    971: #define        SGIOCREQ        _IOWR('s', 1, struct scsi_req)  /* cmd request */
                    972: #define SGIOCENAS      _IO(  's', 2)                   /* enable autosense */
                    973: #define SGIOCDAS       _IO(  's', 3)                   /* disable autosense */
                    974: #define SGIOCRST       _IO(  's', 4)                   /* reset SCSI bus */
                    975: #define SGIOCCNTR       _IOW( 's', 6, int)              /* select controller */
                    976: #define SGIOCGAS       _IOR( 's', 7, int)              /* get autosense */
                    977: #define SGIOCMAXDMA    _IOR( 's', 8, int)              /* max DMA size */
                    978: #define SGIOCNUMTARGS  _IOR( 's', 9, int)              /* # of targets/bus */
                    979: 
                    980: /*
                    981:  *     ioctl requests specific to SCSI disks
                    982:  */
                    983: #define        SDIOCSRQ        _IOWR('s', 1, struct scsi_req)  /* cmd request using */
                    984:                                                        /* struct scsi_req */
                    985: 
                    986: #define SDIOCGETCAP    _IOR  ('s', 5, struct capacity_reply)
                    987:                                                        /* Get Read 
                    988:                                                         * Capacity info */
                    989: 
                    990: /* 
                    991:  *     ioctl requests specific to SCSI tapes 
                    992:  */
                    993:  
                    994: #define        MTIOCFIXBLK     _IOW('m', 5, int )      /* set fixed block mode */
                    995: #define MTIOCVARBLK    _IO('m',  6)            /* set variable block mode */
                    996: #define MTIOCMODSEL    _IOW('m', 7, struct modesel_parms)      
                    997:                                                /* mode select */
                    998: #define MTIOCMODSEN    _IOWR('m',8, struct modesel_parms)      
                    999:                                                /* mode sense */
                   1000: #define MTIOCINILL     _IO('m',  9)            /* inhibit illegal length */
                   1001:                                                /*    errors */
                   1002: #define MTIOCALILL     _IO('m',  10)           /* allow illegal length */
                   1003:                                                /*    errors */
                   1004: #define        MTIOCSRQ        _IOWR('m', 11, struct scsi_req)         
                   1005:                                                /* cmd request using 
                   1006:                                                 * struct scsi_req */
                   1007: 
                   1008: /*
                   1009:  * SCSI-3 ioctl requests
                   1010:  *
                   1011:  * Generic SCSI:
                   1012:  */
                   1013: #define SGIOCSTL3      _IOW ('s', 12, struct scsi3_adr) /* set target/lun */
                   1014: #define SGIOCGTL3      _IOR ('s', 13, struct scsi3_adr) /* get target/lun */
                   1015: #define        SGIOCREQ3       _IOWR('s', 14, struct scsi3_req) /* cmd request */
                   1016: 
                   1017: /*
                   1018:  * Disk
                   1019:  */
                   1020: #define        SDIOCSRQ3       _IOWR('s', 15, struct scsi3_req) /* cmd request */
                   1021: 
                   1022: /*
                   1023:  * Tape
                   1024:  */
                   1025: #define        MTIOCSRQ3       _IOWR('m', 15, struct scsi3_req) /* cmd request */
                   1026: 
                   1027: #endif /* _BSD_DEV_SCSIREG_ */
                   1028: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.