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