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