siopvar.h revision 1.6 1 /* $NetBSD: siopvar.h,v 1.6 1994/12/28 09:26:02 chopps Exp $ */
2
3 /*
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Van Jacobson of Lawrence Berkeley Laboratory.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)siopvar.h 7.1 (Berkeley) 5/8/90
39 */
40 #ifndef _SIOPVAR_H_
41 #define _SIOPVAR_H_
42
43 /*
44 * The largest single request will be MAXPHYS bytes which will require
45 * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
46 * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
47 * buffer is not page aligned (+1).
48 */
49 #define DMAMAXIO (MAXPHYS/NBPG+1)
50
51 struct siop_pending {
52 TAILQ_ENTRY(siop_pending) link;
53 struct scsi_xfer *xs;
54 };
55
56 struct siop_ds { /* Data Structure for SCRIPTS */
57 long scsi_addr; /* SCSI ID & sync */
58 long idlen; /* Identify message */
59 char *idbuf;
60 long cmdlen; /* SCSI command */
61 char *cmdbuf;
62 long stslen; /* Status */
63 char *stsbuf;
64 long msglen; /* Message */
65 char *msgbuf;
66 long msginlen; /* Message in */
67 char *msginbuf;
68 long extmsglen; /* Extended message in */
69 char *extmsgbuf;
70 long synmsglen; /* Sync transfer request */
71 char *synmsgbuf;
72 struct {
73 long datalen;
74 char *databuf;
75 } chain[DMAMAXIO];
76 };
77
78 struct siop_softc {
79 struct device sc_dev;
80
81 u_char sc_istat;
82 u_char sc_dstat;
83 u_char sc_sstat0;
84 u_char sc_sstat1;
85 struct scsi_link sc_link; /* proto for sub devices */
86 siop_regmap_p sc_siopp; /* the SIOP */
87 volatile void *sc_cregs; /* driver specific regs */
88 struct scsi_xfer *sc_xs; /* transfer from high level code */
89 u_long sc_active; /* number of active I/O's */
90 /* I/O blocks for each active I/O */
91 struct siop_iob {
92 struct scsi_xfer *sc_xs;
93 struct siop_ds sc_ds;
94 void *iob_buf;
95 u_long iob_curbuf;
96 u_long iob_len, iob_curlen;
97 u_char sc_msgout[6];
98 u_char sc_msg[6];
99 u_char sc_stat[1];
100 u_char sc_status;
101 u_char sc_dummy[2];
102 } *sc_cur; /* current I/O block */
103 struct siop_iob sc_iob[2]; /* I/O blocks */
104 u_long sc_scriptspa; /* physical address of scripts */
105 u_long sc_clock_freq;
106 u_char sc_flags;
107 u_char sc_slave;
108 /* one for each target */
109 struct syncpar {
110 u_char state;
111 u_char period, offset;
112 } sc_sync[8];
113 TAILQ_HEAD(,siop_pending) sc_xslist; /* LIFO */
114 struct siop_pending sc_xsstore[8][8]; /* one for every unit */
115 };
116
117 /* sc_flags */
118 #define SIOP_DMA 0x80 /* DMA I/O in progress */
119 #define SIOP_ALIVE 0x01 /* controller initialized */
120 #define SIOP_SELECTED 0x04 /* bus is in selected state. Needed for
121 correct abort procedure. */
122
123 /* sync states */
124 #define SYNC_START 0 /* no sync handshake started */
125 #define SYNC_SENT 1 /* we sent sync request, no answer yet */
126 #define SYNC_DONE 2 /* target accepted our (or inferior) settings,
127 or it rejected the request and we stay async */
128
129 #define MSG_CMD_COMPLETE 0x00
130 #define MSG_EXT_MESSAGE 0x01
131 #define MSG_SAVE_DATA_PTR 0x02
132 #define MSG_RESTORE_PTR 0x03
133 #define MSG_DISCONNECT 0x04
134 #define MSG_INIT_DETECT_ERROR 0x05
135 #define MSG_ABORT 0x06
136 #define MSG_REJECT 0x07
137 #define MSG_NOOP 0x08
138 #define MSG_PARITY_ERROR 0x09
139 #define MSG_BUS_DEVICE_RESET 0x0C
140 #define MSG_IDENTIFY 0x80
141 #define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */
142 #define MSG_SYNC_REQ 0x01
143
144 #define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
145 #define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */
146 #define STS_BUSY 0x08
147 #define STS_INTERMED 0x10 /* Intermediate status sent */
148 #define STS_EXT 0x80 /* Extended status valid */
149
150 void siop_minphys __P((struct buf *bp));
151 u_int siop_adinfo __P((void));
152 int siop_scsicmd __P((struct scsi_xfer *));
153
154 #endif /* _SIOPVAR_H */
155