1 /* $Id: scsi-cdb.h,v 1.3 2007/02/15 01:29:37 fredette Exp $ */ 2 3 /* tme/scsi/scsi-cdb.h - header file describing SCSI CDBs: */ 4 5 /* 6 * Copyright (c) 2003 Matt Fredette 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Matt Fredette. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifndef _TME_SCSI_SCSI_CDB_H 37 #define _TME_SCSI_SCSI_CDB_H 38 39 #include <tme/common.h> 40 _TME_RCSID("$Id: scsi-cdb.h,v 1.3 2007/02/15 01:29:37 fredette Exp $"); 41 42 /* includes: */ 43 #include <tme/scsi/scsi-device.h> 44 45 /* macros: */ 46 47 /* CDB groups: */ 48 #define TME_SCSI_CDB_GROUP_MASK (0xe0) 49 #define TME_SCSI_CDB_GROUP_0 (0x00) 50 #define TME_SCSI_CDB_GROUP_1 (0x20) 51 #define TME_SCSI_CDB_GROUP_2 (0x40) 52 #define TME_SCSI_CDB_GROUP_3 (0x60) 53 #define TME_SCSI_CDB_GROUP_4 (0x80) 54 #define TME_SCSI_CDB_GROUP_5 (0xa0) 55 #define TME_SCSI_CDB_GROUP_6 (0xc0) 56 #define TME_SCSI_CDB_GROUP_7 (0xe0) 57 58 /* CDB group lengths: */ 59 #define TME_SCSI_CDB_GROUP_0_LEN (6) 60 #define TME_SCSI_CDB_GROUP_1_LEN (10) 61 #define TME_SCSI_CDB_GROUP_2_LEN (10) 62 #undef TME_SCSI_CDB_GROUP_3_LEN /* reserved */ 63 #define TME_SCSI_CDB_GROUP_4_LEN (16) 64 #define TME_SCSI_CDB_GROUP_5_LEN (12) 65 #undef TME_SCSI_CDB_GROUP_6_LEN /* vendor unique */ 66 #undef TME_SCSI_CDB_GROUP_7_LEN /* vendor unique */ 67 68 /* peripheral device types: */ 69 #define TME_SCSI_TYPE_DISK (0x00) 70 #define TME_SCSI_TYPE_TAPE (0x01) 71 #define TME_SCSI_TYPE_CDROM (0x05) 72 73 /* LUN states: */ 74 #define TME_SCSI_LUN_PRESENT (0x00) 75 #define TME_SCSI_LUN_NOT_PRESENT (0x20) 76 #define TME_SCSI_LUN_UNSUPPORTED (0x60) 77 78 /* SCSI formats: */ 79 #define TME_SCSI_FORMAT_SCSI1 (0x00) 80 #define TME_SCSI_FORMAT_CCS (0x01) 81 #define TME_SCSI_FORMAT_ISO (0x02) 82 83 /* "Group 0 Common Commands for All Device Types" */ 84 #define TME_SCSI_CDB_TEST_UNIT_READY (0x00) 85 /* 0x01 type specific */ 86 /* 0x02 vendor unique */ 87 #define TME_SCSI_CDB_REQUEST_SENSE (0x03) 88 /* 0x04 type specific */ 89 /* 0x05 type specific */ 90 /* 0x06 vendor unique */ 91 /* 0x07 type specific */ 92 /* 0x08 type specific */ 93 /* 0x09 vendor unique */ 94 /* 0x0a type specific */ 95 /* 0x0b type specific */ 96 /* 0x0c vendor unique */ 97 /* 0x0d vendor unique */ 98 /* 0x0e vendor unique */ 99 /* 0x0f type specific */ 100 /* 0x10 type specific */ 101 /* 0x11 type specific */ 102 #define TME_SCSI_CDB_INQUIRY (0x12) 103 /* 0x13 type specific */ 104 /* 0x14 type specific */ 105 /* 0x15 type specific */ 106 /* 0x16 type specific */ 107 /* 0x17 type specific */ 108 #define TME_SCSI_CDB_COPY (0x18) 109 /* 0x19 type specific */ 110 /* 0x1a type specific */ 111 /* 0x1b type specific */ 112 #define TME_SCSI_CDB_DIAG_RESULTS (0x1c) 113 #define TME_SCSI_CDB_DIAG_SEND (0x1d) 114 /* 0x1e type specific */ 115 /* 0x1f reserved */ 116 117 /* "Group 1 Commands for All Device Types" */ 118 /* 0x20 vendor unique */ 119 /* 0x21 vendor unique */ 120 /* 0x22 vendor unique */ 121 /* 0x23 vendor unique */ 122 /* 0x24 vendor unique */ 123 /* 0x25 type specific */ 124 /* 0x26 vendor unique */ 125 /* 0x27 vendor unique */ 126 /* 0x28 type specific */ 127 /* 0x29 vendor unique */ 128 /* 0x2a type specific */ 129 /* 0x2b type specific */ 130 /* 0x2c vendor unique */ 131 /* 0x2d vendor unique */ 132 /* 0x2e type specific */ 133 /* 0x2f type specific */ 134 /* 0x30 type specific */ 135 /* 0x31 type specific */ 136 /* 0x32 type specific */ 137 /* 0x33 type specific */ 138 /* 0x34 reserved */ 139 /* 0x35 reserved */ 140 /* 0x36 reserved */ 141 /* 0x37 reserved */ 142 /* 0x38 reserved */ 143 #define TME_SCSI_CDB_COMPARE (0x39) 144 #define TME_SCSI_CDB_COPY_VERIFY (0x3a) 145 /* 0x3b reserved */ 146 /* 0x3c reserved */ 147 /* 0x3d reserved */ 148 /* 0x3e reserved */ 149 /* 0x3f reserved */ 150 151 /* status values: */ 152 #define TME_SCSI_STATUS_GOOD (0x00) 153 #define TME_SCSI_STATUS_CHECK_CONDITION (0x02) 154 #define TME_SCSI_STATUS_COND_MET (0x04) 155 #define TME_SCSI_STATUS_BUSY (0x08) 156 #define TME_SCSI_STATUS_INT_GOOD (0x10) 157 #define TME_SCSI_STATUS_INT_COND_MET (0x14) 158 #define TME_SCSI_STATUS_RSRV_CONFLICT (0x18) 159 160 /* extended sense keys: */ 161 #define TME_SCSI_SENSE_EXT_KEY_NO_SENSE (0x0) 162 #define TME_SCSI_SENSE_EXT_KEY_RECOVERED_ERROR (0x1) 163 #define TME_SCSI_SENSE_EXT_KEY_NOT_READY (0x2) 164 #define TME_SCSI_SENSE_EXT_KEY_MEDIUM_ERROR (0x3) 165 #define TME_SCSI_SENSE_EXT_KEY_HARDWARE_ERROR (0x4) 166 #define TME_SCSI_SENSE_EXT_KEY_ILLEGAL_REQUEST (0x5) 167 #define TME_SCSI_SENSE_EXT_KEY_UNIT_ATTENTION (0x6) 168 #define TME_SCSI_SENSE_EXT_KEY_DATA_PROTECT (0x7) 169 #define TME_SCSI_SENSE_EXT_KEY_BLANK_CHECK (0x8) 170 /* 0x9 vendor specific */ 171 #define TME_SCSI_SENSE_EXT_KEY_COPY_ABORTED (0xa) 172 #define TME_SCSI_SENSE_EXT_KEY_ABORTED_COMMAND (0xb) 173 #define TME_SCSI_SENSE_EXT_KEY_EQUAL (0xc) 174 #define TME_SCSI_SENSE_EXT_KEY_VOLUME_OVERFLOW (0xd) 175 #define TME_SCSI_SENSE_EXT_KEY_MISCOMPARE (0xe) 176 177 /* extended sense ASC and ASCQ values: */ 178 /* NB: this is a partial list: */ 179 #define TME_SCSI_SENSE_EXT_ASC_ASCQ_NONE (0x0000) 180 #define TME_SCSI_SENSE_EXT_ASC_ASCQ_INVALID_FIELD_CDB (0x2400) 181 #define TME_SCSI_SENSE_EXT_ASC_ASCQ_PARAMETER_LIST_LENGTH_ERROR (0x1a00) 182 #define TME_SCSI_SENSE_EXT_ASC_ASCQ_PARAMETER_VALUE_INVALID (0x2602) 183 184 /* types: */ 185 186 /* SCSI inquiry data: */ 187 struct tme_scsi_device_inquiry { 188 189 /* the device type: */ 190 tme_uint8_t tme_scsi_device_inquiry_type; 191 192 /* the LUN state: */ 193 tme_uint8_t tme_scsi_device_inquiry_lun_state; 194 195 /* the device type qualifier: */ 196 tme_uint8_t tme_scsi_device_inquiry_type_qualifier; 197 198 /* nonzero iff the LUN is removable: */ 199 tme_uint8_t tme_scsi_device_inquiry_lun_removable; 200 201 /* the various standards versions: */ 202 tme_uint8_t tme_scsi_device_inquiry_std_ansi; 203 tme_uint8_t tme_scsi_device_inquiry_std_ecma; 204 tme_uint8_t tme_scsi_device_inquiry_std_iso; 205 206 /* the response format: */ 207 tme_uint8_t tme_scsi_device_response_format; 208 }; 209 210 /* a SCSI MODE SELECT and MODE SENSE block descriptor: */ 211 struct tme_scsi_device_mode_blocks { 212 213 /* the density code: */ 214 tme_uint8_t tme_scsi_device_mode_blocks_density_code; 215 216 /* the number of blocks: */ 217 tme_uint32_t tme_scsi_device_mode_blocks_number; 218 219 /* the length of the blocks: */ 220 tme_uint32_t tme_scsi_device_mode_blocks_length; 221 }; 222 223 /* prototypes: */ 224 _TME_SCSI_DEVICE_CDB_P(tme_scsi_device_cdb_illegal); 225 _TME_SCSI_DEVICE_CDB_P(tme_scsi_device_cdb_tur); 226 _TME_SCSI_DEVICE_CDB_P(tme_scsi_device_cdb_request_sense); 227 228 void tme_scsi_device_mode_select_data _TME_P((struct tme_scsi_device *, 229 int (*) _TME_P((struct tme_scsi_device *, 230 _tme_const struct tme_scsi_device_mode_blocks *)), 231 int (*) _TME_P((struct tme_scsi_device *, 232 const tme_uint8_t *)))); 233 tme_uint8_t *tme_scsi_device_make_inquiry_data _TME_P((struct tme_scsi_device *, 234 _tme_const struct tme_scsi_device_inquiry *)); 235 236 #endif /* !_TME_SCSI_SCSI_CDB_H */ 237