xref: /netbsd/sys/arch/amiga/dev/siopvar.h (revision bf9ec67e)
1 /*	$NetBSD: siopvar.h,v 1.21 2002/05/14 00:08:22 matt 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 /*
52  * Data Structure for SCRIPTS program
53  */
54 struct siop_ds {
55 	long	scsi_addr;		/* SCSI ID & sync */
56 	long	idlen;			/* Identify message */
57 	char	*idbuf;
58 	long	cmdlen;			/* SCSI command */
59 	char	*cmdbuf;
60 	long	stslen;			/* Status */
61 	char	*stsbuf;
62 	long	msglen;			/* Message */
63 	char	*msgbuf;
64 	long	msginlen;		/* Message in */
65 	char	*msginbuf;
66 	long	extmsglen;		/* Extended message in */
67 	char	*extmsgbuf;
68 	long	synmsglen;		/* Sync transfer request */
69 	char	*synmsgbuf;
70 	struct {
71 		long datalen;
72 		char *databuf;
73 	} chain[DMAMAXIO];
74 };
75 
76 /*
77  * ACB. Holds additional information for each SCSI command Comments: We
78  * need a separate scsi command block because we may need to overwrite it
79  * with a request sense command.  Basicly, we refrain from fiddling with
80  * the scsi_xfer struct (except do the expected updating of return values).
81  * We'll generally update: xs->{flags,resid,error,sense,status} and
82  * occasionally xs->retries.
83  */
84 struct siop_acb {
85 	TAILQ_ENTRY(siop_acb) chain;
86 	struct scsipi_xfer *xs;	/* SCSI xfer ctrl block from above */
87 	int		flags;	/* Status */
88 #define ACB_FREE	0x00
89 #define ACB_ACTIVE	0x01
90 #define ACB_DONE	0x04
91 	struct scsi_generic cmd;  /* SCSI command block */
92 	struct siop_ds ds;
93 	void	*iob_buf;
94 	u_long	iob_curbuf;
95 	u_long	iob_len, iob_curlen;
96 	u_char	msgout[6];
97 	u_char	msg[6];
98 	u_char	stat[1];
99 	u_char	status;
100 	u_char	dummy[2];
101 	int	 clen;
102 	char	*daddr;		/* Saved data pointer */
103 	int	 dleft;		/* Residue */
104 };
105 
106 /*
107  * Some info about each (possible) target on the SCSI bus.  This should
108  * probably have been a "per target+lunit" structure, but we'll leave it at
109  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
110  */
111 struct siop_tinfo {
112 	int	cmds;		/* #commands processed */
113 	int	dconns;		/* #disconnects */
114 	int	touts;		/* #timeouts */
115 	int	perrs;		/* #parity errors */
116 	ushort	lubusy;		/* What local units/subr. are busy? */
117 	u_char  flags;
118 	u_char  period;		/* Period suggestion */
119 	u_char  offset;		/* Offset suggestion */
120 };
121 
122 struct	siop_softc {
123 	struct	device sc_dev;
124 	struct	isr sc_isr;
125 
126 	u_char	sc_istat;
127 	u_char	sc_dstat;
128 #ifndef ARCH_720
129 	u_char	sc_sstat0;
130 #endif
131 	u_char	sc_sstat1;
132 #ifdef ARCH_720
133 	u_short	sc_sist;
134 #endif
135 	u_long	sc_intcode;
136 	struct	scsipi_adapter sc_adapter;
137 	struct	scsipi_channel sc_channel;
138 	u_long	sc_scriptspa;		/* physical address of scripts */
139 	siop_regmap_p	sc_siopp;	/* the SIOP */
140 	u_long	sc_active;		/* number of active I/O's */
141 
142 	/* Lists of command blocks */
143 	TAILQ_HEAD(acb_list, siop_acb) free_list,
144 				       ready_list,
145 				       nexus_list;
146 
147 	struct siop_acb *sc_nexus;	/* current command */
148 #define SIOP_NACB 16
149 	struct siop_acb *sc_acb;	/* the real command blocks */
150 #ifndef ARCH_720
151 	struct siop_tinfo sc_tinfo[8];
152 #else
153 	struct siop_tinfo sc_tinfo[16];
154 #endif
155 
156 	u_short	sc_clock_freq;
157 	u_char	sc_dcntl;
158 	u_char	sc_ctest7;
159 	u_short	sc_tcp[4];
160 	u_char	sc_flags;
161 	u_char	sc_dien;
162 	u_char	sc_minsync;
163 #ifndef ARCH_720
164 	u_char	sc_sien;
165 #else
166 	u_short	sc_sien;
167 #endif
168 	/* one for each target */
169 	struct syncpar {
170 		u_char state;
171 		u_char sxfer;
172 #ifndef ARCH_720
173 		u_char sbcl;
174 #else
175 		u_char scntl3;
176 #endif
177 	} sc_sync[16];
178 };
179 
180 /* sc_flags */
181 #define	SIOP_INTSOFF	0x80	/* Interrupts turned off */
182 #define	SIOP_INTDEFER	0x40	/* Level 6 interrupt has been deferred */
183 #define	SIOP_ALIVE	0x01	/* controller initialized */
184 #define SIOP_SELECTED	0x04	/* bus is in selected state. Needed for
185 				   correct abort procedure. */
186 
187 /* negotiation states */
188 #define NEG_WIDE	0	/* Negotiate wide transfers */
189 #define	NEG_WAITW	1	/* Waiting for wide negotation response */
190 #define NEG_SYNC	2	/* Negotiate synch transfers */
191 #define	NEG_WAITS	3	/* Waiting for synch negoation response */
192 #define NEG_DONE	4	/* Wide and/or sync negotation done */
193 
194 #define	MSG_CMD_COMPLETE	0x00
195 #define MSG_EXT_MESSAGE		0x01
196 #define	MSG_SAVE_DATA_PTR	0x02
197 #define	MSG_RESTORE_PTR		0x03
198 #define	MSG_DISCONNECT		0x04
199 #define	MSG_INIT_DETECT_ERROR	0x05
200 #define	MSG_ABORT		0x06
201 #define	MSG_REJECT		0x07
202 #define	MSG_NOOP		0x08
203 #define	MSG_PARITY_ERROR	0x09
204 #define	MSG_BUS_DEVICE_RESET	0x0C
205 #define	MSG_IDENTIFY		0x80
206 #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
207 #define	MSG_SYNC_REQ		0x01
208 #define	MSG_WIDE_REQ		0x03
209 
210 #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
211 #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
212 #define	STS_BUSY	0x08
213 #define	STS_INTERMED	0x10	/* Intermediate status sent */
214 #define	STS_EXT		0x80	/* Extended status valid */
215 
216 #ifdef ARCH_720
217 void siopng_minphys(struct buf *bp);
218 void siopng_scsipi_request(struct scsipi_channel *,
219 			scsipi_adapter_req_t, void *);
220 void siopnginitialize(struct siop_softc *);
221 void siopngintr(struct siop_softc *);
222 void siopng_dump_registers(struct siop_softc *);
223 #ifdef DEBUG
224 void siopng_dump(struct siop_softc *);
225 #endif
226 
227 #else
228 
229 void siop_minphys(struct buf *bp);
230 void siop_scsipi_request(struct scsipi_channel *,
231 			scsipi_adapter_req_t, void *);
232 void siopinitialize(struct siop_softc *);
233 void siopintr(struct siop_softc *);
234 void siop_dump_registers(struct siop_softc *);
235 #ifdef DEBUG
236 void siop_dump(struct siop_softc *);
237 #endif
238 #endif
239 
240 #endif /* _SIOPVAR_H */
241