1*52130Smckusick /* 2*52130Smckusick * Copyright (c) 1992 Regents of the University of California. 3*52130Smckusick * All rights reserved. 4*52130Smckusick * 5*52130Smckusick * This code is derived from software contributed to Berkeley by 6*52130Smckusick * Ralph Campbell. 7*52130Smckusick * 8*52130Smckusick * %sccs.include.redist.c% 9*52130Smckusick * 10*52130Smckusick * @(#)scsi.h 7.1 (Berkeley) 01/07/92 11*52130Smckusick * 12*52130Smckusick * scsi.h -- 13*52130Smckusick * 14*52130Smckusick * Common declarations for SCSI command formaters. This file only covers 15*52130Smckusick * definitions pertaining to the SCSI common command set that are 16*52130Smckusick * common to all SCSI device types (ie disk, tapes, WORM, printers, etc). 17*52130Smckusick * Some of the references from the proceedings of the 18*52130Smckusick * 1984 Mini/Micro Northeast conference might help in understanding SCSI. 19*52130Smckusick * 20*52130Smckusick * from: $Header: /sprite/src/kernel/dev/RCS/scsi.h, 21*52130Smckusick * v 9.1 90/02/13 23:11:24 jhh Exp $ SPRITE (Berkeley) 22*52130Smckusick */ 23*52130Smckusick 24*52130Smckusick #ifndef _SCSI_H 25*52130Smckusick #define _SCSI_H 26*52130Smckusick 27*52130Smckusick /* 28*52130Smckusick * "Standard" SCSI Commands. 29*52130Smckusick * SCSI commands are divided into 8 groups as follows: 30*52130Smckusick * Group0 (0x00 - 0x1f). Basic commands. 6 bytes long 31*52130Smckusick * Group1 (0x20 - 0x3f). Extended command. 10 bytes. 32*52130Smckusick * Group2 (0x40 - 0x5f). Reserved. 33*52130Smckusick * Group2 (0x60 - 0x7f). Reserved. 34*52130Smckusick * Group2 (0x80 - 0x9f). Reserved. 35*52130Smckusick * Group2 (0xa0 - 0xbf). Reserved. 36*52130Smckusick * Group6 (0xc0 - 0xdf). Vendor Unique 37*52130Smckusick * Group7 (0xe0 - 0xff). Vendor Unique 38*52130Smckusick */ 39*52130Smckusick 40*52130Smckusick /* 41*52130Smckusick * Scsi Group0 commands all are 6 bytes and have a format according to 42*52130Smckusick * struct ScsiGroup0Cmd. 43*52130Smckusick */ 44*52130Smckusick #define SCSI_TEST_UNIT_READY 0x00 45*52130Smckusick #define SCSI_REZERO_UNIT 0x01 46*52130Smckusick #define SCSI_REWIND 0x01 47*52130Smckusick #define SCSI_REQUEST_SENSE 0x03 48*52130Smckusick #define SCSI_FORMAT_UNIT 0x04 49*52130Smckusick #define SCSI_READ_BLOCK_LIMITS 0x05 50*52130Smckusick #define SCSI_REASSIGN_BLOCKS 0x07 51*52130Smckusick #define SCSI_READ 0x08 52*52130Smckusick #define SCSI_WRITE 0x0a 53*52130Smckusick #define SCSI_SEEK 0x0b 54*52130Smckusick #define SCSI_TRACK_SELECT 0x0b 55*52130Smckusick #define SCSI_READ_REVERSE 0x0f 56*52130Smckusick #define SCSI_WRITE_EOF 0x10 57*52130Smckusick #define SCSI_SPACE 0x11 58*52130Smckusick #define SCSI_INQUIRY 0x12 59*52130Smckusick #define SCSI_VERIFY 0x13 60*52130Smckusick #define SCSI_READ_BUFFER 0x14 61*52130Smckusick #define SCSI_MODE_SELECT 0x15 62*52130Smckusick #define SCSI_RESERVE_UNIT 0x16 63*52130Smckusick #define SCSI_RELEASE_UNIT 0x17 64*52130Smckusick #define SCSI_COPY 0x18 65*52130Smckusick #define SCSI_ERASE_TAPE 0x19 66*52130Smckusick #define SCSI_MODE_SENSE 0x1a 67*52130Smckusick #define SCSI_START_STOP 0x1b 68*52130Smckusick #define SCSI_LOAD_UNLOAD 0x1b 69*52130Smckusick #define SCSI_RECV_DIAG_RESULTS 0x1c 70*52130Smckusick #define SCSI_SEND_DIAGNOSTIC 0x1d 71*52130Smckusick #define SCSI_PREVENT_ALLOW 0x1e 72*52130Smckusick 73*52130Smckusick /* 74*52130Smckusick * Group1 commands are all 10 bytes and have a format according to 75*52130Smckusick * struct ScsiGroup1Cmd. 76*52130Smckusick */ 77*52130Smckusick #define SCSI_READ_CAPACITY 0x25 78*52130Smckusick #define SCSI_READ_EXT 0x28 79*52130Smckusick #define SCSI_WRITE_EXT 0x2a 80*52130Smckusick #define SCSI_SEEK_EXT 0x2b 81*52130Smckusick #define SCSI_WRITE_VERIFY 0x2e 82*52130Smckusick #define SCSI_VERIFY_EXT 0x2f 83*52130Smckusick #define SCSI_SEARCH_HIGH 0x30 84*52130Smckusick #define SCSI_SEARCH_EQUAL 0x31 85*52130Smckusick #define SCSI_SEARCH_LOW 0x32 86*52130Smckusick #define SCSI_SET_LIMITS 0x33 87*52130Smckusick #define SCSI_COMPARE 0x39 88*52130Smckusick #define SCSI_COPY_VERIFY 0x3a 89*52130Smckusick 90*52130Smckusick /* 91*52130Smckusick * Control byte flags for Group0 and Group1 commands. 92*52130Smckusick * 93*52130Smckusick * SCSI_CTRL_LINK - This is used to prevent a bus free phase between commands. 94*52130Smckusick * If the command terminates successfully, a SCSI_LINKED_CMD_COMPLETE 95*52130Smckusick * message is returned instead of the normal SCSI_COMMAND_COMPLETE message. * The last command in a chain should not have this bit set 96*52130Smckusick * (and consequently gets a normal SCSI_COMMAND_COMPLETE message). 97*52130Smckusick * SCSI_CTRL_LINK_FLAG - This bit should only set when SCSI_CTRL_LINK is set and 98*52130Smckusick * causes a SCSI_LINKED_FLAGED_CMD_COMPLETE to be returned instead of 99*52130Smckusick * a SCSI_LINKED_CMD_COMPLETE. 100*52130Smckusick */ 101*52130Smckusick #define SCSI_CTRL_LINK 0x01 /* Link commands (no bus free phase) */ 102*52130Smckusick #define SCSI_CTRL_LINK_INTR 0x02 /* Interrupt after linked command */ 103*52130Smckusick 104*52130Smckusick /* 105*52130Smckusick * The standard group0 6-byte SCSI control block. Note that the 106*52130Smckusick * fields between highAddr and blockCount inclusive are command dependent. 107*52130Smckusick * The definitions Addr and BlockCount cover most of the commands we will 108*52130Smckusick * use. 109*52130Smckusick */ 110*52130Smckusick typedef struct ScsiGroup0Cmd { 111*52130Smckusick u_char command; /* command code, defined below. The 112*52130Smckusick * upper three bits of this are zero 113*52130Smckusick * to indicate the control block is 114*52130Smckusick * only 6 bytes long */ 115*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 116*52130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 117*52130Smckusick * pass the command. The device 118*52130Smckusick * has already been selected using 119*52130Smckusick * the "targetID" bit. */ 120*52130Smckusick u_char highAddr :5; /* High bits of address */ 121*52130Smckusick #else 122*52130Smckusick u_char highAddr :5; /* High bits of address */ 123*52130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 124*52130Smckusick * pass the command. The device 125*52130Smckusick * has already been selected using 126*52130Smckusick * the "targetID" bit. */ 127*52130Smckusick #endif 128*52130Smckusick u_char midAddr; /* Middle bits of address */ 129*52130Smckusick u_char lowAddr; /* Low bits of address */ 130*52130Smckusick u_char blockCount; /* Blocks to transfer */ 131*52130Smckusick u_char control; /* See flags for common bits */ 132*52130Smckusick } ScsiGroup0Cmd; 133*52130Smckusick 134*52130Smckusick /* 135*52130Smckusick * Format of a SCSI_START_STOP command. This is a group 0 command, but 136*52130Smckusick * the command contents are different. 137*52130Smckusick */ 138*52130Smckusick typedef struct ScsiStartStopCmd { 139*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 140*52130Smckusick u_char command; /* command code, defined below. The 141*52130Smckusick * upper three bits of this are zero 142*52130Smckusick * to indicate the control block is 143*52130Smckusick * only 6 bytes long */ 144*52130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 145*52130Smckusick * pass the command. The device 146*52130Smckusick * has already been selected using 147*52130Smckusick * the "targetID" bit. */ 148*52130Smckusick u_char pad1 :4; /* Reserved */ 149*52130Smckusick u_char immed :1; /* Immediate status bit */ 150*52130Smckusick u_char pad2; /* Reserved */ 151*52130Smckusick u_char pad3; /* Reserved */ 152*52130Smckusick u_char pad4 :6; /* Reserved */ 153*52130Smckusick u_char loadEject :1; /* Load or eject medium */ 154*52130Smckusick u_char start :1; /* Start or stop medium */ 155*52130Smckusick u_char control; /* See flags for common bits */ 156*52130Smckusick #else 157*52130Smckusick u_char command; /* command code, defined below. The 158*52130Smckusick * upper three bits of this are zero 159*52130Smckusick * to indicate the control block is 160*52130Smckusick * only 6 bytes long */ 161*52130Smckusick u_char immed :1; /* Immediate status bit */ 162*52130Smckusick u_char pad1 :4; /* Reserved */ 163*52130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 164*52130Smckusick * pass the command. The device 165*52130Smckusick * has already been selected using 166*52130Smckusick * the "targetID" bit. */ 167*52130Smckusick u_char pad2; /* Reserved */ 168*52130Smckusick u_char pad3; /* Reserved */ 169*52130Smckusick u_char start :1; /* Start or stop medium */ 170*52130Smckusick u_char loadEject :1; /* Load or eject medium */ 171*52130Smckusick u_char pad4 :6; /* Reserved */ 172*52130Smckusick u_char control; /* See flags for common bits */ 173*52130Smckusick #endif 174*52130Smckusick } ScsiStartStopCmd; 175*52130Smckusick 176*52130Smckusick /* 177*52130Smckusick * The standard group1 10-byte SCSI control block. Note that the 178*52130Smckusick * fields between highAddr and blockCount inclusive are command dependent. 179*52130Smckusick * The definitions Addr and BlockCount cover most of the commands we will 180*52130Smckusick * use. 181*52130Smckusick */ 182*52130Smckusick typedef struct ScsiGroup1Cmd { 183*52130Smckusick u_char command; /* command code, defined below. The 184*52130Smckusick * upper three bits of this are zero 185*52130Smckusick * to indicate the control block is 186*52130Smckusick * only 6 bytes long */ 187*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 188*52130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 189*52130Smckusick * pass the command. The device 190*52130Smckusick * has already been selected using 191*52130Smckusick * the "targetID" bit. */ 192*52130Smckusick u_char pad1 :5; /* Reserved */ 193*52130Smckusick #else 194*52130Smckusick u_char pad1 :5; /* Reserved */ 195*52130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 196*52130Smckusick * pass the command. The device 197*52130Smckusick * has already been selected using 198*52130Smckusick * the "targetID" bit. */ 199*52130Smckusick #endif 200*52130Smckusick u_char highAddr; /* High bits of address */ 201*52130Smckusick u_char midHighAddr; /* Middle high bits of address */ 202*52130Smckusick u_char midLowAddr; /* Middle low bits of address */ 203*52130Smckusick u_char lowAddr; /* Low bits of address */ 204*52130Smckusick u_char pad2; /* Reserved */ 205*52130Smckusick u_char highBlockCount; /* High bits of blocks to transfer */ 206*52130Smckusick u_char lowBlockCount; /* Low bits of blocks to transfer */ 207*52130Smckusick u_char control; /* See flags for common bits */ 208*52130Smckusick } ScsiGroup1Cmd; 209*52130Smckusick 210*52130Smckusick /* 211*52130Smckusick * SCSI status completion information. 212*52130Smckusick * This is returned by the device when a command completes. 213*52130Smckusick */ 214*52130Smckusick #define SCSI_STATUS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */ 215*52130Smckusick #define SCSI_STATUS_CONDMET 0x04 /* Condition Met (ie., search worked) */ 216*52130Smckusick #define SCSI_STATUS_BUSY 0x08 217*52130Smckusick #define SCSI_STATUS_INTERMED 0x10 /* Intermediate status sent */ 218*52130Smckusick #define SCSI_STATUS_EXT 0x80 /* Extended status valid */ 219*52130Smckusick 220*52130Smckusick /* 221*52130Smckusick * Sense information provided after some errors. This is divided into 222*52130Smckusick * two kinds, classes 0-6, and class 7. This is 30 bytes big to allow 223*52130Smckusick * for the drive specific sense bytes that follow the standard 4 byte header. 224*52130Smckusick * 225*52130Smckusick * For extended sense, this buffer may be cast into another type. Also 226*52130Smckusick * The actual size of the sense data returned is used to detect what 227*52130Smckusick * kind of tape drive is out there. Kludgy, but true. 228*52130Smckusick */ 229*52130Smckusick typedef struct ScsiClass0Sense { 230*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 231*52130Smckusick u_char valid :1; /* Sense data is valid */ 232*52130Smckusick u_char error :7; /* 3 bits class and 4 bits code */ 233*52130Smckusick #else 234*52130Smckusick u_char error :7; /* 3 bits class and 4 bits code */ 235*52130Smckusick u_char valid :1; /* Sense data is valid */ 236*52130Smckusick #endif 237*52130Smckusick u_char highAddr; /* High byte of block address */ 238*52130Smckusick u_char midAddr; /* Middle byte of block address */ 239*52130Smckusick u_char lowAddr; /* Low byte of block address */ 240*52130Smckusick u_char sense[26]; /* Target specific sense data */ 241*52130Smckusick } ScsiClass0Sense; 242*52130Smckusick 243*52130Smckusick /* 244*52130Smckusick * Definitions for errors in the sense data. The error field is specified 245*52130Smckusick * as a 3 bit class and 4 bit code, but it is easier to treat it as a 246*52130Smckusick * single 7 bit field. 247*52130Smckusick */ 248*52130Smckusick #define SCSI_NO_SENSE_DATA 0x00 249*52130Smckusick #define SCSI_NOT_READY 0x04 250*52130Smckusick #define SCSI_NOT_LOADED 0x09 251*52130Smckusick #define SCSI_INSUF_CAPACITY 0x0a 252*52130Smckusick #define SCSI_HARD_DATA_ERROR 0x11 253*52130Smckusick #define SCSI_WRITE_PROTECT 0x17 254*52130Smckusick #define SCSI_CORRECTABLE_ERROR 0x18 255*52130Smckusick #define SCSI_FILE_MARK 0x1c 256*52130Smckusick #define SCSI_INVALID_COMMAND 0x20 257*52130Smckusick #define SCSI_UNIT_ATTENTION 0x30 258*52130Smckusick #define SCSI_END_OF_MEDIA 0x34 259*52130Smckusick 260*52130Smckusick /* 261*52130Smckusick * The standard "extended" sense data returned by SCSI devices. This 262*52130Smckusick * has an error field of 0x70, for a "class 7" error. 263*52130Smckusick */ 264*52130Smckusick typedef struct ScsiClass7Sense { 265*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 266*52130Smckusick u_char valid :1; /* Sense data is valid */ 267*52130Smckusick u_char error7 :7; /* == 0x70 */ 268*52130Smckusick u_char pad1; /* Also "segment number" for copy */ 269*52130Smckusick u_char fileMark :1; /* File mark on device */ 270*52130Smckusick u_char endOfMedia :1; /* End of media reached */ 271*52130Smckusick u_char badBlockLen :1; /* Block length mis-match (Exabyte) */ 272*52130Smckusick u_char pad2 :1; 273*52130Smckusick u_char key :4; /* Sense keys defined below */ 274*52130Smckusick u_char info1; /* Information byte 1 */ 275*52130Smckusick u_char info2; /* Information byte 2 */ 276*52130Smckusick u_char info3; /* Information byte 3 */ 277*52130Smckusick u_char info4; /* Information byte 4 */ 278*52130Smckusick u_char length; /* Number of additional info bytes */ 279*52130Smckusick #else 280*52130Smckusick u_char error7 :7; /* == 0x70 */ 281*52130Smckusick u_char valid :1; /* Sense data is valid */ 282*52130Smckusick u_char pad1; /* Also "segment number" for copy */ 283*52130Smckusick u_char key :4; /* Sense keys defined below */ 284*52130Smckusick u_char pad2 :1; 285*52130Smckusick u_char badBlockLen :1; /* Block length mis-match (Exabyte) */ 286*52130Smckusick u_char endOfMedia :1; /* End of media reached */ 287*52130Smckusick u_char fileMark :1; /* File mark on device */ 288*52130Smckusick u_char info1; /* Information byte 1 */ 289*52130Smckusick u_char info2; /* Information byte 2 */ 290*52130Smckusick u_char info3; /* Information byte 3 */ 291*52130Smckusick u_char info4; /* Information byte 4 */ 292*52130Smckusick u_char length; /* Number of additional info bytes */ 293*52130Smckusick #endif 294*52130Smckusick } ScsiClass7Sense; /* 8 Bytes */ 295*52130Smckusick 296*52130Smckusick /* 297*52130Smckusick * Key values for standardized sense class 7. 298*52130Smckusick */ 299*52130Smckusick #define SCSI_CLASS7_NO_SENSE 0 300*52130Smckusick #define SCSI_CLASS7_RECOVERABLE 1 301*52130Smckusick #define SCSI_CLASS7_NOT_READY 2 302*52130Smckusick #define SCSI_CLASS7_MEDIA_ERROR 3 303*52130Smckusick #define SCSI_CLASS7_HARDWARE_ERROR 4 304*52130Smckusick #define SCSI_CLASS7_ILLEGAL_REQUEST 5 305*52130Smckusick 306*52130Smckusick /* 307*52130Smckusick * These seem to have different meanings to different vendors.... 308*52130Smckusick */ 309*52130Smckusick #define SCSI_CLASS7_MEDIA_CHANGE 6 310*52130Smckusick #define SCSI_CLASS7_UNIT_ATTN 6 311*52130Smckusick 312*52130Smckusick #define SCSI_CLASS7_WRITE_PROTECT 7 313*52130Smckusick #define SCSI_CLASS7_BLANK_CHECK 8 314*52130Smckusick #define SCSI_CLASS7_VENDOR 9 315*52130Smckusick #define SCSI_CLASS7_POWER_UP_FAILURE 10 316*52130Smckusick #define SCSI_CLASS7_ABORT 11 317*52130Smckusick #define SCSI_CLASS7_EQUAL 12 318*52130Smckusick #define SCSI_CLASS7_OVERFLOW 13 319*52130Smckusick #define SCSI_CLASS7_RESERVED_14 14 320*52130Smckusick #define SCSI_CLASS7_RESERVED_15 15 321*52130Smckusick 322*52130Smckusick /* 323*52130Smckusick * Data return by the SCSI inquiry command. 324*52130Smckusick */ 325*52130Smckusick typedef struct ScsiInquiryData { 326*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 327*52130Smckusick u_char type; /* Peripheral Device type. See below. */ 328*52130Smckusick u_char rmb:1; /* Removable Medium bit. */ 329*52130Smckusick u_char qualifier:7; /* Device type qualifier. */ 330*52130Smckusick u_char version; /* Version info. */ 331*52130Smckusick u_char reserved:4; /* reserved. */ 332*52130Smckusick u_char format:4; /* Response format. */ 333*52130Smckusick u_char length; /* length of data returned. */ 334*52130Smckusick u_char reserved2[2]; /* Reserved */ 335*52130Smckusick u_char flags; /* SCSI II flags (see below) */ 336*52130Smckusick u_char vendorID[8]; /* Vendor ID (ASCII) */ 337*52130Smckusick u_char productID[16]; /* Product ID (ASCII) */ 338*52130Smckusick u_char revLevel[4]; /* Revision level (ASCII) */ 339*52130Smckusick u_char revData[8]; /* Revision data (ASCII) */ 340*52130Smckusick #else 341*52130Smckusick u_char type; /* Peripheral Device type. See below. */ 342*52130Smckusick u_char qualifier:7; /* Device type qualifier. */ 343*52130Smckusick u_char rmb:1; /* Removable Medium bit. */ 344*52130Smckusick u_char version; /* Version info. */ 345*52130Smckusick u_char format:4; /* Response format. */ 346*52130Smckusick u_char reserved:4; /* reserved. */ 347*52130Smckusick u_char length; /* length of data returned. */ 348*52130Smckusick u_char reserved2[2]; /* Reserved */ 349*52130Smckusick u_char flags; /* SCSI II flags (see below) */ 350*52130Smckusick u_char vendorID[8]; /* Vendor ID (ASCII) */ 351*52130Smckusick u_char productID[16]; /* Product ID (ASCII) */ 352*52130Smckusick u_char revLevel[4]; /* Revision level (ASCII) */ 353*52130Smckusick u_char revData[8]; /* Revision data (ASCII) */ 354*52130Smckusick #endif 355*52130Smckusick } ScsiInquiryData; 356*52130Smckusick 357*52130Smckusick /* 358*52130Smckusick * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command. 359*52130Smckusick * 360*52130Smckusick * SCSI_DISK_TYPE - Direct Access Device. 361*52130Smckusick * SCSI_TAPE_TYPE - Sequential Access Device. 362*52130Smckusick * SCSI_PRINTER_TYPE - Printer Device. 363*52130Smckusick * SCSI_HOST_TYPE - Processor Device. 364*52130Smckusick * SCSI_WORM_TYPE - Write-Once Read-Multiple Device. 365*52130Smckusick * SCSI_ROM_TYPE - Read-Only Direct Access Device. 366*52130Smckusick * SCSI_SCANNER_TYPE - Scanner device. 367*52130Smckusick * SCSI_OPTICAL_MEM_TYPE - Optical memory device. 368*52130Smckusick * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device. 369*52130Smckusick * SCSI_COMMUNICATIONS_TYPE - Communications device. 370*52130Smckusick * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented. 371*52130Smckusick * 372*52130Smckusick * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique. 373*52130Smckusick */ 374*52130Smckusick #define SCSI_DISK_TYPE 0 375*52130Smckusick #define SCSI_TAPE_TYPE 1 376*52130Smckusick #define SCSI_PRINTER_TYPE 2 377*52130Smckusick #define SCSI_HOST_TYPE 3 378*52130Smckusick #define SCSI_WORM_TYPE 4 379*52130Smckusick #define SCSI_ROM_TYPE 5 380*52130Smckusick #define SCSI_SCANNER_TYPE 6 381*52130Smckusick #define SCSI_OPTICAL_MEM_TYPE 7 382*52130Smckusick #define SCSI_MEDIUM_CHANGER_TYPE 8 383*52130Smckusick #define SCSI_COMMUNICATIONS_TYPE 9 384*52130Smckusick #define SCSI_NODEVICE_TYPE 0x7f 385*52130Smckusick 386*52130Smckusick /* 387*52130Smckusick * The SCSI I & II inquiry flags. 388*52130Smckusick * 389*52130Smckusick * SCSI_REL_ADR - Relative addressing supported. 390*52130Smckusick * SCSI_WIDE_32 - 32 bit wide SCSI bus transfers supported. 391*52130Smckusick * SCSI_WIDE_16 - 16 bit wide SCSI bus transfers supported. 392*52130Smckusick * SCSI_SYNC - Synchronous data transfers supported. 393*52130Smckusick * SCSI_LINKED - Linked commands supported. 394*52130Smckusick * SCSI_CMD_QUEUE - Tagged command queuing supported. 395*52130Smckusick * SCSI_SOFT_RESET - Soft RESET alternative suported. 396*52130Smckusick */ 397*52130Smckusick #define SCSI_REL_ADR 0x80 398*52130Smckusick #define SCSI_WIDE_32 0x40 399*52130Smckusick #define SCSI_WIDE_16 0x20 400*52130Smckusick #define SCSI_SYNC 0x10 401*52130Smckusick #define SCSI_LINKED 0x08 402*52130Smckusick #define SCSI_CMD_QUEUE 0x02 403*52130Smckusick #define SCSI_SOFT_RESET 0x01 404*52130Smckusick 405*52130Smckusick /* 406*52130Smckusick * Standard header for SCSI_MODE_SELECT commands for tapes. 407*52130Smckusick */ 408*52130Smckusick typedef struct ScsiTapeModeSelectHdr { 409*52130Smckusick #if BYTE_ORDER == BIG_ENDIAN 410*52130Smckusick u_char reserved[2]; /* Reserved. */ 411*52130Smckusick u_char reserved2:1; /* "" */ 412*52130Smckusick u_char bufferedMode:3; /* Type of buffer to be done. */ 413*52130Smckusick u_char speed:4; /* Drive speed. */ 414*52130Smckusick u_char length; /* Block descriptor length. */ 415*52130Smckusick #else 416*52130Smckusick u_char reserved[2]; /* Reserved. */ 417*52130Smckusick u_char speed:4; /* Drive speed. */ 418*52130Smckusick u_char bufferedMode:3; /* Type of buffer to be done. */ 419*52130Smckusick u_char reserved2:1; /* "" */ 420*52130Smckusick u_char length; /* Block descriptor length. */ 421*52130Smckusick #endif 422*52130Smckusick } ScsiTapeModeSelectHdr; 423*52130Smckusick 424*52130Smckusick /* 425*52130Smckusick * Definitions of SCSI messages. 426*52130Smckusick * 427*52130Smckusick * SCSI_COMMAND_COMPLETE - After a command has completed, successfully 428*52130Smckusick * or not, this is returned to the host from the target. 429*52130Smckusick * 430*52130Smckusick * SCSI_EXTENDED_MSG - Indicates that a multi-byte message is being sent. 431*52130Smckusick * 432*52130Smckusick * The following messages are used with connect/disconnect: 433*52130Smckusick * SCSI_SAVE_DATA_POINTER - Sent from target to host to request saving 434*52130Smckusick * of current DMA address and count. Indicates a pending dis-connect. 435*52130Smckusick * SCSI_RESTORE_POINTER - Sent from the target to the host to request 436*52130Smckusick * restoring pointers saved before a disconnect 437*52130Smckusick * SCSI_DISCONNECT - Sent from the target to the host to disconnect. 438*52130Smckusick * SCSI_ABORT - Sent from the host to the target to abort current request. 439*52130Smckusick * SCSI_MESSAGE_REJECT - Indicates receipt, by either host or target, of 440*52130Smckusick * an unimplemented message. 441*52130Smckusick * SCSI_NO_OP - Sent from host to target if it has no real message to send. 442*52130Smckusick * SCSI_MESSAGE_PARITY_ERROR - Sent from host to target on message parity error 443*52130Smckusick * SCSI_BUS_RESET - Sent from host to target to reset all current I/O 444*52130Smckusick * 445*52130Smckusick * SCSI_IDENTIFY - The low order two bits of this message type indicate 446*52130Smckusick * the Logical Unit of the Target which is requesting a reconnect. 447*52130Smckusick * SCSI_DIS_REC_IDENTIFY - Sent from the host to a target to indicate 448*52130Smckusick * is supports connect/dis-connect 449*52130Smckusick * 450*52130Smckusick */ 451*52130Smckusick #define SCSI_COMMAND_COMPLETE 0x00 452*52130Smckusick #define SCSI_EXTENDED_MSG 0x01 453*52130Smckusick #define SCSI_SAVE_DATA_POINTER 0x02 454*52130Smckusick #define SCSI_RESTORE_POINTERS 0x03 455*52130Smckusick #define SCSI_DISCONNECT 0x04 456*52130Smckusick #define SCSI_ABORT 0x06 457*52130Smckusick #define SCSI_MESSAGE_REJECT 0x07 458*52130Smckusick #define SCSI_NO_OP 0x08 459*52130Smckusick #define SCSI_MESSAGE_PARITY_ERROR 0x09 460*52130Smckusick #define SCSI_LINKED_CMD_COMPLETE 0x0A 461*52130Smckusick #define SCSI_LINKED_FLAGED_CMD_COMPLETE 0x0B 462*52130Smckusick #define SCSI_BUS_RESET 0x0C 463*52130Smckusick 464*52130Smckusick #define SCSI_IDENTIFY 0x80 465*52130Smckusick #define SCSI_DIS_REC_IDENTIFY 0xc0 466*52130Smckusick 467*52130Smckusick /* 468*52130Smckusick * Extended message types (2nd byte of SCSI_EXTENDED_MSG). 469*52130Smckusick */ 470*52130Smckusick #define SCSI_MODIFY_DATA_PTR 0x00 471*52130Smckusick #define SCSI_SYNCHRONOUS_XFER 0x01 472*52130Smckusick #define SCSI_EXTENDED_IDENTIFY 0x02 /* only in SCSI I */ 473*52130Smckusick #define SCSI_WIDE_XFER 0x03 474*52130Smckusick 475*52130Smckusick /* 476*52130Smckusick * Driver ioctl's for various scsi operations. 477*52130Smckusick */ 478*52130Smckusick #ifndef _IOCTL_ 479*52130Smckusick #include "ioctl.h" 480*52130Smckusick #endif 481*52130Smckusick 482*52130Smckusick /* 483*52130Smckusick * Control for SCSI "format" mode. 484*52130Smckusick * 485*52130Smckusick * "Format" mode allows a privileged process to issue direct SCSI 486*52130Smckusick * commands to a drive (it is intended primarily to allow on-line 487*52130Smckusick * formatting). SDIOCSFORMAT with a non-zero arg will put the drive 488*52130Smckusick * into format mode; a zero arg will take it out. When in format 489*52130Smckusick * mode, only the process that issued the SDIOCFORMAT can read or 490*52130Smckusick * write the drive. 491*52130Smckusick * 492*52130Smckusick * In format mode, process is expected to 493*52130Smckusick * - do SDIOCSCSICOMMAND to supply cdb for next SCSI op 494*52130Smckusick * - do read or write as appropriate for cdb 495*52130Smckusick * - if i/o error, optionally do SDIOCSENSE to get completion 496*52130Smckusick * status and sense data from last scsi operation. 497*52130Smckusick */ 498*52130Smckusick 499*52130Smckusick struct scsi_fmt_cdb { 500*52130Smckusick int len; /* cdb length (in bytes) */ 501*52130Smckusick u_char cdb[28]; /* cdb to use on next read/write */ 502*52130Smckusick }; 503*52130Smckusick 504*52130Smckusick struct scsi_fmt_sense { 505*52130Smckusick u_int status; /* completion status of last op */ 506*52130Smckusick u_char sense[32]; /* sense data (if any) from last op */ 507*52130Smckusick }; 508*52130Smckusick 509*52130Smckusick #define SDIOCSFORMAT _IOW('S', 0x1, int) 510*52130Smckusick #define SDIOCGFORMAT _IOR('S', 0x2, int) 511*52130Smckusick #define SDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb) 512*52130Smckusick #define SDIOCSENSE _IOR('S', 0x4, struct scsi_fmt_sense) 513*52130Smckusick 514*52130Smckusick #ifdef KERNEL 515*52130Smckusick /* 516*52130Smckusick * Routines. 517*52130Smckusick */ 518*52130Smckusick extern void scsiGroup0Cmd(); 519*52130Smckusick extern void scsiGroup1Cmd(); 520*52130Smckusick #endif KERNEL 521*52130Smckusick 522*52130Smckusick #endif /* _SCSI_H */ 523