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