Home | History | Annotate | Line # | Download | only in dev
hpib.c revision 1.41.2.4
      1  1.41.2.4   thorpej /*	$NetBSD: hpib.c,v 1.41.2.4 2021/04/04 22:01:16 thorpej Exp $	*/
      2      1.18   thorpej 
      3      1.18   thorpej /*-
      4      1.18   thorpej  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
      5      1.18   thorpej  * All rights reserved.
      6      1.18   thorpej  *
      7      1.18   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8      1.18   thorpej  * by Jason R. Thorpe.
      9      1.18   thorpej  *
     10      1.18   thorpej  * Redistribution and use in source and binary forms, with or without
     11      1.18   thorpej  * modification, are permitted provided that the following conditions
     12      1.18   thorpej  * are met:
     13      1.18   thorpej  * 1. Redistributions of source code must retain the above copyright
     14      1.18   thorpej  *    notice, this list of conditions and the following disclaimer.
     15      1.18   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.18   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17      1.18   thorpej  *    documentation and/or other materials provided with the distribution.
     18      1.18   thorpej  *
     19      1.18   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20      1.18   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21      1.18   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22      1.18   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23      1.18   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24      1.18   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25      1.18   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26      1.18   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27      1.18   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28      1.18   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29      1.18   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     30      1.18   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.25       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  *	@(#)hpib.c	8.2 (Berkeley) 1/12/94
     61       1.1       cgd  */
     62       1.1       cgd 
     63       1.1       cgd /*
     64      1.13   thorpej  * HP-IB bus driver
     65       1.1       cgd  */
     66       1.1       cgd 
     67      1.20  gmcgarry #include <sys/cdefs.h>
     68  1.41.2.4   thorpej __KERNEL_RCSID(0, "$NetBSD: hpib.c,v 1.41.2.4 2021/04/04 22:01:16 thorpej Exp $");
     69      1.20  gmcgarry 
     70       1.3   mycroft #include <sys/param.h>
     71       1.3   mycroft #include <sys/systm.h>
     72       1.3   mycroft #include <sys/buf.h>
     73      1.41   thorpej #include <sys/kmem.h>
     74      1.13   thorpej #include <sys/device.h>
     75      1.13   thorpej 
     76      1.13   thorpej #include <hp300/dev/dmavar.h>
     77       1.3   mycroft 
     78       1.3   mycroft #include <hp300/dev/hpibvar.h>
     79       1.1       cgd 
     80       1.3   mycroft #include <machine/cpu.h>
     81      1.16   thorpej #include <machine/hp300spu.h>
     82       1.1       cgd 
     83      1.28   tsutsui #include "ioconf.h"
     84      1.28   tsutsui 
     85      1.36   tsutsui static int	hpibbusmatch(device_t, cfdata_t, void *);
     86      1.36   tsutsui static void	hpibbusattach(device_t, device_t, void *);
     87      1.13   thorpej 
     88      1.36   tsutsui CFATTACH_DECL_NEW(hpibbus, sizeof(struct hpibbus_softc),
     89      1.23   thorpej     hpibbusmatch, hpibbusattach, NULL, NULL);
     90       1.1       cgd 
     91      1.27   thorpej static void	hpibbus_attach_children(struct hpibbus_softc *);
     92      1.36   tsutsui static int	hpibbussearch(device_t, cfdata_t, const int *, void *);
     93      1.27   thorpej static int	hpibbusprint(void *, const char *);
     94      1.27   thorpej 
     95      1.27   thorpej static int	hpibbus_alloc(struct hpibbus_softc *, int, int);
     96      1.27   thorpej #if 0
     97      1.27   thorpej static void	hpibbus_free(struct hpibbus_softc *, int, int);
     98      1.27   thorpej #endif
     99      1.13   thorpej 
    100      1.27   thorpej static void	hpibstart(void *);
    101      1.27   thorpej static void	hpibdone(void *);
    102       1.1       cgd 
    103       1.1       cgd int	hpibtimeout = 100000;	/* # of status tests before we give up */
    104       1.3   mycroft int	hpibidtimeout = 10000;	/* # of status tests for hpibid() calls */
    105       1.1       cgd int	hpibdmathresh = 3;	/* byte count beyond which to attempt dma */
    106       1.1       cgd 
    107      1.13   thorpej /*
    108      1.13   thorpej  * HP-IB is essentially an IEEE 488 bus, with an HP command
    109      1.13   thorpej  * set (CS/80 on `newer' devices, Amigo on before-you-were-born
    110      1.13   thorpej  * devices) thrown on top.  Devices that respond to CS/80 (and
    111      1.13   thorpej  * probably Amigo, too) are tagged with a 16-bit ID.
    112      1.13   thorpej  *
    113      1.13   thorpej  * HP-IB has a 2-level addressing scheme; slave, the analog
    114      1.13   thorpej  * of a SCSI ID, and punit, the analog of a SCSI LUN.  Unforunately,
    115      1.13   thorpej  * IDs are on a per-slave basis; punits are often used for disk
    116      1.13   thorpej  * drives that have an accompanying tape drive on the second punit.
    117      1.13   thorpej  *
    118      1.13   thorpej  * In addition, not all HP-IB devices speak CS/80 or Amigo.
    119      1.13   thorpej  * Examples of such devices are HP-IB plotters, which simply
    120      1.13   thorpej  * take raw plotter commands over 488.  These devices do not
    121      1.13   thorpej  * have ID tags, and often the host cannot even tell if such
    122      1.13   thorpej  * a device is attached to the system!
    123      1.13   thorpej  *
    124      1.13   thorpej  * These two nasty bits mean that we have to treat HP-IB as
    125      1.13   thorpej  * an indirect bus.  However, since we are given some ID
    126      1.13   thorpej  * information, it is unreasonable to disallow cloning of
    127      1.13   thorpej  * CS/80 devices.
    128      1.13   thorpej  *
    129      1.13   thorpej  * To deal with all of this, we use the semi-twisted scheme
    130      1.13   thorpej  * in hpibbus_attach_children().  For each HP-IB slave, we loop
    131      1.13   thorpej  * through all of the possibly-configured children, allowing
    132      1.13   thorpej  * them to modify the punit parameter (but NOT the slave!).
    133      1.13   thorpej  *
    134      1.13   thorpej  * This is evil, but what can you do?
    135      1.13   thorpej  */
    136      1.13   thorpej 
    137      1.27   thorpej static int
    138      1.36   tsutsui hpibbusmatch(device_t parent, cfdata_t cf, void *aux)
    139       1.1       cgd {
    140       1.7   thorpej 
    141      1.34   tsutsui 	return 1;
    142      1.13   thorpej }
    143      1.13   thorpej 
    144      1.27   thorpej static void
    145      1.36   tsutsui hpibbusattach(device_t parent, device_t self, void *aux)
    146      1.13   thorpej {
    147      1.36   tsutsui 	struct hpibbus_softc *sc = device_private(self);
    148      1.13   thorpej 	struct hpibdev_attach_args *ha = aux;
    149      1.13   thorpej 
    150      1.36   tsutsui 	sc->sc_dev = self;
    151      1.36   tsutsui 	aprint_normal("\n");
    152      1.13   thorpej 
    153      1.13   thorpej 	/* Get the operations vector for the controller. */
    154      1.13   thorpej 	sc->sc_ops = ha->ha_ops;
    155      1.13   thorpej 	sc->sc_type = ha->ha_type;		/* XXX */
    156      1.13   thorpej 	sc->sc_ba = ha->ha_ba;
    157      1.13   thorpej 	*(ha->ha_softcpp) = sc;			/* XXX */
    158      1.13   thorpej 
    159      1.33   thorpej 	hpibreset(device_unit(self));		/* XXX souldn't be here */
    160      1.13   thorpej 
    161      1.13   thorpej 	/*
    162      1.13   thorpej 	 * Initialize the DMA queue entry.
    163      1.13   thorpej 	 */
    164      1.41   thorpej 	sc->sc_dq = kmem_alloc(sizeof(struct dmaqueue), KM_SLEEP);
    165      1.13   thorpej 	sc->sc_dq->dq_softc = sc;
    166      1.13   thorpej 	sc->sc_dq->dq_start = hpibstart;
    167      1.13   thorpej 	sc->sc_dq->dq_done = hpibdone;
    168       1.7   thorpej 
    169      1.13   thorpej 	/* Initialize the slave request queue. */
    170      1.13   thorpej 	TAILQ_INIT(&sc->sc_queue);
    171      1.13   thorpej 
    172      1.13   thorpej 	/* Attach any devices on the bus. */
    173      1.13   thorpej 	hpibbus_attach_children(sc);
    174       1.7   thorpej }
    175       1.7   thorpej 
    176      1.27   thorpej static void
    177      1.27   thorpej hpibbus_attach_children(struct hpibbus_softc *sc)
    178       1.7   thorpej {
    179      1.13   thorpej 	struct hpibbus_attach_args ha;
    180      1.13   thorpej 	int slave;
    181       1.7   thorpej 
    182      1.13   thorpej 	for (slave = 0; slave < 8; slave++) {
    183      1.13   thorpej 		/*
    184      1.13   thorpej 		 * Get the ID tag for the device, if any.
    185      1.13   thorpej 		 * Plotters won't identify themselves, and
    186      1.13   thorpej 		 * get the same value as non-existent devices.
    187      1.13   thorpej 		 */
    188      1.36   tsutsui 		ha.ha_id = hpibid(device_unit(sc->sc_dev), slave);
    189      1.13   thorpej 
    190      1.13   thorpej 		ha.ha_slave = slave;	/* not to be modified by children */
    191      1.13   thorpej 		ha.ha_punit = 0;	/* children modify this */
    192      1.13   thorpej 
    193      1.13   thorpej 		/*
    194      1.13   thorpej 		 * Search though all configured children for this bus.
    195      1.13   thorpej 		 */
    196  1.41.2.1   thorpej 		config_search(sc->sc_dev, &ha,
    197  1.41.2.4   thorpej 		    CFARG_SEARCH, hpibbussearch,
    198  1.41.2.1   thorpej 		    CFARG_EOL);
    199      1.13   thorpej 	}
    200      1.13   thorpej }
    201      1.13   thorpej 
    202      1.27   thorpej static int
    203      1.36   tsutsui hpibbussearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    204      1.13   thorpej {
    205      1.36   tsutsui 	struct hpibbus_softc *sc = device_private(parent);
    206      1.13   thorpej 	struct hpibbus_attach_args *ha = aux;
    207      1.13   thorpej 
    208      1.13   thorpej 	/* Make sure this is in a consistent state. */
    209      1.13   thorpej 	ha->ha_punit = 0;
    210      1.13   thorpej 
    211      1.21   thorpej 	if (config_match(parent, cf, ha) > 0) {
    212      1.13   thorpej 		/*
    213      1.13   thorpej 		 * The device probe has succeeded, and filled in
    214      1.13   thorpej 		 * the punit information.  Make sure the configuration
    215      1.13   thorpej 		 * allows for this slave/punit combination.
    216      1.13   thorpej 		 */
    217      1.17       jtk 		if (cf->hpibbuscf_slave != HPIBBUSCF_SLAVE_DEFAULT &&
    218      1.13   thorpej 		    cf->hpibbuscf_slave != ha->ha_slave)
    219      1.13   thorpej 			goto out;
    220      1.17       jtk 		if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
    221      1.13   thorpej 		    cf->hpibbuscf_punit != ha->ha_punit)
    222      1.13   thorpej 			goto out;
    223      1.13   thorpej 
    224      1.13   thorpej 		/*
    225      1.13   thorpej 		 * Allocate the device's address from the bus's
    226      1.13   thorpej 		 * resource map.
    227      1.13   thorpej 		 */
    228      1.13   thorpej 		if (hpibbus_alloc(sc, ha->ha_slave, ha->ha_punit))
    229      1.13   thorpej 			goto out;
    230      1.13   thorpej 
    231      1.13   thorpej 		/*
    232      1.13   thorpej 		 * This device is allowed; attach it.
    233      1.13   thorpej 		 */
    234  1.41.2.3   thorpej 		config_attach(parent, cf, ha, hpibbusprint, CFARG_EOL);
    235       1.7   thorpej 	}
    236      1.13   thorpej  out:
    237      1.34   tsutsui 	return 0;
    238      1.13   thorpej }
    239      1.13   thorpej 
    240      1.27   thorpej static int
    241      1.27   thorpej hpibbusprint(void *aux, const char *pnp)
    242      1.13   thorpej {
    243      1.13   thorpej 	struct hpibbus_attach_args *ha = aux;
    244       1.6   thorpej 
    245      1.24   thorpej 	aprint_normal(" slave %d punit %d", ha->ha_slave, ha->ha_punit);
    246      1.34   tsutsui 	return UNCONF;
    247      1.13   thorpej }
    248      1.13   thorpej 
    249      1.13   thorpej int
    250      1.27   thorpej hpibdevprint(void *aux, const char *pnp)
    251      1.13   thorpej {
    252      1.13   thorpej 
    253      1.13   thorpej 	/* only hpibbus's can attach to hpibdev's -- easy. */
    254      1.13   thorpej 	if (pnp != NULL)
    255      1.24   thorpej 		aprint_normal("hpibbus at %s", pnp);
    256      1.34   tsutsui 	return UNCONF;
    257       1.1       cgd }
    258       1.1       cgd 
    259       1.6   thorpej void
    260      1.27   thorpej hpibreset(int unit)
    261       1.1       cgd {
    262      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    263       1.6   thorpej 
    264      1.13   thorpej 	(*sc->sc_ops->hpib_reset)(sc);
    265       1.1       cgd }
    266       1.1       cgd 
    267       1.6   thorpej int
    268      1.39   tsutsui hpibreq(device_t pdev, struct hpibqueue *hq)
    269      1.13   thorpej {
    270      1.36   tsutsui 	struct hpibbus_softc *sc = device_private(pdev);
    271      1.13   thorpej 	int s;
    272      1.13   thorpej 
    273      1.13   thorpej 	s = splhigh();	/* XXXthorpej */
    274      1.13   thorpej 	TAILQ_INSERT_TAIL(&sc->sc_queue, hq, hq_list);
    275      1.13   thorpej 	splx(s);
    276      1.13   thorpej 
    277      1.35   tsutsui 	if (TAILQ_FIRST(&sc->sc_queue) == hq)
    278      1.34   tsutsui 		return 1;
    279       1.1       cgd 
    280      1.34   tsutsui 	return 0;
    281       1.1       cgd }
    282       1.1       cgd 
    283       1.6   thorpej void
    284      1.39   tsutsui hpibfree(device_t pdev, struct hpibqueue *hq)
    285      1.13   thorpej {
    286      1.36   tsutsui 	struct hpibbus_softc *sc = device_private(pdev);
    287      1.13   thorpej 	int s;
    288      1.13   thorpej 
    289      1.13   thorpej 	s = splhigh();	/* XXXthorpej */
    290      1.13   thorpej 	TAILQ_REMOVE(&sc->sc_queue, hq, hq_list);
    291      1.13   thorpej 	splx(s);
    292       1.1       cgd 
    293      1.35   tsutsui 	if ((hq = TAILQ_FIRST(&sc->sc_queue)) != NULL)
    294      1.13   thorpej 		(*hq->hq_start)(hq->hq_softc);
    295       1.1       cgd }
    296       1.1       cgd 
    297       1.6   thorpej int
    298      1.27   thorpej hpibid(int unit, int slave)
    299       1.1       cgd {
    300       1.1       cgd 	short id;
    301       1.1       cgd 	int ohpibtimeout;
    302       1.1       cgd 
    303       1.1       cgd 	/*
    304       1.3   mycroft 	 * XXX shorten timeout value so autoconfig doesn't
    305       1.3   mycroft 	 * take forever on slow CPUs.
    306       1.1       cgd 	 */
    307       1.1       cgd 	ohpibtimeout = hpibtimeout;
    308       1.9   thorpej 	hpibtimeout = hpibidtimeout * (cpuspeed / 8);
    309       1.1       cgd 	if (hpibrecv(unit, 31, slave, &id, 2) != 2)
    310       1.1       cgd 		id = 0;
    311       1.1       cgd 	hpibtimeout = ohpibtimeout;
    312      1.34   tsutsui 	return id;
    313       1.1       cgd }
    314       1.1       cgd 
    315       1.6   thorpej int
    316      1.27   thorpej hpibsend(int unit, int slave, int sec, void *addr, int cnt)
    317       1.1       cgd {
    318      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    319       1.6   thorpej 
    320      1.34   tsutsui 	return (*sc->sc_ops->hpib_send)(sc, slave, sec, addr, cnt);
    321       1.1       cgd }
    322       1.1       cgd 
    323       1.6   thorpej int
    324      1.27   thorpej hpibrecv(int unit, int slave, int sec, void *addr, int cnt)
    325       1.1       cgd {
    326      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    327       1.6   thorpej 
    328      1.34   tsutsui 	return (*sc->sc_ops->hpib_recv)(sc, slave, sec, addr, cnt);
    329       1.1       cgd }
    330       1.1       cgd 
    331       1.6   thorpej int
    332      1.27   thorpej hpibpptest(int unit, int slave)
    333       1.1       cgd {
    334      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    335       1.1       cgd 
    336      1.34   tsutsui 	return (*sc->sc_ops->hpib_ppoll)(sc) & (0x80 >> slave);
    337       1.1       cgd }
    338       1.1       cgd 
    339       1.6   thorpej void
    340      1.27   thorpej hpibppclear(int unit)
    341       1.5   mycroft {
    342      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    343      1.13   thorpej 
    344      1.13   thorpej 	sc->sc_flags &= ~HPIBF_PPOLL;
    345       1.5   mycroft }
    346       1.5   mycroft 
    347      1.14    scottr void
    348      1.27   thorpej hpibawait(int unit)
    349       1.1       cgd {
    350      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd, unit);
    351       1.1       cgd 
    352      1.13   thorpej 	sc->sc_flags |= HPIBF_PPOLL;
    353      1.13   thorpej 	(*sc->sc_ops->hpib_ppwatch)(sc);
    354       1.1       cgd }
    355       1.1       cgd 
    356       1.6   thorpej int
    357      1.27   thorpej hpibswait(int unit, int slave)
    358       1.1       cgd {
    359      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd, unit);
    360      1.14    scottr 	int timo = hpibtimeout;
    361      1.27   thorpej 	int mask, (*ppoll)(struct hpibbus_softc *);
    362       1.1       cgd 
    363      1.13   thorpej 	ppoll = sc->sc_ops->hpib_ppoll;
    364       1.1       cgd 	mask = 0x80 >> slave;
    365      1.13   thorpej 	while (((*ppoll)(sc) & mask) == 0) {
    366       1.1       cgd 		if (--timo == 0) {
    367      1.36   tsutsui 			printf("%s: swait timeout\n", device_xname(sc->sc_dev));
    368      1.34   tsutsui 			return -1;
    369       1.1       cgd 		}
    370      1.13   thorpej 	}
    371      1.34   tsutsui 	return 0;
    372       1.1       cgd }
    373       1.1       cgd 
    374       1.6   thorpej int
    375      1.27   thorpej hpibustart(int unit)
    376       1.1       cgd {
    377      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    378       1.1       cgd 
    379      1.13   thorpej 	if (sc->sc_type == HPIBA)
    380      1.13   thorpej 		sc->sc_dq->dq_chan = DMA0;
    381       1.1       cgd 	else
    382      1.13   thorpej 		sc->sc_dq->dq_chan = DMA0 | DMA1;
    383      1.13   thorpej 	if (dmareq(sc->sc_dq))
    384      1.34   tsutsui 		return 1;
    385      1.34   tsutsui 	return 0;
    386       1.1       cgd }
    387       1.1       cgd 
    388      1.27   thorpej static void
    389      1.27   thorpej hpibstart(void *arg)
    390       1.1       cgd {
    391      1.13   thorpej 	struct hpibbus_softc *sc = arg;
    392      1.14    scottr 	struct hpibqueue *hq;
    393      1.13   thorpej 
    394      1.35   tsutsui 	hq = TAILQ_FIRST(&sc->sc_queue);
    395      1.13   thorpej 	(*hq->hq_go)(hq->hq_softc);
    396       1.1       cgd }
    397       1.1       cgd 
    398       1.6   thorpej void
    399      1.27   thorpej hpibgo(int unit, int slave, int sec, void *vbuf, int count, int rw, int timo)
    400       1.1       cgd {
    401      1.38    cegger 	struct hpibbus_softc *sc = device_lookup_private(&hpibbus_cd,unit);
    402       1.6   thorpej 
    403      1.13   thorpej 	(*sc->sc_ops->hpib_go)(sc, slave, sec, vbuf, count, rw, timo);
    404       1.1       cgd }
    405       1.1       cgd 
    406      1.27   thorpej static void
    407      1.27   thorpej hpibdone(void *arg)
    408       1.1       cgd {
    409      1.13   thorpej 	struct hpibbus_softc *sc = arg;
    410       1.6   thorpej 
    411      1.13   thorpej 	(*sc->sc_ops->hpib_done)(sc);
    412       1.1       cgd }
    413       1.1       cgd 
    414       1.6   thorpej int
    415      1.27   thorpej hpibintr(void *arg)
    416       1.1       cgd {
    417      1.13   thorpej 	struct hpibbus_softc *sc = arg;
    418      1.13   thorpej 
    419      1.34   tsutsui 	return (sc->sc_ops->hpib_intr)(arg);
    420      1.13   thorpej }
    421      1.13   thorpej 
    422      1.27   thorpej static int
    423      1.27   thorpej hpibbus_alloc(struct hpibbus_softc *sc, int slave, int punit)
    424      1.13   thorpej {
    425      1.13   thorpej 
    426      1.13   thorpej 	if (slave >= HPIB_NSLAVES ||
    427      1.13   thorpej 	    punit >= HPIB_NPUNITS)
    428      1.13   thorpej 		panic("hpibbus_alloc: device address out of range");
    429      1.13   thorpej 
    430      1.13   thorpej 	if (sc->sc_rmap[slave][punit] == 0) {
    431      1.13   thorpej 		sc->sc_rmap[slave][punit] = 1;
    432      1.34   tsutsui 		return 0;
    433      1.13   thorpej 	}
    434      1.34   tsutsui 	return 1;
    435      1.13   thorpej }
    436      1.13   thorpej 
    437      1.27   thorpej #if 0
    438      1.27   thorpej static void
    439      1.27   thorpej hpibbus_free(struct hpibbus_softc *sc, int slave, int punit)
    440      1.13   thorpej {
    441      1.13   thorpej 
    442      1.13   thorpej 	if (slave >= HPIB_NSLAVES ||
    443      1.13   thorpej 	    punit >= HPIB_NPUNITS)
    444      1.13   thorpej 		panic("hpibbus_free: device address out of range");
    445      1.13   thorpej 
    446      1.13   thorpej #ifdef DIAGNOSTIC
    447      1.13   thorpej 	if (sc->sc_rmap[slave][punit] == 0)
    448      1.13   thorpej 		panic("hpibbus_free: not allocated");
    449      1.13   thorpej #endif
    450       1.1       cgd 
    451      1.13   thorpej 	sc->sc_rmap[slave][punit] = 0;
    452       1.1       cgd }
    453      1.27   thorpej #endif
    454