Home | History | Annotate | Line # | Download | only in dev
hpib.c revision 1.14
      1  1.14   scottr /*	$NetBSD: hpib.c,v 1.14 1997/03/31 07:34:24 scottr Exp $	*/
      2   1.4      cgd 
      3   1.1      cgd /*
      4  1.13  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  *	@(#)hpib.c	8.2 (Berkeley) 1/12/94
     37   1.1      cgd  */
     38   1.1      cgd 
     39   1.1      cgd /*
     40  1.13  thorpej  * HP-IB bus driver
     41   1.1      cgd  */
     42   1.1      cgd 
     43   1.3  mycroft #include <sys/param.h>
     44   1.3  mycroft #include <sys/systm.h>
     45   1.3  mycroft #include <sys/buf.h>
     46  1.13  thorpej #include <sys/malloc.h>
     47  1.13  thorpej #include <sys/device.h>
     48  1.13  thorpej 
     49  1.13  thorpej #include <hp300/dev/dmavar.h>
     50   1.3  mycroft 
     51   1.3  mycroft #include <hp300/dev/hpibvar.h>
     52   1.1      cgd 
     53   1.3  mycroft #include <machine/cpu.h>
     54   1.3  mycroft #include <hp300/hp300/isr.h>
     55   1.1      cgd 
     56  1.13  thorpej int	hpibbusmatch __P((struct device *, struct cfdata *, void *));
     57  1.13  thorpej void	hpibbusattach __P((struct device *, struct device *, void *));
     58  1.13  thorpej 
     59  1.13  thorpej struct cfattach hpibbus_ca = {
     60  1.13  thorpej 	sizeof(struct hpibbus_softc), hpibbusmatch, hpibbusattach
     61   1.1      cgd };
     62   1.1      cgd 
     63  1.13  thorpej struct cfdriver hpibbus_cd = {
     64  1.13  thorpej 	NULL, "hpibbus", DV_DULL
     65  1.13  thorpej };
     66   1.6  thorpej 
     67  1.13  thorpej void	hpibbus_attach_children __P((struct hpibbus_softc *));
     68  1.13  thorpej int	hpibbussearch __P((struct device *, struct cfdata *, void *));
     69  1.13  thorpej int	hpibbusprint __P((void *, const char *));
     70  1.13  thorpej 
     71  1.13  thorpej int	hpibbus_alloc __P((struct hpibbus_softc *, int, int));
     72  1.13  thorpej void	hpibbus_free __P((struct hpibbus_softc *, int, int));
     73  1.13  thorpej 
     74  1.13  thorpej void	hpibstart __P((void *));
     75  1.13  thorpej void	hpibdone __P((void *));
     76   1.1      cgd 
     77   1.1      cgd int	hpibtimeout = 100000;	/* # of status tests before we give up */
     78   1.3  mycroft int	hpibidtimeout = 10000;	/* # of status tests for hpibid() calls */
     79   1.1      cgd int	hpibdmathresh = 3;	/* byte count beyond which to attempt dma */
     80   1.1      cgd 
     81  1.13  thorpej /*
     82  1.13  thorpej  * HP-IB is essentially an IEEE 488 bus, with an HP command
     83  1.13  thorpej  * set (CS/80 on `newer' devices, Amigo on before-you-were-born
     84  1.13  thorpej  * devices) thrown on top.  Devices that respond to CS/80 (and
     85  1.13  thorpej  * probably Amigo, too) are tagged with a 16-bit ID.
     86  1.13  thorpej  *
     87  1.13  thorpej  * HP-IB has a 2-level addressing scheme; slave, the analog
     88  1.13  thorpej  * of a SCSI ID, and punit, the analog of a SCSI LUN.  Unforunately,
     89  1.13  thorpej  * IDs are on a per-slave basis; punits are often used for disk
     90  1.13  thorpej  * drives that have an accompanying tape drive on the second punit.
     91  1.13  thorpej  *
     92  1.13  thorpej  * In addition, not all HP-IB devices speak CS/80 or Amigo.
     93  1.13  thorpej  * Examples of such devices are HP-IB plotters, which simply
     94  1.13  thorpej  * take raw plotter commands over 488.  These devices do not
     95  1.13  thorpej  * have ID tags, and often the host cannot even tell if such
     96  1.13  thorpej  * a device is attached to the system!
     97  1.13  thorpej  *
     98  1.13  thorpej  * These two nasty bits mean that we have to treat HP-IB as
     99  1.13  thorpej  * an indirect bus.  However, since we are given some ID
    100  1.13  thorpej  * information, it is unreasonable to disallow cloning of
    101  1.13  thorpej  * CS/80 devices.
    102  1.13  thorpej  *
    103  1.13  thorpej  * To deal with all of this, we use the semi-twisted scheme
    104  1.13  thorpej  * in hpibbus_attach_children().  For each HP-IB slave, we loop
    105  1.13  thorpej  * through all of the possibly-configured children, allowing
    106  1.13  thorpej  * them to modify the punit parameter (but NOT the slave!).
    107  1.13  thorpej  *
    108  1.13  thorpej  * This is evil, but what can you do?
    109  1.13  thorpej  */
    110  1.13  thorpej 
    111   1.6  thorpej int
    112  1.13  thorpej hpibbusmatch(parent, match, aux)
    113  1.13  thorpej 	struct device *parent;
    114  1.13  thorpej 	struct cfdata *match;
    115  1.13  thorpej 	void *aux;
    116   1.1      cgd {
    117   1.7  thorpej 
    118  1.13  thorpej 	return (1);
    119  1.13  thorpej }
    120  1.13  thorpej 
    121  1.13  thorpej void
    122  1.13  thorpej hpibbusattach(parent, self, aux)
    123  1.13  thorpej 	struct device *parent, *self;
    124  1.13  thorpej 	void *aux;
    125  1.13  thorpej {
    126  1.13  thorpej 	struct hpibbus_softc *sc = (struct hpibbus_softc *)self;
    127  1.13  thorpej 	struct hpibdev_attach_args *ha = aux;
    128  1.13  thorpej 
    129  1.13  thorpej 	printf("\n");
    130  1.13  thorpej 
    131  1.13  thorpej 	/* Get the operations vector for the controller. */
    132  1.13  thorpej 	sc->sc_ops = ha->ha_ops;
    133  1.13  thorpej 	sc->sc_type = ha->ha_type;		/* XXX */
    134  1.13  thorpej 	sc->sc_ba = ha->ha_ba;
    135  1.13  thorpej 	*(ha->ha_softcpp) = sc;			/* XXX */
    136  1.13  thorpej 
    137  1.13  thorpej 	hpibreset(self->dv_unit);		/* XXX souldn't be here */
    138  1.13  thorpej 
    139  1.13  thorpej 	/*
    140  1.13  thorpej 	 * Initialize the DMA queue entry.
    141  1.13  thorpej 	 */
    142  1.13  thorpej 	sc->sc_dq = (struct dmaqueue *)malloc(sizeof(struct dmaqueue),
    143  1.13  thorpej 	    M_DEVBUF, M_NOWAIT);
    144  1.13  thorpej 	if (sc->sc_dq == NULL) {
    145  1.13  thorpej 		printf("%s: can't allocate DMA queue entry\n", self->dv_xname);
    146  1.13  thorpej 		return;
    147   1.7  thorpej 	}
    148  1.13  thorpej 	sc->sc_dq->dq_softc = sc;
    149  1.13  thorpej 	sc->sc_dq->dq_start = hpibstart;
    150  1.13  thorpej 	sc->sc_dq->dq_done = hpibdone;
    151   1.7  thorpej 
    152  1.13  thorpej 	/* Initialize the slave request queue. */
    153  1.13  thorpej 	TAILQ_INIT(&sc->sc_queue);
    154  1.13  thorpej 
    155  1.13  thorpej 	/* Attach any devices on the bus. */
    156  1.13  thorpej 	hpibbus_attach_children(sc);
    157   1.7  thorpej }
    158   1.7  thorpej 
    159   1.7  thorpej void
    160  1.13  thorpej hpibbus_attach_children(sc)
    161  1.13  thorpej 	struct hpibbus_softc *sc;
    162   1.7  thorpej {
    163  1.13  thorpej 	struct hpibbus_attach_args ha;
    164  1.13  thorpej 	int slave;
    165   1.7  thorpej 
    166  1.13  thorpej 	for (slave = 0; slave < 8; slave++) {
    167  1.13  thorpej 		/*
    168  1.13  thorpej 		 * Get the ID tag for the device, if any.
    169  1.13  thorpej 		 * Plotters won't identify themselves, and
    170  1.13  thorpej 		 * get the same value as non-existent devices.
    171  1.13  thorpej 		 */
    172  1.13  thorpej 		ha.ha_id = hpibid(sc->sc_dev.dv_unit, slave);
    173  1.13  thorpej 
    174  1.13  thorpej 		ha.ha_slave = slave;	/* not to be modified by children */
    175  1.13  thorpej 		ha.ha_punit = 0;	/* children modify this */
    176  1.13  thorpej 
    177  1.13  thorpej 		/*
    178  1.13  thorpej 		 * Search though all configured children for this bus.
    179  1.13  thorpej 		 */
    180  1.13  thorpej 		(void)config_search(hpibbussearch, &sc->sc_dev, &ha);
    181  1.13  thorpej 	}
    182  1.13  thorpej }
    183  1.13  thorpej 
    184  1.13  thorpej int
    185  1.13  thorpej hpibbussearch(parent, cf, aux)
    186  1.13  thorpej 	struct device *parent;
    187  1.13  thorpej 	struct cfdata *cf;
    188  1.13  thorpej 	void *aux;
    189  1.13  thorpej {
    190  1.13  thorpej 	struct hpibbus_softc *sc = (struct hpibbus_softc *)parent;
    191  1.13  thorpej 	struct hpibbus_attach_args *ha = aux;
    192  1.13  thorpej 
    193  1.13  thorpej 	/* Make sure this is in a consistent state. */
    194  1.13  thorpej 	ha->ha_punit = 0;
    195  1.13  thorpej 
    196  1.13  thorpej 	if ((*cf->cf_attach->ca_match)(parent, cf, ha) > 0) {
    197  1.13  thorpej 		/*
    198  1.13  thorpej 		 * The device probe has succeeded, and filled in
    199  1.13  thorpej 		 * the punit information.  Make sure the configuration
    200  1.13  thorpej 		 * allows for this slave/punit combination.
    201  1.13  thorpej 		 */
    202  1.13  thorpej 		if (cf->hpibbuscf_slave != HPIBBUS_SLAVE_UNK &&
    203  1.13  thorpej 		    cf->hpibbuscf_slave != ha->ha_slave)
    204  1.13  thorpej 			goto out;
    205  1.13  thorpej 		if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK &&
    206  1.13  thorpej 		    cf->hpibbuscf_punit != ha->ha_punit)
    207  1.13  thorpej 			goto out;
    208  1.13  thorpej 
    209  1.13  thorpej 		/*
    210  1.13  thorpej 		 * Allocate the device's address from the bus's
    211  1.13  thorpej 		 * resource map.
    212  1.13  thorpej 		 */
    213  1.13  thorpej 		if (hpibbus_alloc(sc, ha->ha_slave, ha->ha_punit))
    214  1.13  thorpej 			goto out;
    215  1.13  thorpej 
    216  1.13  thorpej 		/*
    217  1.13  thorpej 		 * This device is allowed; attach it.
    218  1.13  thorpej 		 */
    219  1.13  thorpej 		config_attach(parent, cf, ha, hpibbusprint);
    220   1.7  thorpej 	}
    221  1.13  thorpej  out:
    222  1.13  thorpej 	return (0);
    223  1.13  thorpej }
    224  1.13  thorpej 
    225  1.13  thorpej int
    226  1.13  thorpej hpibbusprint(aux, pnp)
    227  1.13  thorpej 	void *aux;
    228  1.13  thorpej 	const char *pnp;
    229  1.13  thorpej {
    230  1.13  thorpej 	struct hpibbus_attach_args *ha = aux;
    231   1.6  thorpej 
    232  1.13  thorpej 	printf(" slave %d punit %d", ha->ha_slave, ha->ha_punit);
    233  1.13  thorpej 	return (UNCONF);
    234  1.13  thorpej }
    235  1.13  thorpej 
    236  1.13  thorpej int
    237  1.13  thorpej hpibdevprint(aux, pnp)
    238  1.13  thorpej 	void *aux;
    239  1.13  thorpej 	const char *pnp;
    240  1.13  thorpej {
    241  1.13  thorpej 
    242  1.13  thorpej 	/* only hpibbus's can attach to hpibdev's -- easy. */
    243  1.13  thorpej 	if (pnp != NULL)
    244  1.13  thorpej 		printf("hpibbus at %s", pnp);
    245  1.13  thorpej 	return (UNCONF);
    246   1.1      cgd }
    247   1.1      cgd 
    248   1.6  thorpej void
    249   1.1      cgd hpibreset(unit)
    250  1.14   scottr 	int unit;
    251   1.1      cgd {
    252  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    253   1.6  thorpej 
    254  1.13  thorpej 	(*sc->sc_ops->hpib_reset)(sc);
    255   1.1      cgd }
    256   1.1      cgd 
    257   1.6  thorpej int
    258  1.13  thorpej hpibreq(pdev, hq)
    259  1.13  thorpej 	struct device *pdev;
    260  1.13  thorpej 	struct hpibqueue *hq;
    261  1.13  thorpej {
    262  1.13  thorpej 	struct hpibbus_softc *sc = (struct hpibbus_softc *)pdev;
    263  1.13  thorpej 	int s;
    264  1.13  thorpej 
    265  1.13  thorpej 	s = splhigh();	/* XXXthorpej */
    266  1.13  thorpej 	TAILQ_INSERT_TAIL(&sc->sc_queue, hq, hq_list);
    267  1.13  thorpej 	splx(s);
    268  1.13  thorpej 
    269  1.13  thorpej 	if (sc->sc_queue.tqh_first == hq)
    270  1.13  thorpej 		return (1);
    271   1.1      cgd 
    272  1.13  thorpej 	return (0);
    273   1.1      cgd }
    274   1.1      cgd 
    275   1.6  thorpej void
    276  1.13  thorpej hpibfree(pdev, hq)
    277  1.13  thorpej 	struct device *pdev;
    278  1.13  thorpej 	struct hpibqueue *hq;
    279  1.13  thorpej {
    280  1.13  thorpej 	struct hpibbus_softc *sc = (struct hpibbus_softc *)pdev;
    281  1.13  thorpej 	int s;
    282  1.13  thorpej 
    283  1.13  thorpej 	s = splhigh();	/* XXXthorpej */
    284  1.13  thorpej 	TAILQ_REMOVE(&sc->sc_queue, hq, hq_list);
    285  1.13  thorpej 	splx(s);
    286   1.1      cgd 
    287  1.13  thorpej 	if ((hq = sc->sc_queue.tqh_first) != NULL)
    288  1.13  thorpej 		(*hq->hq_start)(hq->hq_softc);
    289   1.1      cgd }
    290   1.1      cgd 
    291   1.6  thorpej int
    292   1.1      cgd hpibid(unit, slave)
    293   1.3  mycroft 	int unit, slave;
    294   1.1      cgd {
    295   1.1      cgd 	short id;
    296   1.1      cgd 	int ohpibtimeout;
    297   1.1      cgd 
    298   1.1      cgd 	/*
    299   1.3  mycroft 	 * XXX shorten timeout value so autoconfig doesn't
    300   1.3  mycroft 	 * take forever on slow CPUs.
    301   1.1      cgd 	 */
    302   1.1      cgd 	ohpibtimeout = hpibtimeout;
    303   1.9  thorpej 	hpibtimeout = hpibidtimeout * (cpuspeed / 8);
    304   1.1      cgd 	if (hpibrecv(unit, 31, slave, &id, 2) != 2)
    305   1.1      cgd 		id = 0;
    306   1.1      cgd 	hpibtimeout = ohpibtimeout;
    307   1.1      cgd 	return(id);
    308   1.1      cgd }
    309   1.1      cgd 
    310   1.6  thorpej int
    311   1.1      cgd hpibsend(unit, slave, sec, addr, cnt)
    312   1.6  thorpej 	int unit, slave, sec, cnt;
    313   1.6  thorpej 	void *addr;
    314   1.1      cgd {
    315  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    316   1.6  thorpej 
    317  1.13  thorpej 	return ((*sc->sc_ops->hpib_send)(sc, slave, sec, addr, cnt));
    318   1.1      cgd }
    319   1.1      cgd 
    320   1.6  thorpej int
    321   1.1      cgd hpibrecv(unit, slave, sec, addr, cnt)
    322   1.6  thorpej 	int unit, slave, sec, cnt;
    323   1.6  thorpej 	void *addr;
    324   1.1      cgd {
    325  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    326   1.6  thorpej 
    327  1.13  thorpej 	return ((*sc->sc_ops->hpib_recv)(sc, slave, sec, addr, cnt));
    328   1.1      cgd }
    329   1.1      cgd 
    330   1.6  thorpej int
    331   1.1      cgd hpibpptest(unit, slave)
    332  1.14   scottr 	int unit;
    333   1.3  mycroft 	int slave;
    334   1.1      cgd {
    335  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    336   1.1      cgd 
    337  1.13  thorpej 	return ((*sc->sc_ops->hpib_ppoll)(sc) & (0x80 >> slave));
    338   1.1      cgd }
    339   1.1      cgd 
    340   1.6  thorpej void
    341   1.5  mycroft hpibppclear(unit)
    342   1.5  mycroft 	int unit;
    343   1.5  mycroft {
    344  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    345  1.13  thorpej 
    346  1.13  thorpej 	sc->sc_flags &= ~HPIBF_PPOLL;
    347   1.5  mycroft }
    348   1.5  mycroft 
    349  1.14   scottr void
    350   1.1      cgd hpibawait(unit)
    351   1.3  mycroft 	int unit;
    352   1.1      cgd {
    353  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    354   1.1      cgd 
    355  1.13  thorpej 	sc->sc_flags |= HPIBF_PPOLL;
    356  1.13  thorpej 	(*sc->sc_ops->hpib_ppwatch)(sc);
    357   1.1      cgd }
    358   1.1      cgd 
    359   1.6  thorpej int
    360   1.1      cgd hpibswait(unit, slave)
    361  1.14   scottr 	int unit;
    362   1.3  mycroft 	int slave;
    363   1.1      cgd {
    364  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    365  1.14   scottr 	int timo = hpibtimeout;
    366  1.14   scottr 	int mask, (*ppoll) __P((struct hpibbus_softc *));
    367   1.1      cgd 
    368  1.13  thorpej 	ppoll = sc->sc_ops->hpib_ppoll;
    369   1.1      cgd 	mask = 0x80 >> slave;
    370  1.13  thorpej 	while (((*ppoll)(sc) & mask) == 0) {
    371   1.1      cgd 		if (--timo == 0) {
    372  1.13  thorpej 			printf("%s: swait timeout\n", sc->sc_dev.dv_xname);
    373   1.1      cgd 			return(-1);
    374   1.1      cgd 		}
    375  1.13  thorpej 	}
    376   1.1      cgd 	return(0);
    377   1.1      cgd }
    378   1.1      cgd 
    379   1.6  thorpej int
    380   1.1      cgd hpibustart(unit)
    381   1.3  mycroft 	int unit;
    382   1.1      cgd {
    383  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    384   1.1      cgd 
    385  1.13  thorpej 	if (sc->sc_type == HPIBA)
    386  1.13  thorpej 		sc->sc_dq->dq_chan = DMA0;
    387   1.1      cgd 	else
    388  1.13  thorpej 		sc->sc_dq->dq_chan = DMA0 | DMA1;
    389  1.13  thorpej 	if (dmareq(sc->sc_dq))
    390   1.1      cgd 		return(1);
    391   1.1      cgd 	return(0);
    392   1.1      cgd }
    393   1.1      cgd 
    394   1.6  thorpej void
    395  1.13  thorpej hpibstart(arg)
    396  1.13  thorpej 	void *arg;
    397   1.1      cgd {
    398  1.13  thorpej 	struct hpibbus_softc *sc = arg;
    399  1.14   scottr 	struct hpibqueue *hq;
    400  1.13  thorpej 
    401  1.13  thorpej 	hq = sc->sc_queue.tqh_first;
    402  1.13  thorpej 	(*hq->hq_go)(hq->hq_softc);
    403   1.1      cgd }
    404   1.1      cgd 
    405   1.6  thorpej void
    406  1.13  thorpej hpibgo(unit, slave, sec, vbuf, count, rw, timo)
    407  1.13  thorpej 	int unit, slave, sec;
    408  1.13  thorpej 	void *vbuf;
    409  1.13  thorpej 	int count, rw, timo;
    410   1.1      cgd {
    411  1.13  thorpej 	struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
    412   1.6  thorpej 
    413  1.13  thorpej 	(*sc->sc_ops->hpib_go)(sc, slave, sec, vbuf, count, rw, timo);
    414   1.1      cgd }
    415   1.1      cgd 
    416   1.6  thorpej void
    417  1.13  thorpej hpibdone(arg)
    418  1.13  thorpej 	void *arg;
    419   1.1      cgd {
    420  1.13  thorpej 	struct hpibbus_softc *sc = arg;
    421   1.6  thorpej 
    422  1.13  thorpej 	(*sc->sc_ops->hpib_done)(sc);
    423   1.1      cgd }
    424   1.1      cgd 
    425   1.6  thorpej int
    426   1.8  thorpej hpibintr(arg)
    427   1.8  thorpej 	void *arg;
    428   1.1      cgd {
    429  1.13  thorpej 	struct hpibbus_softc *sc = arg;
    430  1.13  thorpej 
    431  1.13  thorpej 	return ((sc->sc_ops->hpib_intr)(arg));
    432  1.13  thorpej }
    433  1.13  thorpej 
    434  1.13  thorpej int
    435  1.13  thorpej hpibbus_alloc(sc, slave, punit)
    436  1.13  thorpej 	struct hpibbus_softc *sc;
    437  1.13  thorpej 	int slave, punit;
    438  1.13  thorpej {
    439  1.13  thorpej 
    440  1.13  thorpej 	if (slave >= HPIB_NSLAVES ||
    441  1.13  thorpej 	    punit >= HPIB_NPUNITS)
    442  1.13  thorpej 		panic("hpibbus_alloc: device address out of range");
    443  1.13  thorpej 
    444  1.13  thorpej 	if (sc->sc_rmap[slave][punit] == 0) {
    445  1.13  thorpej 		sc->sc_rmap[slave][punit] = 1;
    446  1.13  thorpej 		return (0);
    447  1.13  thorpej 	}
    448  1.13  thorpej 	return (1);
    449  1.13  thorpej }
    450  1.13  thorpej 
    451  1.13  thorpej void
    452  1.13  thorpej hpibbus_free(sc, slave, punit)
    453  1.13  thorpej 	struct hpibbus_softc *sc;
    454  1.13  thorpej 	int slave, punit;
    455  1.13  thorpej {
    456  1.13  thorpej 
    457  1.13  thorpej 	if (slave >= HPIB_NSLAVES ||
    458  1.13  thorpej 	    punit >= HPIB_NPUNITS)
    459  1.13  thorpej 		panic("hpibbus_free: device address out of range");
    460  1.13  thorpej 
    461  1.13  thorpej #ifdef DIAGNOSTIC
    462  1.13  thorpej 	if (sc->sc_rmap[slave][punit] == 0)
    463  1.13  thorpej 		panic("hpibbus_free: not allocated");
    464  1.13  thorpej #endif
    465   1.1      cgd 
    466  1.13  thorpej 	sc->sc_rmap[slave][punit] = 0;
    467   1.1      cgd }
    468