152130Smckusick /* 2*63207Sbostic * Copyright (c) 1992, 1993 3*63207Sbostic * The Regents of the University of California. All rights reserved. 452130Smckusick * 552130Smckusick * This code is derived from software contributed to Berkeley by 652130Smckusick * Ralph Campbell. 752130Smckusick * 852130Smckusick * %sccs.include.redist.c% 952130Smckusick * 10*63207Sbostic * @(#)scsi.h 8.1 (Berkeley) 06/10/93 1152130Smckusick * 1252130Smckusick * scsi.h -- 1352130Smckusick * 1452130Smckusick * Common declarations for SCSI command formaters. This file only covers 1552130Smckusick * definitions pertaining to the SCSI common command set that are 1652130Smckusick * common to all SCSI device types (ie disk, tapes, WORM, printers, etc). 1752130Smckusick * Some of the references from the proceedings of the 1852130Smckusick * 1984 Mini/Micro Northeast conference might help in understanding SCSI. 1952130Smckusick * 2052130Smckusick * from: $Header: /sprite/src/kernel/dev/RCS/scsi.h, 2152130Smckusick * v 9.1 90/02/13 23:11:24 jhh Exp $ SPRITE (Berkeley) 2252130Smckusick */ 2352130Smckusick 2452130Smckusick #ifndef _SCSI_H 2552130Smckusick #define _SCSI_H 2652130Smckusick 2752130Smckusick /* 2852130Smckusick * "Standard" SCSI Commands. 2952130Smckusick * SCSI commands are divided into 8 groups as follows: 3052130Smckusick * Group0 (0x00 - 0x1f). Basic commands. 6 bytes long 3152130Smckusick * Group1 (0x20 - 0x3f). Extended command. 10 bytes. 3252130Smckusick * Group2 (0x40 - 0x5f). Reserved. 3352130Smckusick * Group2 (0x60 - 0x7f). Reserved. 3452130Smckusick * Group2 (0x80 - 0x9f). Reserved. 3552130Smckusick * Group2 (0xa0 - 0xbf). Reserved. 3652130Smckusick * Group6 (0xc0 - 0xdf). Vendor Unique 3752130Smckusick * Group7 (0xe0 - 0xff). Vendor Unique 3852130Smckusick */ 3952130Smckusick 4052130Smckusick /* 4152130Smckusick * Scsi Group0 commands all are 6 bytes and have a format according to 4252130Smckusick * struct ScsiGroup0Cmd. 4352130Smckusick */ 4452130Smckusick #define SCSI_TEST_UNIT_READY 0x00 4552130Smckusick #define SCSI_REZERO_UNIT 0x01 4652130Smckusick #define SCSI_REWIND 0x01 4752130Smckusick #define SCSI_REQUEST_SENSE 0x03 4852130Smckusick #define SCSI_FORMAT_UNIT 0x04 4952130Smckusick #define SCSI_READ_BLOCK_LIMITS 0x05 5052130Smckusick #define SCSI_REASSIGN_BLOCKS 0x07 5152130Smckusick #define SCSI_READ 0x08 5252130Smckusick #define SCSI_WRITE 0x0a 5352130Smckusick #define SCSI_SEEK 0x0b 5452130Smckusick #define SCSI_TRACK_SELECT 0x0b 5552130Smckusick #define SCSI_READ_REVERSE 0x0f 5652130Smckusick #define SCSI_WRITE_EOF 0x10 5752130Smckusick #define SCSI_SPACE 0x11 5852130Smckusick #define SCSI_INQUIRY 0x12 5952130Smckusick #define SCSI_VERIFY 0x13 6052130Smckusick #define SCSI_READ_BUFFER 0x14 6152130Smckusick #define SCSI_MODE_SELECT 0x15 6252130Smckusick #define SCSI_RESERVE_UNIT 0x16 6352130Smckusick #define SCSI_RELEASE_UNIT 0x17 6452130Smckusick #define SCSI_COPY 0x18 6552130Smckusick #define SCSI_ERASE_TAPE 0x19 6652130Smckusick #define SCSI_MODE_SENSE 0x1a 6752130Smckusick #define SCSI_START_STOP 0x1b 6852130Smckusick #define SCSI_LOAD_UNLOAD 0x1b 6952130Smckusick #define SCSI_RECV_DIAG_RESULTS 0x1c 7052130Smckusick #define SCSI_SEND_DIAGNOSTIC 0x1d 7152130Smckusick #define SCSI_PREVENT_ALLOW 0x1e 7252130Smckusick 7352130Smckusick /* 7452130Smckusick * Group1 commands are all 10 bytes and have a format according to 7552130Smckusick * struct ScsiGroup1Cmd. 7652130Smckusick */ 7752130Smckusick #define SCSI_READ_CAPACITY 0x25 7852130Smckusick #define SCSI_READ_EXT 0x28 7952130Smckusick #define SCSI_WRITE_EXT 0x2a 8052130Smckusick #define SCSI_SEEK_EXT 0x2b 8152130Smckusick #define SCSI_WRITE_VERIFY 0x2e 8252130Smckusick #define SCSI_VERIFY_EXT 0x2f 8352130Smckusick #define SCSI_SEARCH_HIGH 0x30 8452130Smckusick #define SCSI_SEARCH_EQUAL 0x31 8552130Smckusick #define SCSI_SEARCH_LOW 0x32 8652130Smckusick #define SCSI_SET_LIMITS 0x33 8752130Smckusick #define SCSI_COMPARE 0x39 8852130Smckusick #define SCSI_COPY_VERIFY 0x3a 8952130Smckusick 9052130Smckusick /* 9152130Smckusick * Control byte flags for Group0 and Group1 commands. 9252130Smckusick * 9352130Smckusick * SCSI_CTRL_LINK - This is used to prevent a bus free phase between commands. 9452130Smckusick * If the command terminates successfully, a SCSI_LINKED_CMD_COMPLETE 9552130Smckusick * message is returned instead of the normal SCSI_COMMAND_COMPLETE message. * The last command in a chain should not have this bit set 9652130Smckusick * (and consequently gets a normal SCSI_COMMAND_COMPLETE message). 9752130Smckusick * SCSI_CTRL_LINK_FLAG - This bit should only set when SCSI_CTRL_LINK is set and 9852130Smckusick * causes a SCSI_LINKED_FLAGED_CMD_COMPLETE to be returned instead of 9952130Smckusick * a SCSI_LINKED_CMD_COMPLETE. 10052130Smckusick */ 10152130Smckusick #define SCSI_CTRL_LINK 0x01 /* Link commands (no bus free phase) */ 10252130Smckusick #define SCSI_CTRL_LINK_INTR 0x02 /* Interrupt after linked command */ 10352130Smckusick 10452130Smckusick /* 10552130Smckusick * The standard group0 6-byte SCSI control block. Note that the 10652130Smckusick * fields between highAddr and blockCount inclusive are command dependent. 10752130Smckusick * The definitions Addr and BlockCount cover most of the commands we will 10852130Smckusick * use. 10952130Smckusick */ 11052130Smckusick typedef struct ScsiGroup0Cmd { 11152130Smckusick u_char command; /* command code, defined below. The 11252130Smckusick * upper three bits of this are zero 11352130Smckusick * to indicate the control block is 11452130Smckusick * only 6 bytes long */ 11552130Smckusick #if BYTE_ORDER == BIG_ENDIAN 11652130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 11752130Smckusick * pass the command. The device 11852130Smckusick * has already been selected using 11952130Smckusick * the "targetID" bit. */ 12052130Smckusick u_char highAddr :5; /* High bits of address */ 12152130Smckusick #else 12252130Smckusick u_char highAddr :5; /* High bits of address */ 12352130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 12452130Smckusick * pass the command. The device 12552130Smckusick * has already been selected using 12652130Smckusick * the "targetID" bit. */ 12752130Smckusick #endif 12852130Smckusick u_char midAddr; /* Middle bits of address */ 12952130Smckusick u_char lowAddr; /* Low bits of address */ 13052130Smckusick u_char blockCount; /* Blocks to transfer */ 13152130Smckusick u_char control; /* See flags for common bits */ 13252130Smckusick } ScsiGroup0Cmd; 13352130Smckusick 13452130Smckusick /* 13552130Smckusick * Format of a SCSI_START_STOP command. This is a group 0 command, but 13652130Smckusick * the command contents are different. 13752130Smckusick */ 13852130Smckusick typedef struct ScsiStartStopCmd { 13952130Smckusick #if BYTE_ORDER == BIG_ENDIAN 14052130Smckusick u_char command; /* command code, defined below. The 14152130Smckusick * upper three bits of this are zero 14252130Smckusick * to indicate the control block is 14352130Smckusick * only 6 bytes long */ 14452130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 14552130Smckusick * pass the command. The device 14652130Smckusick * has already been selected using 14752130Smckusick * the "targetID" bit. */ 14852130Smckusick u_char pad1 :4; /* Reserved */ 14952130Smckusick u_char immed :1; /* Immediate status bit */ 15052130Smckusick u_char pad2; /* Reserved */ 15152130Smckusick u_char pad3; /* Reserved */ 15252130Smckusick u_char pad4 :6; /* Reserved */ 15352130Smckusick u_char loadEject :1; /* Load or eject medium */ 15452130Smckusick u_char start :1; /* Start or stop medium */ 15552130Smckusick u_char control; /* See flags for common bits */ 15652130Smckusick #else 15752130Smckusick u_char command; /* command code, defined below. The 15852130Smckusick * upper three bits of this are zero 15952130Smckusick * to indicate the control block is 16052130Smckusick * only 6 bytes long */ 16152130Smckusick u_char immed :1; /* Immediate status bit */ 16252130Smckusick u_char pad1 :4; /* Reserved */ 16352130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 16452130Smckusick * pass the command. The device 16552130Smckusick * has already been selected using 16652130Smckusick * the "targetID" bit. */ 16752130Smckusick u_char pad2; /* Reserved */ 16852130Smckusick u_char pad3; /* Reserved */ 16952130Smckusick u_char start :1; /* Start or stop medium */ 17052130Smckusick u_char loadEject :1; /* Load or eject medium */ 17152130Smckusick u_char pad4 :6; /* Reserved */ 17252130Smckusick u_char control; /* See flags for common bits */ 17352130Smckusick #endif 17452130Smckusick } ScsiStartStopCmd; 17552130Smckusick 17652130Smckusick /* 17752130Smckusick * The standard group1 10-byte SCSI control block. Note that the 17852130Smckusick * fields between highAddr and blockCount inclusive are command dependent. 17952130Smckusick * The definitions Addr and BlockCount cover most of the commands we will 18052130Smckusick * use. 18152130Smckusick */ 18252130Smckusick typedef struct ScsiGroup1Cmd { 18352130Smckusick u_char command; /* command code, defined below. The 18452130Smckusick * upper three bits of this are zero 18552130Smckusick * to indicate the control block is 18652130Smckusick * only 6 bytes long */ 18752130Smckusick #if BYTE_ORDER == BIG_ENDIAN 18852130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 18952130Smckusick * pass the command. The device 19052130Smckusick * has already been selected using 19152130Smckusick * the "targetID" bit. */ 19252130Smckusick u_char pad1 :5; /* Reserved */ 19352130Smckusick #else 19452130Smckusick u_char pad1 :5; /* Reserved */ 19552130Smckusick u_char unitNumber :3; /* Logical Unit (LUN) to which to 19652130Smckusick * pass the command. The device 19752130Smckusick * has already been selected using 19852130Smckusick * the "targetID" bit. */ 19952130Smckusick #endif 20052130Smckusick u_char highAddr; /* High bits of address */ 20152130Smckusick u_char midHighAddr; /* Middle high bits of address */ 20252130Smckusick u_char midLowAddr; /* Middle low bits of address */ 20352130Smckusick u_char lowAddr; /* Low bits of address */ 20452130Smckusick u_char pad2; /* Reserved */ 20552130Smckusick u_char highBlockCount; /* High bits of blocks to transfer */ 20652130Smckusick u_char lowBlockCount; /* Low bits of blocks to transfer */ 20752130Smckusick u_char control; /* See flags for common bits */ 20852130Smckusick } ScsiGroup1Cmd; 20952130Smckusick 21052130Smckusick /* 21152130Smckusick * SCSI status completion information. 21252130Smckusick * This is returned by the device when a command completes. 21352130Smckusick */ 21452130Smckusick #define SCSI_STATUS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */ 21552130Smckusick #define SCSI_STATUS_CONDMET 0x04 /* Condition Met (ie., search worked) */ 21652130Smckusick #define SCSI_STATUS_BUSY 0x08 21752130Smckusick #define SCSI_STATUS_INTERMED 0x10 /* Intermediate status sent */ 21852130Smckusick #define SCSI_STATUS_EXT 0x80 /* Extended status valid */ 21952130Smckusick 22052130Smckusick /* 22152130Smckusick * Sense information provided after some errors. This is divided into 22252130Smckusick * two kinds, classes 0-6, and class 7. This is 30 bytes big to allow 22352130Smckusick * for the drive specific sense bytes that follow the standard 4 byte header. 22452130Smckusick * 22552130Smckusick * For extended sense, this buffer may be cast into another type. Also 22652130Smckusick * The actual size of the sense data returned is used to detect what 22752130Smckusick * kind of tape drive is out there. Kludgy, but true. 22852130Smckusick */ 22952130Smckusick typedef struct ScsiClass0Sense { 23052130Smckusick #if BYTE_ORDER == BIG_ENDIAN 23152130Smckusick u_char valid :1; /* Sense data is valid */ 23252130Smckusick u_char error :7; /* 3 bits class and 4 bits code */ 23352130Smckusick #else 23452130Smckusick u_char error :7; /* 3 bits class and 4 bits code */ 23552130Smckusick u_char valid :1; /* Sense data is valid */ 23652130Smckusick #endif 23752130Smckusick u_char highAddr; /* High byte of block address */ 23852130Smckusick u_char midAddr; /* Middle byte of block address */ 23952130Smckusick u_char lowAddr; /* Low byte of block address */ 24052130Smckusick u_char sense[26]; /* Target specific sense data */ 24152130Smckusick } ScsiClass0Sense; 24252130Smckusick 24352130Smckusick /* 24452130Smckusick * Definitions for errors in the sense data. The error field is specified 24552130Smckusick * as a 3 bit class and 4 bit code, but it is easier to treat it as a 24652130Smckusick * single 7 bit field. 24752130Smckusick */ 24852130Smckusick #define SCSI_NO_SENSE_DATA 0x00 24952130Smckusick #define SCSI_NOT_READY 0x04 25052130Smckusick #define SCSI_NOT_LOADED 0x09 25152130Smckusick #define SCSI_INSUF_CAPACITY 0x0a 25252130Smckusick #define SCSI_HARD_DATA_ERROR 0x11 25352130Smckusick #define SCSI_WRITE_PROTECT 0x17 25452130Smckusick #define SCSI_CORRECTABLE_ERROR 0x18 25552130Smckusick #define SCSI_FILE_MARK 0x1c 25652130Smckusick #define SCSI_INVALID_COMMAND 0x20 25752130Smckusick #define SCSI_UNIT_ATTENTION 0x30 25852130Smckusick #define SCSI_END_OF_MEDIA 0x34 25952130Smckusick 26052130Smckusick /* 26152130Smckusick * The standard "extended" sense data returned by SCSI devices. This 26252130Smckusick * has an error field of 0x70, for a "class 7" error. 26352130Smckusick */ 26452130Smckusick typedef struct ScsiClass7Sense { 26552130Smckusick #if BYTE_ORDER == BIG_ENDIAN 26652130Smckusick u_char valid :1; /* Sense data is valid */ 26752130Smckusick u_char error7 :7; /* == 0x70 */ 26852130Smckusick u_char pad1; /* Also "segment number" for copy */ 26952130Smckusick u_char fileMark :1; /* File mark on device */ 27052130Smckusick u_char endOfMedia :1; /* End of media reached */ 27152130Smckusick u_char badBlockLen :1; /* Block length mis-match (Exabyte) */ 27252130Smckusick u_char pad2 :1; 27352130Smckusick u_char key :4; /* Sense keys defined below */ 27452130Smckusick u_char info1; /* Information byte 1 */ 27552130Smckusick u_char info2; /* Information byte 2 */ 27652130Smckusick u_char info3; /* Information byte 3 */ 27752130Smckusick u_char info4; /* Information byte 4 */ 27852130Smckusick u_char length; /* Number of additional info bytes */ 27952130Smckusick #else 28052130Smckusick u_char error7 :7; /* == 0x70 */ 28152130Smckusick u_char valid :1; /* Sense data is valid */ 28252130Smckusick u_char pad1; /* Also "segment number" for copy */ 28352130Smckusick u_char key :4; /* Sense keys defined below */ 28452130Smckusick u_char pad2 :1; 28552130Smckusick u_char badBlockLen :1; /* Block length mis-match (Exabyte) */ 28652130Smckusick u_char endOfMedia :1; /* End of media reached */ 28752130Smckusick u_char fileMark :1; /* File mark on device */ 28852130Smckusick u_char info1; /* Information byte 1 */ 28952130Smckusick u_char info2; /* Information byte 2 */ 29052130Smckusick u_char info3; /* Information byte 3 */ 29152130Smckusick u_char info4; /* Information byte 4 */ 29252130Smckusick u_char length; /* Number of additional info bytes */ 29352130Smckusick #endif 29452130Smckusick } ScsiClass7Sense; /* 8 Bytes */ 29552130Smckusick 29652130Smckusick /* 29752130Smckusick * Key values for standardized sense class 7. 29852130Smckusick */ 29952130Smckusick #define SCSI_CLASS7_NO_SENSE 0 30052130Smckusick #define SCSI_CLASS7_RECOVERABLE 1 30152130Smckusick #define SCSI_CLASS7_NOT_READY 2 30252130Smckusick #define SCSI_CLASS7_MEDIA_ERROR 3 30352130Smckusick #define SCSI_CLASS7_HARDWARE_ERROR 4 30452130Smckusick #define SCSI_CLASS7_ILLEGAL_REQUEST 5 30552130Smckusick 30652130Smckusick /* 30752130Smckusick * These seem to have different meanings to different vendors.... 30852130Smckusick */ 30952130Smckusick #define SCSI_CLASS7_MEDIA_CHANGE 6 31052130Smckusick #define SCSI_CLASS7_UNIT_ATTN 6 31152130Smckusick 31252130Smckusick #define SCSI_CLASS7_WRITE_PROTECT 7 31352130Smckusick #define SCSI_CLASS7_BLANK_CHECK 8 31452130Smckusick #define SCSI_CLASS7_VENDOR 9 31552130Smckusick #define SCSI_CLASS7_POWER_UP_FAILURE 10 31652130Smckusick #define SCSI_CLASS7_ABORT 11 31752130Smckusick #define SCSI_CLASS7_EQUAL 12 31852130Smckusick #define SCSI_CLASS7_OVERFLOW 13 31952130Smckusick #define SCSI_CLASS7_RESERVED_14 14 32052130Smckusick #define SCSI_CLASS7_RESERVED_15 15 32152130Smckusick 32252130Smckusick /* 32352130Smckusick * Data return by the SCSI inquiry command. 32452130Smckusick */ 32552130Smckusick typedef struct ScsiInquiryData { 32652130Smckusick #if BYTE_ORDER == BIG_ENDIAN 32752130Smckusick u_char type; /* Peripheral Device type. See below. */ 32852130Smckusick u_char rmb:1; /* Removable Medium bit. */ 32952130Smckusick u_char qualifier:7; /* Device type qualifier. */ 33052130Smckusick u_char version; /* Version info. */ 33152130Smckusick u_char reserved:4; /* reserved. */ 33252130Smckusick u_char format:4; /* Response format. */ 33352130Smckusick u_char length; /* length of data returned. */ 33452130Smckusick u_char reserved2[2]; /* Reserved */ 33552130Smckusick u_char flags; /* SCSI II flags (see below) */ 33652130Smckusick u_char vendorID[8]; /* Vendor ID (ASCII) */ 33752130Smckusick u_char productID[16]; /* Product ID (ASCII) */ 33852130Smckusick u_char revLevel[4]; /* Revision level (ASCII) */ 33952130Smckusick u_char revData[8]; /* Revision data (ASCII) */ 34052130Smckusick #else 34152130Smckusick u_char type; /* Peripheral Device type. See below. */ 34252130Smckusick u_char qualifier:7; /* Device type qualifier. */ 34352130Smckusick u_char rmb:1; /* Removable Medium bit. */ 34452130Smckusick u_char version; /* Version info. */ 34552130Smckusick u_char format:4; /* Response format. */ 34652130Smckusick u_char reserved:4; /* reserved. */ 34752130Smckusick u_char length; /* length of data returned. */ 34852130Smckusick u_char reserved2[2]; /* Reserved */ 34952130Smckusick u_char flags; /* SCSI II flags (see below) */ 35052130Smckusick u_char vendorID[8]; /* Vendor ID (ASCII) */ 35152130Smckusick u_char productID[16]; /* Product ID (ASCII) */ 35252130Smckusick u_char revLevel[4]; /* Revision level (ASCII) */ 35352130Smckusick u_char revData[8]; /* Revision data (ASCII) */ 35452130Smckusick #endif 35552130Smckusick } ScsiInquiryData; 35652130Smckusick 35752130Smckusick /* 35852130Smckusick * The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command. 35952130Smckusick * 36052130Smckusick * SCSI_DISK_TYPE - Direct Access Device. 36152130Smckusick * SCSI_TAPE_TYPE - Sequential Access Device. 36252130Smckusick * SCSI_PRINTER_TYPE - Printer Device. 36352130Smckusick * SCSI_HOST_TYPE - Processor Device. 36452130Smckusick * SCSI_WORM_TYPE - Write-Once Read-Multiple Device. 36552130Smckusick * SCSI_ROM_TYPE - Read-Only Direct Access Device. 36652130Smckusick * SCSI_SCANNER_TYPE - Scanner device. 36752130Smckusick * SCSI_OPTICAL_MEM_TYPE - Optical memory device. 36852130Smckusick * SCSI_MEDIUM_CHANGER_TYPE - Medium changer device. 36952130Smckusick * SCSI_COMMUNICATIONS_TYPE - Communications device. 37052130Smckusick * SCSI_NODEVICE_TYPE - Logical Unit not present or implemented. 37152130Smckusick * 37252130Smckusick * Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique. 37352130Smckusick */ 37452130Smckusick #define SCSI_DISK_TYPE 0 37552130Smckusick #define SCSI_TAPE_TYPE 1 37652130Smckusick #define SCSI_PRINTER_TYPE 2 37752130Smckusick #define SCSI_HOST_TYPE 3 37852130Smckusick #define SCSI_WORM_TYPE 4 37952130Smckusick #define SCSI_ROM_TYPE 5 38052130Smckusick #define SCSI_SCANNER_TYPE 6 38152130Smckusick #define SCSI_OPTICAL_MEM_TYPE 7 38252130Smckusick #define SCSI_MEDIUM_CHANGER_TYPE 8 38352130Smckusick #define SCSI_COMMUNICATIONS_TYPE 9 38452130Smckusick #define SCSI_NODEVICE_TYPE 0x7f 38552130Smckusick 38652130Smckusick /* 38752130Smckusick * The SCSI I & II inquiry flags. 38852130Smckusick * 38952130Smckusick * SCSI_REL_ADR - Relative addressing supported. 39052130Smckusick * SCSI_WIDE_32 - 32 bit wide SCSI bus transfers supported. 39152130Smckusick * SCSI_WIDE_16 - 16 bit wide SCSI bus transfers supported. 39252130Smckusick * SCSI_SYNC - Synchronous data transfers supported. 39352130Smckusick * SCSI_LINKED - Linked commands supported. 39452130Smckusick * SCSI_CMD_QUEUE - Tagged command queuing supported. 39552130Smckusick * SCSI_SOFT_RESET - Soft RESET alternative suported. 39652130Smckusick */ 39752130Smckusick #define SCSI_REL_ADR 0x80 39852130Smckusick #define SCSI_WIDE_32 0x40 39952130Smckusick #define SCSI_WIDE_16 0x20 40052130Smckusick #define SCSI_SYNC 0x10 40152130Smckusick #define SCSI_LINKED 0x08 40252130Smckusick #define SCSI_CMD_QUEUE 0x02 40352130Smckusick #define SCSI_SOFT_RESET 0x01 40452130Smckusick 40552130Smckusick /* 40653084Sralph * Standard header for SCSI_MODE_SENSE and SCSI_MODE_SELECT commands for tapes. 40752130Smckusick */ 40852130Smckusick typedef struct ScsiTapeModeSelectHdr { 40953084Sralph u_char len; /* length */ 41053084Sralph u_char media; /* media type */ 41152130Smckusick #if BYTE_ORDER == BIG_ENDIAN 41253084Sralph u_char writeprot:1; /* Write protected media */ 41352130Smckusick u_char bufferedMode:3; /* Type of buffer to be done. */ 41452130Smckusick u_char speed:4; /* Drive speed. */ 41552130Smckusick #else 41652130Smckusick u_char speed:4; /* Drive speed. */ 41752130Smckusick u_char bufferedMode:3; /* Type of buffer to be done. */ 41853084Sralph u_char writeprot:1; /* Write protected media */ 41953084Sralph #endif 42052130Smckusick u_char length; /* Block descriptor length. */ 42153084Sralph u_char density; /* tape density code */ 42253084Sralph u_char blocks_2; /* number of blocks (MSB) */ 42353084Sralph u_char blocks_1; /* number of blocks */ 42453084Sralph u_char blocks_0; /* number of blocks (LSB) */ 42553084Sralph u_char reserved; /* */ 42653084Sralph u_char block_size2; /* Tape block size (MSB) */ 42753084Sralph u_char block_size1; /* Tape block size */ 42853084Sralph u_char block_size0; /* Tape block size (LSB) */ 42953084Sralph u_char vendor[6]; /* vendor specific data */ 43052130Smckusick } ScsiTapeModeSelectHdr; 43152130Smckusick 43252130Smckusick /* 43352130Smckusick * Definitions of SCSI messages. 43452130Smckusick * 43552130Smckusick * SCSI_COMMAND_COMPLETE - After a command has completed, successfully 43652130Smckusick * or not, this is returned to the host from the target. 43752130Smckusick * 43852130Smckusick * SCSI_EXTENDED_MSG - Indicates that a multi-byte message is being sent. 43952130Smckusick * 44052130Smckusick * The following messages are used with connect/disconnect: 44152130Smckusick * SCSI_SAVE_DATA_POINTER - Sent from target to host to request saving 44252130Smckusick * of current DMA address and count. Indicates a pending dis-connect. 44352130Smckusick * SCSI_RESTORE_POINTER - Sent from the target to the host to request 44452130Smckusick * restoring pointers saved before a disconnect 44552130Smckusick * SCSI_DISCONNECT - Sent from the target to the host to disconnect. 44652130Smckusick * SCSI_ABORT - Sent from the host to the target to abort current request. 44752130Smckusick * SCSI_MESSAGE_REJECT - Indicates receipt, by either host or target, of 44852130Smckusick * an unimplemented message. 44952130Smckusick * SCSI_NO_OP - Sent from host to target if it has no real message to send. 45052130Smckusick * SCSI_MESSAGE_PARITY_ERROR - Sent from host to target on message parity error 45152130Smckusick * SCSI_BUS_RESET - Sent from host to target to reset all current I/O 45252130Smckusick * 45352130Smckusick * SCSI_IDENTIFY - The low order two bits of this message type indicate 45452130Smckusick * the Logical Unit of the Target which is requesting a reconnect. 45552130Smckusick * SCSI_DIS_REC_IDENTIFY - Sent from the host to a target to indicate 45652130Smckusick * is supports connect/dis-connect 45752130Smckusick * 45852130Smckusick */ 45952130Smckusick #define SCSI_COMMAND_COMPLETE 0x00 46052130Smckusick #define SCSI_EXTENDED_MSG 0x01 46152130Smckusick #define SCSI_SAVE_DATA_POINTER 0x02 46252130Smckusick #define SCSI_RESTORE_POINTERS 0x03 46352130Smckusick #define SCSI_DISCONNECT 0x04 46452130Smckusick #define SCSI_ABORT 0x06 46552130Smckusick #define SCSI_MESSAGE_REJECT 0x07 46652130Smckusick #define SCSI_NO_OP 0x08 46752130Smckusick #define SCSI_MESSAGE_PARITY_ERROR 0x09 46852130Smckusick #define SCSI_LINKED_CMD_COMPLETE 0x0A 46952130Smckusick #define SCSI_LINKED_FLAGED_CMD_COMPLETE 0x0B 47052130Smckusick #define SCSI_BUS_RESET 0x0C 47152130Smckusick 47252130Smckusick #define SCSI_IDENTIFY 0x80 47352130Smckusick #define SCSI_DIS_REC_IDENTIFY 0xc0 47452130Smckusick 47552130Smckusick /* 47652130Smckusick * Extended message types (2nd byte of SCSI_EXTENDED_MSG). 47752130Smckusick */ 47852130Smckusick #define SCSI_MODIFY_DATA_PTR 0x00 47952130Smckusick #define SCSI_SYNCHRONOUS_XFER 0x01 48052130Smckusick #define SCSI_EXTENDED_IDENTIFY 0x02 /* only in SCSI I */ 48152130Smckusick #define SCSI_WIDE_XFER 0x03 48252130Smckusick 48352130Smckusick /* 48452130Smckusick * Driver ioctl's for various scsi operations. 48552130Smckusick */ 48652130Smckusick #ifndef _IOCTL_ 48756522Sbostic #include <sys/ioctl.h> 48852130Smckusick #endif 48952130Smckusick 49052130Smckusick /* 49152130Smckusick * Control for SCSI "format" mode. 49252130Smckusick * 49352130Smckusick * "Format" mode allows a privileged process to issue direct SCSI 49452130Smckusick * commands to a drive (it is intended primarily to allow on-line 49552130Smckusick * formatting). SDIOCSFORMAT with a non-zero arg will put the drive 49652130Smckusick * into format mode; a zero arg will take it out. When in format 49752130Smckusick * mode, only the process that issued the SDIOCFORMAT can read or 49852130Smckusick * write the drive. 49952130Smckusick * 50052130Smckusick * In format mode, process is expected to 50152130Smckusick * - do SDIOCSCSICOMMAND to supply cdb for next SCSI op 50252130Smckusick * - do read or write as appropriate for cdb 50352130Smckusick * - if i/o error, optionally do SDIOCSENSE to get completion 50452130Smckusick * status and sense data from last scsi operation. 50552130Smckusick */ 50652130Smckusick 50752130Smckusick struct scsi_fmt_cdb { 50852130Smckusick int len; /* cdb length (in bytes) */ 50952130Smckusick u_char cdb[28]; /* cdb to use on next read/write */ 51052130Smckusick }; 51152130Smckusick 51252130Smckusick struct scsi_fmt_sense { 51352130Smckusick u_int status; /* completion status of last op */ 51452130Smckusick u_char sense[32]; /* sense data (if any) from last op */ 51552130Smckusick }; 51652130Smckusick 51752130Smckusick #define SDIOCSFORMAT _IOW('S', 0x1, int) 51852130Smckusick #define SDIOCGFORMAT _IOR('S', 0x2, int) 51952130Smckusick #define SDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb) 52052130Smckusick #define SDIOCSENSE _IOR('S', 0x4, struct scsi_fmt_sense) 52152130Smckusick 52252130Smckusick #ifdef KERNEL 52352130Smckusick /* 52452130Smckusick * Routines. 52552130Smckusick */ 52652130Smckusick extern void scsiGroup0Cmd(); 52752130Smckusick extern void scsiGroup1Cmd(); 52859822Sralph #endif /* KERNEL */ 52952130Smckusick 53052130Smckusick #endif /* _SCSI_H */ 531