Home | History | Annotate | Line # | Download | only in dev
hpibvar.h revision 1.11
      1  1.11      jtk /*	$NetBSD: hpibvar.h,v 1.11 1997/07/17 01:59:12 jtk Exp $	*/
      2   1.4      cgd 
      3   1.1      cgd /*
      4   1.9  thorpej  * Copyright (c) 1996, 1997 Jason R. Thorpe.  All rights reserved.
      5   1.3  mycroft  * Copyright (c) 1982, 1990, 1993
      6   1.3  mycroft  *	The Regents of the University of California.  All rights reserved.
      7   1.1      cgd  *
      8   1.1      cgd  * Redistribution and use in source and binary forms, with or without
      9   1.1      cgd  * modification, are permitted provided that the following conditions
     10   1.1      cgd  * are met:
     11   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     12   1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     13   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     15   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     16   1.1      cgd  * 3. All advertising materials mentioning features or use of this software
     17   1.1      cgd  *    must display the following acknowledgement:
     18   1.1      cgd  *	This product includes software developed by the University of
     19   1.1      cgd  *	California, Berkeley and its contributors.
     20   1.1      cgd  * 4. Neither the name of the University nor the names of its contributors
     21   1.1      cgd  *    may be used to endorse or promote products derived from this software
     22   1.1      cgd  *    without specific prior written permission.
     23   1.1      cgd  *
     24   1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25   1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26   1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27   1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28   1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29   1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30   1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31   1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32   1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33   1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34   1.1      cgd  * SUCH DAMAGE.
     35   1.1      cgd  *
     36   1.4      cgd  *	@(#)hpibvar.h	8.1 (Berkeley) 6/10/93
     37   1.1      cgd  */
     38   1.1      cgd 
     39   1.9  thorpej #include <sys/queue.h>
     40   1.9  thorpej 
     41   1.1      cgd #define	HPIB_IPL(x)	((((x) >> 4) & 0x3) + 3)
     42   1.1      cgd 
     43   1.1      cgd #define	HPIBA		32
     44   1.1      cgd #define	HPIBB		1
     45   1.1      cgd #define	HPIBC		8
     46   1.1      cgd #define	HPIBA_BA	21
     47   1.1      cgd #define	HPIBC_BA	30
     48   1.1      cgd #define	HPIBA_IPL	3
     49   1.1      cgd 
     50   1.1      cgd #define	CSA_BA		0x1F
     51   1.1      cgd 
     52   1.1      cgd #define	IDS_WDMA	0x04
     53   1.1      cgd #define	IDS_WRITE	0x08
     54   1.1      cgd #define	IDS_IR		0x40
     55   1.1      cgd #define	IDS_IE		0x80
     56   1.1      cgd #define	IDS_DMA(x)	(1 << (x))
     57   1.1      cgd 
     58   1.5  mycroft #define	C_SDC		0x04	/* Selected device clear */
     59   1.5  mycroft #define	C_SDC_P		0x04	/*  with odd parity */
     60   1.5  mycroft #define	C_DCL		0x14	/* Universal device clear */
     61   1.5  mycroft #define	C_DCL_P		0x94	/*  with odd parity */
     62   1.5  mycroft #define	C_LAG		0x20	/* Listener address group commands */
     63   1.5  mycroft #define	C_UNL		0x3f	/* Universal unlisten */
     64   1.5  mycroft #define	C_UNL_P		0xbf	/*  with odd parity */
     65   1.5  mycroft #define	C_TAG		0x40	/* Talker address group commands */
     66   1.5  mycroft #define	C_UNA		0x5e	/* Unaddress (master talk address?) */
     67   1.5  mycroft #define	C_UNA_P		0x5e	/*  with odd parity */
     68   1.5  mycroft #define	C_UNT		0x5f	/* Universal untalk */
     69   1.5  mycroft #define	C_UNT_P		0xdf	/*  with odd parity */
     70   1.5  mycroft #define	C_SCG		0x60	/* Secondary group commands */
     71   1.1      cgd 
     72   1.9  thorpej struct hpibbus_softc;
     73   1.8  thorpej 
     74   1.7  thorpej /*
     75   1.7  thorpej  * Each of the HP-IB controller drivers fills in this structure, which
     76   1.7  thorpej  * is used by the indirect driver to call controller-specific functions.
     77   1.7  thorpej  */
     78   1.7  thorpej struct	hpib_controller {
     79   1.9  thorpej 	void	(*hpib_reset) __P((struct hpibbus_softc *));
     80   1.9  thorpej 	int	(*hpib_send) __P((struct hpibbus_softc *,
     81   1.9  thorpej 		    int, int, void *, int));
     82   1.9  thorpej 	int	(*hpib_recv) __P((struct hpibbus_softc *,
     83   1.9  thorpej 		    int, int, void *, int));
     84   1.9  thorpej 	int	(*hpib_ppoll) __P((struct hpibbus_softc *));
     85   1.7  thorpej 	void	(*hpib_ppwatch) __P((void *));
     86   1.9  thorpej 	void	(*hpib_go) __P((struct hpibbus_softc *,
     87   1.9  thorpej 		    int, int, void *, int, int, int));
     88   1.9  thorpej 	void	(*hpib_done) __P((struct hpibbus_softc *));
     89   1.8  thorpej 	int	(*hpib_intr) __P((void *));
     90   1.1      cgd };
     91   1.1      cgd 
     92   1.9  thorpej /*
     93   1.9  thorpej  * Attach an HP-IB bus to an HP-IB controller.
     94   1.9  thorpej  */
     95   1.9  thorpej struct hpibdev_attach_args {
     96   1.9  thorpej 	struct	hpib_controller *ha_ops;	/* controller ops vector */
     97   1.9  thorpej 	int	ha_type;			/* XXX */
     98   1.9  thorpej 	int	ha_ba;
     99   1.9  thorpej 	struct hpibbus_softc **ha_softcpp;	/* XXX */
    100   1.9  thorpej };
    101   1.9  thorpej 
    102   1.9  thorpej /*
    103   1.9  thorpej  * Attach an HP-IB device to an HP-IB bus.
    104   1.9  thorpej  */
    105   1.9  thorpej struct hpibbus_attach_args {
    106   1.9  thorpej 	u_int16_t ha_id;		/* device id */
    107   1.9  thorpej 	int	ha_slave;		/* HP-IB bus slave */
    108   1.9  thorpej 	int	ha_punit;		/* physical unit on slave */
    109   1.9  thorpej };
    110   1.9  thorpej 
    111   1.9  thorpej /* Locator short-hand */
    112  1.11      jtk #include "locators.h"
    113   1.9  thorpej 
    114  1.11      jtk #define	hpibbuscf_slave		cf_loc[HPIBBUSCF_SLAVE]
    115  1.11      jtk #define	hpibbuscf_punit		cf_loc[HPIBBUSCF_PUNIT]
    116  1.11      jtk 
    117  1.11      jtk #define	HPIBBUS_SLAVE_UNK	HPIBBUSCF_SLAVE_DEFAULT
    118  1.11      jtk #define	HPIBBUS_PUNIT_UNK	HPIBBUSCF_PUNIT_DEFAULT
    119   1.9  thorpej 
    120   1.9  thorpej #define	HPIB_NSLAVES		8	/* number of slaves on a bus */
    121   1.9  thorpej #define	HPIB_NPUNITS		2	/* number of punits per slave */
    122   1.9  thorpej 
    123   1.9  thorpej /*
    124   1.9  thorpej  * An HP-IB job queue entry.  Slave drivers have one of these used
    125   1.9  thorpej  * to queue requests with the controller.
    126   1.9  thorpej  */
    127   1.9  thorpej struct hpibqueue {
    128   1.9  thorpej 	TAILQ_ENTRY(hpibqueue) hq_list;	/* entry on queue */
    129   1.9  thorpej 	void	*hq_softc;		/* slave's softc */
    130   1.9  thorpej 	int	hq_slave;		/* slave on bus */
    131   1.9  thorpej 
    132   1.9  thorpej 	/*
    133   1.9  thorpej 	 * Callbacks used to start and stop the slave driver.
    134   1.9  thorpej 	 */
    135   1.9  thorpej 	void	(*hq_start) __P((void *));
    136   1.9  thorpej 	void	(*hq_go) __P((void *));
    137   1.9  thorpej 	void	(*hq_intr) __P((void *));
    138   1.9  thorpej };
    139   1.9  thorpej 
    140   1.9  thorpej struct dmaqueue;
    141   1.9  thorpej 
    142   1.9  thorpej /*
    143   1.9  thorpej  * Software state per HP-IB bus.
    144   1.9  thorpej  */
    145   1.9  thorpej struct hpibbus_softc {
    146   1.9  thorpej 	struct	device sc_dev;		/* generic device glue */
    147   1.9  thorpej 	struct	hpib_controller *sc_ops; /* controller ops vector */
    148   1.9  thorpej 	volatile int sc_flags;		/* misc flags */
    149   1.9  thorpej 	struct	dmaqueue *sc_dq;
    150   1.9  thorpej 	TAILQ_HEAD(, hpibqueue) sc_queue;
    151   1.9  thorpej 	int	sc_ba;
    152   1.9  thorpej 	int	sc_type;
    153   1.9  thorpej 	char	*sc_addr;
    154   1.9  thorpej 	int	sc_count;
    155   1.9  thorpej 	int	sc_curcnt;
    156   1.9  thorpej 
    157   1.9  thorpej 	/*
    158   1.9  thorpej 	 * HP-IB is an indirect bus; this cheezy resource map
    159   1.9  thorpej 	 * keeps track of slave/punit allocations.
    160   1.9  thorpej 	 */
    161   1.9  thorpej 	char	sc_rmap[HPIB_NSLAVES][HPIB_NPUNITS];
    162   1.9  thorpej };
    163   1.9  thorpej 
    164   1.1      cgd /* sc_flags */
    165   1.1      cgd #define	HPIBF_IO	0x1
    166   1.1      cgd #define	HPIBF_DONE	0x2
    167   1.1      cgd #define	HPIBF_PPOLL	0x4
    168   1.1      cgd #define	HPIBF_READ	0x8
    169   1.5  mycroft #define	HPIBF_TIMO	0x10
    170   1.1      cgd #define	HPIBF_DMA16	0x8000
    171   1.1      cgd 
    172   1.6      jtc #ifdef _KERNEL
    173   1.1      cgd extern	caddr_t internalhpib;
    174   1.1      cgd extern	int hpibtimeout;
    175   1.1      cgd extern	int hpibdmathresh;
    176   1.7  thorpej 
    177   1.7  thorpej void	hpibreset __P((int));
    178   1.7  thorpej int	hpibsend __P((int, int, int, void *, int));
    179   1.7  thorpej int	hpibrecv __P((int, int, int, void *, int));
    180  1.10   scottr int	hpibustart __P((int));
    181  1.10   scottr void	hpibstart __P((void *));
    182   1.9  thorpej void	hpibgo __P((int, int, int, void *, int, int, int));
    183  1.10   scottr void	hpibdone __P((void *));
    184  1.10   scottr int	hpibpptest __P((int, int));
    185   1.9  thorpej void	hpibppclear __P((int));
    186  1.10   scottr void	hpibawait __P((int));
    187  1.10   scottr int	hpibswait __P((int, int));
    188  1.10   scottr int	hpibid __P((int, int));
    189   1.9  thorpej 
    190   1.9  thorpej int	hpibreq __P((struct device *, struct hpibqueue *));
    191   1.9  thorpej void	hpibfree __P((struct device *, struct hpibqueue *));
    192  1.10   scottr int	hpibbus_alloc __P((struct hpibbus_softc *, int, int));
    193  1.10   scottr void	hpibbus_free __P((struct hpibbus_softc *, int, int));
    194   1.9  thorpej 
    195   1.9  thorpej int	hpibintr __P((void *));
    196   1.9  thorpej int	hpibdevprint __P((void *, const char *));
    197   1.1      cgd #endif
    198