1997-01-30 12:06:51 +03:00
|
|
|
/* $NetBSD: nhpib.c,v 1.14 1997/01/30 09:06:54 thorpej Exp $ */
|
1994-10-26 10:22:45 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
/*
|
1997-01-30 12:06:51 +03:00
|
|
|
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
|
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
|
|
|
* @(#)nhpib.c 8.2 (Berkeley) 1/12/94
|
1993-05-13 17:56:20 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal/98624 HPIB driver
|
|
|
|
*/
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1995-01-07 13:30:10 +03:00
|
|
|
#include <sys/kernel.h>
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <sys/buf.h>
|
1997-01-30 12:06:51 +03:00
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
|
|
|
|
|
|
|
#include <hp300/hp300/isr.h>
|
|
|
|
|
|
|
|
#include <hp300/dev/dioreg.h>
|
|
|
|
#include <hp300/dev/diovar.h>
|
|
|
|
#include <hp300/dev/diodevs.h>
|
|
|
|
|
|
|
|
#include <hp300/dev/dmavar.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
#include <hp300/dev/nhpibreg.h>
|
|
|
|
#include <hp300/dev/hpibvar.h>
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-01-07 13:30:10 +03:00
|
|
|
/*
|
|
|
|
* ODD parity table for listen and talk addresses and secondary commands.
|
|
|
|
* The TI9914A doesn't produce the parity bit.
|
|
|
|
*/
|
|
|
|
static u_char listnr_par[] = {
|
|
|
|
0040,0241,0242,0043,0244,0045,0046,0247,
|
|
|
|
0250,0051,0052,0253,0054,0255,0256,0057,
|
|
|
|
0260,0061,0062,0263,0064,0265,0266,0067,
|
|
|
|
0070,0271,0272,0073,0274,0075,0076,0277,
|
|
|
|
};
|
|
|
|
static u_char talker_par[] = {
|
|
|
|
0100,0301,0302,0103,0304,0105,0106,0307,
|
|
|
|
0310,0111,0112,0313,0114,0315,0316,0117,
|
|
|
|
0320,0121,0122,0323,0124,0325,0326,0127,
|
|
|
|
0130,0331,0332,0133,0334,0135,0136,0337,
|
|
|
|
};
|
|
|
|
static u_char sec_par[] = {
|
|
|
|
0340,0141,0142,0343,0144,0345,0346,0147,
|
|
|
|
0150,0351,0352,0153,0354,0155,0156,0357,
|
|
|
|
0160,0361,0362,0163,0364,0165,0166,0367,
|
|
|
|
0370,0171,0172,0373,0174,0375,0376,0177
|
|
|
|
};
|
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
void nhpibifc __P((struct nhpibdevice *));
|
|
|
|
void nhpibreadtimo __P((void *));
|
|
|
|
int nhpibwait __P((struct nhpibdevice *, int));
|
|
|
|
|
|
|
|
void nhpibreset __P((struct hpibbus_softc *));
|
|
|
|
int nhpibsend __P((struct hpibbus_softc *, int, int, void *, int));
|
|
|
|
int nhpibrecv __P((struct hpibbus_softc *, int, int, void *, int));
|
|
|
|
int nhpibppoll __P((struct hpibbus_softc *));
|
1995-11-19 20:57:15 +03:00
|
|
|
void nhpibppwatch __P((void *));
|
1997-01-30 12:06:51 +03:00
|
|
|
void nhpibgo __P((struct hpibbus_softc *, int, int, void *, int, int, int));
|
|
|
|
void nhpibdone __P((struct hpibbus_softc *));
|
1996-02-14 05:43:54 +03:00
|
|
|
int nhpibintr __P((void *));
|
1995-11-19 20:57:15 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Our controller ops structure.
|
|
|
|
*/
|
|
|
|
struct hpib_controller nhpib_controller = {
|
|
|
|
nhpibreset,
|
|
|
|
nhpibsend,
|
|
|
|
nhpibrecv,
|
|
|
|
nhpibppoll,
|
|
|
|
nhpibppwatch,
|
|
|
|
nhpibgo,
|
|
|
|
nhpibdone,
|
|
|
|
nhpibintr
|
|
|
|
};
|
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc {
|
|
|
|
struct device sc_dev; /* generic device glue */
|
|
|
|
struct nhpibdevice *sc_regs; /* device registers */
|
|
|
|
struct hpibbus_softc *sc_hpibbus; /* XXX */
|
|
|
|
};
|
|
|
|
|
|
|
|
int nhpibmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
void nhpibattach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach nhpib_ca = {
|
|
|
|
sizeof(struct nhpib_softc), nhpibmatch, nhpibattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver nhpib_cd = {
|
|
|
|
NULL, "nhpib", DV_DULL
|
|
|
|
};
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct dio_attach_args *da = aux;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
/*
|
|
|
|
* Internal HP-IB doesn't always return a device ID,
|
|
|
|
* so we rely on the sysflags.
|
|
|
|
*/
|
|
|
|
if (da->da_scode == 7 && internalhpib)
|
1995-12-02 21:21:49 +03:00
|
|
|
return (1);
|
1997-01-30 12:06:51 +03:00
|
|
|
|
|
|
|
if (da->da_id == DIO_DEVICE_ID_NHPIB)
|
1995-12-02 21:21:49 +03:00
|
|
|
return (1);
|
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
return (0);
|
1995-12-02 21:21:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibattach(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 nhpib_softc *sc = (struct nhpib_softc *)self;
|
|
|
|
struct dio_attach_args *da = aux;
|
|
|
|
struct hpibdev_attach_args ha;
|
|
|
|
const char *desc;
|
|
|
|
int ipl, type = HPIBA;
|
|
|
|
|
|
|
|
sc->sc_regs = (struct nhpibdevice *)iomap(dio_scodetopa(da->da_scode),
|
|
|
|
da->da_size);
|
|
|
|
if (sc->sc_regs == NULL) {
|
|
|
|
printf("\n%s: can't map registers\n", self->dv_xname);
|
|
|
|
return;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1995-11-19 20:57:15 +03:00
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
ipl = DIO_IPL(sc->sc_regs);
|
|
|
|
|
|
|
|
if (da->da_scode == 7 && internalhpib)
|
|
|
|
desc = DIO_DEVICE_DESC_IHPIB;
|
|
|
|
else if (da->da_id == DIO_DEVICE_ID_NHPIB) {
|
|
|
|
type = HPIBB;
|
|
|
|
desc = DIO_DEVICE_DESC_NHPIB;
|
|
|
|
} else
|
|
|
|
desc = "unknown HP-IB!";
|
|
|
|
|
|
|
|
printf(" ipl %d: %s\n", ipl, desc);
|
|
|
|
|
|
|
|
/* Establish the interrupt handler. */
|
|
|
|
(void) isrlink(nhpibintr, sc, ipl, ISRPRI_BIO);
|
|
|
|
dmacomputeipl();
|
|
|
|
|
|
|
|
ha.ha_ops = &nhpib_controller;
|
|
|
|
ha.ha_type = type; /* XXX */
|
|
|
|
ha.ha_ba = (type == HPIBA) ? HPIBA_BA :
|
|
|
|
(sc->sc_regs->hpib_csa & CSA_BA);
|
|
|
|
ha.ha_softcpp = &sc->sc_hpibbus; /* XXX */
|
|
|
|
(void)config_found(self, &ha, hpibdevprint);
|
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
|
|
|
nhpibreset(hs)
|
|
|
|
struct hpibbus_softc *hs;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
hd->hpib_acr = AUX_SSWRST;
|
|
|
|
hd->hpib_ar = hs->sc_ba;
|
|
|
|
hd->hpib_lim = LIS_ERR;
|
|
|
|
hd->hpib_mim = 0;
|
|
|
|
hd->hpib_acr = AUX_CDAI;
|
|
|
|
hd->hpib_acr = AUX_CSHDW;
|
|
|
|
hd->hpib_acr = AUX_SSTD1;
|
|
|
|
hd->hpib_acr = AUX_SVSTD1;
|
|
|
|
hd->hpib_acr = AUX_CPP;
|
|
|
|
hd->hpib_acr = AUX_CHDFA;
|
|
|
|
hd->hpib_acr = AUX_CHDFE;
|
|
|
|
hd->hpib_acr = AUX_RHDF;
|
|
|
|
hd->hpib_acr = AUX_CSWRST;
|
|
|
|
nhpibifc(hd);
|
|
|
|
hd->hpib_ie = IDS_IE;
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = C_DCL_P;
|
1993-05-13 17:56:20 +04:00
|
|
|
DELAY(100000);
|
|
|
|
}
|
|
|
|
|
1997-01-30 12:06:51 +03:00
|
|
|
void
|
1993-05-13 17:56:20 +04:00
|
|
|
nhpibifc(hd)
|
|
|
|
register struct nhpibdevice *hd;
|
|
|
|
{
|
|
|
|
hd->hpib_acr = AUX_TCA;
|
|
|
|
hd->hpib_acr = AUX_CSRE;
|
|
|
|
hd->hpib_acr = AUX_SSIC;
|
|
|
|
DELAY(100);
|
|
|
|
hd->hpib_acr = AUX_CSIC;
|
|
|
|
hd->hpib_acr = AUX_SSRE;
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibsend(hs, slave, sec, ptr, origcnt)
|
|
|
|
struct hpibbus_softc *hs;
|
|
|
|
int slave, sec, origcnt;
|
1995-11-19 20:57:15 +03:00
|
|
|
void *ptr;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
|
|
|
int cnt = origcnt;
|
1995-11-19 20:57:15 +03:00
|
|
|
char *addr = ptr;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
hd->hpib_acr = AUX_TCA;
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = C_UNL_P;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto senderror;
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = talker_par[hs->sc_ba];
|
1993-05-13 17:56:20 +04:00
|
|
|
hd->hpib_acr = AUX_STON;
|
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto senderror;
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = listnr_par[slave];
|
1993-05-13 17:56:20 +04:00
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto senderror;
|
1995-01-07 13:30:10 +03:00
|
|
|
if (sec >= 0 || sec == -2) {
|
|
|
|
if (sec == -2) /* selected device clear KLUDGE */
|
|
|
|
hd->hpib_data = C_SDC_P;
|
|
|
|
else
|
|
|
|
hd->hpib_data = sec_par[sec];
|
1993-05-13 17:56:20 +04:00
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto senderror;
|
|
|
|
}
|
|
|
|
hd->hpib_acr = AUX_GTS;
|
|
|
|
if (cnt) {
|
|
|
|
while (--cnt > 0) {
|
|
|
|
hd->hpib_data = *addr++;
|
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto senderror;
|
|
|
|
}
|
|
|
|
hd->hpib_acr = AUX_EOI;
|
|
|
|
hd->hpib_data = *addr;
|
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto senderror;
|
|
|
|
hd->hpib_acr = AUX_TCA;
|
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* May be causing 345 disks to hang due to interference
|
|
|
|
* with PPOLL mechanism.
|
|
|
|
*/
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = C_UNL_P;
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) nhpibwait(hd, MIS_BO);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return(origcnt);
|
1995-01-07 13:30:10 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
senderror:
|
|
|
|
nhpibifc(hd);
|
|
|
|
return(origcnt - cnt - 1);
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibrecv(hs, slave, sec, ptr, origcnt)
|
|
|
|
struct hpibbus_softc *hs;
|
|
|
|
int slave, sec, origcnt;
|
1995-11-19 20:57:15 +03:00
|
|
|
void *ptr;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
|
|
|
int cnt = origcnt;
|
1995-11-19 20:57:15 +03:00
|
|
|
char *addr = ptr;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
1995-01-07 13:30:10 +03:00
|
|
|
/*
|
|
|
|
* Slave < 0 implies continuation of a previous receive
|
|
|
|
* that probably timed out.
|
|
|
|
*/
|
|
|
|
if (slave >= 0) {
|
|
|
|
hd->hpib_acr = AUX_TCA;
|
|
|
|
hd->hpib_data = C_UNL_P;
|
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto recverror;
|
|
|
|
hd->hpib_data = listnr_par[hs->sc_ba];
|
|
|
|
hd->hpib_acr = AUX_SLON;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto recverror;
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = talker_par[slave];
|
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto recverror;
|
|
|
|
if (sec >= 0) {
|
|
|
|
hd->hpib_data = sec_par[sec];
|
|
|
|
if (nhpibwait(hd, MIS_BO))
|
|
|
|
goto recverror;
|
|
|
|
}
|
|
|
|
hd->hpib_acr = AUX_RHDF;
|
|
|
|
hd->hpib_acr = AUX_GTS;
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
if (cnt) {
|
|
|
|
while (--cnt >= 0) {
|
|
|
|
if (nhpibwait(hd, MIS_BI))
|
|
|
|
goto recvbyteserror;
|
|
|
|
*addr++ = hd->hpib_data;
|
|
|
|
}
|
|
|
|
hd->hpib_acr = AUX_TCA;
|
1995-01-07 13:30:10 +03:00
|
|
|
hd->hpib_data = (slave == 31) ? C_UNA_P : C_UNT_P;
|
1993-05-13 17:56:20 +04:00
|
|
|
(void) nhpibwait(hd, MIS_BO);
|
|
|
|
}
|
|
|
|
return(origcnt);
|
1995-01-07 13:30:10 +03:00
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
recverror:
|
|
|
|
nhpibifc(hd);
|
|
|
|
recvbyteserror:
|
|
|
|
return(origcnt - cnt - 1);
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibgo(hs, slave, sec, ptr, count, rw, timo)
|
|
|
|
struct hpibbus_softc *hs;
|
|
|
|
int slave, sec, count, rw, timo;
|
1995-11-19 20:57:15 +03:00
|
|
|
void *ptr;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
1995-11-19 20:57:15 +03:00
|
|
|
char *addr = ptr;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
hs->sc_flags |= HPIBF_IO;
|
1995-01-07 13:30:10 +03:00
|
|
|
if (timo)
|
|
|
|
hs->sc_flags |= HPIBF_TIMO;
|
1993-05-13 17:56:20 +04:00
|
|
|
if (rw == B_READ)
|
|
|
|
hs->sc_flags |= HPIBF_READ;
|
|
|
|
#ifdef DEBUG
|
|
|
|
else if (hs->sc_flags & HPIBF_READ) {
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("nhpibgo: HPIBF_READ still set\n");
|
1993-05-13 17:56:20 +04:00
|
|
|
hs->sc_flags &= ~HPIBF_READ;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
hs->sc_count = count;
|
|
|
|
hs->sc_addr = addr;
|
|
|
|
if (hs->sc_flags & HPIBF_READ) {
|
|
|
|
hs->sc_curcnt = count;
|
1997-01-30 12:06:51 +03:00
|
|
|
dmago(hs->sc_dq->dq_chan, addr, count, DMAGO_BYTE|DMAGO_READ);
|
|
|
|
nhpibrecv(hs, slave, sec, 0, 0);
|
1993-05-13 17:56:20 +04:00
|
|
|
hd->hpib_mim = MIS_END;
|
|
|
|
} else {
|
|
|
|
hd->hpib_mim = 0;
|
|
|
|
if (count < hpibdmathresh) {
|
|
|
|
hs->sc_curcnt = count;
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibsend(hs, slave, sec, addr, count);
|
|
|
|
nhpibdone(hs);
|
1993-05-13 17:56:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
hs->sc_curcnt = --count;
|
1997-01-30 12:06:51 +03:00
|
|
|
dmago(hs->sc_dq->dq_chan, addr, count, DMAGO_BYTE);
|
|
|
|
nhpibsend(hs, slave, sec, 0, 0);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
1997-01-30 12:06:51 +03:00
|
|
|
hd->hpib_ie = IDS_IE | IDS_DMA(hs->sc_dq->dq_chan);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
|
1995-01-07 13:30:10 +03:00
|
|
|
/*
|
|
|
|
* This timeout can only happen if a DMA read finishes DMAing with the read
|
|
|
|
* still pending (more data in read transaction than the driver was prepared
|
|
|
|
* to accept). At the moment, variable-record tape drives are the only things
|
|
|
|
* capabale of doing this. We repeat the necessary code from nhpibintr() -
|
|
|
|
* easier and quicker than calling nhpibintr() for this special case.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nhpibreadtimo(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *hs = arg;
|
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
1995-01-07 13:30:10 +03:00
|
|
|
int s = splbio();
|
|
|
|
|
|
|
|
if (hs->sc_flags & HPIBF_IO) {
|
1997-01-30 12:06:51 +03:00
|
|
|
register struct nhpibdevice *hd = sc->sc_regs;
|
|
|
|
register struct hpibqueue *hq;
|
1995-01-07 13:30:10 +03:00
|
|
|
|
|
|
|
hd->hpib_mim = 0;
|
|
|
|
hd->hpib_acr = AUX_TCA;
|
|
|
|
hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO);
|
1997-01-30 12:06:51 +03:00
|
|
|
dmafree(hs->sc_dq);
|
|
|
|
|
|
|
|
hq = hs->sc_queue.tqh_first;
|
|
|
|
(hq->hq_intr)(hq->hq_softc);
|
1995-01-07 13:30:10 +03:00
|
|
|
}
|
1997-01-30 12:06:51 +03:00
|
|
|
splx(s);
|
1995-01-07 13:30:10 +03:00
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
void
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibdone(hs)
|
|
|
|
struct hpibbus_softc *hs;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
|
|
|
int cnt;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
cnt = hs->sc_curcnt;
|
|
|
|
hs->sc_addr += cnt;
|
|
|
|
hs->sc_count -= cnt;
|
|
|
|
hs->sc_flags |= HPIBF_DONE;
|
|
|
|
hd->hpib_ie = IDS_IE;
|
1995-01-07 13:30:10 +03:00
|
|
|
if (hs->sc_flags & HPIBF_READ) {
|
|
|
|
if ((hs->sc_flags & HPIBF_TIMO) &&
|
|
|
|
(hd->hpib_ids & IDS_IR) == 0)
|
1997-01-30 12:06:51 +03:00
|
|
|
timeout(nhpibreadtimo, hs, hz >> 2);
|
1995-01-07 13:30:10 +03:00
|
|
|
} else {
|
1993-05-13 17:56:20 +04:00
|
|
|
if (hs->sc_count == 1) {
|
|
|
|
(void) nhpibwait(hd, MIS_BO);
|
|
|
|
hd->hpib_acr = AUX_EOI;
|
|
|
|
hd->hpib_data = *hs->sc_addr;
|
|
|
|
hd->hpib_mim = MIS_BO;
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else if (hs->sc_count)
|
|
|
|
panic("nhpibdone");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1996-02-14 05:43:54 +03:00
|
|
|
nhpibintr(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = arg;
|
|
|
|
struct hpibbus_softc *hs = sc->sc_hpibbus;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
|
|
|
struct hpibqueue *hq;
|
|
|
|
int stat0;
|
|
|
|
int stat1;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
#ifdef lint
|
|
|
|
if (stat1 = unit) return(1);
|
|
|
|
#endif
|
|
|
|
if ((hd->hpib_ids & IDS_IR) == 0)
|
|
|
|
return(0);
|
|
|
|
stat0 = hd->hpib_mis;
|
|
|
|
stat1 = hd->hpib_lis;
|
1997-01-30 12:06:51 +03:00
|
|
|
|
|
|
|
hq = hs->sc_queue.tqh_first;
|
|
|
|
|
1993-05-13 17:56:20 +04:00
|
|
|
if (hs->sc_flags & HPIBF_IO) {
|
|
|
|
hd->hpib_mim = 0;
|
1995-01-07 13:30:10 +03:00
|
|
|
if ((hs->sc_flags & HPIBF_DONE) == 0) {
|
|
|
|
hs->sc_flags &= ~HPIBF_TIMO;
|
1997-01-30 12:06:51 +03:00
|
|
|
dmastop(hs->sc_dq->dq_chan);
|
1995-01-07 13:30:10 +03:00
|
|
|
} else if (hs->sc_flags & HPIBF_TIMO)
|
1997-01-30 12:06:51 +03:00
|
|
|
untimeout(nhpibreadtimo, hs);
|
1993-05-13 17:56:20 +04:00
|
|
|
hd->hpib_acr = AUX_TCA;
|
1995-01-07 13:30:10 +03:00
|
|
|
hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO);
|
1997-01-30 12:06:51 +03:00
|
|
|
|
|
|
|
dmafree(hs->sc_dq);
|
|
|
|
(hq->hq_intr)(hq->hq_softc);
|
1993-05-13 17:56:20 +04:00
|
|
|
} else if (hs->sc_flags & HPIBF_PPOLL) {
|
|
|
|
hd->hpib_mim = 0;
|
1997-01-30 12:06:51 +03:00
|
|
|
stat0 = nhpibppoll(hs);
|
|
|
|
if (stat0 & (0x80 >> hq->hq_slave)) {
|
1993-05-13 17:56:20 +04:00
|
|
|
hs->sc_flags &= ~HPIBF_PPOLL;
|
1997-01-30 12:06:51 +03:00
|
|
|
(hq->hq_intr)(hq->hq_softc);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
else
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("%s: PPOLL intr bad status %x\n",
|
1997-01-30 12:06:51 +03:00
|
|
|
hs->sc_dev.dv_xname, stat0);
|
1993-05-13 17:56:20 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1997-01-30 12:06:51 +03:00
|
|
|
nhpibppoll(hs)
|
|
|
|
struct hpibbus_softc *hs;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
|
|
|
struct nhpibdevice *hd = sc->sc_regs;
|
|
|
|
int ppoll;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
hd->hpib_acr = AUX_SPP;
|
|
|
|
DELAY(25);
|
|
|
|
ppoll = hd->hpib_cpt;
|
|
|
|
hd->hpib_acr = AUX_CPP;
|
|
|
|
return(ppoll);
|
|
|
|
}
|
|
|
|
|
1995-01-07 13:30:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
int nhpibreporttimo = 0;
|
|
|
|
#endif
|
|
|
|
|
1995-11-19 20:57:15 +03:00
|
|
|
int
|
1993-05-13 17:56:20 +04:00
|
|
|
nhpibwait(hd, x)
|
|
|
|
register struct nhpibdevice *hd;
|
1994-05-23 09:58:16 +04:00
|
|
|
int x;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
|
|
|
register int timo = hpibtimeout;
|
|
|
|
|
|
|
|
while ((hd->hpib_mis & x) == 0 && --timo)
|
1996-05-19 03:56:59 +04:00
|
|
|
DELAY(1);
|
1995-01-07 13:30:10 +03:00
|
|
|
if (timo == 0) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nhpibreporttimo)
|
1996-10-13 07:14:05 +04:00
|
|
|
printf("hpib0: %s timo\n", x==MIS_BO?"OUT":"IN");
|
1995-01-07 13:30:10 +03:00
|
|
|
#endif
|
1993-05-13 17:56:20 +04:00
|
|
|
return(-1);
|
1995-01-07 13:30:10 +03:00
|
|
|
}
|
1993-05-13 17:56:20 +04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1994-05-23 09:58:16 +04:00
|
|
|
void
|
1994-05-05 14:10:21 +04:00
|
|
|
nhpibppwatch(arg)
|
|
|
|
void *arg;
|
1993-05-13 17:56:20 +04:00
|
|
|
{
|
1997-01-30 12:06:51 +03:00
|
|
|
struct hpibbus_softc *hs = arg;
|
|
|
|
struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
|
1994-05-23 09:58:16 +04:00
|
|
|
extern int cold;
|
1993-05-13 17:56:20 +04:00
|
|
|
|
|
|
|
if ((hs->sc_flags & HPIBF_PPOLL) == 0)
|
|
|
|
return;
|
1994-05-23 09:58:16 +04:00
|
|
|
again:
|
1997-01-30 12:06:51 +03:00
|
|
|
if (nhpibppoll(hs) & (0x80 >> hs->sc_queue.tqh_first->hq_slave))
|
|
|
|
sc->sc_regs->hpib_mim = MIS_BO;
|
1994-05-23 09:58:16 +04:00
|
|
|
else if (cold)
|
|
|
|
/* timeouts not working yet */
|
|
|
|
goto again;
|
1993-05-13 17:56:20 +04:00
|
|
|
else
|
1997-01-30 12:06:51 +03:00
|
|
|
timeout(nhpibppwatch, hs, 1);
|
1993-05-13 17:56:20 +04:00
|
|
|
}
|