1 /* $OpenBSD: scsi_all.h,v 1.65 2022/01/11 23:10:11 jsg Exp $ */ 2 /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ 3 4 /* 5 * SCSI general interface description 6 */ 7 8 /* 9 * Largely written by Julian Elischer (julian@tfs.com) 10 * for TRW Financial Systems. 11 * 12 * TRW Financial Systems, in accordance with their agreement with Carnegie 13 * Mellon University, makes this software available to CMU to distribute 14 * or use in any manner that they see fit as long as this message is kept with 15 * the software. For this reason TFS also grants any other persons or 16 * organisations permission to use or modify this software. 17 * 18 * TFS supplies this software to be publicly redistributed 19 * on the understanding that TFS is not responsible for the correct 20 * functioning of this software in any circumstances. 21 * 22 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 23 */ 24 25 #ifndef _SCSI_SCSI_ALL_H 26 #define _SCSI_SCSI_ALL_H 27 28 /* 29 * SCSI command format 30 */ 31 32 /* 33 * Define some bits that are in ALL (or a lot of) scsi commands 34 */ 35 #define SCSI_CTL_LINK 0x01 36 #define SCSI_CTL_FLAG 0x02 37 #define SCSI_CTL_VENDOR 0xC0 38 39 40 /* 41 * Some old SCSI devices need the LUN to be set in the top 3 bits of the 42 * second byte of the CDB. 43 */ 44 #define SCSI_CMD_LUN_MASK 0xe0 45 #define SCSI_CMD_LUN_SHIFT 5 46 47 48 struct scsi_generic { 49 u_int8_t opcode; 50 u_int8_t bytes[15]; 51 }; 52 53 struct scsi_test_unit_ready { 54 u_int8_t opcode; 55 u_int8_t byte2; 56 u_int8_t unused[3]; 57 u_int8_t control; 58 }; 59 60 struct scsi_send_diag { 61 u_int8_t opcode; 62 u_int8_t byte2; 63 #define SSD_UOL 0x01 64 #define SSD_DOL 0x02 65 #define SSD_SELFTEST 0x04 66 #define SSD_PF 0x10 67 u_int8_t unused[1]; 68 u_int8_t paramlen[2]; 69 u_int8_t control; 70 }; 71 72 struct scsi_sense { 73 u_int8_t opcode; 74 u_int8_t byte2; 75 u_int8_t unused[2]; 76 u_int8_t length; 77 u_int8_t control; 78 }; 79 80 struct scsi_inquiry { 81 u_int8_t opcode; 82 u_int8_t flags; 83 #define SI_EVPD 0x01 84 u_int8_t pagecode; 85 #define SI_PG_SUPPORTED 0x00 86 #define SI_PG_SERIAL 0x80 87 #define SI_PG_DEVID 0x83 88 #define SI_PG_ATA 0x89 89 u_int8_t length[2]; 90 u_int8_t control; 91 }; 92 93 struct scsi_mode_sense { 94 u_int8_t opcode; 95 u_int8_t byte2; 96 #define SMS_DBD 0x08 /* Disable Block Descriptors */ 97 u_int8_t page; 98 #define SMS_PAGE_CODE 0x3F 99 #define SMS_PAGE_CTRL 0xC0 100 #define SMS_PAGE_CTRL_CURRENT 0x00 101 #define SMS_PAGE_CTRL_CHANGEABLE 0x40 102 #define SMS_PAGE_CTRL_DEFAULT 0x80 103 #define SMS_PAGE_CTRL_SAVED 0xC0 104 u_int8_t unused; 105 u_int8_t length; 106 u_int8_t control; 107 }; 108 109 struct scsi_mode_sense_big { 110 u_int8_t opcode; 111 u_int8_t byte2; /* same bits as small version */ 112 #define SMS_LLBAA 0x10 /* plus: Long LBA Accepted */ 113 u_int8_t page; /* same bits as small version */ 114 u_int8_t unused[4]; 115 u_int8_t length[2]; 116 u_int8_t control; 117 }; 118 119 struct scsi_mode_select { 120 u_int8_t opcode; 121 u_int8_t byte2; 122 #define SMS_SP 0x01 123 #define SMS_PF 0x10 124 u_int8_t unused[2]; 125 u_int8_t length; 126 u_int8_t control; 127 }; 128 129 struct scsi_mode_select_big { 130 u_int8_t opcode; 131 u_int8_t byte2; /* same bits as small version */ 132 u_int8_t unused[5]; 133 u_int8_t length[2]; 134 u_int8_t control; 135 }; 136 137 struct scsi_reserve { 138 u_int8_t opcode; 139 u_int8_t byte2; 140 u_int8_t unused[2]; 141 u_int8_t length; 142 u_int8_t control; 143 }; 144 145 struct scsi_release { 146 u_int8_t opcode; 147 u_int8_t byte2; 148 u_int8_t unused[2]; 149 u_int8_t length; 150 u_int8_t control; 151 }; 152 153 struct scsi_prevent { 154 u_int8_t opcode; 155 u_int8_t byte2; 156 u_int8_t unused[2]; 157 u_int8_t how; 158 u_int8_t control; 159 }; 160 #define PR_PREVENT 0x01 161 #define PR_ALLOW 0x00 162 163 struct scsi_report_luns { 164 u_int8_t opcode; 165 u_int8_t unused; 166 u_int8_t selectreport; 167 #define REPORT_NORMAL 0x00 168 #define REPORT_WELLKNOWN 0x01 169 #define REPORT_ALL 0x02 170 u_int8_t unused2[3]; 171 u_int8_t length[4]; 172 u_int8_t unused4; 173 u_int8_t control; 174 }; 175 176 /* 177 * Opcodes 178 */ 179 #define TEST_UNIT_READY 0x00 180 #define REQUEST_SENSE 0x03 181 #define INQUIRY 0x12 182 #define MODE_SELECT 0x15 183 #define RESERVE 0x16 184 #define RELEASE 0x17 185 #define MODE_SENSE 0x1a 186 #define START_STOP 0x1b 187 #define RECEIVE_DIAGNOSTIC 0x1c 188 #define SEND_DIAGNOSTIC 0x1d 189 #define PREVENT_ALLOW 0x1e 190 #define POSITION_TO_ELEMENT 0x2b 191 #define WRITE_BUFFER 0x3b 192 #define READ_BUFFER 0x3c 193 #define CHANGE_DEFINITION 0x40 194 #define MODE_SELECT_BIG 0x55 195 #define MODE_SENSE_BIG 0x5a 196 #define REPORT_LUNS 0xa0 197 198 /* 199 * Sort of an extra one, for SCSI_RESET. 200 */ 201 #define GENRETRY 1 202 203 /* 204 * Device Types 205 */ 206 #define T_DIRECT 0x00 /* Direct access block device (SBC-4) */ 207 #define T_SEQUENTIAL 0x01 /* Sequential access device (SSC-3) */ 208 #define T_PRINTER 0x02 /* Printer device (SSC) */ 209 #define T_PROCESSOR 0x03 /* Processor device (SPC-2) */ 210 #define T_WORM 0x04 /* Write once device (SBC) */ 211 #define T_CDROM 0x05 /* CD/DVD device (MMC-5) */ 212 #define T_SCANNER 0x06 /* Scanner device (Obsolete) */ 213 #define T_OPTICAL 0x07 /* Optical memory device (SBC) */ 214 #define T_CHANGER 0x08 /* Media changer device (SMC-3) */ 215 #define T_COMM 0x09 /* Communications device (Obsolete) */ 216 #define T_ASC0 0x0a /* Obsolete */ 217 #define T_ASC1 0x0b /* Obsolete */ 218 #define T_STORARRAY 0x0c /* Storage Array controller device (RAID) */ 219 #define T_ENCLOSURE 0x0d /* Enclosure services device (SES) */ 220 #define T_RDIRECT 0x0e /* Simplified direct access device (RBC) */ 221 #define T_OCRW 0x0f /* Optical card reader/writer (OCRW) */ 222 #define T_BCC 0x10 /* Bridge Controller Commands (BCC) */ 223 #define T_OSD 0x11 /* Object-based Storage device (OSD) */ 224 #define T_ADC 0x12 /* Automation/Drive Interface (ADC-2) */ 225 /* 0x13 - 0x1d RESERVED */ 226 #define T_WELL_KNOWN_LU 0x1e /* Well known logical unit */ 227 #define T_NODEVICE 0x1F /* Unknown or no device type */ 228 229 #define T_REMOV 1 230 #define T_FIXED 0 231 232 struct scsi_inquiry_data { 233 u_int8_t device; 234 #define SID_TYPE 0x1f 235 #define SID_QUAL 0xe0 236 #define SID_QUAL_LU_OK 0x00 237 #define SID_QUAL_LU_OFFLINE 0x20 238 #define SID_QUAL_RSVD 0x40 239 #define SID_QUAL_BAD_LU 0x60 240 u_int8_t dev_qual2; 241 #define SID_QUAL2 0x7f 242 #define SID_REMOVABLE 0x80 243 u_int8_t version; 244 #define SID_ANSII 0x07 245 #define SID_ECMA 0x38 246 #define SID_ISO 0xc0 247 u_int8_t response_format; 248 #define SID_RESPONSE_DATA_FMT 0x0f /* < 2 == obsolete, > 2 reserved! */ 249 #define SID_SCSI2_RESPONSE 0x02 250 #define SID_HiSup 0x10 /* Hierarchical LUNs */ 251 #define SID_NormACA 0x20 /* Normal ACA bit in CCB supported */ 252 #define SID_TrmIOP 0x40 /* obsolete */ 253 #define SID_AENC 0x80 /* obsolete */ 254 u_int8_t additional_length; 255 #define SID_SCSI2_HDRLEN 5 /* Bytes up to & including additional_length */ 256 #define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */ 257 u_int8_t spc3_flags; 258 #define SPC3_SID_PROTECT 0x01 /* 0 == Type 0, 1 == Type 1, 2 or 3 */ 259 #define SPC3_SID_RESERVED 0x06 260 #define SPC3_SID_3PC 0x08 /* 3rd party copy */ 261 #define SPC3_SID_TPGS_IMPLICIT 0x10 /* Implicit asymmetric LU access */ 262 #define SPC3_SID_TPGS_EXPLICIT 0x20 /* Explicit asymmetric LU access */ 263 #define SPC3_SID_ACC 0x40 /* Access controls controller */ 264 #define SPC3_SID_SCCS 0x80 /* Embedded storage array controller */ 265 u_int8_t spc2_flags; 266 #define SPC2_SID_ADDR16 0x01 /* obsolete */ 267 #define SPC2_RESERVED 0x06 268 #define SPC2_SID_NChngr 0x08 /* obsolete */ 269 #define SPC2_SID_MultiP 0x10 /* multi-port target */ 270 #define SPC2_VS 0x20 /* ??? */ 271 #define SPC2_SID_EncServ 0x40 /* Embedded enclosure services */ 272 #define SPC2_SID_BQueue 0x80 /* obsolete */ 273 u_int8_t flags; 274 #define SID_VS 0x01 /* ??? */ 275 #define SID_CmdQue 0x02 /* Task management mode supported */ 276 #define SID_Linked 0x08 /* obsolete */ 277 #define SID_Sync 0x10 /* obsolete */ 278 #define SID_WBus16 0x20 /* obsolete */ 279 #define SID_WBus32 0x40 /* obsolete */ 280 #define SID_RelAdr 0x80 /* obsolete */ 281 char vendor[8]; 282 char product[16]; 283 char revision[4]; 284 u_int8_t extra[20]; 285 u_int8_t reserved[2]; 286 u_int8_t version_descriptor0[2]; 287 u_int8_t version_descriptor1[2]; 288 u_int8_t version_descriptor2[2]; 289 u_int8_t version_descriptor3[2]; 290 u_int8_t version_descriptor4[2]; 291 u_int8_t version_descriptor5[2]; 292 u_int8_t version_descriptor6[2]; 293 u_int8_t version_descriptor7[2]; 294 u_int8_t reserved2[22]; 295 }; 296 297 struct scsi_vpd_hdr { 298 u_int8_t device; 299 u_int8_t page_code; 300 u_int8_t page_length[2]; 301 }; 302 303 struct scsi_vpd_serial { 304 struct scsi_vpd_hdr hdr; 305 char serial[32]; 306 }; 307 308 #define VPD_PROTO_ID_FC 0x0 /* Fibre Channel */ 309 #define VPD_PROTO_ID_SPI 0x1 /* Parallel SCSI */ 310 #define VPD_PROTO_ID_SSA 0x2 311 #define VPD_PROTO_ID_IEEE1394 0x3 312 #define VPD_PROTO_ID_SRP 0x4 /* SCSI RDMA Protocol */ 313 #define VPD_PROTO_ID_ISCSI 0x5 /* Internet SCSI (iSCSI) */ 314 #define VPD_PROTO_ID_SAS 0x6 /* Serial Attached SCSI */ 315 #define VPD_PROTO_ID_ADT 0x7 /* Automation/Drive Interface Transport */ 316 #define VPD_PROTO_ID_ATA 0x7 /* ATA/ATAPI */ 317 #define VPD_PROTO_ID_NONE 0xf 318 319 struct scsi_vpd_devid_hdr { 320 u_int8_t pi_code; 321 #define VPD_DEVID_PI(_f) (((_f) >> 4) & 0x0f) 322 #define VPD_DEVID_CODE(_f) (((_f) >> 0) & 0x0f) 323 #define VPD_DEVID_CODE_BINARY 0x1 324 #define VPD_DEVID_CODE_ASCII 0x2 325 #define VPD_DEVID_CODE_UTF8 0x3 326 u_int8_t flags; 327 #define VPD_DEVID_PIV 0x80 328 #define VPD_DEVID_ASSOC(_f) ((_f) & 0x30) 329 #define VPD_DEVID_ASSOC_LU 0x00 330 #define VPD_DEVID_ASSOC_PORT 0x10 331 #define VPD_DEVID_ASSOC_TARG 0x20 332 #define VPD_DEVID_TYPE(_f) ((_f) & 0x0f) 333 #define VPD_DEVID_TYPE_VENDOR 0x0 334 #define VPD_DEVID_TYPE_T10 0x1 335 #define VPD_DEVID_TYPE_EUI64 0x2 336 #define VPD_DEVID_TYPE_NAA 0x3 337 #define VPD_DEVID_TYPE_RELATIVE 0x4 338 #define VPD_DEVID_TYPE_PORT 0x5 339 #define VPD_DEVID_TYPE_LU 0x6 340 #define VPD_DEVID_TYPE_MD5 0x7 341 #define VPD_DEVID_TYPE_NAME 0x8 342 u_int8_t reserved; 343 u_int8_t len; 344 }; 345 346 struct scsi_vpd_ata { 347 struct scsi_vpd_hdr hdr; 348 349 u_int8_t _reserved1[4]; 350 u_int8_t sat_vendor[8]; 351 u_int8_t sat_product[16]; 352 u_int8_t sat_revision[4]; 353 u_int8_t device_signature[20]; 354 u_int8_t command_code; 355 #define VPD_ATA_COMMAND_CODE_ATA 0xec 356 #define VPD_ATA_COMMAND_CODE_ATAPI 0xa1 357 u_int8_t _reserved2[3]; 358 u_int8_t identify[512]; 359 }; 360 361 struct scsi_read_cap_data { 362 u_int8_t addr[4]; 363 u_int8_t length[4]; 364 }; 365 366 struct scsi_read_cap_data_16 { 367 u_int8_t addr[8]; 368 u_int8_t length[4]; 369 u_int8_t p_type_prot; 370 #define RC16_PROT_EN 0x01 /* Protection type is 0 when 0 */ 371 #define RC16_PROT_P_TYPE 0x0e 372 #define RC16_P_TYPE_1 0x00 /* Protection type 1 */ 373 #define RC16_P_TYPE_2 0x02 /* Protection type 2 */ 374 #define RC16_P_TYPE_3 0x04 /* Protection type 3 */ 375 #define RC16_BASIS 0x30 /* Meaning of addr */ 376 #define RC16_BASIS_HIGH 0x00 /* highest LBA of zone */ 377 #define RC16_BASIS_LAST 0x10 /* last LBA on unit */ 378 u_int8_t logical_per_phys; /* Logical Blks Per Physical Blk Exp */ 379 #define RC16_LBPPB_EXPONENT 0x0f /* 2**N LB per PB, 0 means unknown */ 380 #define RC16_PIIPLB_EXPONENT 0xf0 /* 2**N Prot info intervals per LB */ 381 u_int8_t lowest_aligned[2]; 382 #define RC16_LALBA 0x3fff /* lowest aligned LBA */ 383 #define RC16_LBPRZ 0x4000 /* unmapped LBA returns all zeros */ 384 #define READ_CAP_16_TPRZ 0x4000 /* XXX old name used in driver(s) */ 385 #define RC16_LBPME 0x8000 /* LB provisioning management enabled */ 386 #define READ_CAP_16_TPE 0x8000 /* XXX old name used in driver(s) */ 387 u_int8_t reserved[16]; 388 }; 389 390 struct scsi_sense_data_unextended { 391 /* 1*/ u_int8_t error_code; 392 /* 4*/ u_int8_t block[3]; 393 }; 394 395 struct scsi_sense_data { 396 /* 1*/ u_int8_t error_code; 397 #define SSD_ERRCODE_CURRENT 0x70 398 #define SSD_ERRCODE_DEFERRED 0x71 399 #define SSD_ERRCODE 0x7F 400 #define SSD_ERRCODE_VALID 0x80 401 /* 2*/ u_int8_t segment; 402 /* 3*/ u_int8_t flags; 403 #define SSD_KEY 0x0F 404 #define SSD_ILI 0x20 405 #define SSD_EOM 0x40 406 #define SSD_FILEMARK 0x80 407 /* 7*/ u_int8_t info[4]; 408 /* 8*/ u_int8_t extra_len; 409 /*12*/ u_int8_t cmd_spec_info[4]; 410 /*13*/ u_int8_t add_sense_code; 411 /*14*/ u_int8_t add_sense_code_qual; 412 /*15*/ u_int8_t fru; 413 /*16*/ u_int8_t sense_key_spec_1; 414 #define SSD_SCS_VALID 0x80 415 #define SSD_SCS_CDB_ERROR 0x40 416 #define SSD_SCS_SEGMENT_DESC 0x20 417 #define SSD_SCS_VALID_BIT_INDEX 0x08 418 #define SSD_SCS_BIT_INDEX 0x07 419 /*17*/ u_int8_t sense_key_spec_2; 420 /*18*/ u_int8_t sense_key_spec_3; 421 }; 422 423 #define SKEY_NO_SENSE 0x00 424 #define SKEY_RECOVERED_ERROR 0x01 425 #define SKEY_NOT_READY 0x02 426 #define SKEY_MEDIUM_ERROR 0x03 427 #define SKEY_HARDWARE_ERROR 0x04 428 #define SKEY_ILLEGAL_REQUEST 0x05 429 #define SKEY_UNIT_ATTENTION 0x06 430 #define SKEY_WRITE_PROTECT 0x07 431 #define SKEY_BLANK_CHECK 0x08 432 #define SKEY_VENDOR_UNIQUE 0x09 433 #define SKEY_COPY_ABORTED 0x0A 434 #define SKEY_ABORTED_COMMAND 0x0B 435 #define SKEY_EQUAL 0x0C 436 #define SKEY_VOLUME_OVERFLOW 0x0D 437 #define SKEY_MISCOMPARE 0x0E 438 #define SKEY_RESERVED 0x0F 439 440 441 /* Additional sense code info */ 442 #define ASC_ASCQ(ssd) ((ssd->add_sense_code << 8) | ssd->add_sense_code_qual) 443 444 #define SENSE_FILEMARK_DETECTED 0x0001 445 #define SENSE_END_OF_MEDIUM_DETECTED 0x0002 446 #define SENSE_SETMARK_DETECTED 0x0003 447 #define SENSE_BEGINNING_OF_MEDIUM_DETECTED 0x0004 448 #define SENSE_END_OF_DATA_DETECTED 0x0005 449 #define SENSE_NOT_READY_BECOMING_READY 0x0401 450 #define SENSE_NOT_READY_INIT_REQUIRED 0x0402 451 #define SENSE_NOT_READY_FORMAT 0x0404 452 #define SENSE_NOT_READY_REBUILD 0x0405 453 #define SENSE_NOT_READY_RECALC 0x0406 454 #define SENSE_NOT_READY_INPROGRESS 0x0407 455 #define SENSE_NOT_READY_LONGWRITE 0x0408 456 #define SENSE_NOT_READY_SELFTEST 0x0409 457 #define SENSE_POWER_RESET_OR_BUS 0x2900 458 #define SENSE_POWER_ON 0x2901 459 #define SENSE_BUS_RESET 0x2902 460 #define SENSE_BUS_DEVICE_RESET 0x2903 461 #define SENSE_DEVICE_INTERNAL_RESET 0x2904 462 #define SENSE_TSC_CHANGE_SE 0x2905 463 #define SENSE_TSC_CHANGE_LVD 0x2906 464 #define SENSE_IT_NEXUS_LOSS 0x2907 465 #define SENSE_BAD_MEDIUM 0x3000 466 #define SENSE_NR_MEDIUM_UNKNOWN_FORMAT 0x3001 467 #define SENSE_NR_MEDIUM_INCOMPATIBLE_FORMAT 0x3002 468 #define SENSE_NW_MEDIUM_UNKNOWN_FORMAT 0x3004 469 #define SENSE_NW_MEDIUM_INCOMPATIBLE_FORMAT 0x3005 470 #define SENSE_NF_MEDIUM_INCOMPATIBLE_FORMAT 0x3006 471 #define SENSE_NW_MEDIUM_AC_MISMATCH 0x3008 472 #define SENSE_NOMEDIUM 0x3A00 473 #define SENSE_NOMEDIUM_TCLOSED 0x3A01 474 #define SENSE_NOMEDIUM_TOPEN 0x3A02 475 #define SENSE_NOMEDIUM_LOADABLE 0x3A03 476 #define SENSE_NOMEDIUM_AUXMEM 0x3A04 477 #define SENSE_CARTRIDGE_FAULT 0x5200 478 #define SENSE_MEDIUM_REMOVAL_PREVENTED 0x5302 479 480 struct scsi_blk_desc { 481 u_int8_t density; 482 u_int8_t nblocks[3]; 483 u_int8_t reserved; 484 u_int8_t blklen[3]; 485 }; 486 487 struct scsi_direct_blk_desc { 488 u_int8_t nblocks[4]; 489 u_int8_t density; 490 u_int8_t blklen[3]; 491 }; 492 493 struct scsi_blk_desc_big { 494 u_int8_t nblocks[8]; 495 u_int8_t density; 496 u_int8_t reserved[3]; 497 u_int8_t blklen[4]; 498 }; 499 500 struct scsi_mode_header { 501 u_int8_t data_length; /* Sense data length */ 502 u_int8_t medium_type; 503 u_int8_t dev_spec; 504 u_int8_t blk_desc_len; 505 }; 506 #define VALID_MODE_HDR(_x) ((_x)->data_length >= 3) 507 508 struct scsi_mode_header_big { 509 u_int8_t data_length[2]; /* Sense data length */ 510 u_int8_t medium_type; 511 u_int8_t dev_spec; 512 u_int8_t reserved; 513 #define LONGLBA 0x01 514 u_int8_t reserved2; 515 u_int8_t blk_desc_len[2]; 516 }; 517 #define VALID_MODE_HDR_BIG(_x) (_2btol((_x)->data_length) >= 6) 518 519 /* Both disks and tapes use dev_spec to report READONLY status. */ 520 #define SMH_DSP_WRITE_PROT 0x80 521 522 union scsi_mode_sense_buf { 523 struct scsi_mode_header hdr; 524 struct scsi_mode_header_big hdr_big; 525 u_char buf[254]; /* 255 & 256 bytes breaks some devices. */ 526 /* ahci doesn't like 255, various don't like */ 527 /* 256 because length must fit in 8 bits. */ 528 } __packed; /* Ensure sizeof() is 254! */ 529 530 struct scsi_report_luns_data { 531 u_int8_t length[4]; /* length of LUN inventory, in bytes */ 532 u_int8_t reserved[4]; /* unused */ 533 /* 534 * LUN inventory- we only support the type zero form for now. 535 */ 536 #define RPL_LUNDATA_SIZE 8 /* Bytes per lun */ 537 struct { 538 u_int8_t lundata[RPL_LUNDATA_SIZE]; 539 } luns[256]; /* scsi_link->luns is u_int8_t. */ 540 }; 541 #define RPL_LUNDATA_T0LUN 1 /* Type 0 LUN is in lundata[1] */ 542 543 struct scsi_lun_array { 544 uint8_t luns[256]; 545 int count; 546 int dumbscan; 547 }; 548 549 /* 550 * ATA PASS-THROUGH as per SAT2 551 */ 552 553 #define ATA_PASSTHRU_12 0xa1 554 #define ATA_PASSTHRU_16 0x85 555 556 #define ATA_PASSTHRU_PROTO_MASK 0x1e 557 #define ATA_PASSTHRU_PROTO_HW_RESET 0x00 558 #define ATA_PASSTHRU_PROTO_SW_RESET 0x02 559 #define ATA_PASSTHRU_PROTO_NON_DATA 0x06 560 #define ATA_PASSTHRU_PROTO_PIO_DATAIN 0x08 561 #define ATA_PASSTHRU_PROTO_PIO_DATAOUT 0x0a 562 #define ATA_PASSTHRU_PROTO_DMA 0x0c 563 #define ATA_PASSTHRU_PROTO_DMA_QUEUED 0x0e 564 #define ATA_PASSTHRU_PROTO_EXEC_DIAG 0x10 565 #define ATA_PASSTHRU_PROTO_NON_DATA_RST 0x12 566 #define ATA_PASSTHRU_PROTO_UDMA_DATAIN 0x14 567 #define ATA_PASSTHRU_PROTO_UDMA_DATAOUT 0x16 568 #define ATA_PASSTHRU_PROTO_FPDMA 0x18 569 #define ATA_PASSTHRU_PROTO_RESPONSE 0x1e 570 571 #define ATA_PASSTHRU_T_DIR_MASK 0x08 572 #define ATA_PASSTHRU_T_DIR_READ 0x08 573 #define ATA_PASSTHRU_T_DIR_WRITE 0x00 574 575 #define ATA_PASSTHRU_T_LEN_MASK 0x03 576 #define ATA_PASSTHRU_T_LEN_NONE 0x00 577 #define ATA_PASSTHRU_T_LEN_FEATURES 0x01 578 #define ATA_PASSTHRU_T_LEN_SECTOR_COUNT 0x02 579 #define ATA_PASSTHRU_T_LEN_TPSIU 0x03 580 581 struct scsi_ata_passthru_12 { 582 u_int8_t opcode; 583 u_int8_t count_proto; 584 u_int8_t flags; 585 u_int8_t features; 586 u_int8_t sector_count; 587 u_int8_t lba_low; 588 u_int8_t lba_mid; 589 u_int8_t lba_high; 590 u_int8_t device; 591 u_int8_t command; 592 u_int8_t _reserved; 593 u_int8_t control; 594 }; 595 596 struct scsi_ata_passthru_16 { 597 u_int8_t opcode; 598 u_int8_t count_proto; 599 u_int8_t flags; 600 u_int8_t features[2]; 601 u_int8_t sector_count[2]; 602 u_int8_t lba_low[2]; 603 u_int8_t lba_mid[2]; 604 u_int8_t lba_high[2]; 605 u_int8_t device; 606 u_int8_t command; 607 u_int8_t control; 608 }; 609 610 /* 611 * SPI status information unit. See section 14.3.5 of SPI-3. 612 */ 613 struct scsi_status_iu_header { 614 /* 2*/ u_int8_t reserved[2]; 615 /* 3*/ u_int8_t flags; 616 #define SIU_SNSVALID 0x2 617 #define SIU_RSPVALID 0x1 618 /* 4*/ u_int8_t status; 619 /* 8*/ u_int8_t sense_length[4]; 620 /*12*/ u_int8_t pkt_failures_length[4]; 621 u_int8_t data[1]; /* <pkt failure list><sense data> OR <sense_data> */ 622 }; 623 624 #define SIU_PKTFAIL_CODE(siu) ((siu)->data[3]) 625 #define SIU_PFC_NONE 0x00 626 #define SIU_PFC_CIU_FIELDS_INVALID 0x02 627 #define SIU_PFC_TMF_NOT_SUPPORTED 0x04 628 #define SIU_PFC_TMF_FAILED 0x05 629 #define SIU_PFC_INVALID_TYPE_CODE 0x06 630 #define SIU_PFC_ILLEGAL_REQUEST 0x07 631 632 #define SIU_SENSE_LENGTH(siu) (_4btol((siu)->sense_length)) 633 #define SIU_SENSE_DATA(siu) (((siu)->flags & SIU_RSPVALID) ? \ 634 &(siu)->data[_4btol((siu)->pkt_failures_length)] : &(siu)->data[0]) 635 636 /* 637 * Values for 'Task Management Flags' field of SPI command information unit. 638 * See section 14.3.1 of SPI-3. 639 */ 640 #define SIU_TASKMGMT_NONE 0x00 641 #define SIU_TASKMGMT_ABORT_TASK 0x01 642 #define SIU_TASKMGMT_ABORT_TASK_SET 0x02 643 #define SIU_TASKMGMT_CLEAR_TASK_SET 0x04 644 #define SIU_TASKMGMT_LUN_RESET 0x08 645 #define SIU_TASKMGMT_TARGET_RESET 0x20 646 #define SIU_TASKMGMT_CLEAR_ACA 0x40 647 648 /* 649 * Status Byte 650 */ 651 #define SCSI_OK 0x00 652 #define SCSI_CHECK 0x02 653 #define SCSI_COND_MET 0x04 654 #define SCSI_BUSY 0x08 655 #define SCSI_INTERM 0x10 656 #define SCSI_INTERM_COND_MET 0x14 657 #define SCSI_RESV_CONFLICT 0x18 658 #define SCSI_TERMINATED 0x22 659 #define SCSI_QUEUE_FULL 0x28 /* Old (Pre SCSI-3) name */ 660 #define SCSI_TASKSET_FULL 0x28 /* New (SCSI-3) name */ 661 #define SCSI_ACA_ACTIVE 0x30 662 663 #endif /* _SCSI_SCSI_ALL_H */ 664