Home | History | Annotate | Line # | Download | only in scsipi
scsipi_all.h revision 1.12.8.2
      1 /*	$NetBSD: scsipi_all.h,v 1.12.8.2 2000/11/20 09:59:26 bouyer Exp $	*/
      2 
      3 /*
      4  * SCSI and SCSI-like general interface description
      5  */
      6 
      7 /*
      8  * Largely written by Julian Elischer (julian (at) tfs.com)
      9  * for TRW Financial Systems.
     10  *
     11  * TRW Financial Systems, in accordance with their agreement with Carnegie
     12  * Mellon University, makes this software available to CMU to distribute
     13  * or use in any manner that they see fit as long as this message is kept with
     14  * the software. For this reason TFS also grants any other persons or
     15  * organisations permission to use or modify this software.
     16  *
     17  * TFS supplies this software to be publicly redistributed
     18  * on the understanding that TFS is not responsible for the correct
     19  * functioning of this software in any circumstances.
     20  *
     21  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     22  */
     23 
     24 #ifndef _DEV_SCSIPI_SCSIPI_ALL_H_
     25 #define	_DEV_SCSIPI_SCSIPI_ALL_H_
     26 
     27 /*
     28  * SCSI-like command format and opcode
     29  */
     30 
     31 /*
     32  * Some basic, common SCSI command group definitions.
     33  */
     34 
     35 #define	CDB_GROUPID(cmd)        ((cmd >> 5) & 0x7)
     36 #define	CDB_GROUPID_0	0
     37 #define	CDB_GROUPID_1	1
     38 #define	CDB_GROUPID_2	2
     39 #define	CDB_GROUPID_3	3
     40 #define	CDB_GROUPID_4	4
     41 #define	CDB_GROUPID_5	5
     42 #define	CDB_GROUPID_6	6
     43 #define	CDB_GROUPID_7	7
     44 
     45 #define	CDB_GROUP0	6       /*  6-byte cdb's */
     46 #define	CDB_GROUP1	10      /* 10-byte cdb's */
     47 #define	CDB_GROUP2	10      /* 10-byte cdb's */
     48 #define	CDB_GROUP3	0       /* reserved */
     49 #define	CDB_GROUP4	16      /* 16-byte cdb's */
     50 #define	CDB_GROUP5	12      /* 12-byte cdb's */
     51 #define	CDB_GROUP6	0       /* vendor specific */
     52 #define	CDB_GROUP7	0       /* vendor specific */
     53 
     54 /*
     55  * Some basic, common SCSI commands
     56  */
     57 #define	TEST_UNIT_READY		0x00
     58 struct scsipi_test_unit_ready {
     59 	u_int8_t opcode;
     60 	u_int8_t byte2;
     61 	u_int8_t unused[3];
     62 	u_int8_t control;
     63 };
     64 
     65 #define	REQUEST_SENSE		0x03
     66 struct scsipi_sense {
     67 	u_int8_t opcode;
     68 	u_int8_t byte2;
     69 	u_int8_t unused[2];
     70 	u_int8_t length;
     71 	u_int8_t control;
     72 };
     73 
     74 #define	INQUIRY			0x12
     75 struct scsipi_inquiry {
     76 	u_int8_t opcode;
     77 	u_int8_t byte2;
     78 	u_int8_t unused[2];
     79 	u_int8_t length;
     80 	u_int8_t control;
     81 };
     82 
     83 #define	PREVENT_ALLOW		0x1e
     84 struct scsipi_prevent {
     85 	u_int8_t opcode;
     86 	u_int8_t byte2;
     87 	u_int8_t unused[2];
     88 	u_int8_t how;
     89 	u_int8_t control;
     90 };
     91 #define	PR_PREVENT 0x01
     92 #define	PR_ALLOW   0x00
     93 
     94 /*
     95  * inquiry and sense data format
     96  */
     97 
     98 struct scsipi_sense_data {
     99 /* 1*/	u_int8_t error_code;
    100 #define	SSD_ERRCODE	0x7F
    101 #define	SSD_ERRCODE_VALID 0x80
    102 /* 2*/	u_int8_t segment;
    103 /* 3*/	u_int8_t flags;
    104 #define	SSD_KEY		0x0F
    105 #define	SSD_ILI		0x20
    106 #define	SSD_EOM		0x40
    107 #define	SSD_FILEMARK	0x80
    108 /* 7*/	u_int8_t info[4];
    109 /* 8*/	u_int8_t extra_len;
    110 /*12*/	u_int8_t cmd_spec_info[4];
    111 /*13*/	u_int8_t add_sense_code;
    112 /*14*/	u_int8_t add_sense_code_qual;
    113 /*15*/	u_int8_t fru;
    114 /*16*/	u_int8_t sense_key_spec_1;
    115 #define	SSD_SCS_VALID	0x80
    116 /*17*/	u_int8_t sense_key_spec_2;
    117 /*18*/	u_int8_t sense_key_spec_3;
    118 /*32*/	u_int8_t extra_bytes[14];
    119 };
    120 
    121 #define	SKEY_NO_SENSE		0x00
    122 #define	SKEY_RECOVERED_ERROR	0x01
    123 #define	SKEY_NOT_READY		0x02
    124 #define	SKEY_MEDIUM_ERROR	0x03
    125 #define	SKEY_HARDWARE_ERROR	0x04
    126 #define	SKEY_ILLEGAL_REQUEST	0x05
    127 #define	SKEY_UNIT_ATTENTION	0x06
    128 #define	SKEY_WRITE_PROTECT	0x07
    129 #define	SKEY_BLANK_CHECK	0x08
    130 #define	SKEY_VENDOR_UNIQUE	0x09
    131 #define	SKEY_COPY_ABORTED	0x0A
    132 #define	SKEY_ABORTED_COMMAND	0x0B
    133 #define	SKEY_EQUAL		0x0C
    134 #define	SKEY_VOLUME_OVERFLOW	0x0D
    135 #define	SKEY_MISCOMPARE		0x0E
    136 #define	SKEY_RESERVED		0x0F
    137 
    138 /*
    139  * Sense bytes described by the extra_len tag start at cmd_spec_info,
    140  * and can only continue up to the end of the structure we've defined
    141  * (which is too short for some cases).
    142  */
    143 #define	ADD_BYTES_LIM(sp)	\
    144 	((((int)(sp)->extra_len) < (int) sizeof(struct scsipi_sense_data) - 8)? \
    145 	((sp)->extra_len) : (sizeof (struct scsipi_sense_data) - 8))
    146 
    147 
    148 struct scsipi_sense_data_unextended {
    149 /* 1*/	u_int8_t error_code;
    150 /* 4*/	u_int8_t block[3];
    151 };
    152 
    153 #define	T_REMOV		1	/* device is removable */
    154 #define	T_FIXED		0	/* device is not removable */
    155 
    156 /*
    157  * According to SPC-2r16, in order to know if a U3W device support PPR,
    158  * Inquiry Data structure should be at least 57 Bytes
    159  */
    160 
    161 struct scsipi_inquiry_data {
    162 /* 1*/	u_int8_t device;
    163 #define	SID_TYPE		0x1f	/* device type mask */
    164 #define	SID_QUAL		0xe0	/* device qualifier mask */
    165 #define	SID_QUAL_LU_PRESENT	0x00	/* logical unit present */
    166 #define	SID_QUAL_LU_NOTPRESENT	0x20	/* logical unit not present */
    167 #define	SID_QUAL_reserved	0x40
    168 #define	SID_QUAL_LU_NOT_SUPP	0x60	/* logical unit not supported */
    169 
    170 #define	T_DIRECT		0x00	/* direct access device */
    171 #define	T_SEQUENTIAL		0x01	/* sequential access device */
    172 #define	T_PRINTER		0x02	/* printer device */
    173 #define	T_PROCESSOR		0x03	/* processor device */
    174 #define	T_WORM			0x04	/* write once, read many device */
    175 #define	T_CDROM			0x05	/* cd-rom device */
    176 #define	T_SCANNER 		0x06	/* scanner device */
    177 #define	T_OPTICAL 		0x07	/* optical memory device */
    178 #define	T_CHANGER		0x08	/* medium changer device */
    179 #define	T_COMM			0x09	/* communication device */
    180 #define	T_IT8_1			0x0a	/* Defined by ASC IT8... */
    181 #define	T_IT8_2			0x0b	/* ...(Graphic arts pre-press devices) */
    182 #define	T_STORARRAY		0x0c	/* storage array device */
    183 #define	T_ENCLOSURE		0x0d	/* enclosure services device */
    184 #define	T_SIMPLE_DIRECT		0x0E	/* Simplified direct-access device */
    185 #define	T_OPTIC_CARD_RW		0x0F	/* Optical card reader/writer device */
    186 #define	T_OBJECT_STORED		0x11	/* Object-based Storage Device */
    187 #define	T_NODEVICE		0x1f
    188 
    189 	u_int8_t dev_qual2;
    190 #define	SID_QUAL2		0x7F
    191 #define	SID_REMOVABLE		0x80
    192 
    193 /* 3*/	u_int8_t version;
    194 #define	SID_ANSII	0x07
    195 #define	SID_ECMA	0x38
    196 #define	SID_ISO		0xC0
    197 
    198 /* 4*/	u_int8_t response_format;
    199 #define	SID_RespDataFmt	0x0F
    200 #define	SID_FORMAT_SCSI1	0x00	/* SCSI-1 format */
    201 #define	SID_FORMAT_CCS		0x01	/* SCSI CCS format */
    202 #define	SID_FORMAT_ISO		0x02	/* ISO format */
    203 
    204 /* 5*/	u_int8_t additional_length;	/* n-4 */
    205 /* 6*/	u_int8_t flags1;
    206 #define	SID_SCC		0x80
    207 /* 7*/	u_int8_t flags2;
    208 #define	SID_Addr16	0x01
    209 #define SID_MChngr	0x08
    210 #define	SID_MultiPort	0x10
    211 #define	SID_EncServ	0x40
    212 #define	SID_BasQue	0x80
    213 /* 8*/	u_int8_t flags3;
    214 #define	SID_SftRe	0x01
    215 #define	SID_CmdQue	0x02
    216 #define	SID_Linked	0x08
    217 #define	SID_Sync	0x10
    218 #define	SID_WBus16	0x20
    219 #define	SID_WBus32	0x40
    220 #define	SID_RelAdr	0x80
    221 /* 9*/	char    vendor[8];
    222 /*17*/	char    product[16];
    223 /*33*/	char    revision[4];
    224 /*37*/	u_int8_t vendor_specific[20];
    225 /*57*/	u_int8_t flags4;
    226 #define        SID_IUS         0x01
    227 #define        SID_QAS         0x02
    228 #define        SID_Clocking    0x0C
    229 #define	SID_CLOCKING_ST_ONLY  0x00
    230 #define	SID_CLOCKING_DT_ONLY  0x04
    231 #define	SID_CLOCKING_SD_DT    0x0C
    232 /*58*/	u_int8_t reserved;
    233 /*59*/	char    version_descriptor[8][2];
    234 }; /* 74 Bytes */
    235 
    236 #endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */
    237