1 /* $NetBSD: scsipi_all.h,v 1.5 1997/10/03 02:04:19 thorpej Exp $ */ 2 3 /* 4 * SCSI and SCSI-like general interface description 5 */ 6 7 /* 8 * Largely written by Julian Elischer (julian@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@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 0x00 /* direct access device */ 110 #define T_SEQUENTIAL 0x01 /* sequential access device */ 111 #define T_PRINTER 0x02 /* printer device */ 112 #define T_PROCESSOR 0x03 /* processor device */ 113 #define T_WORM 0x04 /* write once, read many device */ 114 #define T_CDROM 0x05 /* cd-rom device */ 115 #define T_SCANNER 0x06 /* scanner device */ 116 #define T_OPTICAL 0x07 /* optical memory device */ 117 #define T_CHANGER 0x08 /* medium changer device */ 118 #define T_COMM 0x09 /* communication device */ 119 #define T_IT8_1 0x0a /* ??? */ 120 #define T_IT8_2 0x0b /* ??? */ 121 #define T_STORARRAY 0x0c /* storage array device */ 122 #define T_ENCLOSURE 0x0d /* enclosure services device */ 123 #define T_NODEVICE 0x1F 124 125 #define T_REMOV 1 /* device is removable */ 126 #define T_FIXED 0 /* device is not removable */ 127 128 /* 129 * XXX 130 * Actually I think some SCSI driver expects this structure to be 32 bytes, so 131 * don't change it unless you really know what you are doing 132 */ 133 134 struct scsipi_inquiry_data { 135 u_int8_t device; 136 #define SID_TYPE 0x1F 137 #define SID_QUAL 0xE0 138 #define SID_QUAL_LU_OK 0x00 139 #define SID_QUAL_LU_OFFLINE 0x20 140 #define SID_QUAL_RSVD 0x40 141 #define SID_QUAL_BAD_LU 0x60 142 u_int8_t dev_qual2; 143 #define SID_QUAL2 0x7F 144 #define SID_REMOVABLE 0x80 145 u_int8_t version; 146 #define SID_ANSII 0x07 147 #define SID_ECMA 0x38 148 #define SID_ISO 0xC0 149 u_int8_t response_format; 150 u_int8_t additional_length; 151 u_int8_t unused[2]; 152 u_int8_t flags; 153 #define SID_SftRe 0x01 154 #define SID_CmdQue 0x02 155 #define SID_Linked 0x08 156 #define SID_Sync 0x10 157 #define SID_WBus16 0x20 158 #define SID_WBus32 0x40 159 #define SID_RelAdr 0x80 160 char vendor[8]; 161 char product[16]; 162 char revision[4]; 163 u_int8_t extra[8]; 164 }; 165 166 #endif /* _SCSI_PI_ALL_H */ 167