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