1998-01-12 21:30:41 +03:00
|
|
|
/* $NetBSD: hpib.c,v 1.19 1998/01/12 18:31:00 thorpej Exp $ */
|
1997-10-04 13:59:35 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jason R. Thorpe.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1994-10-26 10:22:45 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1994-05-23 09:58:16 +04:00
|
|
|
* Copyright (c) 1982, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-05-13 17:56:20 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1994-10-26 10:22:45 +03:00
|
|
|
* @(#)hpib.c 8.2 (Berkeley) 1/12/94
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1997-01-30 12:06:51 +03:00
|
|
|
* HP-IB bus driver
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/buf.h>
|
1997-01-30 12:06:51 +03:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <hp300/dev/dmavar.h>
|
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
#include <hp300/dev/hpibvar.h>
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <machine/cpu.h>
|
1997-04-28 00:58:55 +04:00
|
|
|
#include <machine/hp300spu.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
int hpibbusmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
void hpibbusattach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach hpibbus_ca = {
|
|
|
|
sizeof(struct hpibbus_softc), hpibbusmatch, hpibbusattach
|
1993-05-13 17:56:20 +04:00
|
|
|
};
|
|
|
|
|
1998-01-12 21:30:41 +03:00
|
|
|
extern struct cfdriver hpibbus_cd;
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
void hpibbus_attach_children __P((struct hpibbus_softc *));
|
|
|
|
int hpibbussearch __P((struct device *, struct cfdata *, void *));
|
|
|
|
int hpibbusprint __P((void *, const char *));
|
|
|
|
|
|
|
|
int hpibbus_alloc __P((struct hpibbus_softc *, int, int));
|
|
|
|
void hpibbus_free __P((struct hpibbus_softc *, int, int));
|
|
|
|
|
|
|
|
void hpibstart __P((void *));
|
|
|
|
void hpibdone __P((void *));
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
int hpibtimeout = 100000; /* # of status tests before we give up */
|
1994-05-23 09:58:16 +04:00
|
|
|
int hpibidtimeout = 10000; /* # of status tests for hpibid() calls */
|
1993-05-13 17:56:20 +04:00
|
|
|
int hpibdmathresh = 3; /* byte count beyond which to attempt dma */
|
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
/*
|
|
|
|
* HP-IB is essentially an IEEE 488 bus, with an HP command
|
|
|
|
* set (CS/80 on `newer' devices, Amigo on before-you-were-born
|
|
|
|
* devices) thrown on top. Devices that respond to CS/80 (and
|
|
|
|
* probably Amigo, too) are tagged with a 16-bit ID.
|
|
|
|
*
|
|
|
|
* HP-IB has a 2-level addressing scheme; slave, the analog
|
|
|
|
* of a SCSI ID, and punit, the analog of a SCSI LUN. Unforunately,
|
|
|
|
* IDs are on a per-slave basis; punits are often used for disk
|
|
|
|
* drives that have an accompanying tape drive on the second punit.
|
|
|
|
*
|
|
|
|
* In addition, not all HP-IB devices speak CS/80 or Amigo.
|
|
|
|
* Examples of such devices are HP-IB plotters, which simply
|
|
|
|
* take raw plotter commands over 488. These devices do not
|
|
|
|
* have ID tags, and often the host cannot even tell if such
|
|
|
|
* a device is attached to the system!
|
|
|
|
*
|
|
|
|
* These two nasty bits mean that we have to treat HP-IB as
|
|
|
|
* an indirect bus. However, since we are given some ID
|
|
|
|
* information, it is unreasonable to disallow cloning of
|
|
|
|
* CS/80 devices.
|
|
|
|
*
|
|
|
|
* To deal with all of this, we use the semi-twisted scheme
|
|
|
|
* in hpibbus_attach_children(). For each HP-IB slave, we loop
|
|
|
|
* through all of the possibly-configured children, allowing
|
|
|
|
* them to modify the punit parameter (but NOT the slave!).
|
|
|
|
*
|
|
|
|
* This is evil, but what can you do?
|
|
|
|
*/
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibbusmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1995-12-02 21:21:49 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
return (1);
|
1995-12-02 21:21:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibbusattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1995-12-02 21:21:49 +03:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = (struct hpibbus_softc *)self;
|
|
|
|
struct hpibdev_attach_args *ha = aux;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
/* Get the operations vector for the controller. */
|
|
|
|
sc->sc_ops = ha->ha_ops;
|
|
|
|
sc->sc_type = ha->ha_type; /* XXX */
|
|
|
|
sc->sc_ba = ha->ha_ba;
|
|
|
|
*(ha->ha_softcpp) = sc; /* XXX */
|
|
|
|
|
|
|
|
hpibreset(self->dv_unit); /* XXX souldn't be here */
|
1995-12-02 21:21:49 +03:00
|
|
|
|
|
|
|
/*
|
1997-01-30 12:06:51 +03:00
|
|
|
* Initialize the DMA queue entry.
|
1995-12-02 21:21:49 +03:00
|
|
|
*/
|
1997-01-30 12:06:51 +03:00
|
|
|
sc->sc_dq = (struct dmaqueue *)malloc(sizeof(struct dmaqueue),
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
if (sc->sc_dq == NULL) {
|
|
|
|
printf("%s: can't allocate DMA queue entry\n", self->dv_xname);
|
|
|
|
return;
|
1995-12-02 21:21:49 +03:00
|
|
|
}
|
1997-01-30 12:06:51 +03:00
|
|
|
sc->sc_dq->dq_softc = sc;
|
|
|
|
sc->sc_dq->dq_start = hpibstart;
|
|
|
|
sc->sc_dq->dq_done = hpibdone;
|
|
|
|
|
|
|
|
/* Initialize the slave request queue. */
|
|
|
|
TAILQ_INIT(&sc->sc_queue);
|
|
|
|
|
|
|
|
/* Attach any devices on the bus. */
|
|
|
|
hpibbus_attach_children(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
hpibbus_attach_children(sc)
|
|
|
|
struct hpibbus_softc *sc;
|
|
|
|
{
|
|
|
|
struct hpibbus_attach_args ha;
|
|
|
|
int slave;
|
|
|
|
|
|
|
|
for (slave = 0; slave < 8; slave++) {
|
|
|
|
/*
|
|
|
|
* Get the ID tag for the device, if any.
|
|
|
|
* Plotters won't identify themselves, and
|
|
|
|
* get the same value as non-existent devices.
|
|
|
|
*/
|
|
|
|
ha.ha_id = hpibid(sc->sc_dev.dv_unit, slave);
|
|
|
|
|
|
|
|
ha.ha_slave = slave; /* not to be modified by children */
|
|
|
|
ha.ha_punit = 0; /* children modify this */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Search though all configured children for this bus.
|
|
|
|
*/
|
|
|
|
(void)config_search(hpibbussearch, &sc->sc_dev, &ha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
hpibbussearch(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct hpibbus_softc *sc = (struct hpibbus_softc *)parent;
|
|
|
|
struct hpibbus_attach_args *ha = aux;
|
|
|
|
|
|
|
|
/* Make sure this is in a consistent state. */
|
|
|
|
ha->ha_punit = 0;
|
|
|
|
|
|
|
|
if ((*cf->cf_attach->ca_match)(parent, cf, ha) > 0) {
|
|
|
|
/*
|
|
|
|
* The device probe has succeeded, and filled in
|
|
|
|
* the punit information. Make sure the configuration
|
|
|
|
* allows for this slave/punit combination.
|
|
|
|
*/
|
1997-07-18 07:38:33 +04:00
|
|
|
if (cf->hpibbuscf_slave != HPIBBUSCF_SLAVE_DEFAULT &&
|
1997-01-30 12:06:51 +03:00
|
|
|
cf->hpibbuscf_slave != ha->ha_slave)
|
|
|
|
goto out;
|
1997-07-18 07:38:33 +04:00
|
|
|
if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
|
1997-01-30 12:06:51 +03:00
|
|
|
cf->hpibbuscf_punit != ha->ha_punit)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate the device's address from the bus's
|
|
|
|
* resource map.
|
|
|
|
*/
|
|
|
|
if (hpibbus_alloc(sc, ha->ha_slave, ha->ha_punit))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This device is allowed; attach it.
|
|
|
|
*/
|
|
|
|
config_attach(parent, cf, ha, hpibbusprint);
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return (0);
|
|
|
|
}
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
int
|
|
|
|
hpibbusprint(aux, pnp)
|
|
|
|
void *aux;
|
|
|
|
const char *pnp;
|
|
|
|
{
|
|
|
|
struct hpibbus_attach_args *ha = aux;
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
printf(" slave %d punit %d", ha->ha_slave, ha->ha_punit);
|
|
|
|
return (UNCONF);
|
|
|
|
}
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
int
|
|
|
|
hpibdevprint(aux, pnp)
|
|
|
|
void *aux;
|
|
|
|
const char *pnp;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* only hpibbus's can attach to hpibdev's -- easy. */
|
|
|
|
if (pnp != NULL)
|
|
|
|
printf("hpibbus at %s", pnp);
|
|
|
|
return (UNCONF);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibreset(unit)
|
1997-03-31 11:32:14 +04:00
|
|
|
int unit;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
(*sc->sc_ops->hpib_reset)(sc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibreq(pdev, hq)
|
|
|
|
struct device *pdev;
|
|
|
|
struct hpibqueue *hq;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = (struct hpibbus_softc *)pdev;
|
|
|
|
int s;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
s = splhigh(); /* XXXthorpej */
|
|
|
|
TAILQ_INSERT_TAIL(&sc->sc_queue, hq, hq_list);
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
if (sc->sc_queue.tqh_first == hq)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibfree(pdev, hq)
|
|
|
|
struct device *pdev;
|
|
|
|
struct hpibqueue *hq;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = (struct hpibbus_softc *)pdev;
|
|
|
|
int s;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
s = splhigh(); /* XXXthorpej */
|
|
|
|
TAILQ_REMOVE(&sc->sc_queue, hq, hq_list);
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
if ((hq = sc->sc_queue.tqh_first) != NULL)
|
|
|
|
(*hq->hq_start)(hq->hq_softc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibid(unit, slave)
|
1994-05-23 09:58:16 +04:00
|
|
|
int unit, slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
short id;
|
|
|
|
int ohpibtimeout;
|
|
|
|
|
|
|
|
/*
|
1994-05-23 09:58:16 +04:00
|
|
|
* XXX shorten timeout value so autoconfig doesn't
|
|
|
|
* take forever on slow CPUs.
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
ohpibtimeout = hpibtimeout;
|
1996-05-17 19:09:39 +04:00
|
|
|
hpibtimeout = hpibidtimeout * (cpuspeed / 8);
|
1993-05-13 17:56:20 +04:00
|
|
|
if (hpibrecv(unit, 31, slave, &id, 2) != 2)
|
|
|
|
id = 0;
|
|
|
|
hpibtimeout = ohpibtimeout;
|
|
|
|
return(id);
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibsend(unit, slave, sec, addr, cnt)
|
1995-11-19 20:57:15 +03:00
|
|
|
int unit, slave, sec, cnt;
|
|
|
|
void *addr;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
return ((*sc->sc_ops->hpib_send)(sc, slave, sec, addr, cnt));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibrecv(unit, slave, sec, addr, cnt)
|
1995-11-19 20:57:15 +03:00
|
|
|
int unit, slave, sec, cnt;
|
|
|
|
void *addr;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
return ((*sc->sc_ops->hpib_recv)(sc, slave, sec, addr, cnt));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibpptest(unit, slave)
|
1997-03-31 11:32:14 +04:00
|
|
|
int unit;
|
1994-05-23 09:58:16 +04:00
|
|
|
int slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
return ((*sc->sc_ops->hpib_ppoll)(sc) & (0x80 >> slave));
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1995-01-07 13:30:10 +03:00
|
|
|
hpibppclear(unit)
|
|
|
|
int unit;
|
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
|
|
|
|
|
|
|
sc->sc_flags &= ~HPIBF_PPOLL;
|
1995-01-07 13:30:10 +03:00
|
|
|
}
|
|
|
|
|
1997-03-31 11:32:14 +04:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibawait(unit)
|
1994-05-23 09:58:16 +04:00
|
|
|
int unit;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
sc->sc_flags |= HPIBF_PPOLL;
|
|
|
|
(*sc->sc_ops->hpib_ppwatch)(sc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibswait(unit, slave)
|
1997-03-31 11:32:14 +04:00
|
|
|
int unit;
|
1994-05-23 09:58:16 +04:00
|
|
|
int slave;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1997-03-31 11:32:14 +04:00
|
|
|
int timo = hpibtimeout;
|
|
|
|
int mask, (*ppoll) __P((struct hpibbus_softc *));
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
ppoll = sc->sc_ops->hpib_ppoll;
|
1993-05-13 17:56:20 +04:00
|
|
|
mask = 0x80 >> slave;
|
1997-01-30 12:06:51 +03:00
|
|
|
while (((*ppoll)(sc) & mask) == 0) {
|
1993-05-13 17:56:20 +04:00
|
|
|
if (--timo == 0) {
|
1997-01-30 12:06:51 +03:00
|
|
|
printf("%s: swait timeout\n", sc->sc_dev.dv_xname);
|
1993-05-13 17:56:20 +04:00
|
|
|
return(-1);
|
|
|
|
}
|
1997-01-30 12:06:51 +03:00
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
hpibustart(unit)
|
1994-05-23 09:58:16 +04:00
|
|
|
int unit;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
if (sc->sc_type == HPIBA)
|
|
|
|
sc->sc_dq->dq_chan = DMA0;
|
1993-05-13 17:56:20 +04:00
|
|
|
else
|
1997-01-30 12:06:51 +03:00
|
|
|
sc->sc_dq->dq_chan = DMA0 | DMA1;
|
|
|
|
if (dmareq(sc->sc_dq))
|
1993-05-13 17:56:20 +04:00
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibstart(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = arg;
|
1997-03-31 11:32:14 +04:00
|
|
|
struct hpibqueue *hq;
|
1997-01-30 12:06:51 +03:00
|
|
|
|
|
|
|
hq = sc->sc_queue.tqh_first;
|
|
|
|
(*hq->hq_go)(hq->hq_softc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibgo(unit, slave, sec, vbuf, count, rw, timo)
|
|
|
|
int unit, slave, sec;
|
|
|
|
void *vbuf;
|
|
|
|
int count, rw, timo;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
(*sc->sc_ops->hpib_go)(sc, slave, sec, vbuf, count, rw, timo);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
hpibdone(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = arg;
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
(*sc->sc_ops->hpib_done)(sc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1996-02-14 05:43:54 +03:00
|
|
|
hpibintr(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *sc = arg;
|
|
|
|
|
|
|
|
return ((sc->sc_ops->hpib_intr)(arg));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
hpibbus_alloc(sc, slave, punit)
|
|
|
|
struct hpibbus_softc *sc;
|
|
|
|
int slave, punit;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (slave >= HPIB_NSLAVES ||
|
|
|
|
punit >= HPIB_NPUNITS)
|
|
|
|
panic("hpibbus_alloc: device address out of range");
|
|
|
|
|
|
|
|
if (sc->sc_rmap[slave][punit] == 0) {
|
|
|
|
sc->sc_rmap[slave][punit] = 1;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
hpibbus_free(sc, slave, punit)
|
|
|
|
struct hpibbus_softc *sc;
|
|
|
|
int slave, punit;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (slave >= HPIB_NSLAVES ||
|
|
|
|
punit >= HPIB_NPUNITS)
|
|
|
|
panic("hpibbus_free: device address out of range");
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (sc->sc_rmap[slave][punit] == 0)
|
|
|
|
panic("hpibbus_free: not allocated");
|
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
sc->sc_rmap[slave][punit] = 0;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|