1 /* $NetBSD: scsi_all.h,v 1.6 1994/12/28 19:42:54 mycroft Exp $ */ 2 3 /* 4 * SCSI 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_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 #define SCSI_CMD_LUN 0xA0 /* these two should not be needed */ 38 #define SCSI_CMD_LUN_SHIFT 5 /* LUN in the cmd is no longer SCSI */ 39 40 41 struct scsi_generic { 42 u_int8_t opcode; 43 u_int8_t bytes[11]; 44 }; 45 46 struct scsi_test_unit_ready { 47 u_int8_t opcode; 48 u_int8_t byte2; 49 u_int8_t unused[3]; 50 u_int8_t control; 51 }; 52 53 struct scsi_send_diag { 54 u_int8_t opcode; 55 u_int8_t byte2; 56 #define SSD_UOL 0x01 57 #define SSD_DOL 0x02 58 #define SSD_SELFTEST 0x04 59 #define SSD_PF 0x10 60 u_int8_t unused[1]; 61 u_int8_t paramlen[2]; 62 u_int8_t control; 63 }; 64 65 struct scsi_sense { 66 u_int8_t opcode; 67 u_int8_t byte2; 68 u_int8_t unused[2]; 69 u_int8_t length; 70 u_int8_t control; 71 }; 72 73 struct scsi_inquiry { 74 u_int8_t opcode; 75 u_int8_t byte2; 76 u_int8_t unused[2]; 77 u_int8_t length; 78 u_int8_t control; 79 }; 80 81 struct scsi_mode_sense { 82 u_int8_t opcode; 83 u_int8_t byte2; 84 #define SMS_DBD 0x08 85 u_int8_t page; 86 #define SMS_PAGE_CODE 0x3F 87 #define SMS_PAGE_CTRL 0xC0 88 #define SMS_PAGE_CTRL_CURRENT 0x00 89 #define SMS_PAGE_CTRL_CHANGEABLE 0x40 90 #define SMS_PAGE_CTRL_DEFAULT 0x80 91 #define SMS_PAGE_CTRL_SAVED 0xC0 92 u_int8_t unused; 93 u_int8_t length; 94 u_int8_t control; 95 }; 96 97 struct scsi_mode_sense_big { 98 u_int8_t opcode; 99 u_int8_t byte2; /* same bits as small version */ 100 u_int8_t page; /* same bits as small version */ 101 u_int8_t unused[4]; 102 u_int8_t length[2]; 103 u_int8_t control; 104 }; 105 106 struct scsi_mode_select { 107 u_int8_t opcode; 108 u_int8_t byte2; 109 #define SMS_SP 0x01 110 #define SMS_PF 0x10 111 u_int8_t unused[2]; 112 u_int8_t length; 113 u_int8_t control; 114 }; 115 116 struct scsi_mode_select_big { 117 u_int8_t opcode; 118 u_int8_t byte2; /* same bits as small version */ 119 u_int8_t unused[5]; 120 u_int8_t length[2]; 121 u_int8_t control; 122 }; 123 124 struct scsi_reserve { 125 u_int8_t opcode; 126 u_int8_t byte2; 127 u_int8_t unused[2]; 128 u_int8_t length; 129 u_int8_t control; 130 }; 131 132 struct scsi_release { 133 u_int8_t opcode; 134 u_int8_t byte2; 135 u_int8_t unused[2]; 136 u_int8_t length; 137 u_int8_t control; 138 }; 139 140 struct scsi_prevent { 141 u_int8_t opcode; 142 u_int8_t byte2; 143 u_int8_t unused[2]; 144 u_int8_t how; 145 u_int8_t control; 146 }; 147 #define PR_PREVENT 0x01 148 #define PR_ALLOW 0x00 149 150 struct scsi_changedef { 151 u_int8_t opcode; 152 u_int8_t byte2; 153 u_int8_t unused1; 154 u_int8_t how; 155 u_int8_t unused[4]; 156 u_int8_t datalen; 157 u_int8_t control; 158 }; 159 #define SC_SCSI_1 0x01 160 #define SC_SCSI_2 0x03 161 162 /* 163 * Opcodes 164 */ 165 #define TEST_UNIT_READY 0x00 166 #define REQUEST_SENSE 0x03 167 #define INQUIRY 0x12 168 #define MODE_SELECT 0x15 169 #define MODE_SENSE 0x1a 170 #define START_STOP 0x1b 171 #define RESERVE 0x16 172 #define RELEASE 0x17 173 #define PREVENT_ALLOW 0x1e 174 #define POSITION_TO_ELEMENT 0x2b 175 #define CHANGE_DEFINITION 0x40 176 #define MODE_SENSE_BIG 0x54 177 #define MODE_SELECT_BIG 0x55 178 #define MOVE_MEDIUM 0xa5 179 #define READ_ELEMENT_STATUS 0xb8 180 181 /* 182 * sense data format 183 */ 184 #define T_DIRECT 0 185 #define T_SEQUENTIAL 1 186 #define T_PRINTER 2 187 #define T_PROCESSOR 3 188 #define T_WORM 4 189 #define T_CDROM 5 190 #define T_SCANNER 6 191 #define T_OPTICAL 7 192 #define T_NODEVICE 0x1F 193 194 #define T_CHANGER 8 195 #define T_COMM 9 196 197 #define T_REMOV 1 198 #define T_FIXED 0 199 200 struct scsi_inquiry_data { 201 u_int8_t device; 202 #define SID_TYPE 0x1F 203 #define SID_QUAL 0xE0 204 #define SID_QUAL_LU_OK 0x00 205 #define SID_QUAL_LU_OFFLINE 0x20 206 #define SID_QUAL_RSVD 0x40 207 #define SID_QUAL_BAD_LU 0x60 208 u_int8_t dev_qual2; 209 #define SID_QUAL2 0x7F 210 #define SID_REMOVABLE 0x80 211 u_int8_t version; 212 #define SID_ANSII 0x07 213 #define SID_ECMA 0x38 214 #define SID_ISO 0xC0 215 u_int8_t response_format; 216 u_int8_t additional_length; 217 u_int8_t unused[2]; 218 u_int8_t flags; 219 #define SID_SftRe 0x01 220 #define SID_CmdQue 0x02 221 #define SID_Linked 0x08 222 #define SID_Sync 0x10 223 #define SID_WBus16 0x20 224 #define SID_WBus32 0x40 225 #define SID_RelAdr 0x80 226 char vendor[8]; 227 char product[16]; 228 char revision[4]; 229 u_int8_t extra[8]; 230 }; 231 232 /* 233 * This looks bad, and it is. However it fixes padding problems 234 * caused by using unions. This *needs* to be an array, if this code 235 * is to work on any architecture. 236 */ 237 struct scsi_sense_data { 238 /* 1*/ u_int8_t error_code; /* same bits as new version */ 239 #define XXX_unextended_blockhi extended_segment 240 #define XXX_unextended_blockmed extended_flags 241 #define XXX_unextended_blocklow extended_info[0] 242 /* 2*/ u_int8_t extended_segment; 243 /* 3*/ u_int8_t extended_flags; /* same bits as new version */ 244 /* 7*/ u_int8_t extended_info[4]; 245 /* 8*/ u_int8_t extended_extra_len; 246 /* 247 * allocate enough room to hold new stuff 248 * (by increasing 16 to 24 below) 249 */ 250 /*32*/ u_int8_t extended_extra_bytes[24]; 251 }; /* total of 32 bytes */ 252 253 struct scsi_sense_data_new { 254 /* 1*/ u_int8_t error_code; 255 #define SSD_ERRCODE 0x7F 256 #define SSD_ERRCODE_VALID 0x80 257 union { 258 struct { /* this is deprecated, the standard says "DON'T"*/ 259 /* 2*/ u_int8_t blockhi; 260 /* 3*/ u_int8_t blockmed; 261 /* 4*/ u_int8_t blocklow; 262 } unextended; 263 struct { 264 /* 2*/ u_int8_t segment; 265 /* 3*/ u_int8_t flags; 266 #define SSD_KEY 0x0F 267 #define SSD_ILI 0x20 268 #define SSD_EOM 0x40 269 #define SSD_FILEMARK 0x80 270 /* 7*/ u_int8_t info[4]; 271 /* 8*/ u_int8_t extra_len; 272 /*12*/ u_int8_t cmd_spec_info[4]; 273 /*13*/ u_int8_t add_sense_code; 274 /*14*/ u_int8_t add_sense_code_qual; 275 /*15*/ u_int8_t fru; 276 /*16*/ u_int8_t sense_key_spec_1; 277 #define SSD_SCS_VALID 0x80 278 /*17*/ u_int8_t sense_key_spec_2; 279 /*18*/ u_int8_t sense_key_spec_3; 280 /*32*/ u_int8_t extra_bytes[14]; 281 } extended; 282 } ext; 283 }; /* total of 32 bytes */ 284 285 struct scsi_blk_desc { 286 u_int8_t density; 287 u_int8_t nblocks[3]; 288 u_int8_t reserved; 289 u_int8_t blklen[3]; 290 }; 291 292 struct scsi_mode_header { 293 u_int8_t data_length; /* Sense data length */ 294 u_int8_t medium_type; 295 u_int8_t dev_spec; 296 u_int8_t blk_desc_len; 297 }; 298 299 struct scsi_mode_header_big { 300 u_int8_t data_length[2]; /* Sense data length */ 301 u_int8_t medium_type; 302 u_int8_t dev_spec; 303 u_int8_t unused[2]; 304 u_int8_t blk_desc_len[2]; 305 }; 306 307 308 /* 309 * Status Byte 310 */ 311 #define SCSI_OK 0x00 312 #define SCSI_CHECK 0x02 313 #define SCSI_BUSY 0x08 314 #define SCSI_INTERM 0x10 315 316 #endif /* _SCSI_SCSI_ALL_H */ 317