Home | History | Annotate | Line # | Download | only in scsipi
scsi_all.h revision 1.2
      1 /*
      2  * SCSI general  interface description
      3  *
      4  * Largely written by Julian Elischer (julian (at) tfs.com)
      5  * for TRW Financial Systems.
      6  *
      7  * TRW Financial Systems, in accordance with their agreement with Carnegie
      8  * Mellon University, makes this software available to CMU to distribute
      9  * or use in any manner that they see fit as long as this message is kept with
     10  * the software. For this reason TFS also grants any other persons or
     11  * organisations permission to use or modify this software.
     12  *
     13  * TFS supplies this software to be publicly redistributed
     14  * on the understanding that TFS is not responsible for the correct
     15  * functioning of this software in any circumstances.
     16  *
     17  *	$Id: scsi_all.h,v 1.2 1993/05/20 03:46:26 cgd Exp $
     18  */
     19 
     20 /*
     21  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     22  */
     23 
     24 /*
     25  * SCSI command format
     26  */
     27 
     28 
     29 struct scsi_generic
     30 {
     31 	u_char	opcode;
     32 	u_char	bytes[11];
     33 };
     34 
     35 struct scsi_test_unit_ready
     36 {
     37 	u_char	op_code;
     38 	u_char	:5;
     39 	u_char	lun:3;
     40 	u_char	unused[3];
     41 	u_char	link:1;
     42 	u_char	flag:4;
     43 	u_char	:3;
     44 };
     45 
     46 struct scsi_send_diag
     47 {
     48 	u_char	op_code;
     49 	u_char	uol:1;
     50 	u_char	dol:1;
     51 	u_char	selftest:1;
     52 	u_char	:1;
     53 	u_char	pf:1;
     54 	u_char	lun:3;
     55 	u_char	unused[1];
     56 	u_char	paramlen[2];
     57 	u_char	link:1;
     58 	u_char	flag:4;
     59 	u_char	:3;
     60 };
     61 
     62 struct scsi_sense
     63 {
     64 	u_char	op_code;
     65 	u_char	:5;
     66 	u_char	lun:3;
     67 	u_char	unused[2];
     68 	u_char	length;
     69 	u_char	link:1;
     70 	u_char	flag:1;
     71 	u_char	:6;
     72 };
     73 
     74 struct scsi_inquiry
     75 {
     76 	u_char	op_code;
     77 	u_char	:5;
     78 	u_char	lun:3;
     79 	u_char	unused[2];
     80 	u_char	length;
     81 	u_char	link:1;
     82 	u_char	flag:1;
     83 	u_char	:6;
     84 };
     85 
     86 struct scsi_mode_sense
     87 {
     88 	u_char	op_code;
     89 	u_char	:3;
     90 	u_char	dbd:1;
     91 	u_char	rsvd:1;
     92 	u_char	lun:3;
     93 	u_char	page_code:6;
     94 	u_char	page_ctrl:2;
     95 	u_char	unused;
     96 	u_char	length;
     97 	u_char	link:1;
     98 	u_char	flag:1;
     99 	u_char	:6;
    100 };
    101 
    102 struct scsi_mode_sense_big
    103 {
    104 	u_char	op_code;
    105 	u_char	:3;
    106 	u_char	dbd:1;
    107 	u_char	rsvd:1;
    108 	u_char	lun:3;
    109 	u_char	page_code:6;
    110 	u_char	page_ctrl:2;
    111 	u_char	unused[4];
    112 	u_char	length[2];
    113 	u_char	link:1;
    114 	u_char	flag:1;
    115 	u_char	:6;
    116 };
    117 
    118 struct scsi_mode_select
    119 {
    120 	u_char	op_code;
    121 	u_char	sp:1;
    122 	u_char	:3;
    123 	u_char	pf:1;
    124 	u_char	lun:3;
    125 	u_char	unused[2];
    126 	u_char	length;
    127 	u_char	link:1;
    128 	u_char	flag:1;
    129 	u_char	:6;
    130 };
    131 
    132 struct scsi_mode_select_big
    133 {
    134 	u_char	op_code;
    135 	u_char	sp:1;
    136 	u_char	:3;
    137 	u_char	pf:1;
    138 	u_char	lun:3;
    139 	u_char	unused[5];
    140 	u_char	length[2];
    141 	u_char	link:1;
    142 	u_char	flag:1;
    143 	u_char	:6;
    144 };
    145 
    146 struct scsi_reserve
    147 {
    148 	u_char	op_code;
    149 	u_char	:5;
    150 	u_char	lun:3;
    151 	u_char	unused[2];
    152 	u_char	length;
    153 	u_char	link:1;
    154 	u_char	flag:1;
    155 	u_char	:6;
    156 };
    157 
    158 struct scsi_release
    159 {
    160 	u_char	op_code;
    161 	u_char	:5;
    162 	u_char	lun:3;
    163 	u_char	unused[2];
    164 	u_char	length;
    165 	u_char	link:1;
    166 	u_char	flag:1;
    167 	u_char	:6;
    168 };
    169 
    170 struct scsi_prevent
    171 {
    172 	u_char	op_code;
    173 	u_char	:5;
    174 	u_char	lun:3;
    175 	u_char	unused[2];
    176 	u_char	prevent:1;
    177 	u_char	:7;
    178 	u_char	link:1;
    179 	u_char	flag:1;
    180 	u_char	:6;
    181 };
    182 #define	PR_PREVENT 1
    183 #define PR_ALLOW   0
    184 
    185 /*
    186  * Opcodes
    187  */
    188 
    189 #define	TEST_UNIT_READY		0x00
    190 #define REQUEST_SENSE		0x03
    191 #define INQUIRY			0x12
    192 #define MODE_SELECT		0x15
    193 #define MODE_SENSE		0x1a
    194 #define START_STOP		0x1b
    195 #define RESERVE      		0x16
    196 #define RELEASE      		0x17
    197 #define PREVENT_ALLOW		0x1e
    198 #define POSITION_TO_ELEMENT	0x2b
    199 #define	MODE_SENSE_BIG		0x54
    200 #define	MODE_SELECT_BIG		0x55
    201 #define MOVE_MEDIUM     	0xa5
    202 #define READ_ELEMENT_STATUS	0xb8
    203 
    204 
    205 /*
    206  * sense data format
    207  */
    208 #define T_DIRECT	0
    209 #define T_SEQUENTIAL	1
    210 #define T_PRINTER	2
    211 #define T_PROCESSOR	3
    212 #define T_WORM		4
    213 #define T_READONLY	5
    214 #define T_SCANNER 	6
    215 #define T_OPTICAL 	7
    216 #define T_NODEVICE	0x1F
    217 
    218 #define T_CHANGER	8
    219 #define T_COMM		9
    220 
    221 #define T_REMOV		1
    222 #define	T_FIXED		0
    223 
    224 struct scsi_inquiry_data
    225 {
    226 	u_char	device_type:5;
    227 	u_char	device_qualifier:3;
    228 	u_char	dev_qual2:7;
    229 	u_char	removable:1;
    230 	u_char	ansii_version:3;
    231 	u_char	:5;
    232 	u_char	response_format;
    233 	u_char	additional_length;
    234 	u_char	unused[2];
    235 	u_char	:3;
    236 	u_char	can_link:1;
    237 	u_char	can_sync:1;
    238 	u_char	:3;
    239 	char	vendor[8];
    240 	char	product[16];
    241 	char	revision[4];
    242 	u_char	extra[8];
    243 };
    244 
    245 
    246 struct	scsi_sense_data
    247 {
    248 	u_char	error_code:4;
    249 	u_char	error_class:3;
    250 	u_char	valid:1;
    251 	union
    252 	{
    253 		struct
    254 		{
    255 			u_char	blockhi:5;
    256 			u_char	vendor:3;
    257 			u_char	blockmed;
    258 			u_char	blocklow;
    259 		} unextended;
    260 		struct
    261 		{
    262 			u_char	segment;
    263 			u_char	sense_key:4;
    264 			u_char	:1;
    265 			u_char	ili:1;
    266 			u_char	eom:1;
    267 			u_char	filemark:1;
    268 			u_char	info[4];
    269 			u_char	extra_len;
    270 			/* allocate enough room to hold new stuff
    271 			u_char	cmd_spec_info[4];
    272 			u_char	add_sense_code;
    273 			u_char	add_sense_code_qual;
    274 			u_char	fru;
    275 			u_char	sense_key_spec_1:7;
    276 			u_char	sksv:1;
    277 			u_char	sense_key_spec_2;
    278 			u_char	sense_key_spec_3;
    279 			( by increasing 16 to 26 below) */
    280 			u_char	extra_bytes[26];
    281 		} extended;
    282 	}ext;
    283 };
    284 struct	scsi_sense_data_new
    285 {
    286 	u_char	error_code:7;
    287 	u_char	valid:1;
    288 	union
    289 	{
    290 		struct
    291 		{
    292 			u_char	blockhi:5;
    293 			u_char	vendor:3;
    294 			u_char	blockmed;
    295 			u_char	blocklow;
    296 		} unextended;
    297 		struct
    298 		{
    299 			u_char	segment;
    300 			u_char	sense_key:4;
    301 			u_char	:1;
    302 			u_char	ili:1;
    303 			u_char	eom:1;
    304 			u_char	filemark:1;
    305 			u_char	info[4];
    306 			u_char	extra_len;
    307 			u_char	cmd_spec_info[4];
    308 			u_char	add_sense_code;
    309 			u_char	add_sense_code_qual;
    310 			u_char	fru;
    311 			u_char	sense_key_spec_1:7;
    312 			u_char	sksv:1;
    313 			u_char	sense_key_spec_2;
    314 			u_char	sense_key_spec_3;
    315 			u_char	extra_bytes[16];
    316 		} extended;
    317 	}ext;
    318 };
    319 
    320 struct	blk_desc
    321 {
    322 	u_char	density;
    323 	u_char	nblocks[3];
    324 	u_char	reserved;
    325 	u_char	blklen[3];
    326 };
    327 
    328 struct scsi_mode_header
    329 {
    330 	u_char	data_length;	/* Sense data length */
    331 	u_char	medium_type;
    332 	u_char	dev_spec;
    333 	u_char	blk_desc_len;
    334 };
    335 
    336 struct scsi_mode_header_big
    337 {
    338 	u_char	data_length[2];	/* Sense data length */
    339 	u_char	medium_type;
    340 	u_char	dev_spec;
    341 	u_char	unused[2];
    342 	u_char	blk_desc_len[2];
    343 };
    344 
    345 
    346 /*
    347  * Status Byte
    348  */
    349 #define	SCSI_OK		0x00
    350 #define	SCSI_CHECK		0x02
    351 #define	SCSI_BUSY		0x08
    352 #define SCSI_INTERM		0x10
    353