1 /* $NetBSD: scsipi_all.h,v 1.7 1998/02/13 08:28:47 enami Exp $ */ 2 3 /* 4 * SCSI and SCSI-like general interface description 5 */ 6 7 /* 8 * Largely written by Julian Elischer (julian (at) 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 (at) tfs.com) Sept 1992 22 */ 23 24 /* 25 * SCSI-like command format and opcode 26 */ 27 28 #define TEST_UNIT_READY 0x00 29 struct scsipi_test_unit_ready { 30 u_int8_t opcode; 31 u_int8_t byte2; 32 u_int8_t unused[3]; 33 u_int8_t control; 34 }; 35 36 #define REQUEST_SENSE 0x03 37 struct scsipi_sense { 38 u_int8_t opcode; 39 u_int8_t byte2; 40 u_int8_t unused[2]; 41 u_int8_t length; 42 u_int8_t control; 43 }; 44 45 #define INQUIRY 0x12 46 struct scsipi_inquiry { 47 u_int8_t opcode; 48 u_int8_t byte2; 49 u_int8_t unused[2]; 50 u_int8_t length; 51 u_int8_t control; 52 }; 53 54 #define PREVENT_ALLOW 0x1e 55 struct scsipi_prevent { 56 u_int8_t opcode; 57 u_int8_t byte2; 58 u_int8_t unused[2]; 59 u_int8_t how; 60 u_int8_t control; 61 }; 62 #define PR_PREVENT 0x01 63 #define PR_ALLOW 0x00 64 65 /* 66 * inquiry and sense data format 67 */ 68 69 struct scsipi_sense_data { 70 /* 1*/ u_int8_t error_code; 71 #define SSD_ERRCODE 0x7F 72 #define SSD_ERRCODE_VALID 0x80 73 /* 2*/ u_int8_t segment; 74 /* 3*/ u_int8_t flags; 75 #define SSD_KEY 0x0F 76 #define SSD_ILI 0x20 77 #define SSD_EOM 0x40 78 #define SSD_FILEMARK 0x80 79 /* 7*/ u_int8_t info[4]; 80 /* 8*/ u_int8_t extra_len; 81 /*12*/ u_int8_t cmd_spec_info[4]; 82 /*13*/ u_int8_t add_sense_code; 83 /*14*/ u_int8_t add_sense_code_qual; 84 /*15*/ u_int8_t fru; 85 /*16*/ u_int8_t sense_key_spec_1; 86 #define SSD_SCS_VALID 0x80 87 /*17*/ u_int8_t sense_key_spec_2; 88 /*18*/ u_int8_t sense_key_spec_3; 89 /*32*/ u_int8_t extra_bytes[14]; 90 }; 91 /* 92 * Sense bytes described by the extra_len tag start at cmd_spec_info, 93 * and can only continue up to the end of the structure we've defined 94 * (which is too short for some cases). 95 */ 96 #define ADD_BYTES_LIM(sp) \ 97 (((int)(sp)->extra_len) < (int) sizeof(struct scsipi_sense_data) - 8)? \ 98 ((sp)->extra_len) : (sizeof (struct scsipi_sense_data) - 8) 99 100 101 struct scsipi_sense_data_unextended { 102 /* 1*/ u_int8_t error_code; 103 /* 4*/ u_int8_t block[3]; 104 }; 105 106 #define T_DIRECT 0x00 /* direct access device */ 107 #define T_SEQUENTIAL 0x01 /* sequential access device */ 108 #define T_PRINTER 0x02 /* printer device */ 109 #define T_PROCESSOR 0x03 /* processor device */ 110 #define T_WORM 0x04 /* write once, read many device */ 111 #define T_CDROM 0x05 /* cd-rom device */ 112 #define T_SCANNER 0x06 /* scanner device */ 113 #define T_OPTICAL 0x07 /* optical memory device */ 114 #define T_CHANGER 0x08 /* medium changer device */ 115 #define T_COMM 0x09 /* communication device */ 116 #define T_IT8_1 0x0a /* ??? */ 117 #define T_IT8_2 0x0b /* ??? */ 118 #define T_STORARRAY 0x0c /* storage array device */ 119 #define T_ENCLOSURE 0x0d /* enclosure services device */ 120 #define T_NODEVICE 0x1F 121 122 #define T_REMOV 1 /* device is removable */ 123 #define T_FIXED 0 /* device is not removable */ 124 125 /* 126 * XXX 127 * Actually I think some SCSI driver expects this structure to be 32 bytes, so 128 * don't change it unless you really know what you are doing 129 */ 130 131 struct scsipi_inquiry_data { 132 u_int8_t device; 133 #define SID_TYPE 0x1F 134 #define SID_QUAL 0xE0 135 #define SID_QUAL_LU_OK 0x00 136 #define SID_QUAL_LU_OFFLINE 0x20 137 #define SID_QUAL_RSVD 0x40 138 #define SID_QUAL_BAD_LU 0x60 139 u_int8_t dev_qual2; 140 #define SID_QUAL2 0x7F 141 #define SID_REMOVABLE 0x80 142 u_int8_t version; 143 #define SID_ANSII 0x07 144 #define SID_ECMA 0x38 145 #define SID_ISO 0xC0 146 u_int8_t response_format; 147 u_int8_t additional_length; 148 u_int8_t unused[2]; 149 u_int8_t flags; 150 #define SID_SftRe 0x01 151 #define SID_CmdQue 0x02 152 #define SID_Linked 0x08 153 #define SID_Sync 0x10 154 #define SID_WBus16 0x20 155 #define SID_WBus32 0x40 156 #define SID_RelAdr 0x80 157 char vendor[8]; 158 char product[16]; 159 char revision[4]; 160 u_int8_t extra[8]; 161 }; 162