1 /* $OpenBSD: scsireg.h,v 1.2 2013/10/29 21:49:07 miod Exp $ */ 2 /* $NetBSD: scsireg.h,v 1.2 2013/01/22 15:48:40 tsutsui Exp $ */ 3 4 /* 5 * Copyright (c) 1990, 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Van Jacobson of Lawrence Berkeley Laboratory. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)scsireg.h 8.1 (Berkeley) 6/10/93 36 */ 37 38 /* 39 * MB89352 SCSI Protocol Controller Hardware Description. 40 */ 41 42 struct scsidevice { 43 volatile u_char scsi_bdid, p0, p1, p2; /* 000 */ 44 volatile u_char scsi_sctl, p3, p4, p5; /* 004 */ 45 #define SCTL_DISABLE 0x80 46 #define SCTL_CTRLRST 0x40 47 #define SCTL_DIAG 0x20 48 #define SCTL_ABRT_ENAB 0x10 49 #define SCTL_PARITY_ENAB 0x08 50 #define SCTL_SEL_ENAB 0x04 51 #define SCTL_RESEL_ENAB 0x02 52 #define SCTL_INTR_ENAB 0x01 53 volatile u_char scsi_scmd, p6, p7, p8; /* 008 */ 54 #define SCMD_RST 0x10 55 #define SCMD_ICPT_XFR 0x08 56 #define SCMD_PROG_XFR 0x04 57 #define SCMD_PAD 0x01 /* if initiator */ 58 #define SCMD_PERR_STOP 0x01 /* if target */ 59 /* command codes */ 60 #define SCMD_BUS_REL 0x00 61 #define SCMD_SELECT 0x20 62 #define SCMD_RST_ATN 0x40 63 #define SCMD_SET_ATN 0x60 64 #define SCMD_XFR 0x80 65 #define SCMD_XFR_PAUSE 0xa0 66 #define SCMD_RST_ACK 0xc0 67 #define SCMD_SET_ACK 0xe0 68 volatile u_char scsi_tmod, p9, p10, p11; /* 00C */ 69 #define TMOD_SYNC 0x80 70 volatile u_char scsi_ints, p12, p13, p14; /* 010 */ 71 #define INTS_SEL 0x80 72 #define INTS_RESEL 0x40 73 #define INTS_DISCON 0x20 74 #define INTS_CMD_DONE 0x10 75 #define INTS_SRV_REQ 0x08 76 #define INTS_TIMEOUT 0x04 77 #define INTS_HARD_ERR 0x02 78 #define INTS_RST 0x01 79 volatile u_char scsi_psns, p15, p16, p17; /* 014 */ 80 #define PSNS_REQ 0x80 81 #define PSNS_ACK 0x40 82 #define PSNS_ATN 0x20 83 #define PSNS_SEL 0x10 84 #define PSNS_BSY 0x08 85 #define scsi_sdgc scsi_psns 86 #define SDGC_XFER_ENAB 0x20 87 volatile u_char scsi_ssts, p18, p19, p20; /* 018 */ 88 #define SSTS_INITIATOR 0x80 89 #define SSTS_TARGET 0x40 90 #define SSTS_BUSY 0x20 91 #define SSTS_XFR 0x10 92 #define SSTS_ACTIVE (SSTS_INITIATOR|SSTS_XFR) 93 #define SSTS_RST 0x08 94 #define SSTS_TCZERO 0x04 95 #define SSTS_DREG_FULL 0x02 96 #define SSTS_DREG_EMPTY 0x01 97 volatile u_char scsi_serr, p21, p22, p23; /* 01C */ 98 #define SERR_SCSI_PAR 0x80 99 #define SERR_SPC_PAR 0x40 100 #define SERR_XFER_OUT 0x20 101 #define SERR_TC_PAR 0x08 102 #define SERR_PHASE_ERR 0x04 103 #define SERR_SHORT_XFR 0x02 104 #define SERR_OFFSET 0x01 105 volatile u_char scsi_pctl, p24, p25, p26; /* 020 */ 106 #define PCTL_BFINT_ENAB 0x80 107 volatile u_char scsi_mbc, p27, p28, p29; /* 024 */ 108 volatile u_char scsi_dreg, p30, p31, p32; /* 028 */ 109 volatile u_char scsi_temp, p33, p34, p35; /* 02C */ 110 volatile u_char scsi_tch, p36, p37, p38; /* 030 */ 111 volatile u_char scsi_tcm, p39, p40, p41; /* 034 */ 112 volatile u_char scsi_tcl, p42, p43, p44; /* 038 */ 113 volatile u_char scsi_exbf, p45, p46, p47; /* 03C */ 114 }; 115 116 /* psns/pctl phase lines as bits */ 117 #define PHASE_MSG 0x04 118 #define PHASE_CD 0x02 /* =1 if 'command' */ 119 #define PHASE_IO 0x01 /* =1 if data inbound */ 120 /* Phase lines as values */ 121 #define PHASE 0x07 /* mask for psns/pctl phase */ 122 #define DATA_OUT_PHASE 0x00 123 #define DATA_IN_PHASE 0x01 124 #define CMD_PHASE 0x02 125 #define STATUS_PHASE 0x03 126 #define BUS_FREE_PHASE 0x04 127 #define ARB_SEL_PHASE 0x05 /* Fuji chip combines arbitration with sel. */ 128 #define MESG_OUT_PHASE 0x06 129 #define MESG_IN_PHASE 0x07 130 131 /* SCSI Messages */ 132 133 #define MSG_CMD_COMPLETE 0x00 134 #define MSG_EXT_MESSAGE 0x01 135 #define MSG_SAVE_DATA_PTR 0x02 136 #define MSG_RESTORE_PTR 0x03 137 #define MSG_DISCONNECT 0x04 138 #define MSG_INIT_DETECT_ERROR 0x05 139 #define MSG_ABORT 0x06 140 #define MSG_REJECT 0x07 141 #define MSG_NOOP 0x08 142 #define MSG_PARITY_ERROR 0x09 143 #define MSG_BUS_DEVICE_RESET 0x0C 144 #define MSG_IDENTIFY 0x80 145 #define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */ 146 #define MSG_SYNC_REQ 0x01 147 148 /* SCSI Commands */ 149 150 #define CMD_TEST_UNIT_READY 0x00 151 #define CMD_REQUEST_SENSE 0x03 152 #define CMD_INQUIRY 0x12 153 #define CMD_SEND_DIAGNOSTIC 0x1D 154 155 #define CMD_REWIND 0x01 156 #define CMD_FORMAT_UNIT 0x04 157 #define CMD_READ_BLOCK_LIMITS 0x05 158 #define CMD_REASSIGN_BLOCKS 0x07 159 #define CMD_READ 0x08 160 #define CMD_WRITE 0x0A 161 #define CMD_WRITE_FILEMARK 0x10 162 #define CMD_SPACE 0x11 163 #define CMD_MODE_SELECT 0x15 164 #define CMD_RELEASE_UNIT 0x17 165 #define CMD_ERASE 0x19 166 #define CMD_MODE_SENSE 0x1A 167 #define CMD_LOADUNLOAD 0x1B 168 #define CMD_RECEIVE_DIAG 0x1C 169 #define CMD_SEND_DIAG 0x1D 170 #define CMD_P_A_MEDIA_REMOVAL 0x1E 171 #define CMD_READ_CAPACITY 0x25 172 #define CMD_READ_EXT 0x28 173 #define CMD_WRITE_EXT 0x2A 174 #define CMD_READ_DEFECT_DATA 0x37 175 #define SD_MANUFAC_DEFECTS 0x14000000 176 #define SD_GROWN_DEFECTS 0x0c000000 177 #define CMD_READ_BUFFER 0x3B 178 #define CMD_WRITE_BUFFER 0x3C 179 #define CMD_READ_FULL 0xF0 180 #define CMD_MEDIA_TEST 0xF1 181 #define CMD_ACCESS_LOG 0xF2 182 #define CMD_WRITE_FULL 0xFC 183 #define CMD_MANAGE_PRIMARY 0xFD 184 #define CMD_EXECUTE_DATA 0xFE 185 186 /* SCSI status bits */ 187 188 #define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */ 189 #define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */ 190 #define STS_BUSY 0x08 191 #define STS_INTERMED 0x10 /* Intermediate status sent */ 192 #define STS_EXT 0x80 /* Extended status valid */ 193 194 /* command descriptor blocks */ 195 196 struct scsi_cdb6 { 197 u_char cmd; /* command code */ 198 u_char lun: 3, /* logical unit on ctlr */ 199 lbah: 5; /* msb of read/write logical block addr */ 200 u_char lbam; /* middle byte of l.b.a. */ 201 u_char lbal; /* lsb of l.b.a. */ 202 u_char len; /* transfer length */ 203 u_char xtra; 204 }; 205 206 struct scsi_cdb10 { 207 u_char cmd; /* command code */ 208 u_char lun: 3, /* logical unit on ctlr */ 209 : 4, 210 rel: 1; /* l.b.a. is relative addr if =1 */ 211 u_char lbah; /* msb of read/write logical block addr */ 212 u_char lbahm; /* high middle byte of l.b.a. */ 213 u_char lbalm; /* low middle byte of l.b.a. */ 214 u_char lbal; /* lsb of l.b.a. */ 215 u_char reserved; 216 u_char lenh; /* msb transfer length */ 217 u_char lenl; /* lsb transfer length */ 218 u_char xtra; 219 }; 220 221 /* basic sense data */ 222 223 struct scsi_sense { 224 u_char valid: 1, /* l.b.a. is valid */ 225 class: 3, 226 code: 4; 227 u_char vu: 4, /* vendor unique */ 228 lbah: 4; 229 u_char lbam; 230 u_char lbal; 231 }; 232 233 struct scsi_xsense { 234 u_char valid: 1, /* l.b.a. is valid */ 235 class: 3, 236 code: 4; 237 u_char segment; 238 u_char filemark: 1, 239 eom: 1, 240 ili: 1, /* illegal length indicator */ 241 rsvd: 1, 242 key: 4; 243 u_char info1; 244 u_char info2; 245 u_char info3; 246 u_char info4; 247 u_char len; /* additional sense length */ 248 }; 249 250 /* inquiry data */ 251 struct scsi_inquiry { 252 u_char type; 253 u_char qual; 254 u_char version; 255 u_char rsvd; 256 u_char len; 257 char class[3]; 258 char vendor_id[8]; 259 char product_id[16]; 260 char rev[4]; 261 }; 262 263 struct scsi_generic_cdb { 264 int len; /* cdb length (in bytes) */ 265 u_char cdb[28]; /* cdb to use on next read/write */ 266 }; 267