xref: /netbsd-src/sys/arch/amiga/dev/siopvar.h (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /*	$NetBSD: siopvar.h,v 1.25 2005/12/11 12:16:28 christos 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. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)siopvar.h	7.1 (Berkeley) 5/8/90
35  */
36 #ifndef _SIOPVAR_H_
37 #define _SIOPVAR_H_
38 
39 /*
40  * The largest single request will be MAXPHYS bytes which will require
41  * at most MAXPHYS/PAGE_SIZE+1 chain elements to describe, i.e. if none of
42  * the buffer pages are physically contiguous (MAXPHYS/PAGE_SIZE) and the
43  * buffer is not page aligned (+1).
44  */
45 #define	DMAMAXIO	(MAXPHYS/PAGE_SIZE+1)
46 
47 /*
48  * Data Structure for SCRIPTS program
49  */
50 struct siop_ds {
51 	long	scsi_addr;		/* SCSI ID & sync */
52 	long	idlen;			/* Identify message */
53 	char	*idbuf;
54 	long	cmdlen;			/* SCSI command */
55 	char	*cmdbuf;
56 	long	stslen;			/* Status */
57 	char	*stsbuf;
58 	long	msglen;			/* Message */
59 	char	*msgbuf;
60 	long	msginlen;		/* Message in */
61 	char	*msginbuf;
62 	long	extmsglen;		/* Extended message in */
63 	char	*extmsgbuf;
64 	long	synmsglen;		/* Sync transfer request */
65 	char	*synmsgbuf;
66 	struct {
67 		long datalen;
68 		char *databuf;
69 	} chain[DMAMAXIO];
70 };
71 
72 /*
73  * ACB. Holds additional information for each SCSI command Comments: We
74  * need a separate scsi command block because we may need to overwrite it
75  * with a request sense command.  Basicly, we refrain from fiddling with
76  * the scsi_xfer struct (except do the expected updating of return values).
77  * We'll generally update: xs->{flags,resid,error,sense,status} and
78  * occasionally xs->retries.
79  */
80 struct siop_acb {
81 	TAILQ_ENTRY(siop_acb) chain;
82 	struct scsipi_xfer *xs;	/* SCSI xfer ctrl block from above */
83 	int		flags;	/* Status */
84 #define ACB_FREE	0x00
85 #define ACB_ACTIVE	0x01
86 #define ACB_DONE	0x04
87 	struct scsipi_generic cmd;  /* SCSI command block */
88 	struct siop_ds ds;
89 	void	*iob_buf;
90 	u_long	iob_curbuf;
91 	u_long	iob_len, iob_curlen;
92 	u_char	msgout[6];
93 	u_char	msg[6];
94 	u_char	stat[1];
95 	u_char	status;
96 	u_char	dummy[2];
97 	int	 clen;
98 	char	*daddr;		/* Saved data pointer */
99 	int	 dleft;		/* Residue */
100 };
101 
102 /*
103  * Some info about each (possible) target on the SCSI bus.  This should
104  * probably have been a "per target+lunit" structure, but we'll leave it at
105  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
106  */
107 struct siop_tinfo {
108 	int	cmds;		/* #commands processed */
109 	int	dconns;		/* #disconnects */
110 	int	touts;		/* #timeouts */
111 	int	perrs;		/* #parity errors */
112 	ushort	lubusy;		/* What local units/subr. are busy? */
113 	u_char  flags;
114 	u_char  period;		/* Period suggestion */
115 	u_char  offset;		/* Offset suggestion */
116 };
117 
118 struct	siop_softc {
119 	struct	device sc_dev;
120 	struct	isr sc_isr;
121 
122 	u_char	sc_istat;
123 	u_char	sc_dstat;
124 #ifndef ARCH_720
125 	u_char	sc_sstat0;
126 #endif
127 	u_char	sc_sstat1;
128 #ifdef ARCH_720
129 	u_short	sc_sist;
130 #endif
131 	u_long	sc_intcode;
132 	struct	scsipi_adapter sc_adapter;
133 	struct	scsipi_channel sc_channel;
134 	u_long	sc_scriptspa;		/* physical address of scripts */
135 	siop_regmap_p	sc_siopp;	/* the SIOP */
136 	u_long	sc_active;		/* number of active I/O's */
137 
138 	/* Lists of command blocks */
139 	TAILQ_HEAD(acb_list, siop_acb) free_list,
140 				       ready_list,
141 				       nexus_list;
142 
143 	struct siop_acb *sc_nexus;	/* current command */
144 #define SIOP_NACB 16
145 	struct siop_acb *sc_acb;	/* the real command blocks */
146 #ifndef ARCH_720
147 	struct siop_tinfo sc_tinfo[8];
148 #else
149 	struct siop_tinfo sc_tinfo[16];
150 #endif
151 
152 	u_short	sc_clock_freq;
153 	u_char	sc_dcntl;
154 	u_char	sc_ctest7;
155 	u_short	sc_tcp[4];
156 	u_char	sc_flags;
157 	u_char	sc_dien;
158 	u_char	sc_minsync;
159 #ifndef ARCH_720
160 	u_char	sc_sien;
161 #else
162 	u_short	sc_sien;
163 #endif
164 	/* one for each target */
165 	struct syncpar {
166 		u_char state;
167 		u_char sxfer;
168 #ifndef ARCH_720
169 		u_char sbcl;
170 #else
171 		u_char scntl3;
172 #endif
173 	} sc_sync[16];
174 };
175 
176 /* sc_flags */
177 #define	SIOP_INTSOFF	0x80	/* Interrupts turned off */
178 #define	SIOP_INTDEFER	0x40	/* Level 6 interrupt has been deferred */
179 #define	SIOP_ALIVE	0x01	/* controller initialized */
180 #define SIOP_SELECTED	0x04	/* bus is in selected state. Needed for
181 				   correct abort procedure. */
182 
183 /* negotiation states */
184 #define NEG_WIDE	0	/* Negotiate wide transfers */
185 #define	NEG_WAITW	1	/* Waiting for wide negotation response */
186 #define NEG_SYNC	2	/* Negotiate synch transfers */
187 #define	NEG_WAITS	3	/* Waiting for synch negoation response */
188 #define NEG_DONE	4	/* Wide and/or sync negotation done */
189 
190 #define	MSG_CMD_COMPLETE	0x00
191 #define MSG_EXT_MESSAGE		0x01
192 #define	MSG_SAVE_DATA_PTR	0x02
193 #define	MSG_RESTORE_PTR		0x03
194 #define	MSG_DISCONNECT		0x04
195 #define	MSG_INIT_DETECT_ERROR	0x05
196 #define	MSG_ABORT		0x06
197 #define	MSG_REJECT		0x07
198 #define	MSG_NOOP		0x08
199 #define	MSG_PARITY_ERROR	0x09
200 #define	MSG_BUS_DEVICE_RESET	0x0C
201 #define	MSG_IDENTIFY		0x80
202 #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
203 #define	MSG_SYNC_REQ		0x01
204 #define	MSG_WIDE_REQ		0x03
205 
206 #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
207 #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
208 #define	STS_BUSY	0x08
209 #define	STS_INTERMED	0x10	/* Intermediate status sent */
210 #define	STS_EXT		0x80	/* Extended status valid */
211 
212 #ifdef ARCH_720
213 void siopng_minphys(struct buf *bp);
214 void siopng_scsipi_request(struct scsipi_channel *,
215 			scsipi_adapter_req_t, void *);
216 void siopnginitialize(struct siop_softc *);
217 void siopngintr(struct siop_softc *);
218 void siopng_dump_registers(struct siop_softc *);
219 #ifdef DEBUG
220 void siopng_dump(struct siop_softc *);
221 #endif
222 
223 #else
224 
225 void siop_minphys(struct buf *bp);
226 void siop_scsipi_request(struct scsipi_channel *,
227 			scsipi_adapter_req_t, void *);
228 void siopinitialize(struct siop_softc *);
229 void siopintr(struct siop_softc *);
230 void siop_dump_registers(struct siop_softc *);
231 #ifdef DEBUG
232 void siop_dump(struct siop_softc *);
233 #endif
234 #endif
235 
236 #endif /* _SIOPVAR_H */
237