Home | History | Annotate | Line # | Download | only in dev
sbicvar.h revision 1.2
      1  1.1  chopps /*
      2  1.1  chopps  * Copyright (c) 1990 The Regents of the University of California.
      3  1.1  chopps  * All rights reserved.
      4  1.1  chopps  *
      5  1.1  chopps  * This code is derived from software contributed to Berkeley by
      6  1.1  chopps  * Van Jacobson of Lawrence Berkeley Laboratory.
      7  1.1  chopps  *
      8  1.1  chopps  * Redistribution and use in source and binary forms, with or without
      9  1.1  chopps  * modification, are permitted provided that the following conditions
     10  1.1  chopps  * are met:
     11  1.1  chopps  * 1. Redistributions of source code must retain the above copyright
     12  1.1  chopps  *    notice, this list of conditions and the following disclaimer.
     13  1.1  chopps  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  chopps  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  chopps  *    documentation and/or other materials provided with the distribution.
     16  1.1  chopps  * 3. All advertising materials mentioning features or use of this software
     17  1.1  chopps  *    must display the following acknowledgement:
     18  1.1  chopps  *	This product includes software developed by the University of
     19  1.1  chopps  *	California, Berkeley and its contributors.
     20  1.1  chopps  * 4. Neither the name of the University nor the names of its contributors
     21  1.1  chopps  *    may be used to endorse or promote products derived from this software
     22  1.1  chopps  *    without specific prior written permission.
     23  1.1  chopps  *
     24  1.1  chopps  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  1.1  chopps  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  1.1  chopps  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  1.1  chopps  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  1.1  chopps  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  1.1  chopps  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  1.1  chopps  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  1.1  chopps  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  1.1  chopps  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  1.1  chopps  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  1.1  chopps  * SUCH DAMAGE.
     35  1.1  chopps  *
     36  1.1  chopps  *	@(#)scsivar.h	7.1 (Berkeley) 5/8/90
     37  1.2  chopps  *	$Id: sbicvar.h,v 1.2 1994/06/14 00:59:03 chopps Exp $
     38  1.1  chopps  */
     39  1.1  chopps #ifndef _SBICVAR_H_
     40  1.1  chopps #define _SBICVAR_H_
     41  1.1  chopps 
     42  1.1  chopps /*
     43  1.1  chopps  * The largest single request will be MAXPHYS bytes which will require
     44  1.1  chopps  * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
     45  1.1  chopps  * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
     46  1.1  chopps  * buffer is not page aligned (+1).
     47  1.1  chopps  */
     48  1.1  chopps #define	DMAMAXIO	(MAXPHYS/NBPG+1)
     49  1.1  chopps 
     50  1.1  chopps struct	dma_chain {
     51  1.1  chopps 	int	dc_count;
     52  1.1  chopps 	char	*dc_addr;
     53  1.1  chopps };
     54  1.1  chopps 
     55  1.1  chopps struct	sbic_pending {
     56  1.1  chopps 	TAILQ_ENTRY(sbic_pending) link;
     57  1.1  chopps 	struct scsi_xfer *xs;
     58  1.1  chopps };
     59  1.1  chopps 
     60  1.1  chopps struct	sbic_softc {
     61  1.1  chopps 	struct	device sc_dev;
     62  1.1  chopps 	struct	target_sync {
     63  1.1  chopps 		u_char	state;
     64  1.1  chopps 		u_char	period;
     65  1.1  chopps 		u_char	offset;
     66  1.1  chopps 	} sc_sync[8];
     67  1.1  chopps 	struct	scsi_link sc_link;	/* proto for sub devices */
     68  1.1  chopps 	sbic_regmap_p	sc_sbicp;	/* the SBIC */
     69  1.1  chopps 	volatile void 	*sc_cregs;	/* driver specific regs */
     70  1.1  chopps 	TAILQ_HEAD(,sbic_pending) sc_xslist;	/* LIFO */
     71  1.1  chopps 	struct	sbic_pending sc_xsstore[8][8];	/* one for every unit */
     72  1.1  chopps 	struct	scsi_xfer *sc_xs;	/* transfer from high level code */
     73  1.1  chopps 	u_char	sc_flags;
     74  1.1  chopps 	u_char	sc_scsiaddr;
     75  1.1  chopps 	u_char	sc_stat[2];
     76  1.1  chopps 	u_char	sc_msg[7];
     77  1.1  chopps 	u_long	sc_clkfreq;
     78  1.1  chopps 	u_long	sc_tcnt;		/* number of bytes transfered */
     79  1.1  chopps 	u_char *sc_dmabuffer;
     80  1.1  chopps 	u_char *sc_dmausrbuf;
     81  1.1  chopps 	u_long  sc_dmausrlen;
     82  1.1  chopps 	u_short sc_dmacmd;		/* used by dma drivers */
     83  1.1  chopps 	u_short	sc_dmatimo;		/* dma timeout */
     84  1.1  chopps 	u_long	sc_dmamask;		/* dma valid mem mask */
     85  1.1  chopps 	struct	dma_chain sc_chain[DMAMAXIO];
     86  1.1  chopps 	struct	dma_chain *sc_cur;
     87  1.1  chopps 	struct	dma_chain *sc_last;
     88  1.1  chopps 	int  (*sc_dmago)	__P((struct sbic_softc *, char *, int, int));
     89  1.1  chopps 	int  (*sc_dmanext)	__P((struct sbic_softc *));
     90  1.1  chopps 	void (*sc_dmafree)	__P((struct sbic_softc *));
     91  1.1  chopps 	void (*sc_dmastop)	__P((struct sbic_softc *));
     92  1.1  chopps 	u_short	gtsc_bankmask;		/* GVP specific bank selected */
     93  1.1  chopps };
     94  1.1  chopps 
     95  1.1  chopps /* sc_flags */
     96  1.1  chopps #define	SBICF_ALIVE	0x01	/* controller initialized */
     97  1.2  chopps #define SBICF_DCFLUSH	0x02	/* need flush for overlap after dma finishes */
     98  1.1  chopps #define SBICF_SELECTED	0x04	/* bus is in selected state. */
     99  1.1  chopps #define SBICF_BADDMA	0x10	/* controller can only DMA to ztwobus space */
    100  1.1  chopps #define SBICF_BBUF	0x20	/* DMA input needs to be copied from bounce */
    101  1.1  chopps #define	SBICF_INTR	0x40	/* SBICF interrupt expected */
    102  1.1  chopps #define	SBICF_INDMA	0x80	/* not used yet, DMA I/O in progress */
    103  1.1  chopps 
    104  1.1  chopps /* sync states */
    105  1.1  chopps #define SYNC_START	0	/* no sync handshake started */
    106  1.1  chopps #define SYNC_SENT	1	/* we sent sync request, no answer yet */
    107  1.1  chopps #define SYNC_DONE	2	/* target accepted our (or inferior) settings,
    108  1.1  chopps 				   or it rejected the request and we stay async */
    109  1.1  chopps #ifdef DEBUG
    110  1.1  chopps #define	DDB_FOLLOW	0x04
    111  1.1  chopps #define DDB_IO		0x08
    112  1.1  chopps #endif
    113  1.1  chopps extern int sbic_inhibit_sync;
    114  1.1  chopps extern int sbic_no_dma;
    115  1.1  chopps extern int sbic_clock_override;
    116  1.1  chopps 
    117  1.1  chopps #define	PHASE		0x07		/* mask for psns/pctl phase */
    118  1.1  chopps #define	DATA_OUT_PHASE	0x00
    119  1.1  chopps #define	DATA_IN_PHASE	0x01
    120  1.1  chopps #define	CMD_PHASE	0x02
    121  1.1  chopps #define	STATUS_PHASE	0x03
    122  1.1  chopps #define	BUS_FREE_PHASE	0x04
    123  1.1  chopps #define	ARB_SEL_PHASE	0x05	/* Fuji chip combines arbitration with sel. */
    124  1.1  chopps #define	MESG_OUT_PHASE	0x06
    125  1.1  chopps #define	MESG_IN_PHASE	0x07
    126  1.1  chopps 
    127  1.1  chopps #define	MSG_CMD_COMPLETE	0x00
    128  1.1  chopps #define MSG_EXT_MESSAGE		0x01
    129  1.1  chopps #define	MSG_SAVE_DATA_PTR	0x02
    130  1.1  chopps #define	MSG_RESTORE_PTR		0x03
    131  1.1  chopps #define	MSG_DISCONNECT		0x04
    132  1.1  chopps #define	MSG_INIT_DETECT_ERROR	0x05
    133  1.1  chopps #define	MSG_ABORT		0x06
    134  1.1  chopps #define	MSG_REJECT		0x07
    135  1.1  chopps #define	MSG_NOOP		0x08
    136  1.1  chopps #define	MSG_PARITY_ERROR	0x09
    137  1.1  chopps #define	MSG_BUS_DEVICE_RESET	0x0C
    138  1.1  chopps #define	MSG_IDENTIFY		0x80
    139  1.1  chopps #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
    140  1.1  chopps #define	MSG_SYNC_REQ 		0x01
    141  1.1  chopps 
    142  1.1  chopps 
    143  1.1  chopps #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
    144  1.1  chopps #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
    145  1.1  chopps #define	STS_BUSY	0x08
    146  1.1  chopps #define	STS_INTERMED	0x10	/* Intermediate status sent */
    147  1.1  chopps #define	STS_EXT		0x80	/* Extended status valid */
    148  1.1  chopps 
    149  1.1  chopps /*
    150  1.1  chopps  * XXXX
    151  1.1  chopps  */
    152  1.1  chopps struct scsi_fmt_cdb {
    153  1.1  chopps 	int len;		/* cdb length (in bytes) */
    154  1.1  chopps 	u_char cdb[28];		/* cdb to use on next read/write */
    155  1.1  chopps };
    156  1.1  chopps 
    157  1.1  chopps struct buf;
    158  1.1  chopps struct scsi_xfer;
    159  1.1  chopps 
    160  1.1  chopps void sbic_minphys __P((struct buf *bp));
    161  1.1  chopps u_int sbic_adinfo __P((void));
    162  1.1  chopps int sbic_scsicmd __P((struct scsi_xfer *));
    163  1.1  chopps 
    164  1.1  chopps #endif /* _SBICVAR_H_ */
    165