1998-10-18 22:47:18 +04:00
|
|
|
/* $NetBSD: ubavar.h,v 1.20 1998/10/18 18:51:30 ragge Exp $ */
|
1994-10-26 11:01:33 +03:00
|
|
|
|
1994-08-03 00:18:46 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1982, 1986 Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-10-26 11:01:33 +03:00
|
|
|
* @(#)ubavar.h 7.7 (Berkeley) 6/28/90
|
1994-08-03 00:18:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains definitions related to the kernel structures
|
|
|
|
* for dealing with the unibus adapters.
|
|
|
|
*
|
1995-11-10 22:25:46 +03:00
|
|
|
* Each uba has a uba_softc structure.
|
1994-08-03 00:18:46 +04:00
|
|
|
* Each unibus controller which is not a device has a uba_ctlr structure.
|
|
|
|
* Each unibus device has a uba_device structure.
|
|
|
|
*/
|
|
|
|
|
1996-02-02 21:05:36 +03:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/device.h>
|
1996-03-02 17:09:57 +03:00
|
|
|
|
|
|
|
#include <machine/trap.h> /* For struct ivec_dsp */
|
1994-08-03 00:18:46 +04:00
|
|
|
/*
|
|
|
|
* Per-uba structure.
|
|
|
|
*
|
|
|
|
* This structure holds the interrupt vector for the uba,
|
|
|
|
* and its address in physical and virtual space. At boot time
|
|
|
|
* we determine the devices attached to the uba's and their
|
|
|
|
* interrupt vectors, filling in uh_vec. We free the map
|
|
|
|
* register and bdp resources of the uba into the structures
|
|
|
|
* defined here.
|
|
|
|
*
|
|
|
|
* During normal operation, resources are allocated and returned
|
|
|
|
* to the structures here. We watch the number of passive releases
|
|
|
|
* on each uba, and if the number is excessive may reset the uba.
|
|
|
|
*
|
|
|
|
* When uba resources are needed and not available, or if a device
|
|
|
|
* which can tolerate no other uba activity (rk07) gets on the bus,
|
|
|
|
* then device drivers may have to wait to get to the bus and are
|
|
|
|
* queued here. It is also possible for processes to block in
|
|
|
|
* the unibus driver in resource wait (mrwant, bdpwant); these
|
|
|
|
* wait states are also recorded here.
|
|
|
|
*/
|
1995-11-10 22:25:46 +03:00
|
|
|
struct uba_softc {
|
|
|
|
struct device uh_dev; /* Device struct, autoconfig */
|
1996-08-20 17:37:57 +04:00
|
|
|
SIMPLEQ_HEAD(, uba_unit) uh_resq; /* resource wait chain */
|
1994-08-03 00:18:46 +04:00
|
|
|
int uh_type; /* type of adaptor */
|
|
|
|
struct uba_regs *uh_uba; /* virt addr of uba adaptor regs */
|
|
|
|
struct pte *uh_mr; /* start of page map */
|
|
|
|
int uh_memsize; /* size of uba memory, pages */
|
|
|
|
caddr_t uh_iopage; /* start of uba io page */
|
1996-04-08 22:32:26 +04:00
|
|
|
void (**uh_reset) __P((int));/* UBA reset function array */
|
1996-03-18 19:47:24 +03:00
|
|
|
int *uh_resarg; /* array of ubareset args */
|
|
|
|
int uh_resno; /* Number of devices to reset */
|
1995-11-10 22:25:46 +03:00
|
|
|
struct ivec_dsp *uh_idsp; /* Interrupt dispatch area */
|
|
|
|
u_int *uh_iarea; /* Interrupt vector array */
|
1994-08-03 00:18:46 +04:00
|
|
|
short uh_mrwant; /* someone is waiting for map reg */
|
|
|
|
short uh_bdpwant; /* someone awaits bdp's */
|
|
|
|
int uh_bdpfree; /* free bdp's */
|
|
|
|
int uh_zvcnt; /* number of recent 0 vectors */
|
|
|
|
long uh_zvtime; /* time over which zvcnt accumulated */
|
|
|
|
int uh_zvtotal; /* total number of 0 vectors */
|
|
|
|
int uh_lastiv; /* last free interrupt vector */
|
|
|
|
short uh_users; /* transient bdp use count */
|
|
|
|
short uh_xclu; /* an rk07 is using this uba! */
|
|
|
|
int uh_lastmem; /* limit of any unibus memory */
|
|
|
|
struct map *uh_map; /* register free map */
|
1996-08-20 17:37:57 +04:00
|
|
|
int (*uh_errchk) __P((struct uba_softc *));
|
|
|
|
void (*uh_beforescan) __P((struct uba_softc *));
|
|
|
|
void (*uh_afterscan) __P((struct uba_softc *));
|
|
|
|
void (*uh_ubainit) __P((struct uba_softc *));
|
|
|
|
void (*uh_ubapurge) __P((struct uba_softc *, int));
|
|
|
|
#ifdef DW780
|
1996-03-02 17:09:57 +03:00
|
|
|
struct ivec_dsp uh_dw780; /* Interrupt handles for DW780 */
|
1996-08-20 17:37:57 +04:00
|
|
|
#endif
|
|
|
|
short uh_nr; /* Unibus sequential number */
|
|
|
|
short uh_nbdp; /* # of BDP's */
|
1994-08-03 00:18:46 +04:00
|
|
|
};
|
|
|
|
|
1996-08-20 17:37:57 +04:00
|
|
|
#define UAMSIZ 100
|
|
|
|
|
1994-08-03 00:18:46 +04:00
|
|
|
/*
|
|
|
|
* Per-controller structure.
|
1996-07-02 01:31:36 +04:00
|
|
|
* The unit struct is common to both the adapter and the controller
|
|
|
|
* to which it belongs. It is only used on controllers that handles
|
|
|
|
* BDP's, and calls the adapter queueing subroutines.
|
1994-08-03 00:18:46 +04:00
|
|
|
*/
|
1996-07-02 01:31:36 +04:00
|
|
|
struct uba_unit {
|
1996-08-20 17:37:57 +04:00
|
|
|
SIMPLEQ_ENTRY(uba_unit) uu_resq;/* Queue while waiting for resources */
|
1996-07-02 01:31:36 +04:00
|
|
|
void *uu_softc; /* Pointer to units softc */
|
|
|
|
int uu_ubinfo; /* save unibus registers, etc */
|
|
|
|
int uu_bdp; /* for controllers that hang on to bdp's */
|
1996-08-20 17:37:57 +04:00
|
|
|
int (*uu_ready) __P((struct uba_unit *));
|
1996-07-02 01:31:36 +04:00
|
|
|
short uu_xclu; /* want exclusive use of bdp's */
|
|
|
|
short uu_keepbdp; /* hang on to bdp's once allocated */
|
1994-08-03 00:18:46 +04:00
|
|
|
};
|
1995-12-01 22:22:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* uba_attach_args is used during autoconfiguration. It is sent
|
|
|
|
* from ubascan() to each (possible) device.
|
|
|
|
*/
|
|
|
|
struct uba_attach_args {
|
|
|
|
caddr_t ua_addr;
|
1996-04-08 22:32:26 +04:00
|
|
|
/* Pointer to int routine, filled in by probe*/
|
|
|
|
void (*ua_ivec) __P((int));
|
|
|
|
/* UBA reset routine, filled in by probe */
|
|
|
|
void (*ua_reset) __P((int));
|
1995-12-01 22:22:56 +03:00
|
|
|
int ua_iaddr;
|
|
|
|
int ua_br;
|
|
|
|
int ua_cvec;
|
|
|
|
};
|
1994-08-03 00:18:46 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Flags to UBA map/bdp allocation routines
|
|
|
|
*/
|
|
|
|
#define UBA_NEEDBDP 0x01 /* transfer needs a bdp */
|
|
|
|
#define UBA_CANTWAIT 0x02 /* don't block me */
|
|
|
|
#define UBA_NEED16 0x04 /* need 16 bit addresses only */
|
|
|
|
#define UBA_HAVEBDP 0x08 /* use bdp specified in high bits */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros to bust return word from map allocation routines.
|
|
|
|
* SHOULD USE STRUCTURE TO STORE UBA RESOURCE ALLOCATION:
|
|
|
|
*/
|
|
|
|
#ifdef notyet
|
|
|
|
struct ubinfo {
|
|
|
|
long ub_addr; /* unibus address: mr + boff */
|
|
|
|
int ub_nmr; /* number of registers, 0 if empty */
|
|
|
|
int ub_bdp; /* bdp number, 0 if none */
|
|
|
|
};
|
|
|
|
#define UBAI_MR(i) (((i) >> 9) & 0x7ff) /* starting map register */
|
|
|
|
#define UBAI_BOFF(i) ((i)&0x1ff) /* page offset */
|
|
|
|
#else
|
|
|
|
#define UBAI_BDP(i) ((int)(((unsigned)(i)) >> 28))
|
|
|
|
#define BDPMASK 0xf0000000
|
|
|
|
#define UBAI_NMR(i) ((int)((i) >> 20) & 0xff) /* max 255 (=127.5K) */
|
|
|
|
#define UBA_MAXNMR 255
|
|
|
|
#define UBAI_MR(i) ((int)((i) >> 9) & 0x7ff) /* max 2047 */
|
|
|
|
#define UBA_MAXMR 2047
|
|
|
|
#define UBAI_BOFF(i) ((int)((i) & 0x1ff))
|
|
|
|
#define UBAI_ADDR(i) ((int)((i) & 0xfffff)) /* uba addr (boff+mr) */
|
|
|
|
#define UBAI_INFO(off, mr, nmr, bdp) \
|
|
|
|
(((bdp) << 28) | ((nmr) << 20) | ((mr) << 9) | (off))
|
|
|
|
#endif
|
|
|
|
|
1996-02-02 01:28:24 +03:00
|
|
|
#ifndef _LOCORE
|
1995-05-11 20:52:54 +04:00
|
|
|
#ifdef _KERNEL
|
1996-08-20 17:37:57 +04:00
|
|
|
#define ubago(ui) ubaqueue(ui)
|
1996-07-02 01:31:36 +04:00
|
|
|
#define b_forw b_hash.le_next /* Nice to have when handling uba queues */
|
1994-08-03 00:18:46 +04:00
|
|
|
|
1998-10-18 22:47:18 +04:00
|
|
|
void uba_attach __P((struct uba_softc *, unsigned long));
|
1996-04-08 22:32:26 +04:00
|
|
|
void ubasetvec __P((struct device *, int, void (*) __P((int))));
|
1996-08-20 17:37:57 +04:00
|
|
|
int uballoc __P((struct uba_softc *, caddr_t, int, int));
|
|
|
|
void ubarelse __P((struct uba_softc *, int *));
|
|
|
|
int ubaqueue __P((struct uba_unit *, struct buf *));
|
1996-07-02 01:31:36 +04:00
|
|
|
void ubadone __P((struct uba_unit *));
|
1996-04-08 22:32:26 +04:00
|
|
|
void ubareset __P((int));
|
1998-10-18 22:47:18 +04:00
|
|
|
int ubasetup __P((struct uba_softc *, struct buf *, int));
|
1995-12-01 22:22:56 +03:00
|
|
|
|
1995-05-11 20:52:54 +04:00
|
|
|
#endif /* _KERNEL */
|
1996-02-02 01:28:24 +03:00
|
|
|
#endif !_LOCORE
|