1 /* $NetBSD: scsi_all.h,v 1.16 2000/11/29 12:49:56 wiz Exp $ */ 2 3 /* 4 * SCSI-specific 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 command format 26 */ 27 28 /* 29 * Define dome bits that are in ALL (or a lot of) scsi commands 30 */ 31 #define SCSI_CTL_LINK 0x01 32 #define SCSI_CTL_FLAG 0x02 33 #define SCSI_CTL_VENDOR 0xC0 34 35 36 /* 37 * Some old SCSI devices need the LUN to be set in the top 3 bits of the 38 * second byte of the CDB. 39 */ 40 #define SCSI_CMD_LUN_MASK 0xe0 41 #define SCSI_CMD_LUN_SHIFT 5 42 43 /* 44 * XXX 45 * Actually some SCSI driver expects this structure to be 12 bytes, so 46 * don't change it unless you really know what you are doing 47 */ 48 49 struct scsi_generic { 50 u_int8_t opcode; 51 u_int8_t bytes[11]; 52 }; 53 54 /* XXX Is this a command ? What's its opcode ? */ 55 struct scsi_send_diag { 56 u_int8_t opcode; 57 u_int8_t byte2; 58 #define SSD_UOL 0x01 59 #define SSD_DOL 0x02 60 #define SSD_SELFTEST 0x04 61 #define SSD_PF 0x10 62 u_int8_t unused[1]; 63 u_int8_t paramlen[2]; 64 u_int8_t control; 65 }; 66 67 #define SCSI_MODE_SENSE 0x1a 68 struct scsi_mode_sense { 69 u_int8_t opcode; 70 u_int8_t byte2; 71 #define SMS_DBD 0x08 72 u_int8_t page; 73 #define SMS_PAGE_CODE 0x3F 74 #define SMS_PAGE_CTRL 0xC0 75 #define SMS_PAGE_CTRL_CURRENT 0x00 76 #define SMS_PAGE_CTRL_CHANGEABLE 0x40 77 #define SMS_PAGE_CTRL_DEFAULT 0x80 78 #define SMS_PAGE_CTRL_SAVED 0xC0 79 u_int8_t unused; 80 u_int8_t length; 81 u_int8_t control; 82 }; 83 84 #define SCSI_MODE_SENSE_BIG 0x54 85 struct scsi_mode_sense_big { 86 u_int8_t opcode; 87 u_int8_t byte2; /* same bits as small version */ 88 u_int8_t page; /* same bits as small version */ 89 u_int8_t unused[4]; 90 u_int8_t length[2]; 91 u_int8_t control; 92 }; 93 94 #define SCSI_MODE_SELECT 0x15 95 struct scsi_mode_select { 96 u_int8_t opcode; 97 u_int8_t byte2; 98 #define SMS_SP 0x01 99 #define SMS_PF 0x10 100 u_int8_t unused[2]; 101 u_int8_t length; 102 u_int8_t control; 103 }; 104 105 #define SCSI_MODE_SELECT_BIG 0x55 106 struct scsi_mode_select_big { 107 u_int8_t opcode; 108 u_int8_t byte2; /* same bits as small version */ 109 u_int8_t unused[5]; 110 u_int8_t length[2]; 111 u_int8_t control; 112 }; 113 114 #define SCSI_RESERVE 0x16 115 struct scsi_reserve { 116 u_int8_t opcode; 117 u_int8_t byte2; 118 u_int8_t unused[2]; 119 u_int8_t length; 120 u_int8_t control; 121 }; 122 123 #define SCSI_RELEASE 0x17 124 struct scsi_release { 125 u_int8_t opcode; 126 u_int8_t byte2; 127 u_int8_t unused[2]; 128 u_int8_t length; 129 u_int8_t control; 130 }; 131 132 #define SCSI_CHANGE_DEFINITION 0x40 133 struct scsi_changedef { 134 u_int8_t opcode; 135 u_int8_t byte2; 136 u_int8_t unused1; 137 u_int8_t how; 138 u_int8_t unused[4]; 139 u_int8_t datalen; 140 u_int8_t control; 141 }; 142 #define SC_SCSI_1 0x01 143 #define SC_SCSI_2 0x03 144 145 struct scsi_blk_desc { 146 u_int8_t density; 147 u_int8_t nblocks[3]; 148 u_int8_t reserved; 149 u_int8_t blklen[3]; 150 }; 151 152 struct scsi_mode_header { 153 u_int8_t data_length; /* Sense data length */ 154 u_int8_t medium_type; 155 u_int8_t dev_spec; 156 u_int8_t blk_desc_len; 157 }; 158 159 struct scsi_mode_header_big { 160 u_int8_t data_length[2]; /* Sense data length */ 161 u_int8_t medium_type; 162 u_int8_t dev_spec; 163 u_int8_t unused[2]; 164 u_int8_t blk_desc_len[2]; 165 }; 166 167 168 /* 169 * Status Byte 170 */ 171 #define SCSI_OK 0x00 172 #define SCSI_CHECK 0x02 173 #define SCSI_BUSY 0x08 174 #define SCSI_INTERM 0x10 175 #define SCSI_RESV_CONFLICT 0x18 176 #define SCSI_TERMINATED 0x22 177 #define SCSI_QUEUE_FULL 0x28 178 #define SCSI_ACA_ACTIVE 0x30 179