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