Home | History | Annotate | Line # | Download | only in scsipi
scsi_all.h revision 1.9
      1 /*	$NetBSD: scsi_all.h,v 1.9 1996/09/03 18:20:31 thorpej Exp $	*/
      2 
      3 /*
      4  * SCSI 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	_SCSI_SCSI_ALL_H
     25 #define _SCSI_SCSI_ALL_H 1
     26 
     27 /*
     28  * SCSI command format
     29  */
     30 
     31 /*
     32  * Define dome bits that are in ALL (or a lot of) scsi commands
     33  */
     34 #define SCSI_CTL_LINK		0x01
     35 #define SCSI_CTL_FLAG		0x02
     36 #define SCSI_CTL_VENDOR		0xC0
     37 
     38 
     39 /*
     40  * Some old SCSI devices need the LUN to be set in the top 3 bits of the
     41  * second byte of the CDB.
     42  */
     43 #define	SCSI_CMD_LUN_MASK	0xe0
     44 #define	SCSI_CMD_LUN_SHIFT	5
     45 
     46 
     47 struct scsi_generic {
     48 	u_int8_t opcode;
     49 	u_int8_t bytes[11];
     50 };
     51 
     52 struct scsi_test_unit_ready {
     53 	u_int8_t opcode;
     54 	u_int8_t byte2;
     55 	u_int8_t unused[3];
     56 	u_int8_t control;
     57 };
     58 
     59 struct scsi_send_diag {
     60 	u_int8_t opcode;
     61 	u_int8_t byte2;
     62 #define	SSD_UOL		0x01
     63 #define	SSD_DOL		0x02
     64 #define	SSD_SELFTEST	0x04
     65 #define	SSD_PF		0x10
     66 	u_int8_t unused[1];
     67 	u_int8_t paramlen[2];
     68 	u_int8_t control;
     69 };
     70 
     71 struct scsi_sense {
     72 	u_int8_t opcode;
     73 	u_int8_t byte2;
     74 	u_int8_t unused[2];
     75 	u_int8_t length;
     76 	u_int8_t control;
     77 };
     78 
     79 struct scsi_inquiry {
     80 	u_int8_t opcode;
     81 	u_int8_t byte2;
     82 	u_int8_t unused[2];
     83 	u_int8_t length;
     84 	u_int8_t control;
     85 };
     86 
     87 struct scsi_mode_sense {
     88 	u_int8_t opcode;
     89 	u_int8_t byte2;
     90 #define	SMS_DBD				0x08
     91 	u_int8_t page;
     92 #define	SMS_PAGE_CODE 			0x3F
     93 #define	SMS_PAGE_CTRL 			0xC0
     94 #define	SMS_PAGE_CTRL_CURRENT 		0x00
     95 #define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
     96 #define	SMS_PAGE_CTRL_DEFAULT 		0x80
     97 #define	SMS_PAGE_CTRL_SAVED 		0xC0
     98 	u_int8_t unused;
     99 	u_int8_t length;
    100 	u_int8_t control;
    101 };
    102 
    103 struct scsi_mode_sense_big {
    104 	u_int8_t opcode;
    105 	u_int8_t byte2;		/* same bits as small version */
    106 	u_int8_t page; 		/* same bits as small version */
    107 	u_int8_t unused[4];
    108 	u_int8_t length[2];
    109 	u_int8_t control;
    110 };
    111 
    112 struct scsi_mode_select {
    113 	u_int8_t opcode;
    114 	u_int8_t byte2;
    115 #define	SMS_SP	0x01
    116 #define	SMS_PF	0x10
    117 	u_int8_t unused[2];
    118 	u_int8_t length;
    119 	u_int8_t control;
    120 };
    121 
    122 struct scsi_mode_select_big {
    123 	u_int8_t opcode;
    124 	u_int8_t byte2;		/* same bits as small version */
    125 	u_int8_t unused[5];
    126 	u_int8_t length[2];
    127 	u_int8_t control;
    128 };
    129 
    130 struct scsi_reserve {
    131 	u_int8_t opcode;
    132 	u_int8_t byte2;
    133 	u_int8_t unused[2];
    134 	u_int8_t length;
    135 	u_int8_t control;
    136 };
    137 
    138 struct scsi_release {
    139 	u_int8_t opcode;
    140 	u_int8_t byte2;
    141 	u_int8_t unused[2];
    142 	u_int8_t length;
    143 	u_int8_t control;
    144 };
    145 
    146 struct scsi_prevent {
    147 	u_int8_t opcode;
    148 	u_int8_t byte2;
    149 	u_int8_t unused[2];
    150 	u_int8_t how;
    151 	u_int8_t control;
    152 };
    153 #define	PR_PREVENT 0x01
    154 #define PR_ALLOW   0x00
    155 
    156 struct scsi_changedef {
    157 	u_int8_t opcode;
    158 	u_int8_t byte2;
    159 	u_int8_t unused1;
    160 	u_int8_t how;
    161 	u_int8_t unused[4];
    162 	u_int8_t datalen;
    163 	u_int8_t control;
    164 };
    165 #define SC_SCSI_1 0x01
    166 #define SC_SCSI_2 0x03
    167 
    168 /*
    169  * Opcodes
    170  */
    171 #define	TEST_UNIT_READY		0x00
    172 #define REQUEST_SENSE		0x03
    173 #define INQUIRY			0x12
    174 #define MODE_SELECT		0x15
    175 #define MODE_SENSE		0x1a
    176 #define START_STOP		0x1b
    177 #define RESERVE      		0x16
    178 #define RELEASE      		0x17
    179 #define PREVENT_ALLOW		0x1e
    180 #define POSITION_TO_ELEMENT	0x2b
    181 #define	CHANGE_DEFINITION	0x40
    182 #define	MODE_SENSE_BIG		0x54
    183 #define	MODE_SELECT_BIG		0x55
    184 #define MOVE_MEDIUM     	0xa5
    185 #define READ_ELEMENT_STATUS	0xb8
    186 
    187 /*
    188  * sense data format
    189  */
    190 #define T_DIRECT	0
    191 #define T_SEQUENTIAL	1
    192 #define T_PRINTER	2
    193 #define T_PROCESSOR	3
    194 #define T_WORM		4
    195 #define T_CDROM		5
    196 #define T_SCANNER 	6
    197 #define T_OPTICAL 	7
    198 #define T_NODEVICE	0x1F
    199 
    200 #define T_CHANGER	8
    201 #define T_COMM		9
    202 
    203 #define T_REMOV		1
    204 #define	T_FIXED		0
    205 
    206 struct scsi_inquiry_data {
    207 	u_int8_t device;
    208 #define	SID_TYPE	0x1F
    209 #define	SID_QUAL	0xE0
    210 #define	SID_QUAL_LU_OK	0x00
    211 #define	SID_QUAL_LU_OFFLINE	0x20
    212 #define	SID_QUAL_RSVD	0x40
    213 #define	SID_QUAL_BAD_LU	0x60
    214 	u_int8_t dev_qual2;
    215 #define	SID_QUAL2	0x7F
    216 #define	SID_REMOVABLE	0x80
    217 	u_int8_t version;
    218 #define SID_ANSII	0x07
    219 #define SID_ECMA	0x38
    220 #define SID_ISO		0xC0
    221 	u_int8_t response_format;
    222 	u_int8_t additional_length;
    223 	u_int8_t unused[2];
    224 	u_int8_t flags;
    225 #define	SID_SftRe	0x01
    226 #define	SID_CmdQue	0x02
    227 #define	SID_Linked	0x08
    228 #define	SID_Sync	0x10
    229 #define	SID_WBus16	0x20
    230 #define	SID_WBus32	0x40
    231 #define	SID_RelAdr	0x80
    232 	char	vendor[8];
    233 	char	product[16];
    234 	char	revision[4];
    235 	u_int8_t extra[8];
    236 };
    237 
    238 struct scsi_sense_data_unextended {
    239 /* 1*/	u_int8_t error_code;
    240 /* 4*/	u_int8_t block[3];
    241 };
    242 
    243 struct scsi_sense_data {
    244 /* 1*/	u_int8_t error_code;
    245 #define	SSD_ERRCODE		0x7F
    246 #define	SSD_ERRCODE_VALID	0x80
    247 /* 2*/	u_int8_t segment;
    248 /* 3*/	u_int8_t flags;
    249 #define	SSD_KEY		0x0F
    250 #define	SSD_ILI		0x20
    251 #define	SSD_EOM		0x40
    252 #define	SSD_FILEMARK	0x80
    253 /* 7*/	u_int8_t info[4];
    254 /* 8*/	u_int8_t extra_len;
    255 /*12*/	u_int8_t cmd_spec_info[4];
    256 /*13*/	u_int8_t add_sense_code;
    257 /*14*/	u_int8_t add_sense_code_qual;
    258 /*15*/	u_int8_t fru;
    259 /*16*/	u_int8_t sense_key_spec_1;
    260 #define	SSD_SCS_VALID	0x80
    261 /*17*/	u_int8_t sense_key_spec_2;
    262 /*18*/	u_int8_t sense_key_spec_3;
    263 /*32*/	u_int8_t extra_bytes[14];
    264 };
    265 
    266 struct scsi_blk_desc {
    267 	u_int8_t density;
    268 	u_int8_t nblocks[3];
    269 	u_int8_t reserved;
    270 	u_int8_t blklen[3];
    271 };
    272 
    273 struct scsi_mode_header {
    274 	u_int8_t data_length;	/* Sense data length */
    275 	u_int8_t medium_type;
    276 	u_int8_t dev_spec;
    277 	u_int8_t blk_desc_len;
    278 };
    279 
    280 struct scsi_mode_header_big {
    281 	u_int8_t data_length[2];	/* Sense data length */
    282 	u_int8_t medium_type;
    283 	u_int8_t dev_spec;
    284 	u_int8_t unused[2];
    285 	u_int8_t blk_desc_len[2];
    286 };
    287 
    288 
    289 /*
    290  * Status Byte
    291  */
    292 #define	SCSI_OK		0x00
    293 #define	SCSI_CHECK	0x02
    294 #define	SCSI_BUSY	0x08
    295 #define SCSI_INTERM	0x10
    296 #define SCSI_QUEUE_FULL		0x28
    297 
    298 #endif /* _SCSI_SCSI_ALL_H */
    299