Home | History | Annotate | Line # | Download | only in dev
sbcvar.h revision 1.1
      1  1.1  scottr /*	$NetBSD: sbcvar.h,v 1.1 1997/03/01 20:19:00 scottr Exp $	*/
      2  1.1  scottr 
      3  1.1  scottr /*
      4  1.1  scottr  * Copyright (C) 1996 Scott Reynolds.  All rights reserved.
      5  1.1  scottr  *
      6  1.1  scottr  * Redistribution and use in source and binary forms, with or without
      7  1.1  scottr  * modification, are permitted provided that the following conditions
      8  1.1  scottr  * are met:
      9  1.1  scottr  * 1. Redistributions of source code must retain the above copyright
     10  1.1  scottr  *    notice, this list of conditions and the following disclaimer.
     11  1.1  scottr  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  scottr  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  scottr  *    documentation and/or other materials provided with the distribution.
     14  1.1  scottr  * 3. All advertising materials mentioning features or use of this software
     15  1.1  scottr  *    must display the following acknowledgement:
     16  1.1  scottr  *      This product includes software developed by Scott Reynolds for
     17  1.1  scottr  *      the NetBSD Project.
     18  1.1  scottr  * 4. The name of the author may not be used to endorse or promote products
     19  1.1  scottr  *    derived from this software without specific prior written permission
     20  1.1  scottr  *
     21  1.1  scottr  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  scottr  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  scottr  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  scottr  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  scottr  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  scottr  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  scottr  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  scottr  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  scottr  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  scottr  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  scottr  */
     32  1.1  scottr 
     33  1.1  scottr /*
     34  1.1  scottr  * Transfers smaller than this are done using PIO
     35  1.1  scottr  * (on assumption they're not worth PDMA overhead)
     36  1.1  scottr  */
     37  1.1  scottr #define	MIN_DMA_LEN 128
     38  1.1  scottr 
     39  1.1  scottr /*
     40  1.1  scottr  * Transfers larger than 8192 bytes need to be split up
     41  1.1  scottr  * due to the size of the PDMA space.
     42  1.1  scottr  */
     43  1.1  scottr #define	MAX_DMA_LEN 0x2000
     44  1.1  scottr 
     45  1.1  scottr #ifdef SBC_DEBUG
     46  1.1  scottr # define	SBC_DB_INTR	0x01
     47  1.1  scottr # define	SBC_DB_DMA	0x02
     48  1.1  scottr # define	SBC_DB_REG	0x04
     49  1.1  scottr # define	SBC_DB_BREAK	0x08
     50  1.1  scottr # ifndef DDB
     51  1.1  scottr #  define	Debugger()	printf("Debug: sbc.c:%d\n", __LINE__)
     52  1.1  scottr # endif
     53  1.1  scottr # define	SBC_BREAK \
     54  1.1  scottr 		do { if (sbc_debug & SBC_DB_BREAK) Debugger(); } while (0)
     55  1.1  scottr #else
     56  1.1  scottr # define	SBC_BREAK
     57  1.1  scottr #endif
     58  1.1  scottr 
     59  1.1  scottr /*
     60  1.1  scottr  * This structure is used to keep track of PDMA requests.
     61  1.1  scottr  */
     62  1.1  scottr struct sbc_pdma_handle {
     63  1.1  scottr 	int	dh_flags;	/* flags */
     64  1.1  scottr #define	SBC_DH_BUSY	0x01	/* This handle is in use */
     65  1.1  scottr #define	SBC_DH_OUT	0x02	/* PDMA data out (write) */
     66  1.1  scottr #define	SBC_DH_DONE	0x04	/* PDMA transfer is complete */
     67  1.1  scottr 	u_char	*dh_addr;	/* data buffer */
     68  1.1  scottr 	int	dh_len;		/* length of data buffer */
     69  1.1  scottr };
     70  1.1  scottr 
     71  1.1  scottr /*
     72  1.1  scottr  * The first structure member has to be the ncr5380_softc
     73  1.1  scottr  * so we can just cast to go back and forth between them.
     74  1.1  scottr  */
     75  1.1  scottr struct sbc_softc {
     76  1.1  scottr 	struct ncr5380_softc ncr_sc;
     77  1.1  scottr 	volatile struct sbc_regs *sc_regs;
     78  1.1  scottr 	volatile vm_offset_t	sc_drq_addr;
     79  1.1  scottr 	volatile vm_offset_t	sc_nodrq_addr;
     80  1.1  scottr 	void			(*sc_clrintr) __P((struct ncr5380_softc *));
     81  1.1  scottr 	int			sc_options;	/* options for this instance. */
     82  1.1  scottr 	struct sbc_pdma_handle sc_pdma[SCI_OPENINGS];
     83  1.1  scottr };
     84  1.1  scottr 
     85  1.1  scottr /*
     86  1.1  scottr  * Options.  By default, SCSI interrupts and reselect are disabled.
     87  1.1  scottr  * You may enable either of these features with the `flags' directive
     88  1.1  scottr  * in your kernel's configuration file.
     89  1.1  scottr  *
     90  1.1  scottr  * Alternatively, you can patch your kernel with DDB or some other
     91  1.1  scottr  * mechanism.  The sc_options member of the softc is OR'd with
     92  1.1  scottr  * the value in sbc_options.
     93  1.1  scottr  *
     94  1.1  scottr  * The options code is based on the sparc 'si' driver's version of
     95  1.1  scottr  * the same.
     96  1.1  scottr  */
     97  1.1  scottr #define	SBC_PDMA	0x01	/* Use PDMA for polled transfers */
     98  1.1  scottr #define	SBC_INTR	0x02	/* Allow SCSI IRQ/DRQ interrupts */
     99  1.1  scottr #define	SBC_RESELECT	0x04	/* Allow disconnect/reselect */
    100  1.1  scottr #define	SBC_OPTIONS_MASK	(SBC_RESELECT|SBC_INTR|SBC_PDMA)
    101  1.1  scottr #define	SBC_OPTIONS_BITS	"\10\3RESELECT\2INTR\1PDMA"
    102  1.1  scottr 
    103  1.1  scottr extern int	sbc_debug;
    104  1.1  scottr extern int	sbc_link_flags;
    105  1.1  scottr extern int	sbc_options;
    106  1.1  scottr extern struct scsi_adapter sbc_ops;
    107  1.1  scottr extern struct scsi_device sbc_dev;
    108  1.1  scottr 
    109  1.1  scottr int	sbc_pdma_in __P((struct ncr5380_softc *, int, int, u_char *));
    110  1.1  scottr int	sbc_pdma_out __P((struct ncr5380_softc *, int, int, u_char *));
    111  1.1  scottr void	sbc_irq_intr __P((void *));
    112  1.1  scottr void	sbc_drq_intr __P((void *));
    113  1.1  scottr void	sbc_dma_alloc __P((struct ncr5380_softc *));
    114  1.1  scottr void	sbc_dma_free __P((struct ncr5380_softc *));
    115  1.1  scottr void	sbc_dma_poll __P((struct ncr5380_softc *));
    116  1.1  scottr void	sbc_dma_setup __P((struct ncr5380_softc *));
    117  1.1  scottr void	sbc_dma_start __P((struct ncr5380_softc *));
    118  1.1  scottr void	sbc_dma_eop __P((struct ncr5380_softc *));
    119  1.1  scottr void	sbc_dma_stop __P((struct ncr5380_softc *));
    120  1.1  scottr #ifdef SBC_DEBUG
    121  1.1  scottr void	decode_5380_intr __P((struct ncr5380_softc *));
    122  1.1  scottr #endif
    123