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