sbicvar.h revision 1.7 1 /* $NetBSD: sbicvar.h,v 1.7 1995/08/12 20:30:48 mycroft 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 * @(#)scsivar.h 7.1 (Berkeley) 5/8/90
39 */
40 #ifndef _SBICVAR_H_
41 #define _SBICVAR_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 dma_chain {
52 int dc_count;
53 char *dc_addr;
54 };
55
56 struct sbic_pending {
57 TAILQ_ENTRY(sbic_pending) link;
58 struct scsi_xfer *xs;
59 };
60
61 struct sbic_softc {
62 struct device sc_dev;
63 struct isr sc_isr;
64 struct target_sync {
65 u_char state;
66 u_char period;
67 u_char offset;
68 } sc_sync[8];
69 struct scsi_link sc_link; /* proto for sub devices */
70 sbic_regmap_p sc_sbicp; /* the SBIC */
71 volatile void *sc_cregs; /* driver specific regs */
72 TAILQ_HEAD(,sbic_pending) sc_xslist; /* LIFO */
73 struct sbic_pending sc_xsstore[8][8]; /* one for every unit */
74 struct scsi_xfer *sc_xs; /* transfer from high level code */
75 u_char sc_flags;
76 u_char sc_scsiaddr;
77 u_char sc_stat[2];
78 u_char sc_msg[7];
79 u_long sc_clkfreq;
80 u_long sc_tcnt; /* number of bytes transfered */
81 u_char *sc_dmabuffer;
82 u_char *sc_dmausrbuf;
83 u_long sc_dmausrlen;
84 u_short sc_dmacmd; /* used by dma drivers */
85 u_short sc_dmatimo; /* dma timeout */
86 u_long sc_dmamask; /* dma valid mem mask */
87 struct dma_chain sc_chain[DMAMAXIO];
88 struct dma_chain *sc_cur;
89 struct dma_chain *sc_last;
90 int (*sc_dmago) __P((struct sbic_softc *, char *, int, int));
91 int (*sc_dmanext) __P((struct sbic_softc *));
92 void (*sc_dmafree) __P((struct sbic_softc *));
93 void (*sc_dmastop) __P((struct sbic_softc *));
94 u_short gtsc_bankmask; /* GVP specific bank selected */
95 };
96
97 /* sc_flags */
98 #define SBICF_ALIVE 0x01 /* controller initialized */
99 #define SBICF_DCFLUSH 0x02 /* need flush for overlap after dma finishes */
100 #define SBICF_SELECTED 0x04 /* bus is in selected state. */
101 #define SBICF_BADDMA 0x10 /* controller can only DMA to ztwobus space */
102 #define SBICF_BBUF 0x20 /* DMA input needs to be copied from bounce */
103 #define SBICF_INTR 0x40 /* SBICF interrupt expected */
104 #define SBICF_INDMA 0x80 /* not used yet, DMA I/O in progress */
105
106 /* sync states */
107 #define SYNC_START 0 /* no sync handshake started */
108 #define SYNC_SENT 1 /* we sent sync request, no answer yet */
109 #define SYNC_DONE 2 /* target accepted our (or inferior) settings,
110 or it rejected the request and we stay async */
111 #ifdef DEBUG
112 #define DDB_FOLLOW 0x04
113 #define DDB_IO 0x08
114 #endif
115 extern int sbic_inhibit_sync;
116 extern int sbic_no_dma;
117 extern int sbic_clock_override;
118
119 #define PHASE 0x07 /* mask for psns/pctl phase */
120 #define DATA_OUT_PHASE 0x00
121 #define DATA_IN_PHASE 0x01
122 #define CMD_PHASE 0x02
123 #define STATUS_PHASE 0x03
124 #define BUS_FREE_PHASE 0x04
125 #define ARB_SEL_PHASE 0x05 /* Fuji chip combines arbitration with sel. */
126 #define MESG_OUT_PHASE 0x06
127 #define MESG_IN_PHASE 0x07
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
145 #define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
146 #define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */
147 #define STS_BUSY 0x08
148 #define STS_INTERMED 0x10 /* Intermediate status sent */
149 #define STS_EXT 0x80 /* Extended status valid */
150
151 /*
152 * XXXX
153 */
154 struct scsi_fmt_cdb {
155 int len; /* cdb length (in bytes) */
156 u_char cdb[28]; /* cdb to use on next read/write */
157 };
158
159 struct buf;
160 struct scsi_xfer;
161
162 void sbic_minphys __P((struct buf *bp));
163 int sbic_scsicmd __P((struct scsi_xfer *));
164
165 #endif /* _SBICVAR_H_ */
166