Home | History | Annotate | Line # | Download | only in qbus
ubavar.h revision 1.27
      1 /*	$NetBSD: ubavar.h,v 1.27 2000/04/30 11:46:03 ragge Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1982, 1986 Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the University of
     18  *	California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  *	@(#)ubavar.h	7.7 (Berkeley) 6/28/90
     36  */
     37 #ifndef _QBUS_UBAVAR_H
     38 #define	_QBUS_UBAVAR_H
     39 
     40 /*
     41  * This file contains definitions related to the kernel structures
     42  * for dealing with the unibus adapters.
     43  *
     44  * Each uba has a uba_softc structure.
     45  * Each unibus controller which is not a device has a uba_ctlr structure.
     46  * Each unibus device has a uba_device structure.
     47  */
     48 
     49 /*
     50  * Per-uba structure.
     51  *
     52  * This structure holds the interrupt vector for the uba,
     53  * and its address in physical and virtual space.  At boot time
     54  * we determine the devices attached to the uba's and their
     55  * interrupt vectors, filling in uh_vec.  We free the map
     56  * register and bdp resources of the uba into the structures
     57  * defined here.
     58  *
     59  * During normal operation, resources are allocated and returned
     60  * to the structures here.  We watch the number of passive releases
     61  * on each uba, and if the number is excessive may reset the uba.
     62  *
     63  * When uba resources are needed and not available, or if a device
     64  * which can tolerate no other uba activity (rk07) gets on the bus,
     65  * then device drivers may have to wait to get to the bus and are
     66  * queued here.  It is also possible for processes to block in
     67  * the unibus driver in resource wait (mrwant, bdpwant); these
     68  * wait states are also recorded here.
     69  */
     70 struct	uba_softc {
     71 	struct	device uh_dev;		/* Device struct, autoconfig */
     72 	SIMPLEQ_HEAD(, uba_unit) uh_resq;	/* resource wait chain */
     73 	SIMPLEQ_HEAD(, uba_reset) uh_resetq;	/* ubareset queue */
     74 	int	uh_lastiv;		/* last free interrupt vector */
     75 	int	(*uh_errchk) __P((struct uba_softc *));
     76 	void	(*uh_beforescan) __P((struct uba_softc *));
     77 	void	(*uh_afterscan) __P((struct uba_softc *));
     78 	void	(*uh_ubainit) __P((struct uba_softc *));
     79 	void	(*uh_ubapurge) __P((struct uba_softc *, int));
     80 	short	uh_nr;			/* Unibus sequential number */
     81 	bus_space_tag_t	uh_iot;		/* Tag for this Unibus */
     82 	bus_space_handle_t uh_ioh;	/* Handle for I/O space */
     83 	bus_dma_tag_t	uh_dmat;
     84 };
     85 
     86 /*
     87  * Per-controller structure.
     88  * The unit struct is common to both the adapter and the controller
     89  * to which it belongs. It is only used on controllers that handles
     90  * BDP's, and calls the adapter queueing subroutines.
     91  */
     92 struct	uba_unit {
     93 	SIMPLEQ_ENTRY(uba_unit) uu_resq;/* Queue while waiting for resources */
     94 	void	*uu_softc;	/* Pointer to units softc */
     95 	int	uu_bdp;		/* for controllers that hang on to bdp's */
     96 	int    (*uu_ready) __P((struct uba_unit *));
     97 	void	*uu_ref;	/* Buffer this is related to */
     98 	short   uu_xclu;        /* want exclusive use of bdp's */
     99 	short   uu_keepbdp;     /* hang on to bdp's once allocated */
    100 };
    101 
    102 /*
    103  * Reset structure. All devices that needs to be reinitialized
    104  * after an ubareset registers with this struct.
    105  */
    106 struct	uba_reset {
    107 	SIMPLEQ_ENTRY(uba_reset) ur_resetq;
    108 	void (*ur_reset)(struct device *);
    109 	struct device *ur_dev;
    110 };
    111 
    112 /*
    113  * uba_attach_args is used during autoconfiguration. It is sent
    114  * from ubascan() to each (possible) device.
    115  */
    116 struct uba_attach_args {
    117 	bus_space_tag_t	ua_iot;		/* Tag for this bus I/O-space */
    118 	bus_addr_t	ua_ioh;		/* I/O regs addr */
    119 	bus_dma_tag_t	ua_dmat;
    120 	void		*ua_icookie;	/* Cookie for interrupt establish */
    121 	int		ua_iaddr;	/* Full CSR address of device */
    122 	int		ua_br;		/* IPL this dev interrupted on */
    123 	int		ua_cvec;	/* Vector for this device */
    124 };
    125 
    126 /*
    127  * Flags to UBA map/bdp allocation routines
    128  */
    129 #define	UBA_NEEDBDP	0x01		/* transfer needs a bdp */
    130 #define	UBA_CANTWAIT	0x02		/* don't block me */
    131 #define	UBA_NEED16	0x04		/* need 16 bit addresses only */
    132 #define	UBA_HAVEBDP	0x08		/* use bdp specified in high bits */
    133 #define	UBA_DONTQUE	0x10		/* Do not enqueue xfer */
    134 
    135 /*
    136  * Some common defines for all subtypes of U/Q-buses/adapters.
    137  */
    138 #define	MAXUBAXFER	(63*1024)	/* Max transfer size in bytes */
    139 #define ubdevreg(addr) ((addr) & 017777)
    140 
    141 #ifdef _KERNEL
    142 void	uba_intr_establish(void *, int, void (*)(void *), void *);
    143 void	uba_reset_establish(void (*)(struct device *), struct device *);
    144 void	uba_attach(struct uba_softc *, unsigned long);
    145 void	uba_enqueue(struct uba_unit *);
    146 void	uba_done(struct uba_softc *);
    147 void	ubareset(struct uba_softc *);
    148 #endif /* _KERNEL */
    149 
    150 #endif /* _QBUS_UBAVAR_H */
    151