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