Home | History | Annotate | Line # | Download | only in scsipi
scsipi_all.h revision 1.4
      1 /*	$NetBSD: scsipi_all.h,v 1.4 1997/10/02 16:03:47 mjacob 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	_SCSI_PI_ALL_H
     25 #define	_SCSI_PI_ALL_H 1
     26 
     27 /*
     28  * SCSI-like command format and opcode
     29  */
     30 
     31 #define	TEST_UNIT_READY		0x00
     32 struct scsipi_test_unit_ready {
     33 	u_int8_t opcode;
     34 	u_int8_t byte2;
     35 	u_int8_t unused[3];
     36 	u_int8_t control;
     37 };
     38 
     39 #define	REQUEST_SENSE		0x03
     40 struct scsipi_sense {
     41 	u_int8_t opcode;
     42 	u_int8_t byte2;
     43 	u_int8_t unused[2];
     44 	u_int8_t length;
     45 	u_int8_t control;
     46 };
     47 
     48 #define	INQUIRY			0x12
     49 struct scsipi_inquiry {
     50 	u_int8_t opcode;
     51 	u_int8_t byte2;
     52 	u_int8_t unused[2];
     53 	u_int8_t length;
     54 	u_int8_t control;
     55 };
     56 
     57 #define	PREVENT_ALLOW		0x1e
     58 struct scsipi_prevent {
     59 	u_int8_t opcode;
     60 	u_int8_t byte2;
     61 	u_int8_t unused[2];
     62 	u_int8_t how;
     63 	u_int8_t control;
     64 };
     65 #define	PR_PREVENT 0x01
     66 #define	PR_ALLOW   0x00
     67 
     68 /*
     69  * inquiry and sense data format
     70  */
     71 
     72 struct scsipi_sense_data {
     73 /* 1*/	u_int8_t error_code;
     74 #define	SSD_ERRCODE	0x7F
     75 #define	SSD_ERRCODE_VALID 0x80
     76 /* 2*/	u_int8_t segment;
     77 /* 3*/	u_int8_t flags;
     78 #define	SSD_KEY		0x0F
     79 #define	SSD_ILI		0x20
     80 #define	SSD_EOM		0x40
     81 #define	SSD_FILEMARK	0x80
     82 /* 7*/	u_int8_t info[4];
     83 /* 8*/	u_int8_t extra_len;
     84 /*12*/	u_int8_t cmd_spec_info[4];
     85 /*13*/	u_int8_t add_sense_code;
     86 /*14*/	u_int8_t add_sense_code_qual;
     87 /*15*/	u_int8_t fru;
     88 /*16*/	u_int8_t sense_key_spec_1;
     89 #define	SSD_SCS_VALID	0x80
     90 /*17*/	u_int8_t sense_key_spec_2;
     91 /*18*/	u_int8_t sense_key_spec_3;
     92 /*32*/	u_int8_t extra_bytes[14];
     93 };
     94 /*
     95  * Sense bytes described by the extra_len tag start at cmd_spec_info,
     96  * and can only continue up to the end of the structure we've defined
     97  * (which is too short for some cases).
     98  */
     99 #define	ADD_BYTES_LIM(sp)	\
    100 	(((int)(sp)->extra_len) < (int) sizeof(struct scsipi_sense_data) - 8)? \
    101 	((sp)->extra_len) : (sizeof (struct scsipi_sense_data) - 8)
    102 
    103 
    104 struct scsipi_sense_data_unextended {
    105 /* 1*/	u_int8_t error_code;
    106 /* 4*/	u_int8_t block[3];
    107 };
    108 
    109 #define	T_DIRECT	0
    110 #define	T_SEQUENTIAL	1
    111 #define	T_PRINTER	2
    112 #define	T_PROCESSOR	3
    113 #define	T_WORM		4
    114 #define	T_CDROM		5
    115 #define	T_SCANNER 	6
    116 #define	T_OPTICAL 	7
    117 #define	T_NODEVICE	0x1F
    118 
    119 #define	T_CHANGER	8
    120 #define	T_COMM		9
    121 
    122 #define	T_REMOV		1
    123 #define	T_FIXED		0
    124 
    125 /*
    126  * XXX
    127  * Actually I think some SCSI driver expects this structure to be 32 bytes, so
    128  * don't change it unless you really know what you are doing
    129  */
    130 
    131 struct scsipi_inquiry_data {
    132 	u_int8_t device;
    133 #define	SID_TYPE	0x1F
    134 #define	SID_QUAL	0xE0
    135 #define	SID_QUAL_LU_OK	0x00
    136 #define	SID_QUAL_LU_OFFLINE	0x20
    137 #define	SID_QUAL_RSVD	0x40
    138 #define	SID_QUAL_BAD_LU	0x60
    139 	u_int8_t dev_qual2;
    140 #define	SID_QUAL2	0x7F
    141 #define	SID_REMOVABLE	0x80
    142 	u_int8_t version;
    143 #define	SID_ANSII	0x07
    144 #define	SID_ECMA	0x38
    145 #define	SID_ISO		0xC0
    146 	u_int8_t response_format;
    147 	u_int8_t additional_length;
    148 	u_int8_t unused[2];
    149 	u_int8_t flags;
    150 #define	SID_SftRe	0x01
    151 #define	SID_CmdQue	0x02
    152 #define	SID_Linked	0x08
    153 #define	SID_Sync	0x10
    154 #define	SID_WBus16	0x20
    155 #define	SID_WBus32	0x40
    156 #define	SID_RelAdr	0x80
    157 	char	vendor[8];
    158 	char	product[16];
    159 	char	revision[4];
    160 	u_int8_t extra[8];
    161 };
    162 
    163 #endif /* _SCSI_PI_ALL_H */
    164