1 1.1 cgd /* 2 1.2 cgd * SCSI general interface description 3 1.3 mycroft */ 4 1.3 mycroft 5 1.3 mycroft /* 6 1.1 cgd * Largely written by Julian Elischer (julian (at) tfs.com) 7 1.1 cgd * for TRW Financial Systems. 8 1.1 cgd * 9 1.1 cgd * TRW Financial Systems, in accordance with their agreement with Carnegie 10 1.1 cgd * Mellon University, makes this software available to CMU to distribute 11 1.1 cgd * or use in any manner that they see fit as long as this message is kept with 12 1.1 cgd * the software. For this reason TFS also grants any other persons or 13 1.1 cgd * organisations permission to use or modify this software. 14 1.1 cgd * 15 1.1 cgd * TFS supplies this software to be publicly redistributed 16 1.1 cgd * on the understanding that TFS is not responsible for the correct 17 1.1 cgd * functioning of this software in any circumstances. 18 1.1 cgd * 19 1.3 mycroft * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992 20 1.3 mycroft * 21 1.4 chopps * $Id: scsi_all.h,v 1.4 1994/05/09 07:40:50 chopps Exp $ 22 1.1 cgd */ 23 1.1 cgd 24 1.3 mycroft #ifndef _SCSI_SCSI_ALL_H 25 1.3 mycroft #define _SCSI_SCSI_ALL_H 1 26 1.1 cgd /* 27 1.3 mycroft * SCSI command format 28 1.1 cgd */ 29 1.1 cgd 30 1.1 cgd /* 31 1.3 mycroft * Define dome bits that are in ALL (or a lot of) scsi commands 32 1.1 cgd */ 33 1.3 mycroft #define SCSI_CTL_LINK 0x01 34 1.3 mycroft #define SCSI_CTL_FLAG 0x02 35 1.3 mycroft #define SCSI_CTL_VENDOR 0xC0 36 1.3 mycroft #define SCSI_CMD_LUN 0xA0 /* these two should not be needed */ 37 1.3 mycroft #define SCSI_CMD_LUN_SHIFT 5 /* LUN in the cmd is no longer SCSI */ 38 1.1 cgd 39 1.1 cgd 40 1.1 cgd struct scsi_generic 41 1.1 cgd { 42 1.1 cgd u_char opcode; 43 1.1 cgd u_char bytes[11]; 44 1.1 cgd }; 45 1.1 cgd 46 1.1 cgd struct scsi_test_unit_ready 47 1.1 cgd { 48 1.1 cgd u_char op_code; 49 1.3 mycroft u_char byte2; 50 1.1 cgd u_char unused[3]; 51 1.3 mycroft u_char control; 52 1.1 cgd }; 53 1.1 cgd 54 1.1 cgd struct scsi_send_diag 55 1.1 cgd { 56 1.1 cgd u_char op_code; 57 1.3 mycroft u_char byte2; 58 1.3 mycroft #define SSD_UOL 0x01 59 1.3 mycroft #define SSD_DOL 0x02 60 1.3 mycroft #define SSD_SELFTEST 0x04 61 1.3 mycroft #define SSD_PF 0x10 62 1.1 cgd u_char unused[1]; 63 1.1 cgd u_char paramlen[2]; 64 1.3 mycroft u_char control; 65 1.1 cgd }; 66 1.1 cgd 67 1.1 cgd struct scsi_sense 68 1.1 cgd { 69 1.1 cgd u_char op_code; 70 1.3 mycroft u_char byte2; 71 1.1 cgd u_char unused[2]; 72 1.1 cgd u_char length; 73 1.3 mycroft u_char control; 74 1.1 cgd }; 75 1.1 cgd 76 1.1 cgd struct scsi_inquiry 77 1.1 cgd { 78 1.1 cgd u_char op_code; 79 1.3 mycroft u_char byte2; 80 1.1 cgd u_char unused[2]; 81 1.1 cgd u_char length; 82 1.3 mycroft u_char control; 83 1.1 cgd }; 84 1.1 cgd 85 1.1 cgd struct scsi_mode_sense 86 1.1 cgd { 87 1.1 cgd u_char op_code; 88 1.3 mycroft u_char byte2; 89 1.3 mycroft #define SMS_DBD 0x08 90 1.3 mycroft u_char page; 91 1.3 mycroft #define SMS_PAGE_CODE 0x3F 92 1.3 mycroft #define SMS_PAGE_CTRL 0xC0 93 1.3 mycroft #define SMS_PAGE_CTRL_CURRENT 0x00 94 1.3 mycroft #define SMS_PAGE_CTRL_CHANGEABLE 0x40 95 1.3 mycroft #define SMS_PAGE_CTRL_DEFAULT 0x80 96 1.3 mycroft #define SMS_PAGE_CTRL_SAVED 0xC0 97 1.1 cgd u_char unused; 98 1.1 cgd u_char length; 99 1.3 mycroft u_char control; 100 1.1 cgd }; 101 1.1 cgd 102 1.1 cgd struct scsi_mode_sense_big 103 1.1 cgd { 104 1.1 cgd u_char op_code; 105 1.3 mycroft u_char byte2; /* same bits as small version */ 106 1.3 mycroft u_char page; /* same bits as small version */ 107 1.1 cgd u_char unused[4]; 108 1.1 cgd u_char length[2]; 109 1.3 mycroft u_char control; 110 1.1 cgd }; 111 1.1 cgd 112 1.1 cgd struct scsi_mode_select 113 1.1 cgd { 114 1.1 cgd u_char op_code; 115 1.3 mycroft u_char byte2; 116 1.3 mycroft #define SMS_SP 0x01 117 1.3 mycroft #define SMS_PF 0x10 118 1.1 cgd u_char unused[2]; 119 1.1 cgd u_char length; 120 1.3 mycroft u_char control; 121 1.1 cgd }; 122 1.1 cgd 123 1.1 cgd struct scsi_mode_select_big 124 1.1 cgd { 125 1.1 cgd u_char op_code; 126 1.3 mycroft u_char byte2; /* same bits as small version */ 127 1.1 cgd u_char unused[5]; 128 1.1 cgd u_char length[2]; 129 1.3 mycroft u_char control; 130 1.1 cgd }; 131 1.1 cgd 132 1.1 cgd struct scsi_reserve 133 1.1 cgd { 134 1.1 cgd u_char op_code; 135 1.3 mycroft u_char byte2; 136 1.1 cgd u_char unused[2]; 137 1.1 cgd u_char length; 138 1.3 mycroft u_char control; 139 1.1 cgd }; 140 1.1 cgd 141 1.1 cgd struct scsi_release 142 1.1 cgd { 143 1.1 cgd u_char op_code; 144 1.3 mycroft u_char byte2; 145 1.1 cgd u_char unused[2]; 146 1.1 cgd u_char length; 147 1.3 mycroft u_char control; 148 1.1 cgd }; 149 1.1 cgd 150 1.1 cgd struct scsi_prevent 151 1.1 cgd { 152 1.1 cgd u_char op_code; 153 1.3 mycroft u_char byte2; 154 1.1 cgd u_char unused[2]; 155 1.3 mycroft u_char how; 156 1.3 mycroft u_char control; 157 1.1 cgd }; 158 1.3 mycroft #define PR_PREVENT 0x01 159 1.3 mycroft #define PR_ALLOW 0x00 160 1.3 mycroft 161 1.3 mycroft struct scsi_changedef 162 1.3 mycroft { 163 1.3 mycroft u_char op_code; 164 1.3 mycroft u_char byte2; 165 1.3 mycroft u_char unused1; 166 1.3 mycroft u_char how; 167 1.3 mycroft u_char unused[4]; 168 1.3 mycroft u_char datalen; 169 1.3 mycroft u_char control; 170 1.3 mycroft }; 171 1.3 mycroft #define SC_SCSI_1 0x01 172 1.3 mycroft #define SC_SCSI_2 0x03 173 1.1 cgd 174 1.1 cgd /* 175 1.1 cgd * Opcodes 176 1.1 cgd */ 177 1.1 cgd 178 1.1 cgd #define TEST_UNIT_READY 0x00 179 1.1 cgd #define REQUEST_SENSE 0x03 180 1.1 cgd #define INQUIRY 0x12 181 1.1 cgd #define MODE_SELECT 0x15 182 1.1 cgd #define MODE_SENSE 0x1a 183 1.1 cgd #define START_STOP 0x1b 184 1.1 cgd #define RESERVE 0x16 185 1.1 cgd #define RELEASE 0x17 186 1.1 cgd #define PREVENT_ALLOW 0x1e 187 1.1 cgd #define POSITION_TO_ELEMENT 0x2b 188 1.3 mycroft #define CHANGE_DEFINITION 0x40 189 1.1 cgd #define MODE_SENSE_BIG 0x54 190 1.1 cgd #define MODE_SELECT_BIG 0x55 191 1.1 cgd #define MOVE_MEDIUM 0xa5 192 1.1 cgd #define READ_ELEMENT_STATUS 0xb8 193 1.1 cgd 194 1.1 cgd 195 1.1 cgd /* 196 1.1 cgd * sense data format 197 1.1 cgd */ 198 1.1 cgd #define T_DIRECT 0 199 1.1 cgd #define T_SEQUENTIAL 1 200 1.1 cgd #define T_PRINTER 2 201 1.1 cgd #define T_PROCESSOR 3 202 1.1 cgd #define T_WORM 4 203 1.1 cgd #define T_READONLY 5 204 1.1 cgd #define T_SCANNER 6 205 1.1 cgd #define T_OPTICAL 7 206 1.1 cgd #define T_NODEVICE 0x1F 207 1.1 cgd 208 1.1 cgd #define T_CHANGER 8 209 1.1 cgd #define T_COMM 9 210 1.1 cgd 211 1.1 cgd #define T_REMOV 1 212 1.1 cgd #define T_FIXED 0 213 1.1 cgd 214 1.1 cgd struct scsi_inquiry_data 215 1.1 cgd { 216 1.3 mycroft u_char device; 217 1.3 mycroft #define SID_TYPE 0x1F 218 1.3 mycroft #define SID_QUAL 0xE0 219 1.3 mycroft #define SID_QUAL_LU_OK 0x00 220 1.3 mycroft #define SID_QUAL_LU_OFFLINE 0x20 221 1.3 mycroft #define SID_QUAL_RSVD 0x40 222 1.3 mycroft #define SID_QUAL_BAD_LU 0x60 223 1.3 mycroft u_char dev_qual2; 224 1.3 mycroft #define SID_QUAL2 0x7F 225 1.3 mycroft #define SID_REMOVABLE 0x80 226 1.3 mycroft u_char version; 227 1.3 mycroft #define SID_ANSII 0x07 228 1.3 mycroft #define SID_ECMA 0x38 229 1.3 mycroft #define SID_ISO 0xC0 230 1.1 cgd u_char response_format; 231 1.1 cgd u_char additional_length; 232 1.1 cgd u_char unused[2]; 233 1.3 mycroft u_char flags; 234 1.3 mycroft #define SID_SftRe 0x01 235 1.3 mycroft #define SID_CmdQue 0x02 236 1.3 mycroft #define SID_Linked 0x08 237 1.3 mycroft #define SID_Sync 0x10 238 1.3 mycroft #define SID_WBus16 0x20 239 1.3 mycroft #define SID_WBus32 0x40 240 1.3 mycroft #define SID_RelAdr 0x80 241 1.1 cgd char vendor[8]; 242 1.1 cgd char product[16]; 243 1.1 cgd char revision[4]; 244 1.1 cgd u_char extra[8]; 245 1.1 cgd }; 246 1.1 cgd 247 1.4 chopps /* 248 1.4 chopps * The union had to die. It caused a padding problem with 249 1.4 chopps * m68k gcc, specifically `ext.extended.segment' was being 250 1.4 chopps * read at byte 2 not 1. 251 1.4 chopps */ 252 1.4 chopps struct scsi_sense_data_old /* XXXX The union had to die. */ 253 1.1 cgd { 254 1.3 mycroft /* 1*/ u_char error_code; /* same bits as new version */ 255 1.1 cgd union 256 1.1 cgd { 257 1.1 cgd struct 258 1.1 cgd { 259 1.3 mycroft /* 2*/ u_char blockhi; 260 1.3 mycroft /* 3*/ u_char blockmed; 261 1.3 mycroft /* 4*/ u_char blocklow; 262 1.1 cgd } unextended; 263 1.1 cgd struct 264 1.1 cgd { 265 1.3 mycroft /* 2*/ u_char segment; 266 1.3 mycroft /* 3*/ u_char flags; /* same bits as new version */ 267 1.3 mycroft /* 7*/ u_char info[4]; 268 1.3 mycroft /* 8*/ u_char extra_len; 269 1.1 cgd /* allocate enough room to hold new stuff 270 1.3 mycroft ( by increasing 16 to 24 below) */ 271 1.3 mycroft /*32*/ u_char extra_bytes[24]; 272 1.1 cgd } extended; 273 1.1 cgd }ext; 274 1.3 mycroft }; /* total of 32 bytes */ 275 1.4 chopps 276 1.4 chopps /* 277 1.4 chopps * This looks bad, and it is. However it fixes padding problems 278 1.4 chopps * caused by using unions. This *needs* to be an array, if this code 279 1.4 chopps * is to work on any architecture. 280 1.4 chopps */ 281 1.4 chopps struct scsi_sense_data 282 1.4 chopps { 283 1.4 chopps /* 1*/ u_char error_code; /* same bits as new version */ 284 1.4 chopps #define XXX_unextended_blockhi extended_segment 285 1.4 chopps #define XXX_unextended_blockmed extended_flags 286 1.4 chopps #define XXX_unextended_blocklow extended_info[0] 287 1.4 chopps /* 2*/ u_char extended_segment; 288 1.4 chopps /* 3*/ u_char extended_flags; /* same bits as new version */ 289 1.4 chopps /* 7*/ u_char extended_info[4]; 290 1.4 chopps /* 8*/ u_char extended_extra_len; 291 1.4 chopps /* 292 1.4 chopps * allocate enough room to hold new stuff 293 1.4 chopps * (by increasing 16 to 24 below) 294 1.4 chopps */ 295 1.4 chopps /*32*/ u_char extended_extra_bytes[24]; 296 1.4 chopps }; /* total of 32 bytes */ 297 1.4 chopps 298 1.1 cgd struct scsi_sense_data_new 299 1.1 cgd { 300 1.3 mycroft /* 1*/ u_char error_code; 301 1.3 mycroft #define SSD_ERRCODE 0x7F 302 1.3 mycroft #define SSD_ERRCODE_VALID 0x80 303 1.1 cgd union 304 1.1 cgd { 305 1.3 mycroft struct /* this is deprecated, the standard says "DON'T"*/ 306 1.1 cgd { 307 1.3 mycroft /* 2*/ u_char blockhi; 308 1.3 mycroft /* 3*/ u_char blockmed; 309 1.3 mycroft /* 4*/ u_char blocklow; 310 1.1 cgd } unextended; 311 1.1 cgd struct 312 1.1 cgd { 313 1.3 mycroft /* 2*/ u_char segment; 314 1.3 mycroft /* 3*/ u_char flags; 315 1.3 mycroft #define SSD_KEY 0x0F 316 1.3 mycroft #define SSD_ILI 0x20 317 1.3 mycroft #define SSD_EOM 0x40 318 1.3 mycroft #define SSD_FILEMARK 0x80 319 1.3 mycroft /* 7*/ u_char info[4]; 320 1.3 mycroft /* 8*/ u_char extra_len; 321 1.3 mycroft /*12*/ u_char cmd_spec_info[4]; 322 1.3 mycroft /*13*/ u_char add_sense_code; 323 1.3 mycroft /*14*/ u_char add_sense_code_qual; 324 1.3 mycroft /*15*/ u_char fru; 325 1.3 mycroft /*16*/ u_char sense_key_spec_1; 326 1.3 mycroft #define SSD_SCS_VALID 0x80 327 1.3 mycroft /*17*/ u_char sense_key_spec_2; 328 1.3 mycroft /*18*/ u_char sense_key_spec_3; 329 1.3 mycroft /*32*/ u_char extra_bytes[14]; 330 1.1 cgd } extended; 331 1.1 cgd }ext; 332 1.3 mycroft }; /* total of 32 bytes */ 333 1.1 cgd 334 1.1 cgd struct blk_desc 335 1.1 cgd { 336 1.1 cgd u_char density; 337 1.1 cgd u_char nblocks[3]; 338 1.1 cgd u_char reserved; 339 1.1 cgd u_char blklen[3]; 340 1.1 cgd }; 341 1.1 cgd 342 1.1 cgd struct scsi_mode_header 343 1.1 cgd { 344 1.1 cgd u_char data_length; /* Sense data length */ 345 1.1 cgd u_char medium_type; 346 1.1 cgd u_char dev_spec; 347 1.1 cgd u_char blk_desc_len; 348 1.1 cgd }; 349 1.1 cgd 350 1.1 cgd struct scsi_mode_header_big 351 1.1 cgd { 352 1.1 cgd u_char data_length[2]; /* Sense data length */ 353 1.1 cgd u_char medium_type; 354 1.1 cgd u_char dev_spec; 355 1.1 cgd u_char unused[2]; 356 1.1 cgd u_char blk_desc_len[2]; 357 1.1 cgd }; 358 1.1 cgd 359 1.1 cgd 360 1.1 cgd /* 361 1.1 cgd * Status Byte 362 1.1 cgd */ 363 1.1 cgd #define SCSI_OK 0x00 364 1.1 cgd #define SCSI_CHECK 0x02 365 1.1 cgd #define SCSI_BUSY 0x08 366 1.1 cgd #define SCSI_INTERM 0x10 367 1.3 mycroft #endif /*_SCSI_SCSI_ALL_H*/ 368