summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/dev
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-02-03 04:48:09 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-02-03 04:48:09 +0000
commit3dc2bab62b31e6caa1a00fece6004504f8e08033 (patch)
treec3a44aeae3938880a95422164280589feafe53aa /sys/arch/hp300/dev
parent08e8d869ff1f7248522b236f25044d2744c972dd (diff)
Merge new config(8) support from NetBSD, by Jason Thorpe.
Also add siginfo glue, BOOT_CONFIG, and various other changes.
Diffstat (limited to 'sys/arch/hp300/dev')
-rw-r--r--sys/arch/hp300/dev/Makefile4
-rw-r--r--sys/arch/hp300/dev/ac.c230
-rw-r--r--sys/arch/hp300/dev/acvar.h11
-rw-r--r--sys/arch/hp300/dev/ct.c462
-rw-r--r--sys/arch/hp300/dev/dca.c106
-rw-r--r--sys/arch/hp300/dev/dcm.c137
-rw-r--r--sys/arch/hp300/dev/device.h141
-rw-r--r--sys/arch/hp300/dev/devlist2h.awk4
-rw-r--r--sys/arch/hp300/dev/dio.c21
-rw-r--r--sys/arch/hp300/dev/diodevs4
-rw-r--r--sys/arch/hp300/dev/diodevs.h2
-rw-r--r--sys/arch/hp300/dev/diodevs_data.h2
-rw-r--r--sys/arch/hp300/dev/dioreg.h11
-rw-r--r--sys/arch/hp300/dev/diovar.h4
-rw-r--r--sys/arch/hp300/dev/dma.c175
-rw-r--r--sys/arch/hp300/dev/dmareg.h16
-rw-r--r--sys/arch/hp300/dev/dmavar.h25
-rw-r--r--sys/arch/hp300/dev/fhpib.c294
-rw-r--r--sys/arch/hp300/dev/grf.c64
-rw-r--r--sys/arch/hp300/dev/grf_conf.c83
-rw-r--r--sys/arch/hp300/dev/grf_dv.c18
-rw-r--r--sys/arch/hp300/dev/grf_gb.c18
-rw-r--r--sys/arch/hp300/dev/grf_hy.c13
-rw-r--r--sys/arch/hp300/dev/grf_machdep.c179
-rw-r--r--sys/arch/hp300/dev/grf_rb.c18
-rw-r--r--sys/arch/hp300/dev/grf_subr.c4
-rw-r--r--sys/arch/hp300/dev/grf_tc.c18
-rw-r--r--sys/arch/hp300/dev/grfvar.h11
-rw-r--r--sys/arch/hp300/dev/hpib.c405
-rw-r--r--sys/arch/hp300/dev/hpibvar.h115
-rw-r--r--sys/arch/hp300/dev/if_le.c64
-rw-r--r--sys/arch/hp300/dev/if_levar.h7
-rw-r--r--sys/arch/hp300/dev/intio.c17
-rw-r--r--sys/arch/hp300/dev/intiovar.h4
-rw-r--r--sys/arch/hp300/dev/ite.c98
-rw-r--r--sys/arch/hp300/dev/itevar.h6
-rw-r--r--sys/arch/hp300/dev/mt.c374
-rw-r--r--sys/arch/hp300/dev/nhpib.c280
-rw-r--r--sys/arch/hp300/dev/ppi.c201
-rw-r--r--sys/arch/hp300/dev/rd.c495
-rw-r--r--sys/arch/hp300/dev/rd_compat.c16
-rw-r--r--sys/arch/hp300/dev/rdvar.h31
-rw-r--r--sys/arch/hp300/dev/scsi.c440
-rw-r--r--sys/arch/hp300/dev/scsivar.h66
-rw-r--r--sys/arch/hp300/dev/sd.c519
-rw-r--r--sys/arch/hp300/dev/sd_compat.c18
-rw-r--r--sys/arch/hp300/dev/sdvar.h28
-rw-r--r--sys/arch/hp300/dev/st.c483
48 files changed, 2762 insertions, 2980 deletions
diff --git a/sys/arch/hp300/dev/Makefile b/sys/arch/hp300/dev/Makefile
index 9d0c418ba17..683bed14833 100644
--- a/sys/arch/hp300/dev/Makefile
+++ b/sys/arch/hp300/dev/Makefile
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.1 1997/01/12 15:12:17 downsj Exp $
-# $NetBSD: Makefile,v 1.1 1996/12/17 08:40:59 thorpej Exp $
+# $OpenBSD: Makefile,v 1.2 1997/02/03 04:47:10 downsj Exp $
+# $NetBSD: Makefile,v 1.2 1997/01/30 09:18:33 thorpej Exp $
AWK= awk
diff --git a/sys/arch/hp300/dev/ac.c b/sys/arch/hp300/dev/ac.c
index 1e6c54544cc..8597ace1823 100644
--- a/sys/arch/hp300/dev/ac.c
+++ b/sys/arch/hp300/dev/ac.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: ac.c,v 1.4 1997/01/12 15:12:17 downsj Exp $
-/* $NetBSD: ac.c,v 1.6 1996/10/13 03:14:05 christos Exp $ */
+/* $OpenBSD: ac.c,v 1.5 1997/02/03 04:47:11 downsj Exp $
+/* $NetBSD: ac.c,v 1.7 1997/01/30 09:14:10 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1991 University of Utah.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -52,42 +53,34 @@
* never uses it.
*/
-#include "ac.h"
-#if NAC > 0
-
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/device.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/scsireg.h>
+#include <hp300/dev/scsivar.h>
+
#include <hp300/dev/acioctl.h>
#include <hp300/dev/acvar.h>
-extern int scsi_test_unit_rdy();
-extern int scsi_request_sense();
-extern int scsiustart();
-extern int scsigo();
-extern void scsifree();
-extern void scsireset();
-extern void scsi_delay();
-extern void scsi_str __P((char *, char *, size_t));
+int acmatch __P((struct device *, void *, void *));
+void acattach __P((struct device *, struct device *, void *));
-extern int scsi_immed_command();
-
-int acmatch(), acstart(), acgo(), acintr();
-void acattach();
+struct cfattach ac_ca = {
+ sizeof(struct ac_softc), acmatch, acattach
+};
-struct driver acdriver = {
- acmatch, acattach, "ac", acstart, acgo, acintr,
+struct cfdriver ac_cd = {
+ NULL, "ac", DV_DULL
};
-struct ac_softc ac_softc[NAC];
-static struct buf acbuf[NAC];
-static struct scsi_fmt_cdb accmd[NAC];
+void acstart __P((void *));
+void acgo __P((void *));
+void acintr __P((void *, int));
#ifdef DEBUG
int ac_debug = 0x0000;
@@ -96,108 +89,51 @@ int ac_debug = 0x0000;
#endif
int
-acmatch(hd)
- register struct hp_device *hd;
+acmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- int unit = hd->hp_unit;
- register struct ac_softc *sc = &ac_softc[unit];
+ struct oscsi_attach_args *osa = aux;
- sc->sc_hd = hd;
- sc->sc_punit = hd->hp_flags & 7;
- if (acident(sc, hd, 0) < 0)
+ if (osa->osa_inqbuf->type != 8 || osa->osa_inqbuf->qual != 0x80 ||
+ osa->osa_inqbuf->version != 2)
return (0);
return (1);
}
void
-acattach(hd)
- register struct hp_device *hd;
-{
- int unit = hd->hp_unit;
- register struct ac_softc *sc = &ac_softc[unit];
-
- (void)acident(sc, hd, 1); /* XXX Ick. */
-
- sc->sc_dq.dq_softc = sc;
- sc->sc_dq.dq_unit = unit;
- sc->sc_dq.dq_ctlr = hd->hp_ctlr;
- sc->sc_dq.dq_slave = hd->hp_slave;
- sc->sc_dq.dq_driver = &acdriver;
- sc->sc_bp = &acbuf[unit];
- sc->sc_cmd = &accmd[unit];
- sc->sc_flags = ACF_ALIVE;
-}
-
-acident(sc, hd, verbose)
- register struct ac_softc *sc;
- register struct hp_device *hd;
- int verbose;
+acattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- int unit;
- register int ctlr, slave;
- int i, stat;
- int tries = 5;
- struct scsi_inquiry inqbuf;
- char vendor[9], product[17], revision[5];
- static struct scsi_fmt_cdb inq = {
- 6,
- CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0
- };
-
- ctlr = hd->hp_ctlr;
- slave = hd->hp_slave;
- unit = sc->sc_punit;
- scsi_delay(-1);
-
- /*
- * See if device is ready
- */
- while ((i = scsi_test_unit_rdy(ctlr, slave, unit)) != 0) {
- if (i == -1 || --tries < 0)
- /* doesn't exist or not a CCS device */
- goto failed;
- if (i == STS_CHECKCOND) {
- u_char sensebuf[128];
- struct scsi_xsense *sp;
-
- scsi_request_sense(ctlr, slave, unit,
- sensebuf, sizeof(sensebuf));
- sp = (struct scsi_xsense *) sensebuf;
- if (sp->class == 7 && sp->key == 6)
- /* drive doing an RTZ -- give it a while */
- DELAY(1000000);
- }
- DELAY(1000);
+ struct ac_softc *sc = (struct ac_softc *)self;
+ struct oscsi_attach_args *osa = aux;
+
+ printf("\n");
+
+ sc->sc_target = osa->osa_target;
+ sc->sc_lun = osa->osa_lun;
+
+ /* Initialize SCSI queue entry. */
+ sc->sc_sq.sq_softc = sc;
+ sc->sc_sq.sq_target = sc->sc_target;
+ sc->sc_sq.sq_lun = sc->sc_lun;
+ sc->sc_sq.sq_start = acstart;
+ sc->sc_sq.sq_go = acgo;
+ sc->sc_sq.sq_intr = acintr;
+
+ sc->sc_bp = (struct buf *)malloc(sizeof(struct buf),
+ M_DEVBUF, M_NOWAIT);
+ sc->sc_cmd = (struct scsi_fmt_cdb *)malloc(sizeof(struct scsi_fmt_cdb),
+ M_DEVBUF, M_NOWAIT);
+
+ if (sc->sc_bp == NULL || sc->sc_cmd == NULL) {
+ printf("%s: memory allocation failed\n", sc->sc_dev.dv_xname);
+ return;
}
- /*
- * Find out if it is an autochanger
- */
- if (scsi_immed_command(ctlr, slave, unit, &inq,
- (u_char *)&inqbuf, sizeof(inqbuf), B_READ))
- goto failed;
- if (inqbuf.type != 8 || inqbuf.qual != 0x80 || inqbuf.version != 2)
- goto failed;
-
- /*
- * Get a usable id string
- */
- bzero(vendor, sizeof(vendor));
- bzero(product, sizeof(product));
- bzero(revision, sizeof(revision));
- scsi_str(inqbuf.vendor_id, vendor, sizeof(inqbuf.vendor_id));
- scsi_str(inqbuf.product_id, product, sizeof(inqbuf.product_id));
- scsi_str(inqbuf.rev, revision, sizeof(inqbuf.rev));
-
- if (verbose)
- printf(": <%s, %s, %s>\n", vendor, product, revision);
-
- scsi_delay(0);
- return(inqbuf.type);
-failed:
- scsi_delay(0);
- return(-1);
+ sc->sc_flags = ACF_ALIVE;
}
/*ARGSUSED*/
@@ -207,13 +143,17 @@ acopen(dev, flag, mode, p)
struct proc *p;
{
register int unit = minor(dev);
- register struct ac_softc *sc = &ac_softc[unit];
+ struct ac_softc *sc;
int error = 0;
- if (unit >= NAC || (sc->sc_flags & ACF_ALIVE) == 0)
- return(ENXIO);
+ if (unit >= ac_cd.cd_ndevs ||
+ (sc = ac_cd.cd_devs[unit]) == NULL ||
+ (sc->sc_flags & ACF_ALIVE) == 0)
+ return (ENXIO);
+
if (sc->sc_flags & ACF_OPEN)
- return(EBUSY);
+ return (EBUSY);
+
/*
* Since acgeteinfo can block we mark the changer open now.
*/
@@ -222,7 +162,7 @@ acopen(dev, flag, mode, p)
sc->sc_flags &= ~ACF_OPEN;
return(EIO);
}
- return(0);
+ return (0);
}
/*ARGSUSED*/
@@ -231,9 +171,10 @@ acclose(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
- struct ac_softc *sc = &ac_softc[minor(dev)];
+ struct ac_softc *sc = ac_cd.cd_devs[minor(dev)];
sc->sc_flags &= ~ACF_OPEN;
+ return (0);
}
#define ACRESLEN(ep) \
@@ -247,7 +188,7 @@ acioctl(dev, cmd, data, flag, p)
int flag;
struct proc *p;
{
- register struct ac_softc *sc = &ac_softc[minor(dev)];
+ struct ac_softc *sc = ac_cd.cd_devs[minor(dev)];
char *dp;
int dlen, error = 0;
@@ -324,7 +265,7 @@ accommand(dev, command, bufp, buflen)
int buflen;
{
int unit = minor(dev);
- register struct ac_softc *sc = &ac_softc[unit];
+ struct ac_softc *sc = ac_cd.cd_devs[unit];
register struct buf *bp = sc->sc_bp;
register struct scsi_fmt_cdb *cmd = sc->sc_cmd;
int error;
@@ -380,38 +321,41 @@ accommand(dev, command, bufp, buflen)
bp->b_resid = 0;
bp->b_blkno = 0;
bp->b_error = 0;
- if (scsireq(&sc->sc_dq))
- acstart(unit);
+ if (scsireq(sc->sc_dev.dv_parent, &sc->sc_sq))
+ acstart(sc);
error = biowait(bp);
sc->sc_flags &= ~ACF_ACTIVE;
return (error);
}
-acstart(unit)
- int unit;
+void
+acstart(arg)
+ void *arg;
{
+ struct ac_softc *sc = arg;
+
#ifdef DEBUG
if (ac_debug & ACD_FOLLOW)
printf("acstart(unit=%x)\n", unit);
#endif
- if (scsiustart(ac_softc[unit].sc_hd->hp_ctlr))
- acgo(unit);
+ if (scsiustart(sc->sc_dev.dv_parent->dv_unit))
+ acgo(arg);
}
-acgo(unit)
- int unit;
+void
+acgo(arg)
+ void *arg;
{
- register struct ac_softc *sc = &ac_softc[unit];
+ struct ac_softc *sc = arg;
register struct buf *bp = sc->sc_bp;
- struct hp_device *hp = sc->sc_hd;
int stat;
#ifdef DEBUG
if (ac_debug & ACD_FOLLOW)
printf("acgo(unit=%x): ", unit);
#endif
- stat = scsigo(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
- bp, sc->sc_cmd, 0);
+ stat = scsigo(sc->sc_dev.dv_parent->dv_unit, sc->sc_target,
+ sc->sc_lun, bp, sc->sc_cmd, 0);
#ifdef DEBUG
if (ac_debug & ACD_FOLLOW)
printf("scsigo returns %x\n", stat);
@@ -420,10 +364,11 @@ acgo(unit)
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
(void) biodone(bp);
- scsifree(&sc->sc_dq);
+ scsifree(sc->sc_dev.dv_parent, &sc->sc_sq);
}
}
+void
acintr(arg, stat)
void *arg;
int stat;
@@ -432,7 +377,7 @@ acintr(arg, stat)
register struct buf *bp = sc->sc_bp;
u_char sensebuf[78];
struct scsi_xsense *sp;
- int unit = sc->sc_hd->hp_unit;
+ int unit = sc->sc_dev.dv_unit;
#ifdef DEBUG
if (ac_debug & ACD_FOLLOW)
@@ -443,27 +388,27 @@ acintr(arg, stat)
bp->b_resid = 0;
break;
case STS_CHECKCOND:
- scsi_request_sense(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- sc->sc_punit, sensebuf, sizeof sensebuf);
+ scsi_request_sense(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, sensebuf, sizeof sensebuf);
sp = (struct scsi_xsense *)sensebuf;
printf("%s: acintr sense key=%x, ac=%x, acq=%x\n",
- sc->sc_hd->hp_xname, sp->key, sp->info4, sp->len);
+ sc->sc_dev.dv_xname, sp->key, sp->info4, sp->len);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
default:
- printf("%s: acintr unknown status 0x%x\n", sc->sc_hd->hp_xname,
+ printf("%s: acintr unknown status 0x%x\n", sc->sc_dev.dv_xname,
stat);
break;
}
(void) biodone(sc->sc_bp);
- scsifree(&sc->sc_dq);
+ scsifree(sc->sc_dev.dv_parent, &sc->sc_sq);
}
acgeteinfo(dev)
dev_t dev;
{
- register struct ac_softc *sc = &ac_softc[minor(dev)];
+ struct ac_softc *sc = ac_cd.cd_devs[minor(dev)];
register char *bp;
char msbuf[48];
int error;
@@ -551,4 +496,3 @@ acconvert(sbuf, dbuf, ne)
#endif
}
}
-#endif
diff --git a/sys/arch/hp300/dev/acvar.h b/sys/arch/hp300/dev/acvar.h
index e3dac326867..91d330c36ae 100644
--- a/sys/arch/hp300/dev/acvar.h
+++ b/sys/arch/hp300/dev/acvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: acvar.h,v 1.2 1997/01/12 15:12:19 downsj Exp $ */
-/* $NetBSD: acvar.h,v 1.2 1994/10/26 07:23:27 cgd Exp $ */
+/* $OpenBSD: acvar.h,v 1.3 1997/02/03 04:47:11 downsj Exp $ */
+/* $NetBSD: acvar.h,v 1.3 1997/01/30 09:14:11 thorpej Exp $ */
/*
* Copyright (c) 1991 University of Utah.
@@ -44,14 +44,15 @@
*/
struct ac_softc {
- struct hp_device *sc_hd;
+ struct device sc_dev;
+ int sc_target;
+ int sc_lun;
int sc_flags;
struct buf *sc_bp;
struct scsi_fmt_cdb *sc_cmd;
struct acinfo sc_einfo;
- short sc_punit;
short sc_picker;
- struct devqueue sc_dq;
+ struct scsiqueue sc_sq;
};
#define ACF_ALIVE 0x01
diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c
index 596375523f8..528d104da46 100644
--- a/sys/arch/hp300/dev/ct.c
+++ b/sys/arch/hp300/dev/ct.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: ct.c,v 1.5 1997/01/12 15:12:19 downsj Exp $ */
-/* $NetBSD: ct.c,v 1.18 1996/10/14 07:14:11 thorpej Exp $ */
+/* $OpenBSD: ct.c,v 1.6 1997/02/03 04:47:12 downsj Exp $ */
+/* $NetBSD: ct.c,v 1.19 1997/01/30 09:14:12 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -36,8 +37,6 @@
* @(#)ct.c 8.2 (Berkeley) 1/12/94
*/
-#include "ct.h"
-#if NCT > 0
/*
* CS80 cartridge tape driver (9144, 88140, 9145)
*
@@ -58,21 +57,20 @@
#include <sys/mtio.h>
#include <sys/tprintf.h>
#include <sys/proc.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+
+#include <hp300/dev/hpibvar.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/ctreg.h>
/* number of eof marks to remember */
#define EOFS 128
-int ctmatch(), ctstart(), ctgo(), ctintr();
-void ctattach(), ctstrategy(), ctdone();
-struct driver ctdriver = {
- ctmatch, ctattach, "ct", ctstart, ctgo, ctintr,
-};
-
struct ct_softc {
- struct hp_device *sc_hd;
+ struct device sc_dev;
+ int sc_slave; /* HP-IB slave ID */
+ int sc_punit; /* physical unit */
struct ct_iocmd sc_ioc;
struct ct_rscmd sc_rsc;
struct ct_stat sc_stat;
@@ -82,19 +80,20 @@ struct ct_softc {
struct ct_ulcmd sc_ul;
struct ct_wfmcmd sc_wfm;
struct ct_clearcmd sc_clear;
+ struct buf sc_tab;
struct buf *sc_bp;
+ struct buf sc_bufstore; /* XXX */
int sc_blkno;
int sc_cmd;
int sc_resid;
char *sc_addr;
int sc_flags;
short sc_type;
- short sc_punit;
tpr_t sc_tpr;
- struct devqueue sc_dq;
+ struct hpibqueue sc_hq; /* entry on hpib job queue */
int sc_eofp;
int sc_eofs[EOFS];
-} ct_softc[NCT];
+};
/* flags */
#define CTF_OPEN 0x01
@@ -109,6 +108,35 @@ struct ct_softc {
#define CTF_CANSTREAM 0x200
#define CTF_WRTTN 0x400
+int ctmatch __P((struct device *, void *, void *));
+void ctattach __P((struct device *, struct device *, void *));
+
+struct cfattach ct_ca = {
+ sizeof(struct ct_softc), ctmatch, ctattach
+};
+
+struct cfdriver ct_cd = {
+ NULL, "ct", DV_TAPE
+};
+
+int ctident __P((struct device *, struct ct_softc *,
+ struct hpibbus_attach_args *));
+
+void ctreset __P((struct ct_softc *));
+void ctaddeof __P((struct ct_softc *));
+void ctustart __P((struct ct_softc *));
+void cteof __P((struct ct_softc *, struct buf *));
+void ctdone __P((struct ct_softc *, struct buf *));
+
+void ctstart __P((void *));
+void ctgo __P((void *));
+void ctintr __P((void *));
+
+void ctcommand __P((dev_t, int, int));
+
+cdev_decl(ct);
+bdev_decl(ct);
+
struct ctinfo {
short hwid;
short punit;
@@ -122,9 +150,6 @@ struct ctinfo {
};
int nctinfo = sizeof(ctinfo) / sizeof(ctinfo[0]);
-struct buf cttab[NCT];
-struct buf ctbuf[NCT];
-
#define CT_NOREW 4
#define CT_STREAM 8
#define UNIT(x) (minor(x) & 3)
@@ -137,164 +162,183 @@ int ctdebug = 0;
#endif
int
-ctmatch(hd)
- register struct hp_device *hd;
+ctmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct ct_softc *sc = &ct_softc[hd->hp_unit];
- register struct buf *bp;
+ struct hpibbus_attach_args *ha = aux;
- for (bp = cttab; bp < &cttab[NCT]; bp++)
- bp->b_actb = &bp->b_actf;
- sc->sc_hd = hd;
- sc->sc_punit = ctpunit(hd->hp_flags);
- if (ctident(sc, hd, 0) < 0)
- return (0);
-
- return (1);
+ return (ctident(parent, NULL, ha));
}
void
-ctattach(hd)
- register struct hp_device *hd;
+ctattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- struct ct_softc *sc = &ct_softc[hd->hp_unit];
+ struct ct_softc *sc = (struct ct_softc *)self;
+ struct hpibbus_attach_args *ha = aux;
- (void)ctident(sc, hd, 1); /* XXX Ick. */
+ if (ctident(parent, sc, ha) == 0) {
+ printf("\n%s: didn't respond to describe command!\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
- ctreset(sc, hd);
- sc->sc_dq.dq_softc = sc;
- sc->sc_dq.dq_ctlr = hd->hp_ctlr;
- sc->sc_dq.dq_unit = hd->hp_unit;
- sc->sc_dq.dq_slave = hd->hp_slave;
- sc->sc_dq.dq_driver = &ctdriver;
- sc->sc_flags |= CTF_ALIVE;
+ sc->sc_slave = ha->ha_slave;
+ sc->sc_punit = ha->ha_punit;
+
+ sc->sc_tab.b_actb = &sc->sc_tab.b_actf;
+
+ /* Initialize hpib job queue entry. */
+ sc->sc_hq.hq_softc = sc;
+ sc->sc_hq.hq_slave = sc->sc_slave;
+ sc->sc_hq.hq_start = ctstart;
+ sc->sc_hq.hq_go = ctgo;
+ sc->sc_hq.hq_intr = ctintr;
- /* XXX Set device class. */
- hd->hp_dev.dv_class = DV_TAPE;
+ ctreset(sc);
+ sc->sc_flags |= CTF_ALIVE;
}
int
-ctident(sc, hd, verbose)
- register struct ct_softc *sc;
- register struct hp_device *hd;
- int verbose;
+ctident(parent, sc, ha)
+ struct device *parent;
+ struct ct_softc *sc;
+ struct hpibbus_attach_args *ha;
{
struct ct_describe desc;
u_char stat, cmd[3];
char name[7];
- int id, i;
+ int i, id, n, type, canstream;
- /*
- * Read device id and verify that:
- * 1. It is a CS80 device
- * 2. It is one of our recognized tape devices
- * 3. It has the proper physical unit number
- */
- id = hpibid(hd->hp_ctlr, hd->hp_slave);
- if ((id & 0x200) == 0)
- return(-1);
- for (i = 0; i < nctinfo; i++)
- if (id == ctinfo[i].hwid)
+ type = canstream = 0;
+
+ /* Verify that we have a CS80 device. */
+ if ((ha->ha_id & 0x200) == 0)
+ return (0);
+
+ /* Is it one of the tapes we support? */
+ for (id = 0; id < nctinfo; id++)
+ if (ha->ha_id == ctinfo[id].hwid)
break;
- if (i == nctinfo || sc->sc_punit != ctinfo[i].punit)
- return(-1);
- id = i;
+ if (id == nctinfo)
+ return (0);
+
+ ha->ha_punit = ctinfo[id].punit;
/*
- * Collect device description.
- * Right now we only need this to differentiate 7945 from 7946.
- * Note that we always issue the describe command to unit 0.
+ * So far, so good. Get drive parameters. Note command
+ * is always issued to unit 0.
*/
cmd[0] = C_SUNIT(0);
cmd[1] = C_SVOL(0);
cmd[2] = C_DESC;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, cmd, sizeof(cmd));
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_EXEC, &desc, 37);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(parent->dv_unit, ha->ha_slave, C_CMD, cmd, sizeof(cmd));
+ hpibrecv(parent->dv_unit, ha->ha_slave, C_EXEC, &desc, 37);
+ hpibrecv(parent->dv_unit, ha->ha_slave, C_QSTAT, &stat, sizeof(stat));
+
bzero(name, sizeof(name));
- if (!stat) {
- register int n = desc.d_name;
+ if (stat == 0) {
+ n = desc.d_name;
for (i = 5; i >= 0; i--) {
name[i] = (n & 0xf) + '0';
n >>= 4;
}
}
- switch (ctinfo[id].hwid) {
+
+ switch (ha->ha_id) {
case CT7946ID:
if (bcmp(name, "079450", 6) == 0)
- return(-1); /* not really a 7946 */
+ return (0); /* not really a 7946 */
/* fall into... */
case CT9144ID:
case CT9145ID:
- sc->sc_type = CT9144;
- sc->sc_flags |= CTF_CANSTREAM;
+ type = CT9144;
+ canstream = 1;
break;
case CT7912PID:
case CT7914PID:
- sc->sc_type = CT88140;
+ type = CT88140;
break;
}
- if (verbose)
+
+ if (sc != NULL) {
+ sc->sc_type = type;
+ sc->sc_flags = canstream ? CTF_CANSTREAM : 0;
printf(": %s %stape\n", ctinfo[id].desc,
- (sc->sc_flags & CTF_CANSTREAM) ? "streaming " : " ");
- return(id);
+ canstream ? "streaming " : "");
+ }
+
+ return (1);
}
-ctreset(sc, hd)
- register struct ct_softc *sc;
- register struct hp_device *hd;
+void
+ctreset(sc)
+ struct ct_softc *sc;
{
+ int ctlr, slave;
u_char stat;
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_slave;
+
sc->sc_clear.unit = C_SUNIT(sc->sc_punit);
sc->sc_clear.cmd = C_CLEAR;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_TCMD, &sc->sc_clear,
- sizeof(sc->sc_clear));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_TCMD, &sc->sc_clear, sizeof(sc->sc_clear));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
+
sc->sc_src.unit = C_SUNIT(CTCTLR);
sc->sc_src.nop = C_NOP;
sc->sc_src.cmd = C_SREL;
sc->sc_src.param = C_REL;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &sc->sc_src,
- sizeof(sc->sc_src));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_src, sizeof(sc->sc_src));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
+
sc->sc_ssmc.unit = C_SUNIT(sc->sc_punit);
sc->sc_ssmc.cmd = C_SSM;
sc->sc_ssmc.refm = REF_MASK;
sc->sc_ssmc.fefm = FEF_MASK;
sc->sc_ssmc.aefm = AEF_MASK;
sc->sc_ssmc.iefm = IEF_MASK;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &sc->sc_ssmc,
- sizeof(sc->sc_ssmc));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_ssmc, sizeof(sc->sc_ssmc));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
+
sc->sc_soptc.unit = C_SUNIT(sc->sc_punit);
sc->sc_soptc.nop = C_NOP;
sc->sc_soptc.cmd = C_SOPT;
sc->sc_soptc.opt = C_SPAR;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &sc->sc_soptc,
- sizeof(sc->sc_soptc));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_soptc, sizeof(sc->sc_soptc));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
}
/*ARGSUSED*/
+int
ctopen(dev, flag, type, p)
dev_t dev;
int flag, type;
struct proc *p;
{
- register struct ct_softc *sc = &ct_softc[UNIT(dev)];
+ struct ct_softc *sc;
u_char stat;
- int cc;
+ int cc, ctlr, slave;
+
+ if (UNIT(dev) >= ct_cd.cd_ndevs ||
+ (sc = ct_cd.cd_devs[UNIT(dev)]) == NULL ||
+ (sc->sc_flags & CTF_ALIVE) == 0)
+ return (ENXIO);
- if (UNIT(dev) >= NCT || (sc->sc_flags & CTF_ALIVE) == 0)
- return(ENXIO);
if (sc->sc_flags & CTF_OPEN)
- return(EBUSY);
+ return (EBUSY);
+
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_slave;
+
sc->sc_soptc.unit = C_SUNIT(sc->sc_punit);
sc->sc_soptc.nop = C_NOP;
sc->sc_soptc.cmd = C_SOPT;
@@ -302,31 +346,34 @@ ctopen(dev, flag, type, p)
sc->sc_soptc.opt = C_SPAR | C_IMRPT;
else
sc->sc_soptc.opt = C_SPAR;
+
/*
* Check the return of hpibsend() and hpibswait().
* Drive could be loading/unloading a tape. If not checked,
* driver hangs.
*/
- cc = hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- C_CMD, &sc->sc_soptc, sizeof(sc->sc_soptc));
+ cc = hpibsend(ctlr, slave, C_CMD, &sc->sc_soptc, sizeof(sc->sc_soptc));
if (cc != sizeof(sc->sc_soptc))
- return(EBUSY);
- hpibswait(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave);
- cc = hpibrecv(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_QSTAT,
- &stat, sizeof(stat));
+ return (EBUSY);
+
+ hpibswait(ctlr, slave);
+ cc = hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
if (cc != sizeof(stat))
return(EBUSY);
+
sc->sc_tpr = tprintf_open(p);
sc->sc_flags |= CTF_OPEN;
return(0);
}
/*ARGSUSED*/
-ctclose(dev, flag)
+int
+ctclose(dev, flag, fmt, p)
dev_t dev;
- int flag;
+ int flag, fmt;
+ struct proc *p;
{
- register struct ct_softc *sc = &ct_softc[UNIT(dev)];
+ struct ct_softc *sc = ct_cd.cd_devs[UNIT(dev)];
if ((sc->sc_flags & (CTF_WRT|CTF_WRTTN)) == (CTF_WRT|CTF_WRTTN) &&
(sc->sc_flags & CTF_EOT) == 0 ) { /* XXX return error if EOT ?? */
@@ -339,7 +386,7 @@ ctclose(dev, flag)
#ifdef DEBUG
if(ctdebug & CT_BSF)
printf("%s: ctclose backup eofs prt %d blk %d\n",
- sc->sc_hd->hp_xname, sc->sc_eofp,
+ sc->sc_dev.dv_xname, sc->sc_eofp,
sc->sc_eofs[sc->sc_eofp]);
#endif
}
@@ -354,13 +401,14 @@ ctclose(dev, flag)
return(0); /* XXX */
}
+void
ctcommand(dev, cmd, cnt)
dev_t dev;
int cmd;
register int cnt;
{
- register struct ct_softc *sc = &ct_softc[UNIT(dev)];
- register struct buf *bp = &ctbuf[UNIT(dev)];
+ struct ct_softc *sc = ct_cd.cd_devs[UNIT(dev)];
+ register struct buf *bp = &sc->sc_bufstore;
register struct buf *nbp = 0;
if (cmd == MTBSF && sc->sc_eofp == EOFS - 1) {
@@ -394,7 +442,7 @@ ctcommand(dev, cmd, cnt)
#ifdef DEBUG
if (ctdebug & CT_BSF)
printf("%s: backup eof pos %d blk %d\n",
- sc->sc_hd->hp_xname, sc->sc_eofp,
+ sc->sc_dev.dv_xname, sc->sc_eofp,
sc->sc_eofs[sc->sc_eofp]);
#endif
}
@@ -413,45 +461,51 @@ ctstrategy(bp)
{
register struct buf *dp;
register int s, unit;
+ struct ct_softc *sc;
unit = UNIT(bp->b_dev);
- dp = &cttab[unit];
+ sc = ct_cd.cd_devs[unit];
+
+ dp = &sc->sc_tab;
bp->b_actf = NULL;
s = splbio();
bp->b_actb = dp->b_actb;
- *dp->b_actb = bp;
+ *(dp->b_actb) = bp;
dp->b_actb = &bp->b_actf;
if (dp->b_active == 0) {
dp->b_active = 1;
- ctustart(unit);
+ ctustart(sc);
}
splx(s);
}
-ctustart(unit)
- register int unit;
+void
+ctustart(sc)
+ struct ct_softc *sc;
{
- register struct ct_softc *sc = &ct_softc[unit];
register struct buf *bp;
- bp = cttab[unit].b_actf;
+ bp = sc->sc_tab.b_actf;
sc->sc_addr = bp->b_un.b_addr;
sc->sc_resid = bp->b_bcount;
- if (hpibreq(&sc->sc_dq))
- ctstart(unit);
+ if (hpibreq(sc->sc_dev.dv_parent, &sc->sc_hq))
+ ctstart(sc);
}
-ctstart(unit)
- register int unit;
+void
+ctstart(arg)
+ void *arg;
{
- register struct ct_softc *sc = &ct_softc[unit];
- register struct buf *bp, *dp;
- register int i;
+ struct ct_softc *sc = arg;
+ struct buf *bp, *dp;
+ int i, ctlr, slave;
- bp = cttab[unit].b_actf;
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_slave;
+
+ bp = sc->sc_tab.b_actf;
if ((sc->sc_flags & CTF_CMD) && sc->sc_bp == bp) {
switch(sc->sc_cmd) {
-
case MTFSF:
bp->b_flags |= B_READ;
goto mustio;
@@ -463,8 +517,8 @@ ctstart(unit)
sc->sc_blkno = 0;
sc->sc_ul.unit = C_SUNIT(sc->sc_punit);
sc->sc_ul.cmd = C_UNLOAD;
- hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- C_CMD, &sc->sc_ul, sizeof(sc->sc_ul));
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_ul,
+ sizeof(sc->sc_ul));
break;
case MTWEOF:
@@ -472,9 +526,9 @@ ctstart(unit)
sc->sc_flags |= CTF_WRT;
sc->sc_wfm.unit = C_SUNIT(sc->sc_punit);
sc->sc_wfm.cmd = C_WFM;
- hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- C_CMD, &sc->sc_wfm, sizeof(sc->sc_wfm));
- ctaddeof(unit);
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_wfm,
+ sizeof(sc->sc_wfm));
+ ctaddeof(sc);
break;
case MTBSR:
@@ -490,7 +544,7 @@ ctstart(unit)
#ifdef DEBUG
if(ctdebug & CT_BSF)
printf("%s: clearing eofs\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
#endif
for (i=0; i<EOFS; i++)
sc->sc_eofs[i] = 0;
@@ -506,29 +560,30 @@ gotaddr:
sc->sc_ioc.len = 0;
sc->sc_ioc.nop3 = C_NOP;
sc->sc_ioc.cmd = C_READ;
- hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- C_CMD, &sc->sc_ioc, sizeof(sc->sc_ioc));
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_ioc,
+ sizeof(sc->sc_ioc));
break;
}
- }
- else {
+ } else {
mustio:
if ((bp->b_flags & B_READ) &&
sc->sc_flags & (CTF_BEOF|CTF_EOT)) {
#ifdef DEBUG
if (ctdebug & CDB_FILES)
- printf("ctstart: before flags %x\n", sc->sc_flags);
+ printf("ctstart: before flags %x\n",
+ sc->sc_flags);
#endif
if (sc->sc_flags & CTF_BEOF) {
sc->sc_flags &= ~CTF_BEOF;
sc->sc_flags |= CTF_AEOF;
#ifdef DEBUG
if (ctdebug & CDB_FILES)
- printf("ctstart: after flags %x\n", sc->sc_flags);
+ printf("ctstart: after flags %x\n",
+ sc->sc_flags);
#endif
}
bp->b_resid = bp->b_bcount;
- ctdone(unit, bp);
+ ctdone(sc, bp);
return;
}
sc->sc_flags |= CTF_IO;
@@ -546,28 +601,29 @@ mustio:
sc->sc_ioc.cmd = C_WRITE;
sc->sc_flags |= (CTF_WRT | CTF_WRTTN);
}
- hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_CMD,
- &sc->sc_ioc, sizeof(sc->sc_ioc));
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_ioc, sizeof(sc->sc_ioc));
}
- hpibawait(sc->sc_hd->hp_ctlr);
+ hpibawait(ctlr);
}
-ctgo(unit)
- register int unit;
+void
+ctgo(arg)
+ void *arg;
{
- register struct ct_softc *sc = &ct_softc[unit];
+ struct ct_softc *sc = arg;
register struct buf *bp;
int rw;
- bp = cttab[unit].b_actf;
+ bp = sc->sc_tab.b_actf;
rw = bp->b_flags & B_READ;
- hpibgo(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_EXEC,
- sc->sc_addr, sc->sc_resid, rw, rw != 0);
+ hpibgo(sc->sc_dev.dv_parent->dv_unit, sc->sc_slave, C_EXEC,
+ sc->sc_addr, sc->sc_resid, rw, rw != 0);
}
/*
* Hideous grue to handle EOF/EOT (mostly for reads)
*/
+void
cteof(sc, bp)
register struct ct_softc *sc;
register struct buf *bp;
@@ -640,35 +696,40 @@ cteof(sc, bp)
#endif
}
-int
+/* ARGSUSED */
+void
ctintr(arg)
void *arg;
{
register struct ct_softc *sc = arg;
- register struct buf *bp, *dp;
+ register struct buf *bp;
u_char stat;
- int unit = sc->sc_hd->hp_unit;
+ int ctlr, slave, unit;
+
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_slave;
+ unit = sc->sc_dev.dv_unit;
- bp = cttab[unit].b_actf;
+ bp = sc->sc_tab.b_actf;
if (bp == NULL) {
- printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
+ printf("%s: bp == NULL\n", sc->sc_dev.dv_xname);
return;
}
if (sc->sc_flags & CTF_IO) {
sc->sc_flags &= ~CTF_IO;
- if (hpibustart(sc->sc_hd->hp_ctlr))
- ctgo(unit);
+ if (hpibustart(ctlr))
+ ctgo(sc);
return;
}
if ((sc->sc_flags & CTF_STATWAIT) == 0) {
- if (hpibpptest(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave) == 0) {
+ if (hpibpptest(ctlr, slave) == 0) {
sc->sc_flags |= CTF_STATWAIT;
- hpibawait(sc->sc_hd->hp_ctlr);
+ hpibawait(ctlr);
return;
}
} else
sc->sc_flags &= ~CTF_STATWAIT;
- hpibrecv(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_QSTAT, &stat, 1);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, 1);
#ifdef DEBUG
if (ctdebug & CDB_FILES)
printf("ctintr: before flags %x\n", sc->sc_flags);
@@ -676,12 +737,10 @@ ctintr(arg)
if (stat) {
sc->sc_rsc.unit = C_SUNIT(sc->sc_punit);
sc->sc_rsc.cmd = C_STATUS;
- hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_CMD,
- &sc->sc_rsc, sizeof(sc->sc_rsc));
- hpibrecv(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_EXEC,
- &sc->sc_stat, sizeof(sc->sc_stat));
- hpibrecv(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave, C_QSTAT,
- &stat, 1);
+ hpibsend(ctlr, slave, C_CMD, &sc->sc_rsc, sizeof(sc->sc_rsc));
+ hpibrecv(ctlr, slave, C_EXEC, &sc->sc_stat,
+ sizeof(sc->sc_stat));
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, 1);
#ifdef DEBUG
if (ctdebug & CDB_FILES)
printf("ctintr: return stat 0x%x, A%x F%x blk %d\n",
@@ -691,34 +750,34 @@ ctintr(arg)
if (stat == 0) {
if (sc->sc_stat.c_aef & (AEF_EOF | AEF_EOV)) {
cteof(sc, bp);
- ctaddeof(unit);
+ ctaddeof(sc);
goto done;
}
if (sc->sc_stat.c_fef & FEF_PF) {
- ctreset(sc, sc->sc_hd);
- ctstart(unit);
+ ctreset(sc);
+ ctstart(sc);
return;
}
if (sc->sc_stat.c_fef & FEF_REXMT) {
- ctstart(unit);
+ ctstart(sc);
return;
}
if (sc->sc_stat.c_aef & 0x5800) {
if (sc->sc_stat.c_aef & 0x4000)
tprintf(sc->sc_tpr,
"%s: uninitialized media\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (sc->sc_stat.c_aef & 0x1000)
tprintf(sc->sc_tpr,
"%s: not ready\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (sc->sc_stat.c_aef & 0x0800)
tprintf(sc->sc_tpr,
"%s: write protect\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
} else {
printf("%s err: v%d u%d ru%d bn%d, ",
- sc->sc_hd->hp_xname,
+ sc->sc_dev.dv_xname,
(sc->sc_stat.c_vu>>4)&0xF,
sc->sc_stat.c_vu&0xF,
sc->sc_stat.c_pend,
@@ -731,7 +790,7 @@ ctintr(arg)
}
} else
printf("%s: request status failed\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
goto done;
@@ -742,7 +801,7 @@ ctintr(arg)
case MTFSF:
sc->sc_flags &= ~(CTF_BEOF|CTF_AEOF);
sc->sc_blkno += CTBTOK(sc->sc_resid);
- ctstart(unit);
+ ctstart(sc);
return;
case MTBSF:
sc->sc_flags &= ~(CTF_AEOF|CTF_BEOF|CTF_EOT);
@@ -779,29 +838,28 @@ done:
if (ctdebug & CDB_FILES)
printf("ctintr: after flags %x\n", sc->sc_flags);
#endif
- ctdone(unit, bp);
+ ctdone(sc, bp);
}
void
-ctdone(unit, bp)
- int unit;
+ctdone(sc, bp)
+ struct ct_softc *sc;
register struct buf *bp;
{
- register struct ct_softc *sc = &ct_softc[unit];
register struct buf *dp;
- if (dp = bp->b_actf)
+ if ((dp = bp->b_actf) != NULL)
dp->b_actb = bp->b_actb;
else
- cttab[unit].b_actb = bp->b_actb;
+ sc->sc_tab.b_actb = bp->b_actb;
*bp->b_actb = dp;
biodone(bp);
- hpibfree(&sc->sc_dq);
- if (cttab[unit].b_actf == NULL) {
- cttab[unit].b_active = 0;
+ hpibfree(sc->sc_dev.dv_parent, &sc->sc_hq);
+ if (sc->sc_tab.b_actf == NULL) {
+ sc->sc_tab.b_active = 0;
return;
}
- ctustart(unit);
+ ctustart(sc);
}
int
@@ -824,9 +882,11 @@ ctwrite(dev, uio, flags)
}
/*ARGSUSED*/
+int
ctioctl(dev, cmd, data, flag, p)
dev_t dev;
- int cmd, flag;
+ u_long cmd;
+ int flag;
caddr_t data;
struct proc *p;
{
@@ -867,18 +927,23 @@ ctioctl(dev, cmd, data, flag, p)
return(0);
}
-/*ARGSUSED*/
-ctdump(dev)
+/* ARGSUSED */
+int
+ctdump(dev, blkno, va, size)
dev_t dev;
+ daddr_t blkno;
+ caddr_t va;
+ size_t size;
{
- return(ENXIO);
+
+ return (ENODEV);
}
-ctaddeof(unit)
- int unit;
+void
+ctaddeof(sc)
+ struct ct_softc *sc;
{
- register struct ct_softc *sc = &ct_softc[unit];
-
+
if (sc->sc_eofp == EOFS - 1)
sc->sc_eofs[EOFS - 1]++;
else {
@@ -892,8 +957,7 @@ ctaddeof(unit)
#ifdef DEBUG
if (ctdebug & CT_BSF)
printf("%s: add eof pos %d blk %d\n",
- sc->sc_hd->hp_xname, sc->sc_eofp,
+ sc->sc_dev.dv_xname, sc->sc_eofp,
sc->sc_eofs[sc->sc_eofp]);
#endif
}
-#endif
diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c
index 6d13a06bef3..4e0f6154699 100644
--- a/sys/arch/hp300/dev/dca.c
+++ b/sys/arch/hp300/dev/dca.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dca.c,v 1.6 1997/01/12 15:12:21 downsj Exp $ */
-/* $NetBSD: dca.c,v 1.31 1996/12/17 08:41:00 thorpej Exp $ */
+/* $OpenBSD: dca.c,v 1.7 1997/02/03 04:47:13 downsj Exp $ */
+/* $NetBSD: dca.c,v 1.32 1997/01/30 09:18:34 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
@@ -66,10 +66,6 @@
#include <dev/cons.h>
-#ifndef NEWCONFIG
-#include <hp300/dev/device.h>
-#endif
-
#include <hp300/dev/dioreg.h>
#include <hp300/dev/diovar.h>
#include <hp300/dev/diodevs.h>
@@ -78,9 +74,6 @@
struct dca_softc {
struct device sc_dev; /* generic device glue */
-#ifndef NEWCONFIG
- struct hp_device *sc_hd; /* device info */
-#endif
struct dcadevice *sc_dca; /* pointer to hardware */
struct tty *sc_tty; /* our tty instance */
int sc_oflows; /* overflow counter */
@@ -96,8 +89,7 @@ struct dca_softc {
};
-#ifdef NEWCONFIG
-int dcamatch __P((struct device *, struct cfdata *, void *));
+int dcamatch __P((struct device *, void *, void *));
void dcaattach __P((struct device *, struct device *, void *));
struct cfattach dca_ca = {
@@ -107,16 +99,6 @@ struct cfattach dca_ca = {
struct cfdriver dca_cd = {
NULL, "dca", DV_TTY
};
-#else /* ! NEWCONFIG */
-int dcamatch();
-void dcaattach();
-struct driver dcadriver = {
- dcamatch, dcaattach, "dca",
-};
-
-#include "dca.h"
-struct dca_softc dca_softc[NDCA];
-#endif /* NEWCONFIG */
void dcastart();
int dcaparam();
@@ -169,12 +151,10 @@ long dcamintcount[16];
void dcainit __P((struct dcadevice *, int));
-#ifdef NEWCONFIG
int
dcamatch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -188,28 +168,7 @@ dcamatch(parent, match, aux)
return (0);
}
-#else /* ! NEWCONFIG */
-int
-dcamatch(hd)
- register struct hp_device *hd;
-{
- struct dcadevice *dca = (struct dcadevice *)hd->hp_addr;
- struct dca_softc *sc = &dca_softc[hd->hp_unit];
- if (dca->dca_id != DCAID0 &&
- dca->dca_id != DCAREMID0 &&
- dca->dca_id != DCAID1 &&
- dca->dca_id != DCAREMID1)
- return (0);
-
- hd->hp_ipl = DCAIPL(dca->dca_ic);
- sc->sc_hd = hd;
-
- return (1);
-}
-#endif /* NEWCONFIG */
-
-#ifdef NEWCONFIG
void
dcaattach(parent, self, aux)
struct device *parent, *self;
@@ -221,17 +180,6 @@ dcaattach(parent, self, aux)
int unit = self->dv_unit;
int scode = da->da_scode;
int ipl;
-#else /* ! NEWCONFIG */
-void
-dcaattach(hd)
- register struct hp_device *hd;
-{
- int unit = hd->hp_unit;
- struct dcadevice *dca = (struct dcadevice *)hd->hp_addr;
- struct dca_softc *sc = &dca_softc[unit];
- int scode = hd->hp_args->hw_sc;
- int ipl = hd->hp_ipl;
-#endif /* NEWCONFIG */
if (scode == conscode) {
dca = (struct dcadevice *)conaddr;
@@ -244,7 +192,6 @@ dcaattach(hd)
*/
cn_tab->cn_dev = makedev(dcamajor, unit);
} else {
-#ifdef NEWCONFIG
dca = (struct dcadevice *)iomap(dio_scodetopa(da->da_scode),
da->da_size);
if (dca == NULL) {
@@ -252,19 +199,12 @@ dcaattach(hd)
sc->sc_dev.dv_xname);
return;
}
-#endif /* NEWCONFIG */
}
sc->sc_dca = dca;
-#ifdef NEWCONFIG
ipl = DIO_IPL(dca);
printf(" ipl %d", ipl);
-#else /* ! NEWCONFIG */
- /* XXX Set the device class. */
- hd->hp_dev.dv_class = DV_TTY;
- bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device));
-#endif /* NEWCONFIG */
dca->dca_reset = 0xFF;
DELAY(100);
@@ -280,11 +220,7 @@ dcaattach(hd)
(sc->sc_flags & DCA_HASFIFO) ? ISRPRI_TTY : ISRPRI_TTYNOBUF);
sc->sc_flags |= DCA_ACTIVE;
-#ifdef NEWCONFIG
if (self->dv_cfdata->cf_flags)
-#else
- if (hd->hp_flags)
-#endif
sc->sc_flags |= DCA_SOFTCAR;
/* Enable interrupts. */
@@ -342,15 +278,9 @@ dcaopen(dev, flag, mode, p)
u_char code;
int s, error = 0;
-#ifdef NEWCONFIG
if (unit >= dca_cd.cd_ndevs ||
(sc = dca_cd.cd_devs[unit]) == NULL)
return (ENXIO);
-#else
- if (unit >= NDCA)
- return (ENXIO);
- sc = &dca_softc[unit];
-#endif /* NEWCONFIG */
if ((sc->sc_flags & DCA_ACTIVE) == 0)
return (ENXIO);
@@ -445,11 +375,7 @@ dcaclose(dev, flag, mode, p)
unit = DCAUNIT(dev);
-#ifdef NEWCONFIG
sc = dca_cd.cd_devs[unit];
-#else
- sc = &dca_softc[unit];
-#endif
dca = sc->sc_dca;
tp = sc->sc_tty;
@@ -489,11 +415,7 @@ dcaread(dev, uio, flag)
struct tty *tp;
int error, of;
-#ifdef NEWCONFIG
sc = dca_cd.cd_devs[unit];
-#else
- sc = &dca_softc[unit];
-#endif
tp = sc->sc_tty;
of = sc->sc_oflows;
@@ -513,12 +435,8 @@ dcawrite(dev, uio, flag)
struct uio *uio;
int flag;
{
-#ifdef NEWCONFIG
struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)];
struct tty *tp = sc->sc_tty;
-#else
- struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty;
-#endif
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}
@@ -527,11 +445,7 @@ struct tty *
dcatty(dev)
dev_t dev;
{
-#ifdef NEWCONFIG
struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)];
-#else
- struct dca_softc *sc = &dca_softc[DCAUNIT(dev)];
-#endif
return (sc->sc_tty);
}
@@ -703,11 +617,7 @@ dcaioctl(dev, cmd, data, flag, p)
struct proc *p;
{
int unit = DCAUNIT(dev);
-#ifdef NEWCONFIG
struct dca_softc *sc = dca_cd.cd_devs[unit];
-#else
- struct dca_softc *sc = &dca_softc[unit];
-#endif
struct tty *tp = sc->sc_tty;
struct dcadevice *dca = sc->sc_dca;
int error;
@@ -796,11 +706,7 @@ dcaparam(tp, t)
register struct termios *t;
{
int unit = DCAUNIT(tp->t_dev);
-#ifdef NEWCONFIG
struct dca_softc *sc = dca_cd.cd_devs[unit];
-#else
- struct dca_softc *sc = &dca_softc[unit];
-#endif
struct dcadevice *dca = sc->sc_dca;
int cfcr, cflag = t->c_cflag;
int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab);
@@ -876,11 +782,7 @@ dcastart(tp)
register struct tty *tp;
{
int s, c, unit = DCAUNIT(tp->t_dev);
-#ifdef NEWCONFIG
struct dca_softc *sc = dca_cd.cd_devs[unit];
-#else
- struct dca_softc *sc = &dca_softc[unit];
-#endif
struct dcadevice *dca = sc->sc_dca;
s = spltty();
diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c
index 5f211ba768b..843b75e0626 100644
--- a/sys/arch/hp300/dev/dcm.c
+++ b/sys/arch/hp300/dev/dcm.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dcm.c,v 1.6 1997/01/12 15:12:22 downsj Exp $ */
-/* $NetBSD: dcm.c,v 1.34 1996/12/17 08:41:01 thorpej Exp $ */
+/* $OpenBSD: dcm.c,v 1.7 1997/02/03 04:47:15 downsj Exp $ */
+/* $NetBSD: dcm.c,v 1.35 1997/01/30 09:11:24 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
@@ -71,10 +71,6 @@
#include <dev/cons.h>
-#ifndef NEWCONFIG
-#include <hp300/dev/device.h>
-#endif
-
#include <hp300/dev/dioreg.h>
#include <hp300/dev/diovar.h>
#include <hp300/dev/diodevs.h>
@@ -224,9 +220,6 @@ static char iconv[16] = {
struct dcm_softc {
struct device sc_dev; /* generic device glue */
-#ifndef NEWCONFIG
- struct hp_device *sc_hd; /* device info */
-#endif
struct dcmdevice *sc_dcm; /* pointer to hardware */
struct tty *sc_tty[NDCMPORT]; /* our tty instances */
struct modemreg *sc_modem[NDCMPORT]; /* modem control */
@@ -254,8 +247,7 @@ struct dcm_softc {
#endif
};
-#ifdef NEWCONFIG
-int dcmmatch __P((struct device *, struct cfdata *, void *));
+int dcmmatch __P((struct device *, void *, void *));
void dcmattach __P((struct device *, struct device *, void *));
struct cfattach dcm_ca = {
@@ -265,17 +257,6 @@ struct cfattach dcm_ca = {
struct cfdriver dcm_cd = {
NULL, "dcm", DV_TTY
};
-#else /* ! NEWCONFIG */
-int dcmmatch();
-void dcmattach();
-
-struct driver dcmdriver = {
- dcmmatch, dcmattach, "dcm",
-};
-
-#include "dcm.h"
-struct dcm_softc dcm_softc[NDCM];
-#endif /* NEWCONFIG */
int dcmparam();
void dcmstart();
@@ -285,12 +266,10 @@ int dcmintr __P((void *));
int dcmselftest __P((struct dcm_softc *));
-#ifdef NEWCONFIG
int
dcmmatch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -302,23 +281,7 @@ dcmmatch(parent, match, aux)
return (0);
}
-#else /* ! NEWCONFIG */
-int
-dcmmatch(hd)
- register struct hp_device *hd;
-{
- struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
- struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr;
-
- if ((dcm->dcm_rsid & 0x1f) != DCMID)
- return (0);
-
- sc->sc_hd = hd;
- hd->hp_ipl = DCMIPL(dcm->dcm_ic);
-}
-#endif /* NEWCONFIG */
-#ifdef NEWCONFIG
void
dcmattach(parent, self, aux)
struct device *parent, *self;
@@ -330,17 +293,6 @@ dcmattach(parent, self, aux)
int brd = self->dv_unit;
int scode = da->da_scode;
int i, mbits, ipl;
-#else /* ! NEWCONFIG */
-void
-dcmattach(hd)
- register struct hp_device *hd;
-{
- struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
- struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr;
- int brd = hd->hp_unit;
- int scode = hd->hp_args->hw_sc;
- int i, mbits, ipl = hd->hp_ipl;
-#endif /* NEWCONFIG */
if (scode == conscode) {
dcm = (struct dcmdevice *)conaddr;
@@ -353,7 +305,6 @@ dcmattach(hd)
*/
cn_tab->cn_dev = makedev(dcmmajor, (brd << 2) | DCMCONSPORT);
} else {
-#ifdef NEWCONFIG
dcm = (struct dcmdevice *)iomap(dio_scodetopa(da->da_scode),
da->da_size);
if (dcm == NULL) {
@@ -361,19 +312,12 @@ dcmattach(hd)
sc->sc_dev.dv_xname);
return;
}
-#endif
}
sc->sc_dcm = dcm;
-#ifdef NEWCONFIG
ipl = DIO_IPL(dcm);
printf(" ipl %d", ipl);
-#else /* ! NEWCONFIG */
- /* XXX Set the device class. */
- hd->hp_dev.dv_class = DV_TTY;
- bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device));
-#endif /* NEWCONFIG */
if (dcmselftest(sc)) {
printf("\n%s: self-test failed\n", sc->sc_dev.dv_xname);
@@ -381,13 +325,8 @@ dcmattach(hd)
}
/* Extract configuration info from flags. */
-#ifdef NEWCONFIG
sc->sc_softCAR = self->dv_cfdata->cf_flags & DCM_SOFTCAR;
sc->sc_flags = self->dv_cfdata->cf_flags & DCM_FLAGMASK;
-#else
- sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR);
- sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK);
-#endif /* NEWCONFIG */
/* Mark our unit as configured. */
sc->sc_flags |= DCM_ACTIVE;
@@ -472,15 +411,9 @@ dcmopen(dev, flag, mode, p)
brd = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
if (brd >= dcm_cd.cd_ndevs || port >= NDCMPORT ||
(sc = dcm_cd.cd_devs[brd]) == NULL)
return (ENXIO);
-#else /* ! NEWCONFIG */
- if ((brd >= NDCM) || (port >= NDCMPORT))
- return (ENXIO);
- sc = &dcm_softc[brd];
-#endif /* NEWCONFIG */
if ((sc->sc_flags & DCM_ACTIVE) == 0)
return (ENXIO);
@@ -580,11 +513,7 @@ dcmclose(dev, flag, mode, p)
board = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
tp = sc->sc_tty[port];
(*linesw[tp->t_line].l_close)(tp, flag);
@@ -623,11 +552,7 @@ dcmread(dev, uio, flag)
board = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
tp = sc->sc_tty[port];
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
@@ -647,11 +572,7 @@ dcmwrite(dev, uio, flag)
board = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
tp = sc->sc_tty[port];
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
@@ -668,11 +589,7 @@ dcmtty(dev)
board = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
return (sc->sc_tty[port]);
}
@@ -965,11 +882,7 @@ dcmioctl(dev, cmd, data, flag, p)
port = DCMPORT(unit);
board = DCMBOARD(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
dcm = sc->sc_dcm;
tp = sc->sc_tty[port];
@@ -1084,11 +997,7 @@ dcmparam(tp, t)
board = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
dcm = sc->sc_dcm;
/* check requested parameters */
@@ -1175,11 +1084,7 @@ dcmstart(tp)
board = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[board];
-#else
- sc = &dcm_softc[board];
-#endif
dcm = sc->sc_dcm;
s = spltty();
@@ -1318,11 +1223,7 @@ dcmmctl(dev, bits, how)
brd = DCMBOARD(unit);
port = DCMPORT(unit);
-#ifdef NEWCONFIG
sc = dcm_cd.cd_devs[brd];
-#else
- sc = &dcm_softc[brd];
-#endif
dcm = sc->sc_dcm;
#ifdef DEBUG
@@ -1372,11 +1273,7 @@ dcmmctl(dev, bits, how)
dcmsetischeme(brd, flags)
int brd, flags;
{
-#ifdef NEWCONFIG
struct dcm_softc *sc = dcm_cd.cd_devs[brd];
-#else
- struct dcm_softc *sc = &dcm_softc[brd];
-#endif
struct dcmdevice *dcm = sc->sc_dcm;
struct dcmischeme *dis = &sc->sc_scheme;
int i;
@@ -1481,21 +1378,27 @@ dcmselftest(sc)
{
struct dcmdevice *dcm = sc->sc_dcm;
int i, timo = 0;
- int s, brd, mbits;
+ int s, brd, mbits, rv;
- s = spltty();
+ rv = 1;
+
+ s = splhigh();
dcm->dcm_rsid = DCMRS;
DELAY(50000); /* 5000 is not long enough */
dcm->dcm_rsid = 0;
dcm->dcm_ic = IC_IE;
dcm->dcm_cr = CR_SELFT;
- while ((dcm->dcm_ic & IC_IR) == 0)
+ while ((dcm->dcm_ic & IC_IR) == 0) {
if (++timo == 20000)
- return (1);
+ goto out;
+ DELAY(1);
+ }
DELAY(50000); /* XXX why is this needed ???? */
- while ((dcm->dcm_iir & IIR_SELFT) == 0)
+ while ((dcm->dcm_iir & IIR_SELFT) == 0) {
if (++timo == 400000)
- return (1);
+ goto out;
+ DELAY(1);
+ }
DELAY(50000); /* XXX why is this needed ???? */
if (dcm->dcm_stcon != ST_OK) {
#if 0
@@ -1503,12 +1406,14 @@ dcmselftest(sc)
printf("dcm%d: self test failed: %x\n",
brd, dcm->dcm_stcon);
#endif
- return (1);
+ goto out;
}
dcm->dcm_ic = IC_ID;
- splx(s);
+ rv = 0;
- return (0);
+ out:
+ splx(s);
+ return (rv);
}
/*
diff --git a/sys/arch/hp300/dev/device.h b/sys/arch/hp300/dev/device.h
deleted file mode 100644
index 32dee0bf48b..00000000000
--- a/sys/arch/hp300/dev/device.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/* $OpenBSD: device.h,v 1.4 1997/01/12 15:12:24 downsj Exp $ */
-/* $NetBSD: device.h,v 1.9 1996/10/20 23:47:40 thorpej Exp $ */
-
-/*
- * Copyright (c) 1982, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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.
- *
- * @(#)device.h 8.1 (Berkeley) 6/10/93
- */
-
-#include <sys/device.h>
-
-struct driver {
- int (*d_match)();
- void (*d_attach)();
- char *d_name;
- int (*d_start)();
- int (*d_go)();
- int (*d_intr)();
- int (*d_done)();
-};
-
-struct hp_hw {
- caddr_t hw_pa; /* physical address of control space */
- int hw_size; /* size of control space */
- caddr_t hw_kva; /* kernel virtual address of control space */
- short hw_id; /* HW returned id */
- short hw_secid; /* secondary HW id (displays) */
- short hw_type; /* type (defined below) */
- short hw_sc; /* select code (if applicable) */
-};
-
-struct hp_ctlr {
- struct driver *hp_driver;
- int hp_unit;
- int hp_alive;
- char *hp_addr;
- int hp_flags;
- int hp_ipl;
- struct hp_hw *hp_args;
- char hp_xname[8];
- struct device hp_dev;
-};
-
-struct hp_device {
- struct driver *hp_driver;
- struct driver *hp_cdriver;
- int hp_unit;
- int hp_ctlr;
- int hp_slave;
- char *hp_addr;
- int hp_dk;
- int hp_flags;
- int hp_alive;
- int hp_ipl;
- struct hp_hw *hp_args;
- struct device hp_dev;
-};
-
-/* XXX until the code is cleaed up */
-#define hp_xname hp_dev.dv_xname
-
-/* XXX This needs to die. */
-struct devqueue {
- struct devqueue *dq_forw;
- struct devqueue *dq_back;
- int dq_ctlr;
- int dq_unit;
- int dq_slave;
- void *dq_softc;
- struct driver *dq_driver;
-};
-
-#define MAXCTLRS 16 /* Size of HW table (arbitrary) */
-#define MAXSLAVES 8 /* Slaves per controller (HPIB/SCSI limit) */
-
-/* bus types */
-#define B_MASK 0xE000
-#define B_DIO 0x2000
-#define B_DIOII 0x4000
-#define B_VME 0x6000
-/* controller types */
-#define C_MASK 0x8F
-#define C_FLAG 0x80
-#define C_HPIB 0x81
-#define C_SCSI 0x82
-#define C_VME 0x83
-/* device types (controllers with no slaves) */
-#define D_MASK 0x8F
-#define D_BITMAP 0x01
-#define D_LAN 0x02
-#define D_FPA 0x03
-#define D_KEYBOARD 0x04
-#define D_COMMDCA 0x05
-#define D_COMMDCM 0x06
-#define D_COMMDCL 0x07
-#define D_PPORT 0x08
-#define D_MISC 0x7F
-
-#define HW_ISCTLR(hw) ((hw)->hw_type & C_FLAG)
-#define HW_ISDIOII(hw) ((hw)->hw_type & B_DIOII)
-#define HW_ISHPIB(hw) (((hw)->hw_type & C_MASK) == C_HPIB)
-#define HW_ISSCSI(hw) (((hw)->hw_type & C_MASK) == C_SCSI)
-#define HW_ISDEV(hw,d) (((hw)->hw_type & D_MASK) == (d))
-
-#ifdef _KERNEL
-#ifdef hp300
-extern struct hp_hw sc_table[];
-extern struct hp_ctlr hp_cinit[];
-extern struct hp_device hp_dinit[];
-extern caddr_t sctopa(), iomap();
-#endif
-#endif
diff --git a/sys/arch/hp300/dev/devlist2h.awk b/sys/arch/hp300/dev/devlist2h.awk
index db29dec28b9..0354a5fe0d1 100644
--- a/sys/arch/hp300/dev/devlist2h.awk
+++ b/sys/arch/hp300/dev/devlist2h.awk
@@ -1,7 +1,7 @@
#! /usr/bin/awk -f
#
-# $OpenBSD: devlist2h.awk,v 1.1 1997/01/12 15:12:24 downsj Exp $
-# $NetBSD: devlist2h.awk,v 1.1 1996/12/17 08:41:02 thorpej Exp $
+# $OpenBSD: devlist2h.awk,v 1.2 1997/02/03 04:47:16 downsj Exp $
+# $NetBSD: devlist2h.awk,v 1.2 1997/01/30 09:18:36 thorpej Exp $
#
# Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
# Copyright (c) 1995, 1996 Christopher G. Demetriou
diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c
index 4662dc685f9..4f6e3bcdc32 100644
--- a/sys/arch/hp300/dev/dio.c
+++ b/sys/arch/hp300/dev/dio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dio.c,v 1.2 1997/01/13 18:03:53 downsj Exp $ */
-/* $NetBSD: dio.c,v 1.1 1996/12/17 08:41:02 thorpej Exp $ */
+/* $OpenBSD: dio.c,v 1.3 1997/02/03 04:47:17 downsj Exp $ */
+/* $NetBSD: dio.c,v 1.3 1997/01/30 09:18:37 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -61,11 +61,10 @@ extern caddr_t internalhpib;
int dio_scodesize __P((struct dio_attach_args *));
char *dio_devinfo __P((struct dio_attach_args *, char *, size_t));
-#ifdef NEWCONFIG
-int diomatch __P((struct device *, struct cfdata *, void *));
+int diomatch __P((struct device *, void *, void *));
void dioattach __P((struct device *, struct device *, void *));
int dioprint __P((void *, const char *));
-int diosubmatch __P((struct device *, struct cfdata *, void *));
+int diosubmatch __P((struct device *, void *, void *));
struct cfattach dio_ca = {
sizeof(struct device), diomatch, dioattach
@@ -78,8 +77,7 @@ struct cfdriver dio_cd = {
int
diomatch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
static int dio_matched = 0;
@@ -164,11 +162,11 @@ dioattach(parent, self, aux)
}
int
-diosubmatch(parent, cf, aux)
+diosubmatch(parent, match, aux)
struct device *parent;
- struct cfdata *cf;
- void *aux;
+ void *match, *aux;
{
+ struct cfdata *cf = match;
struct dio_attach_args *da = aux;
if (cf->diocf_scode != DIO_UNKNOWN_SCODE &&
@@ -191,7 +189,6 @@ dioprint(aux, pnp)
printf(" scode %d", da->da_scode);
return (UNCONF);
}
-#endif /* NEWCONFIG */
/*
* Convert a select code to a system physical address.
@@ -207,7 +204,7 @@ dio_scodetopa(scode)
else if (DIO_ISDIO(scode))
rval = DIO_BASE + (scode * DIO_DEVSIZE);
else if (DIO_ISDIOII(scode))
- rval = DIOII_BASE + ((scode - 132) * DIOII_DEVSIZE);
+ rval = DIOII_BASE + ((scode - DIOII_SCBASE) * DIOII_DEVSIZE);
else
rval = 0;
diff --git a/sys/arch/hp300/dev/diodevs b/sys/arch/hp300/dev/diodevs
index 5df0b035ddd..0d36aa512e0 100644
--- a/sys/arch/hp300/dev/diodevs
+++ b/sys/arch/hp300/dev/diodevs
@@ -1,5 +1,5 @@
-$OpenBSD: diodevs,v 1.1 1997/01/12 15:12:25 downsj Exp $
-$NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp $
+$OpenBSD: diodevs,v 1.2 1997/02/03 04:47:18 downsj Exp $
+$NetBSD: diodevs,v 1.2 1997/01/30 09:18:38 thorpej Exp $
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
diff --git a/sys/arch/hp300/dev/diodevs.h b/sys/arch/hp300/dev/diodevs.h
index 297f4dda8aa..6f32981098c 100644
--- a/sys/arch/hp300/dev/diodevs.h
+++ b/sys/arch/hp300/dev/diodevs.h
@@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
- * NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp
+ * NetBSD: diodevs,v 1.2 1997/01/30 09:18:38 thorpej Exp
*/
/*-
diff --git a/sys/arch/hp300/dev/diodevs_data.h b/sys/arch/hp300/dev/diodevs_data.h
index 9ada75170fe..af82b96aef9 100644
--- a/sys/arch/hp300/dev/diodevs_data.h
+++ b/sys/arch/hp300/dev/diodevs_data.h
@@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
*
* generated from:
- * NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp
+ * NetBSD: diodevs,v 1.2 1997/01/30 09:18:38 thorpej Exp
*/
/*-
diff --git a/sys/arch/hp300/dev/dioreg.h b/sys/arch/hp300/dev/dioreg.h
index a5d096dbd5b..5d0d9a1efd9 100644
--- a/sys/arch/hp300/dev/dioreg.h
+++ b/sys/arch/hp300/dev/dioreg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: dioreg.h,v 1.1 1997/01/12 15:12:26 downsj Exp $ */
-/* $NetBSD: dioreg.h,v 1.1 1996/12/17 08:41:04 thorpej Exp $ */
+/* $OpenBSD: dioreg.h,v 1.2 1997/02/03 04:47:20 downsj Exp $ */
+/* $NetBSD: dioreg.h,v 1.3 1997/01/30 09:18:40 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -90,6 +90,11 @@
#define DIO_SCMAX(machineid) ((machineid) == HP_320 ? 32 : 256)
/*
+ * Base of DIO-II select codes.
+ */
+#define DIOII_SCBASE 132
+
+/*
* Macro that returns true if a select code lies within
* the select code `hole'.
*/
@@ -99,7 +104,7 @@
* Macros to determine if device is DIO or DIO-II.
*/
#define DIO_ISDIO(scode) ((scode) >= 0 && (scode) < 32)
-#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
+#define DIO_ISDIOII(scode) ((scode) >= DIOII_SCBASE && (scode) < 256)
/*
* Macro to determine if device is a framebuffer, given the
diff --git a/sys/arch/hp300/dev/diovar.h b/sys/arch/hp300/dev/diovar.h
index d2c22432c17..555cb0b4924 100644
--- a/sys/arch/hp300/dev/diovar.h
+++ b/sys/arch/hp300/dev/diovar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: diovar.h,v 1.1 1997/01/12 15:12:27 downsj Exp $ */
-/* $NetBSD: diovar.h,v 1.1 1996/12/17 08:41:05 thorpej Exp $ */
+/* $OpenBSD: diovar.h,v 1.2 1997/02/03 04:47:21 downsj Exp $ */
+/* $NetBSD: diovar.h,v 1.2 1997/01/30 09:18:41 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c
index ebfa5901534..fb0e25179c1 100644
--- a/sys/arch/hp300/dev/dma.c
+++ b/sys/arch/hp300/dev/dma.c
@@ -1,8 +1,9 @@
-/* $OpenBSD: dma.c,v 1.4 1997/01/12 15:12:28 downsj Exp $ */
-/* $NetBSD: dma.c,v 1.10 1996/12/09 03:09:51 thorpej Exp $ */
+/* $OpenBSD: dma.c,v 1.5 1997/02/03 04:47:22 downsj Exp $ */
+/* $NetBSD: dma.c,v 1.11 1997/01/30 09:04:33 thorpej Exp $ */
/*
- * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
+ * Copyright (c) 1995, 1996, 1997
+ * Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -46,17 +47,15 @@
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/proc.h>
+#include <sys/device.h>
#include <machine/cpu.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/dmareg.h>
#include <hp300/dev/dmavar.h>
#include <hp300/hp300/isr.h>
-extern void _insque();
-extern void _remque();
extern u_int kvtop();
extern void PCIA();
@@ -74,13 +73,14 @@ struct dma_chain {
};
struct dma_channel {
+ struct dmaqueue *dm_job; /* current job */
struct dma_softc *dm_softc; /* pointer back to softc */
struct dmadevice *dm_hwaddr; /* registers if DMA_C */
struct dmaBdevice *dm_Bhwaddr; /* registers if not DMA_C */
char dm_flags; /* misc. flags */
u_short dm_cmd; /* DMA controller command */
- struct dma_chain *dm_cur; /* current segment */
- struct dma_chain *dm_last; /* last segment */
+ int dm_cur; /* current segment */
+ int dm_last; /* last segment */
struct dma_chain dm_chain[DMAMAXIO]; /* all segments */
};
@@ -88,6 +88,7 @@ struct dma_softc {
char *sc_xname; /* XXX external name */
struct dmareg *sc_dmareg; /* pointer to our hardware */
struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */
+ TAILQ_HEAD(, dmaqueue) sc_queue; /* job queue */
char sc_type; /* A, B, or C */
int sc_ipl; /* our interrupt level */
void *sc_ih; /* interrupt cookie */
@@ -102,7 +103,6 @@ struct dma_softc {
#define DMAF_VCFLUSH 0x02
#define DMAF_NOINTR 0x04
-struct devqueue dmachan[NDMACHAN + 1];
int dmaintr __P((void *));
#ifdef DEBUG
@@ -154,9 +154,12 @@ dmainit()
sc->sc_type = (rev == 'B') ? DMA_B : DMA_C;
+ TAILQ_INIT(&sc->sc_queue);
+
for (i = 0; i < NDMACHAN; i++) {
dc = &sc->sc_chan[i];
dc->dm_softc = sc;
+ dc->dm_job = NULL;
switch (i) {
case 0:
dc->dm_hwaddr = &dma->dma_chan0;
@@ -172,9 +175,8 @@ dmainit()
panic("dmainit: more than 2 channels?");
/* NOTREACHED */
}
- dmachan[i].dq_forw = dmachan[i].dq_back = &dmachan[i];
}
- dmachan[i].dq_forw = dmachan[i].dq_back = &dmachan[i];
+
#ifdef DEBUG
/* make sure timeout is really not needed */
timeout(dmatimeout, sc, 30 * hz);
@@ -212,43 +214,68 @@ dmacomputeipl()
int
dmareq(dq)
- register struct devqueue *dq;
+ struct dmaqueue *dq;
{
- register int i;
- register int chan;
- register int s = splbio();
+ struct dma_softc *sc = &Dma_softc;
+ int i, chan, s;
+
+#if 1
+ s = splhigh(); /* XXXthorpej */
+#else
+ s = splbio();
+#endif
- chan = dq->dq_ctlr;
- i = NDMACHAN;
- while (--i >= 0) {
+ chan = dq->dq_chan;
+ for (i = NDMACHAN - 1; i >= 0; i--) {
+ /*
+ * Can we use this channel?
+ */
if ((chan & (1 << i)) == 0)
continue;
- if (dmachan[i].dq_forw != &dmachan[i])
+
+ /*
+ * We can use it; is it busy?
+ */
+ if (sc->sc_chan[i].dm_job != NULL)
continue;
- insque(dq, &dmachan[i]);
- dq->dq_ctlr = i;
+
+ /*
+ * Not busy; give the caller this channel.
+ */
+ sc->sc_chan[i].dm_job = dq;
+ dq->dq_chan = i;
splx(s);
- return(1);
+ return (1);
}
- insque(dq, dmachan[NDMACHAN].dq_back);
+
+ /*
+ * Couldn't get a channel now; put this in the queue.
+ */
+ TAILQ_INSERT_TAIL(&sc->sc_queue, dq, dq_list);
splx(s);
- return(0);
+ return (0);
}
void
dmafree(dq)
- register struct devqueue *dq;
+ struct dmaqueue *dq;
{
- int unit = dq->dq_ctlr;
+ int unit = dq->dq_chan;
struct dma_softc *sc = &Dma_softc;
- register struct dma_channel *dc = &sc->sc_chan[unit];
- register struct devqueue *dn;
- register int chan, s;
+ struct dma_channel *dc = &sc->sc_chan[unit];
+ struct dmaqueue *dn;
+ int chan, s;
+#if 1
+ s = splhigh(); /* XXXthorpej */
+#else
s = splbio();
+#endif
+
#ifdef DEBUG
dmatimo[unit] = 0;
#endif
+
DMA_CLEAR(dc);
#if defined(HP360) || defined(HP370) || defined(HP380)
/*
@@ -274,16 +301,23 @@ dmafree(dq)
dc->dm_flags &= ~DMAF_VCFLUSH;
}
#endif
- remque(dq);
+ /*
+ * Channel is now free. Look for another job to run on this
+ * channel.
+ */
+ dc->dm_job = NULL;
chan = 1 << unit;
- for (dn = dmachan[NDMACHAN].dq_forw;
- dn != &dmachan[NDMACHAN]; dn = dn->dq_forw) {
- if (dn->dq_ctlr & chan) {
- remque((caddr_t)dn);
- insque((caddr_t)dn, (caddr_t)dq->dq_back);
+ for (dn = sc->sc_queue.tqh_first; dn != NULL;
+ dn = dn->dq_list.tqe_next) {
+ if (dn->dq_chan & chan) {
+ /* Found one... */
+ TAILQ_REMOVE(&sc->sc_queue, dn, dq_list);
+ dc->dm_job = dn;
+ dn->dq_chan = dq->dq_chan;
splx(s);
- dn->dq_ctlr = dq->dq_ctlr;
- (dn->dq_driver->d_start)(dn->dq_unit);
+
+ /* Start the initiator. */
+ (*dn->dq_start)(dn->dq_softc);
return;
}
}
@@ -299,9 +333,8 @@ dmago(unit, addr, count, flags)
{
struct dma_softc *sc = &Dma_softc;
register struct dma_channel *dc = &sc->sc_chan[unit];
- register struct dma_chain *dcp;
register char *dmaend = NULL;
- register int tcount;
+ register int seg, tcount;
if (count > MAXPHYS)
panic("dmago: count > MAXPHYS");
@@ -323,46 +356,52 @@ dmago(unit, addr, count, flags)
/*
* Build the DMA chain
*/
- for (dcp = dc->dm_chain; count > 0; dcp++) {
- dcp->dc_addr = (char *) kvtop(addr);
+ for (seg = 0; count > 0; seg++) {
+ dc->dm_chain[seg].dc_addr = (char *) kvtop(addr);
#if defined(HP380)
/*
* Push back dirty cache lines
*/
if (mmutype == MMU_68040)
- DCFP(dcp->dc_addr);
+ DCFP(dc->dm_chain[seg].dc_addr);
#endif
if (count < (tcount = NBPG - ((int)addr & PGOFSET)))
tcount = count;
- dcp->dc_count = tcount;
+ dc->dm_chain[seg].dc_count = tcount;
addr += tcount;
count -= tcount;
if (flags & DMAGO_LWORD)
tcount >>= 2;
else if (flags & DMAGO_WORD)
tcount >>= 1;
- if (dcp->dc_addr == dmaend
+
+ /*
+ * Try to compact the DMA transfer if the pages are adjacent.
+ * Note: this will never happen on the first iteration.
+ */
+ if (dc->dm_chain[seg].dc_addr == dmaend
#if defined(HP320)
/* only 16-bit count on 98620B */
&& (sc->sc_type != DMA_B ||
- (dcp-1)->dc_count + tcount <= 65536)
+ dc->dm_chain[seg - 1].dc_count + tcount <= 65536)
#endif
) {
#ifdef DEBUG
dmahits[unit]++;
#endif
- dmaend += dcp->dc_count;
- (--dcp)->dc_count += tcount;
+ dmaend += dc->dm_chain[seg].dc_count;
+ dc->dm_chain[--seg].dc_count += tcount;
} else {
#ifdef DEBUG
dmamisses[unit]++;
#endif
- dmaend = dcp->dc_addr + dcp->dc_count;
- dcp->dc_count = tcount;
+ dmaend = dc->dm_chain[seg].dc_addr +
+ dc->dm_chain[seg].dc_count;
+ dc->dm_chain[seg].dc_count = tcount;
}
}
- dc->dm_cur = dc->dm_chain;
- dc->dm_last = --dcp;
+ dc->dm_cur = 0;
+ dc->dm_last = --seg;
dc->dm_flags = 0;
/*
* Set up the command word based on flags
@@ -410,15 +449,17 @@ dmago(unit, addr, count, flags)
dc->dm_flags |= DMAF_NOINTR;
}
#ifdef DEBUG
- if (dmadebug & DDB_IO)
+ if (dmadebug & DDB_IO) {
if ((dmadebug&DDB_WORD) && (dc->dm_cmd&DMA_WORD) ||
(dmadebug&DDB_LWORD) && (dc->dm_cmd&DMA_LWORD)) {
printf("dmago: cmd %x, flags %x\n",
dc->dm_cmd, dc->dm_flags);
- for (dcp = dc->dm_chain; dcp <= dc->dm_last; dcp++)
- printf(" %d: %d@%x\n", dcp-dc->dm_chain,
- dcp->dc_count, dcp->dc_addr);
+ for (seg = 0; seg <= dc->dm_last; seg++)
+ printf(" %d: %d@%x\n", seg,
+ dc->dm_chain[seg].dc_count,
+ dc->dm_chain[seg].dc_addr);
}
+ }
dmatimo[unit] = 1;
#endif
DMA_ARM(dc);
@@ -430,7 +471,7 @@ dmastop(unit)
{
struct dma_softc *sc = &Dma_softc;
register struct dma_channel *dc = &sc->sc_chan[unit];
- register struct devqueue *dq;
+ struct dmaqueue *dq;
#ifdef DEBUG
if (dmadebug & DDB_FOLLOW)
@@ -464,9 +505,8 @@ dmastop(unit)
* has freed the dma channel. So, ignore the intr if there's
* nothing on the queue.
*/
- dq = dmachan[unit].dq_forw;
- if (dq != &dmachan[unit])
- (dq->dq_driver->d_done)(dq->dq_unit);
+ if (dc->dm_job != NULL)
+ (*dc->dm_job->dq_done)(dc->dm_job->dq_softc);
}
int
@@ -492,19 +532,24 @@ dmaintr(arg)
if (dmadebug & DDB_IO) {
if ((dmadebug&DDB_WORD) && (dc->dm_cmd&DMA_WORD) ||
(dmadebug&DDB_LWORD) && (dc->dm_cmd&DMA_LWORD))
- printf("dmaintr: unit %d stat %x next %d\n",
- i, stat, (dc->dm_cur-dc->dm_chain)+1);
+ printf("dmaintr: flags %x unit %d stat %x next %d\n",
+ dc->dm_flags, i, stat, dc->dm_cur + 1);
}
if (stat & DMA_ARMED)
printf("%s, chan %d: intr when armed\n",
sc->sc_xname, i);
#endif
- if (++dc->dm_cur <= dc->dm_last) {
+ /*
+ * Load the next segemnt, or finish up if we're done.
+ */
+ dc->dm_cur++;
+ if (dc->dm_cur <= dc->dm_last) {
#ifdef DEBUG
dmatimo[i] = 1;
#endif
/*
- * Last chain segment, disable DMA interrupt.
+ * If we're the last segment, disable the
+ * completion interrupt, if necessary.
*/
if (dc->dm_cur == dc->dm_last &&
(dc->dm_flags & DMAF_NOINTR))
@@ -529,8 +574,8 @@ dmatimeout(arg)
s = splbio();
if (dmatimo[i]) {
if (dmatimo[i] > 1)
- printf("%s: timeout #%d\n", sc->sc_xname,
- i, dmatimo[i]-1);
+ printf("%s: chan %d timeout #%d\n",
+ sc->sc_xname, i, dmatimo[i]-1);
dmatimo[i]++;
}
splx(s);
diff --git a/sys/arch/hp300/dev/dmareg.h b/sys/arch/hp300/dev/dmareg.h
index 1e94ae6c069..96f9741dbce 100644
--- a/sys/arch/hp300/dev/dmareg.h
+++ b/sys/arch/hp300/dev/dmareg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: dmareg.h,v 1.3 1997/01/12 15:12:28 downsj Exp $ */
-/* $NetBSD: dmareg.h,v 1.7 1996/12/09 06:18:13 thorpej Exp $ */
+/* $OpenBSD: dmareg.h,v 1.4 1997/02/03 04:47:22 downsj Exp $ */
+/* $NetBSD: dmareg.h,v 1.8 1997/01/30 09:04:34 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -116,21 +116,21 @@ struct dmareg {
#define DMA_ARM(dc) \
if (dc->dm_softc->sc_type == DMA_B) { \
register struct dmaBdevice *dma = dc->dm_Bhwaddr; \
- dma->dmaB_addr = dc->dm_cur->dc_addr; \
- dma->dmaB_count = dc->dm_cur->dc_count - 1; \
+ dma->dmaB_addr = dc->dm_chain[dc->dm_cur].dc_addr; \
+ dma->dmaB_count = dc->dm_chain[dc->dm_cur].dc_count - 1; \
dma->dmaB_cmd = dc->dm_cmd; \
} else { \
register struct dmadevice *dma = dc->dm_hwaddr; \
- dma->dma_addr = dc->dm_cur->dc_addr; \
- dma->dma_count = dc->dm_cur->dc_count - 1; \
+ dma->dma_addr = dc->dm_chain[dc->dm_cur].dc_addr; \
+ dma->dma_count = dc->dm_chain[dc->dm_cur].dc_count - 1; \
dma->dma_cmd = dc->dm_cmd; \
}
#else
#define DMA_ARM(dc) \
{ \
register struct dmadevice *dma = dc->dm_hwaddr; \
- dma->dma_addr = dc->dm_cur->dc_addr; \
- dma->dma_count = dc->dm_cur->dc_count - 1; \
+ dma->dma_addr = dc->dm_chain[dc->dm_cur].dc_addr; \
+ dma->dma_count = dc->dm_chain[dc->dm_cur].dc_count - 1; \
dma->dma_cmd = dc->dm_cmd; \
}
#endif
diff --git a/sys/arch/hp300/dev/dmavar.h b/sys/arch/hp300/dev/dmavar.h
index cd814185f6e..844e68a6ea3 100644
--- a/sys/arch/hp300/dev/dmavar.h
+++ b/sys/arch/hp300/dev/dmavar.h
@@ -1,7 +1,8 @@
-/* $OpenBSD: dmavar.h,v 1.2 1997/01/12 15:12:29 downsj Exp $ */
-/* $NetBSD: dmavar.h,v 1.6 1996/12/09 03:09:51 thorpej Exp $ */
+/* $OpenBSD: dmavar.h,v 1.3 1997/02/03 04:47:23 downsj Exp $ */
+/* $NetBSD: dmavar.h,v 1.7 1997/01/30 09:04:35 thorpej Exp $ */
/*
+ * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -36,6 +37,8 @@
* @(#)dmavar.h 8.1 (Berkeley) 6/10/93
*/
+#include <sys/queue.h>
+
/* dmago flags */
#define DMAGO_BYTE 0x00 /* do byte (8 bit) transfers */
#define DMAGO_WORD 0x01 /* do word (16 bit) transfers */
@@ -48,6 +51,24 @@
#define DMA0 0x1
#define DMA1 0x2
+/*
+ * A DMA queue entry. Initiator drivers each have one of these,
+ * used to queue access to the DMA controller.
+ */
+struct dmaqueue {
+ TAILQ_ENTRY(dmaqueue) dq_list; /* entry on the queue */
+ int dq_chan; /* OR of channels initiator can use */
+ void *dq_softc; /* initiator's softc */
+
+ /*
+ * These functions are called to start the initiator when
+ * it has been given the DMA controller, and to stop the
+ * initiator when the DMA controller has stopped.
+ */
+ void (*dq_start) __P((void *));
+ void (*dq_done) __P((void *));
+};
+
#ifdef _KERNEL
extern void dmago(), dmafree();
extern int dmareq();
diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c
index af421d6f542..e695517123e 100644
--- a/sys/arch/hp300/dev/fhpib.c
+++ b/sys/arch/hp300/dev/fhpib.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: fhpib.c,v 1.5 1997/01/12 15:12:29 downsj Exp $ */
-/* $NetBSD: fhpib.c,v 1.13 1996/10/13 03:14:10 christos Exp $ */
+/* $OpenBSD: fhpib.c,v 1.6 1997/02/03 04:47:24 downsj Exp $ */
+/* $NetBSD: fhpib.c,v 1.14 1997/01/30 09:06:53 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -39,18 +40,25 @@
/*
* 98625A/B HPIB driver
*/
-#include "hpib.h"
-#if NHPIB > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/buf.h>
+#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>
-#include <hp300/dev/device.h>
#include <hp300/dev/fhpibreg.h>
#include <hp300/dev/hpibvar.h>
-#include <hp300/dev/dmavar.h>
/*
* Inline version of fhpibwait to be used in places where
@@ -70,23 +78,19 @@ int dopriodma = 0; /* use high priority DMA */
int doworddma = 1; /* non-zero if we should attempt word dma */
int doppollint = 1; /* use ppoll interrupts instead of watchdog */
int fhpibppolldelay = 50;
-
-long fhpibbadint[2] = { 0 };
-long fhpibtransfer[NHPIB] = { 0 };
-long fhpibnondma[NHPIB] = { 0 };
-long fhpibworddma[NHPIB] = { 0 };
-long fhpibppollfail[NHPIB] = { 0 };
#endif
-int fhpibcmd[NHPIB];
+void fhpibifc __P((struct fhpibdevice *));
+void fhpibdmadone __P((void *));
+int fhpibwait __P((struct fhpibdevice *, int));
-void fhpibreset __P((int));
-int fhpibsend __P((int, int, int, void *, int));
-int fhpibrecv __P((int, int, int, void *, int));
-int fhpibppoll __P((int));
+void fhpibreset __P((struct hpibbus_softc *));
+int fhpibsend __P((struct hpibbus_softc *, int, int, void *, int));
+int fhpibrecv __P((struct hpibbus_softc *, int, int, void *, int));
+int fhpibppoll __P((struct hpibbus_softc *));
void fhpibppwatch __P((void *));
-void fhpibgo __P((int, int, int, void *, int, int, int));
-void fhpibdone __P((int));
+void fhpibgo __P((struct hpibbus_softc *, int, int, void *, int, int, int));
+void fhpibdone __P((struct hpibbus_softc *));
int fhpibintr __P((void *));
/*
@@ -103,45 +107,75 @@ struct hpib_controller fhpib_controller = {
fhpibintr
};
+struct fhpib_softc {
+ struct device sc_dev; /* generic device glue */
+ struct fhpibdevice *sc_regs; /* device registers */
+ int sc_cmd;
+ struct hpibbus_softc *sc_hpibbus; /* XXX */
+};
+
+int fhpibmatch __P((struct device *, void *, void *));
+void fhpibattach __P((struct device *, struct device *, void *));
+
+struct cfattach fhpib_ca = {
+ sizeof(struct fhpib_softc), fhpibmatch, fhpibattach
+};
+
+struct cfdriver fhpib_cd = {
+ NULL, "fhpib", DV_DULL
+};
+
int
-fhpibtype(hc)
- register struct hp_ctlr *hc;
+fhpibmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
- register struct fhpibdevice *hd = (struct fhpibdevice *)hc->hp_addr;
+ struct dio_attach_args *da = aux;
- if (hd->hpib_cid != HPIBC)
- return (0);
+ if (da->da_id == DIO_DEVICE_ID_FHPIB)
+ return (1);
- hs->sc_type = HPIBC;
- hc->hp_ipl = HPIB_IPL(hd->hpib_ids);
-
- return (1);
+ return (0);
}
void
-fhpibattach(hc)
- struct hp_ctlr *hc;
+fhpibattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- register struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
+ struct fhpib_softc *sc = (struct fhpib_softc *)self;
+ struct dio_attach_args *da = aux;
+ struct hpibdev_attach_args ha;
+ int ipl;
+
+ sc->sc_regs = (struct fhpibdevice *)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;
+ }
+
+ ipl = DIO_IPL(sc->sc_regs);
+ printf(" ipl %d: %s\n", ipl, DIO_DEVICE_DESC_FHPIB);
- if (hs->sc_type != HPIBC)
- panic("fhpibattach: unknown type 0x%x", hs->sc_type);
- /* NOTREACHED */
+ /* Establish the interrupt handler. */
+ (void) isrlink(fhpibintr, sc, ipl, ISRPRI_BIO);
+ dmacomputeipl();
- hs->sc_ba = HPIBC_BA;
- hs->sc_descrip = "98625A or 98625B fast HP-IB";
- hs->sc_controller = &fhpib_controller;
+ ha.ha_ops = &fhpib_controller;
+ ha.ha_type = HPIBC; /* XXX */
+ ha.ha_ba = HPIBC_BA;
+ ha.ha_softcpp = &sc->sc_hpibbus; /* XXX */
+ (void)config_found(self, &ha, hpibdevprint);
}
void
-fhpibreset(unit)
- int unit;
+fhpibreset(hs)
+ struct hpibbus_softc *hs;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct fhpibdevice *hd;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ struct fhpibdevice *hd = sc->sc_regs;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_cid = 0xFF;
DELAY(100);
hd->hpib_cmd = CT_8BIT;
@@ -160,12 +194,14 @@ fhpibreset(unit)
hs->sc_flags |= HPIBF_DMA16;
#ifdef DEBUG
if (fhpibdebug & FDB_DMA)
- printf("fhpibtype: unit %d has word dma\n", unit);
+ printf("fhpibtype: %s has word dma\n",
+ sc->sc_dev.dv_xname);
#endif
}
}
+void
fhpibifc(hd)
register struct fhpibdevice *hd;
{
@@ -178,17 +214,17 @@ fhpibifc(hd)
}
int
-fhpibsend(unit, slave, sec, ptr, origcnt)
- int unit, slave, sec, origcnt;
+fhpibsend(hs, slave, sec, ptr, origcnt)
+ struct hpibbus_softc *hs;
+ int slave, sec, origcnt;
void *ptr;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct fhpibdevice *hd;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ struct fhpibdevice *hd = sc->sc_regs;
register int cnt = origcnt;
register int timo;
char *addr = ptr;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_stat = 0;
hd->hpib_imask = IM_IDLE | IM_ROOM;
if (fhpibwait(hd, IM_IDLE) < 0)
@@ -234,7 +270,7 @@ senderr:
#ifdef DEBUG
if (fhpibdebug & FDB_FAIL) {
printf("%s: fhpibsend failed: slave %d, sec %x, ",
- hs->sc_hc->hp_xname, slave, sec);
+ sc->sc_dev.dv_xname, slave, sec);
printf("sent %d of %d bytes\n", origcnt-cnt-1, origcnt);
}
#endif
@@ -242,17 +278,17 @@ senderr:
}
int
-fhpibrecv(unit, slave, sec, ptr, origcnt)
- int unit, slave, sec, origcnt;
+fhpibrecv(hs, slave, sec, ptr, origcnt)
+ struct hpibbus_softc *hs;
+ int slave, sec, origcnt;
void *ptr;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct fhpibdevice *hd;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ struct fhpibdevice *hd = sc->sc_regs;
register int cnt = origcnt;
register int timo;
char *addr = ptr;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
/*
* Slave < 0 implies continuation of a previous receive
* that probably timed out.
@@ -298,7 +334,7 @@ recvbyteserror:
#ifdef DEBUG
if (fhpibdebug & FDB_FAIL) {
printf("%s: fhpibrecv failed: slave %d, sec %x, ",
- hs->sc_hc->hp_xname, slave, sec);
+ sc->sc_dev.dv_xname, slave, sec);
printf("got %d of %d bytes\n", origcnt-cnt-1, origcnt);
}
#endif
@@ -306,17 +342,17 @@ recvbyteserror:
}
void
-fhpibgo(unit, slave, sec, ptr, count, rw, timo)
- int unit, slave, sec, count, rw, timo;
+fhpibgo(hs, slave, sec, ptr, count, rw, timo)
+ struct hpibbus_softc *hs;
+ int slave, sec, count, rw, timo;
void *ptr;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct fhpibdevice *hd;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ register struct fhpibdevice *hd = sc->sc_regs;
register int i;
char *addr = ptr;
int flags = 0;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
hs->sc_flags |= HPIBF_IO;
if (timo)
hs->sc_flags |= HPIBF_TIMO;
@@ -331,7 +367,7 @@ fhpibgo(unit, slave, sec, ptr, count, rw, timo)
hs->sc_count = count;
hs->sc_addr = addr;
#ifdef DEBUG
- fhpibtransfer[unit]++;
+ /* fhpibtransfer[unit]++; XXX */
#endif
if ((hs->sc_flags & HPIBF_DMA16) &&
((int)addr & 1) == 0 && count && (count & 1) == 0
@@ -340,7 +376,7 @@ fhpibgo(unit, slave, sec, ptr, count, rw, timo)
#endif
) {
#ifdef DEBUG
- fhpibworddma[unit]++;
+ /* fhpibworddma[unit]++; XXX */
#endif
flags |= DMAGO_WORD;
hd->hpib_latch = 0;
@@ -350,45 +386,45 @@ fhpibgo(unit, slave, sec, ptr, count, rw, timo)
flags |= DMAGO_PRI;
#endif
if (hs->sc_flags & HPIBF_READ) {
- fhpibcmd[unit] = CT_REN | CT_8BIT;
+ sc->sc_cmd = CT_REN | CT_8BIT;
hs->sc_curcnt = count;
- dmago(hs->sc_dq.dq_ctlr, addr, count, flags|DMAGO_READ);
- if (fhpibrecv(unit, slave, sec, 0, 0) < 0) {
+ dmago(hs->sc_dq->dq_chan, addr, count, flags|DMAGO_READ);
+ if (fhpibrecv(hs, slave, sec, 0, 0) < 0) {
#ifdef DEBUG
printf("fhpibgo: recv failed, retrying...\n");
#endif
- (void) fhpibrecv(unit, slave, sec, 0, 0);
+ (void) fhpibrecv(hs, slave, sec, 0, 0);
}
i = hd->hpib_cmd;
- hd->hpib_cmd = fhpibcmd[unit];
- hd->hpib_ie = IDS_DMA(hs->sc_dq.dq_ctlr) |
+ hd->hpib_cmd = sc->sc_cmd;
+ hd->hpib_ie = IDS_DMA(hs->sc_dq->dq_chan) |
((flags & DMAGO_WORD) ? IDS_WDMA : 0);
return;
}
- fhpibcmd[unit] = CT_REN | CT_8BIT | CT_FIFOSEL;
+ sc->sc_cmd = CT_REN | CT_8BIT | CT_FIFOSEL;
if (count < hpibdmathresh) {
#ifdef DEBUG
- fhpibnondma[unit]++;
+ /* fhpibnondma[unit]++; XXX */
if (flags & DMAGO_WORD)
- fhpibworddma[unit]--;
+ /* fhpibworddma[unit]--; XXX */ ;
#endif
hs->sc_curcnt = count;
- (void) fhpibsend(unit, slave, sec, addr, count);
- fhpibdone(unit);
+ (void) fhpibsend(hs, slave, sec, addr, count);
+ fhpibdone(hs);
return;
}
count -= (flags & DMAGO_WORD) ? 2 : 1;
hs->sc_curcnt = count;
- dmago(hs->sc_dq.dq_ctlr, addr, count, flags);
- if (fhpibsend(unit, slave, sec, 0, 0) < 0) {
+ dmago(hs->sc_dq->dq_chan, addr, count, flags);
+ if (fhpibsend(hs, slave, sec, 0, 0) < 0) {
#ifdef DEBUG
printf("fhpibgo: send failed, retrying...\n");
#endif
- (void) fhpibsend(unit, slave, sec, 0, 0);
+ (void) fhpibsend(hs, slave, sec, 0, 0);
}
i = hd->hpib_cmd;
- hd->hpib_cmd = fhpibcmd[unit];
- hd->hpib_ie = IDS_DMA(hs->sc_dq.dq_ctlr) | IDS_WRITE |
+ hd->hpib_cmd = sc->sc_cmd;
+ hd->hpib_ie = IDS_DMA(hs->sc_dq->dq_chan) | IDS_WRITE |
((flags & DMAGO_WORD) ? IDS_WDMA : 0);
}
@@ -402,17 +438,14 @@ void
fhpibdmadone(arg)
void *arg;
{
- register int unit;
- register struct hpib_softc *hs;
+ register struct hpibbus_softc *hs = arg;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
int s = splbio();
- unit = (int)arg;
- hs = &hpib_softc[unit];
if (hs->sc_flags & HPIBF_IO) {
- register struct fhpibdevice *hd;
- register struct devqueue *dq;
+ register struct fhpibdevice *hd = sc->sc_regs;
+ register struct hpibqueue *hq;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_imask = 0;
hd->hpib_cid = 0xFF;
DELAY(100);
@@ -421,23 +454,23 @@ fhpibdmadone(arg)
fhpibifc(hd);
hd->hpib_ie = IDS_IE;
hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO);
- dmafree(&hs->sc_dq);
- dq = hs->sc_sq.dq_forw;
- (dq->dq_driver->d_intr)(dq->dq_softc);
+ dmafree(hs->sc_dq);
+
+ hq = hs->sc_queue.tqh_first;
+ (hq->hq_intr)(hq->hq_softc);
}
- (void) splx(s);
+ splx(s);
}
void
-fhpibdone(unit)
- int unit;
+fhpibdone(hs)
+ struct hpibbus_softc *hs;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct fhpibdevice *hd;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ register struct fhpibdevice *hd = sc->sc_regs;
register char *addr;
register int cnt;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
cnt = hs->sc_curcnt;
hs->sc_addr += cnt;
hs->sc_count -= cnt;
@@ -449,7 +482,7 @@ fhpibdone(unit)
if (hs->sc_flags & HPIBF_READ) {
hd->hpib_imask = IM_IDLE | IM_BYTE;
if (hs->sc_flags & HPIBF_TIMO)
- timeout(fhpibdmadone, (void *)unit, hz >> 2);
+ timeout(fhpibdmadone, hs, hz >> 2);
} else {
cnt = hs->sc_count;
if (cnt) {
@@ -475,26 +508,26 @@ int
fhpibintr(arg)
void *arg;
{
- register struct hpib_softc *hs = arg;
- register struct fhpibdevice *hd;
- register struct devqueue *dq;
- register int stat0, unit = hs->sc_hc->hp_unit;
+ struct fhpib_softc *sc = arg;
+ register struct hpibbus_softc *hs = sc->sc_hpibbus;
+ register struct fhpibdevice *hd = sc->sc_regs;
+ register struct hpibqueue *hq;
+ register int stat0, unit = sc->sc_dev.dv_unit;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
stat0 = hd->hpib_ids;
if ((stat0 & (IDS_IE|IDS_IR)) != (IDS_IE|IDS_IR)) {
#ifdef DEBUG
if ((fhpibdebug & FDB_FAIL) && (stat0 & IDS_IR) &&
(hs->sc_flags & (HPIBF_IO|HPIBF_DONE)) != HPIBF_IO)
printf("%s: fhpibintr: bad status %x\n",
- hs->sc_hc->hp_xname, stat0);
- fhpibbadint[0]++;
+ sc->sc_dev.dv_xname, stat0);
+ /* fhpibbadint[0]++; XXX */
#endif
return(0);
}
if ((hs->sc_flags & (HPIBF_IO|HPIBF_DONE)) == HPIBF_IO) {
#ifdef DEBUG
- fhpibbadint[1]++;
+ /* fhpibbadint[1]++; XXX */
#endif
return(0);
}
@@ -502,60 +535,60 @@ fhpibintr(arg)
if ((fhpibdebug & FDB_DMA) && fhpibdebugunit == unit)
printf("fhpibintr: flags %x\n", hs->sc_flags);
#endif
- dq = hs->sc_sq.dq_forw;
+ hq = hs->sc_queue.tqh_first;
if (hs->sc_flags & HPIBF_IO) {
if (hs->sc_flags & HPIBF_TIMO)
- untimeout(fhpibdmadone, (void *)unit);
+ untimeout(fhpibdmadone, hs);
stat0 = hd->hpib_cmd;
- hd->hpib_cmd = fhpibcmd[unit] & ~CT_8BIT;
+ hd->hpib_cmd = sc->sc_cmd & ~CT_8BIT;
hd->hpib_stat = 0;
hd->hpib_cmd = CT_REN | CT_8BIT;
stat0 = hd->hpib_intr;
hd->hpib_imask = 0;
hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO);
- dmafree(&hs->sc_dq);
- (dq->dq_driver->d_intr)(dq->dq_softc);
+ dmafree(hs->sc_dq);
+ (hq->hq_intr)(hq->hq_softc);
} else if (hs->sc_flags & HPIBF_PPOLL) {
stat0 = hd->hpib_intr;
#ifdef DEBUG
if ((fhpibdebug & FDB_FAIL) &&
doppollint && (stat0 & IM_PPRESP) == 0)
printf("%s: fhpibintr: bad intr reg %x\n",
- hs->sc_hc->hp_xname, stat0);
+ sc->sc_dev.dv_xname, stat0);
#endif
hd->hpib_stat = 0;
hd->hpib_imask = 0;
#ifdef DEBUG
- stat0 = fhpibppoll(unit);
+ stat0 = fhpibppoll(hs);
if ((fhpibdebug & FDB_PPOLL) && unit == fhpibdebugunit)
printf("fhpibintr: got PPOLL status %x\n", stat0);
- if ((stat0 & (0x80 >> dq->dq_slave)) == 0) {
+ if ((stat0 & (0x80 >> hq->hq_slave)) == 0) {
/*
* XXX give it another shot (68040)
*/
- fhpibppollfail[unit]++;
+ /* fhpibppollfail[unit]++; XXX */
DELAY(fhpibppolldelay);
- stat0 = fhpibppoll(unit);
- if ((stat0 & (0x80 >> dq->dq_slave)) == 0 &&
+ stat0 = fhpibppoll(hs);
+ if ((stat0 & (0x80 >> hq->hq_slave)) == 0 &&
(fhpibdebug & FDB_PPOLL) && unit == fhpibdebugunit)
printf("fhpibintr: PPOLL: unit %d slave %d stat %x\n",
unit, dq->dq_slave, stat0);
}
#endif
hs->sc_flags &= ~HPIBF_PPOLL;
- (dq->dq_driver->d_intr)(dq->dq_softc);
+ (hq->hq_intr)(hq->hq_softc);
}
return(1);
}
int
-fhpibppoll(unit)
- int unit;
+fhpibppoll(hs)
+ struct hpibbus_softc *hs;
{
- register struct fhpibdevice *hd;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ register struct fhpibdevice *hd = sc->sc_regs;
register int ppoll;
- hd = (struct fhpibdevice *)hpib_softc[unit].sc_hc->hp_addr;
hd->hpib_stat = 0;
hd->hpib_psense = 0;
hd->hpib_pmask = 0xFF;
@@ -598,28 +631,26 @@ void
fhpibppwatch(arg)
void *arg;
{
- register int unit;
- register struct hpib_softc *hs;
- register struct fhpibdevice *hd;
+ register struct hpibbus_softc *hs = arg;
+ struct fhpib_softc *sc = (struct fhpib_softc *)hs->sc_dev.dv_parent;
+ register struct fhpibdevice *hd = sc->sc_regs;
register int slave;
- unit = (int)arg;
- hs = &hpib_softc[unit];
if ((hs->sc_flags & HPIBF_PPOLL) == 0)
return;
- hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
- slave = (0x80 >> hs->sc_sq.dq_forw->dq_slave);
+ slave = (0x80 >> hs->sc_queue.tqh_first->hq_slave);
#ifdef DEBUG
if (!doppollint) {
- if (fhpibppoll(unit) & slave) {
+ if (fhpibppoll(hs) & slave) {
hd->hpib_stat = ST_IENAB;
hd->hpib_imask = IM_IDLE | IM_ROOM;
} else
- timeout(fhpibppwatch, (void *)unit, 1);
+ timeout(fhpibppwatch, sc, 1);
return;
}
- if ((fhpibdebug & FDB_PPOLL) && unit == fhpibdebugunit)
- printf("fhpibppwatch: sense request on %d\n", unit);
+ if ((fhpibdebug & FDB_PPOLL) && sc->sc_dev.dv_unit == fhpibdebugunit)
+ printf("fhpibppwatch: sense request on %s\n",
+ sc->sc_dev.dv_xname);
#endif
hd->hpib_psense = ~slave;
hd->hpib_pmask = slave;
@@ -627,4 +658,3 @@ fhpibppwatch(arg)
hd->hpib_imask = IM_PPRESP | IM_PABORT;
hd->hpib_ie = IDS_IE;
}
-#endif /* NHPIB > 0 */
diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c
index 8f3abe5bbcb..3c9d16d3b40 100644
--- a/sys/arch/hp300/dev/grf.c
+++ b/sys/arch/hp300/dev/grf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf.c,v 1.4 1997/01/12 15:12:31 downsj Exp $ */
-/* $NetBSD: grf.c,v 1.22 1997/01/10 00:07:27 scottr Exp $ */
+/* $OpenBSD: grf.c,v 1.5 1997/02/03 04:47:25 downsj Exp $ */
+/* $NetBSD: grf.c,v 1.23 1997/01/30 09:18:42 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -82,15 +82,14 @@ extern struct emul emul_hpux;
#if NITE > 0
#include <hp300/dev/itevar.h>
#else
-#define iteon(u,f) 0 /* normally returns int */
+#define iteon(u,f) 0 /* noramlly returns int */
#define iteoff(u,f)
#endif /* NITE > 0 */
/* prototypes for the devsw entry points */
cdev_decl(grf);
-#ifdef NEWCONFIG
-int grfmatch __P((struct device *, struct cfdata *, void *));
+int grfmatch __P((struct device *, void *, void *));
void grfattach __P((struct device *, struct device *, void *));
struct cfattach grf_ca = {
@@ -102,10 +101,6 @@ struct cfdriver grf_cd = {
};
int grfprint __P((void *, const char *));
-#else /* ! NEWCONFIG */
-#include "grf.h"
-struct grf_softc grf_softc[NGRF];
-#endif /* NEWCONFIG */
/*
* Frambuffer state information, statically allocated for benefit
@@ -121,12 +116,10 @@ int grfdebug = 0;
#define GDB_LOCK 0x08
#endif
-#ifdef NEWCONFIG
int
grfmatch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
return (1);
@@ -161,7 +154,6 @@ grfprint(aux, pnp)
return (UNCONF);
}
-#endif /* NEWCONFIG */
/*ARGSUSED*/
int
@@ -175,15 +167,9 @@ grfopen(dev, flags, mode, p)
struct grf_data *gp;
int error = 0;
-#ifdef NEWCONFIG
if (unit >= grf_cd.cd_ndevs ||
(sc = grf_cd.cd_devs[unit]) == NULL)
return (ENXIO);
-#else
- if (unit >= NGRF)
- return(ENXIO);
- sc = &grf_softc[unit];
-#endif
gp = sc->sc_data;
@@ -230,11 +216,7 @@ grfclose(dev, flags, mode, p)
struct grf_softc *sc;
struct grf_data *gp;
-#ifdef NEWCONFIG
sc = grf_cd.cd_devs[unit];
-#else
- sc = &grf_softc[unit];
-#endif
gp = sc->sc_data;
@@ -262,11 +244,7 @@ grfioctl(dev, cmd, data, flag, p)
struct grf_data *gp;
int error, unit = GRFUNIT(dev);
-#ifdef NEWCONFIG
sc = grf_cd.cd_devs[unit];
-#else
- sc = &grf_softc[unit];
-#endif
gp = sc->sc_data;
@@ -326,11 +304,7 @@ grfmmap(dev, off, prot)
dev_t dev;
int off, prot;
{
-#ifdef NEWCONFIG
struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
-#else
- struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
-#endif
return (grfaddr(sc, off));
}
@@ -343,11 +317,7 @@ grfon(dev)
struct grf_softc *sc;
struct grf_data *gp;
-#ifdef NEWCONFIG
sc = grf_cd.cd_devs[unit];
-#else
- sc = &grf_softc[unit];
-#endif
gp = sc->sc_data;
/*
@@ -370,11 +340,7 @@ grfoff(dev)
struct grf_data *gp;
int error;
-#ifdef NEWCONFIG
sc = grf_cd.cd_devs[unit];
-#else
- sc = &grf_softc[unit];
-#endif
gp = sc->sc_data;
(void) grfunmap(dev, (caddr_t)0, curproc);
@@ -382,7 +348,7 @@ grfoff(dev)
(dev&GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF,
(caddr_t)0);
/* XXX: see comment for iteoff above */
- iteon(sc->sc_ite->sc_data, 2);
+ (void) iteon(sc->sc_ite->sc_data, 2);
return(error);
}
@@ -420,11 +386,7 @@ hpuxgrfioctl(dev, cmd, data, flag, p)
caddr_t data;
struct proc *p;
{
-#ifdef NEWCONFIG
struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
-#else
- struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
-#endif
struct grf_data *gp = sc->sc_data;
int error;
@@ -622,15 +584,9 @@ grfdevno(dev)
struct grf_data *gp;
int newdev;
-#ifdef NEWCONFIG
if (unit >= grf_cd.cd_ndevs ||
(sc = grf_cd.cd_devs[unit]) == NULL)
return (bsdtohpuxdev(dev));
-#else
- if (unit >= NGRF)
- return (bsdtohpuxdev(dev));
- sc = &grf_softc[unit];
-#endif
gp = sc->sc_data;
if ((gp->g_flags & GF_ALIVE) == 0)
@@ -660,11 +616,7 @@ grfmap(dev, addrp, p)
caddr_t *addrp;
struct proc *p;
{
-#ifdef NEWCONFIG
struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
-#else
- struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
-#endif
struct grf_data *gp = sc->sc_data;
int len, error;
struct vnode vn;
@@ -697,11 +649,7 @@ grfunmap(dev, addr, p)
caddr_t addr;
struct proc *p;
{
-#ifdef NEWCONFIG
struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
-#else
- struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
-#endif
struct grf_data *gp = sc->sc_data;
vm_size_t size;
int rv;
diff --git a/sys/arch/hp300/dev/grf_conf.c b/sys/arch/hp300/dev/grf_conf.c
deleted file mode 100644
index 3d0dae6bb12..00000000000
--- a/sys/arch/hp300/dev/grf_conf.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* $OpenBSD: grf_conf.c,v 1.3 1997/01/12 15:12:31 downsj Exp $ */
-/* $NetBSD: grf_conf.c,v 1.4 1996/12/17 08:41:06 thorpej Exp $ */
-
-/*
- * XXX This file is old config only!
- */
-
-/*
- * Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
- * Copyright (c) 1991 University of Utah.
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- *
- * from: Utah $Hdr: grf_conf.c 1.2 92/01/22$
- *
- * @(#)grf_conf.c 8.1 (Berkeley) 6/10/93
- */
-
-/*
- * XXX this information could be generated by config.
- */
-#include "grf.h"
-#if NGRF > 0
-
-#include <sys/types.h>
-#include <sys/device.h>
-
-#include <hp300/dev/grfioctl.h> /* XXX */
-#include <hp300/dev/grfvar.h>
-
-extern struct grfsw dvbox_grfsw;
-extern struct grfsw gbox_grfsw;
-extern struct grfsw hyper_grfsw;
-extern struct grfsw rbox_grfsw;
-extern struct grfsw topcat_grfsw;
-extern struct grfsw lrcatseye_grfsw;
-extern struct grfsw hrcatseye_grfsw;
-extern struct grfsw hrmcatseye_grfsw;
-
-struct grfsw *grfsw[] = {
- &topcat_grfsw,
- &gbox_grfsw,
- &rbox_grfsw,
- &lrcatseye_grfsw,
- &hrcatseye_grfsw,
- &hrmcatseye_grfsw,
- &dvbox_grfsw,
- &hyper_grfsw,
-};
-int ngrfsw = sizeof(grfsw) / sizeof(grfsw[0]);
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_dv.c b/sys/arch/hp300/dev/grf_dv.c
index eab98b4e939..401f8d34ee3 100644
--- a/sys/arch/hp300/dev/grf_dv.c
+++ b/sys/arch/hp300/dev/grf_dv.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_dv.c,v 1.3 1997/01/12 15:12:32 downsj Exp $ */
-/* $NetBSD: grf_dv.c,v 1.9 1996/12/17 08:41:07 thorpej Exp $ */
+/* $OpenBSD: grf_dv.c,v 1.4 1997/02/03 04:47:26 downsj Exp $ */
+/* $NetBSD: grf_dv.c,v 1.10 1997/01/30 09:18:45 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -79,11 +79,10 @@ int dv_init __P((struct grf_data *, int, caddr_t));
int dv_mode __P((struct grf_data *, int, caddr_t));
void dv_reset __P((struct dvboxfb *));
-#ifdef NEWCONFIG
-int dvbox_intio_match __P((struct device *, struct cfdata *, void *));
+int dvbox_intio_match __P((struct device *, void *, void *));
void dvbox_intio_attach __P((struct device *, struct device *, void *));
-int dvbox_dio_match __P((struct device *, struct cfdata *, void *));
+int dvbox_dio_match __P((struct device *, void *, void *));
void dvbox_dio_attach __P((struct device *, struct device *, void *));
struct cfattach dvbox_intio_ca = {
@@ -97,7 +96,6 @@ struct cfattach dvbox_dio_ca = {
struct cfdriver dvbox_cd = {
NULL, "dvbox", DV_DULL
};
-#endif /* NEWCONFIG */
/* DaVinci grf switch */
struct grfsw dvbox_grfsw = {
@@ -121,12 +119,10 @@ struct itesw dvbox_itesw = {
};
#endif /* NITE > 0 */
-#ifdef NEWCONFIG
int
dvbox_intio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct intio_attach_args *ia = aux;
struct grfreg *grf;
@@ -161,8 +157,7 @@ dvbox_intio_attach(parent, self, aux)
int
dvbox_dio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -196,7 +191,6 @@ dvbox_dio_attach(parent, self, aux)
grfdev_attach(sc, dv_init, grf, &dvbox_grfsw);
}
-#endif /* NEWCONFIG */
/*
* Initialize hardware.
diff --git a/sys/arch/hp300/dev/grf_gb.c b/sys/arch/hp300/dev/grf_gb.c
index f7aac480613..ad53e886b58 100644
--- a/sys/arch/hp300/dev/grf_gb.c
+++ b/sys/arch/hp300/dev/grf_gb.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_gb.c,v 1.3 1997/01/12 15:12:33 downsj Exp $ */
-/* $NetBSD: grf_gb.c,v 1.9 1996/12/17 08:41:08 thorpej Exp $ */
+/* $OpenBSD: grf_gb.c,v 1.4 1997/02/03 04:47:27 downsj Exp $ */
+/* $NetBSD: grf_gb.c,v 1.10 1997/01/30 09:18:45 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -89,11 +89,10 @@ int gb_init __P((struct grf_data *gp, int, caddr_t));
int gb_mode __P((struct grf_data *gp, int, caddr_t));
void gb_microcode __P((struct gboxfb *));
-#ifdef NEWCONFIG
-int gbox_intio_match __P((struct device *, struct cfdata *, void *));
+int gbox_intio_match __P((struct device *, void *, void *));
void gbox_intio_attach __P((struct device *, struct device *, void *));
-int gbox_dio_match __P((struct device *, struct cfdata *, void *));
+int gbox_dio_match __P((struct device *, void *, void *));
void gbox_dio_attach __P((struct device *, struct device *, void *));
struct cfattach gbox_intio_ca = {
@@ -107,7 +106,6 @@ struct cfattach gbox_dio_ca = {
struct cfdriver gbox_cd = {
NULL, "gbox", DV_DULL
};
-#endif /* NEWCONFIG */
/* Gatorbox grf switch */
struct grfsw gbox_grfsw = {
@@ -131,12 +129,10 @@ struct itesw gbox_itesw = {
};
#endif /* NITE > 0 */
-#ifdef NEWCONFIG
int
gbox_intio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct intio_attach_args *ia = aux;
struct grfreg *grf;
@@ -171,8 +167,7 @@ gbox_intio_attach(parent, self, aux)
int
gbox_dio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -206,7 +201,6 @@ gbox_dio_attach(parent, self, aux)
grfdev_attach(sc, gb_init, grf, &gbox_grfsw);
}
-#endif /* NEWCONFIG */
/*
* Initialize hardware.
diff --git a/sys/arch/hp300/dev/grf_hy.c b/sys/arch/hp300/dev/grf_hy.c
index 4a4155c5e42..52f7ddf6ae0 100644
--- a/sys/arch/hp300/dev/grf_hy.c
+++ b/sys/arch/hp300/dev/grf_hy.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_hy.c,v 1.3 1997/01/12 15:12:35 downsj Exp $ */
-/* $NetBSD: grf_hy.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */
+/* $OpenBSD: grf_hy.c,v 1.4 1997/02/03 04:47:28 downsj Exp $ */
+/* $NetBSD: grf_hy.c,v 1.8 1997/01/30 09:18:47 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -83,8 +83,7 @@ int hy_init __P((struct grf_data *gp, int, caddr_t));
int hy_mode __P((struct grf_data *gp, int, caddr_t));
void hyper_ite_fontinit __P((struct ite_data *));
-#ifdef NEWCONFIG
-int hyper_dio_match __P((struct device *, struct cfdata *, void *));
+int hyper_dio_match __P((struct device *, void *, void *));
void hyper_dio_attach __P((struct device *, struct device *, void *));
struct cfattach hyper_dio_ca = {
@@ -94,7 +93,6 @@ struct cfattach hyper_dio_ca = {
struct cfdriver hyper_cd = {
NULL, "hyper", DV_DULL
};
-#endif /* NEWCONFIG */
/* Hyperion grf switch */
struct grfsw hyper_grfsw = {
@@ -119,12 +117,10 @@ struct itesw hyper_itesw = {
};
#endif /* NITE > 0 */
-#ifdef NEWCONFIG
int
hyper_dio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -158,7 +154,6 @@ hyper_dio_attach(parent, self, aux)
grfdev_attach(sc, hy_init, grf, &hyper_grfsw);
}
-#endif /* NEWCONFIG */
/*
* Initialize hardware.
diff --git a/sys/arch/hp300/dev/grf_machdep.c b/sys/arch/hp300/dev/grf_machdep.c
deleted file mode 100644
index aed8e6c91dc..00000000000
--- a/sys/arch/hp300/dev/grf_machdep.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* $OpenBSD: grf_machdep.c,v 1.4 1997/01/12 15:12:36 downsj Exp $ */
-/* $NetBSD: grf_machdep.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */
-
-/*
- * XXX This file is old config only!
- */
-
-/*
- * Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
- * Copyright (c) 1991 University of Utah.
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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.
- *
- * from: Utah $Hdr: grf_machdep.c 1.1 92/01/21
- *
- * @(#)grf_machdep.c 8.2 (Berkeley) 1/12/94
- */
-
-/*
- * Graphics display driver for the HP300/400 DIO/DIO-II based machines.
- * This is the hardware-dependent configuration portion of the driver.
- */
-
-#include "grf.h"
-#if NGRF > 0
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-
-#include <machine/autoconf.h>
-
-#include <hp300/dev/device.h>
-#include <hp300/dev/grfioctl.h>
-#include <hp300/dev/grfvar.h>
-#include <hp300/dev/grfreg.h>
-
-#include <hp300/dev/itevar.h>
-
-#include "ite.h"
-
-int grfmatch();
-void grfattach();
-
-int grfinit __P((struct hp_device *, struct grf_data *, int));
-
-struct driver grfdriver = { grfmatch, grfattach, "grf" };
-
-int
-grfmatch(hd)
- struct hp_device *hd;
-{
- struct grf_softc *sc = &grf_softc[hd->hp_unit];
- int scode;
-
- if (hd->hp_args->hw_pa == (caddr_t)GRFIADDR) /* XXX */
- scode = -1;
- else
- scode = hd->hp_args->hw_sc;
-
- if (scode == conscode) {
- /*
- * We've already been initialized.
- */
- sc->sc_data = &grf_cn;
- return (1);
- }
-
- /*
- * Allocate storage space for the grf_data.
- */
- sc->sc_data = (struct grf_data *)malloc(sizeof(struct grf_data),
- M_DEVBUF, M_NOWAIT);
- if (sc->sc_data == NULL) {
- printf("grfmatch: malloc for grf_data failed\n");
- return (0);
- }
- bzero(sc->sc_data, sizeof(struct grf_data));
-
- return (grfinit(hd, sc->sc_data, scode));
-}
-
-void
-grfattach(hd)
- struct hp_device *hd;
-{
- struct grf_softc *sc = &grf_softc[hd->hp_unit];
- struct grf_data *gp = sc->sc_data;
- int scode, isconsole;
-
- if (hd->hp_args->hw_pa == (caddr_t)GRFIADDR) /* XXX */
- scode = -1;
- else
- scode = hd->hp_args->hw_sc;
-
- if (scode == conscode)
- isconsole = 1;
- else
- isconsole = 0;
-
- sc->sc_scode = scode;
-
- printf(": %d x %d ", gp->g_display.gd_dwidth,
- gp->g_display.gd_dheight);
- if (gp->g_display.gd_colors == 2)
- printf("monochrome");
- else
- printf("%d color", gp->g_display.gd_colors);
- printf(" %s display", gp->g_sw->gd_desc);
- if (isconsole)
- printf(" (console)");
- printf("\n");
-
-#if NITE > 0
- /* XXX hack */
- ite_attach_grf(hd->hp_unit, isconsole);
-#endif /* NITE > 0 */
-}
-
-int
-grfinit(hd, gp, scode)
- struct hp_device *hd;
- struct grf_data *gp;
- int scode;
-{
- register struct grfsw *gsw;
- struct grfreg *gr;
- caddr_t addr = hd->hp_addr;
- int i;
-
- gr = (struct grfreg *) addr;
- if (gr->gr_id != GRFHWID)
- return(0);
- for (i = 0; i < ngrfsw; ++i) {
- gsw = grfsw[i];
- if (gsw->gd_hwid == gr->gr_id2)
- break;
- }
- if ((i < ngrfsw) && (*gsw->gd_init)(gp, scode, addr)) {
- gp->g_sw = gsw;
- gp->g_display.gd_id = gsw->gd_swid;
- gp->g_flags = GF_ALIVE;
- return(1);
- }
- return(0);
-}
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_rb.c b/sys/arch/hp300/dev/grf_rb.c
index ba5e98f0313..4689c88657c 100644
--- a/sys/arch/hp300/dev/grf_rb.c
+++ b/sys/arch/hp300/dev/grf_rb.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_rb.c,v 1.3 1997/01/12 15:12:36 downsj Exp $ */
-/* $NetBSD: grf_rb.c,v 1.9 1996/12/17 08:41:10 thorpej Exp $ */
+/* $OpenBSD: grf_rb.c,v 1.4 1997/02/03 04:47:30 downsj Exp $ */
+/* $NetBSD: grf_rb.c,v 1.10 1997/01/30 09:18:48 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -78,11 +78,10 @@
int rb_init __P((struct grf_data *gp, int, caddr_t));
int rb_mode __P((struct grf_data *gp, int, caddr_t));
-#ifdef NEWCONFIG
-int rbox_intio_match __P((struct device *, struct cfdata *, void *));
+int rbox_intio_match __P((struct device *, void *, void *));
void rbox_intio_attach __P((struct device *, struct device *, void *));
-int rbox_dio_match __P((struct device *, struct cfdata *, void *));
+int rbox_dio_match __P((struct device *, void *, void *));
void rbox_dio_attach __P((struct device *, struct device *, void *));
struct cfattach rbox_intio_ca = {
@@ -96,7 +95,6 @@ struct cfattach rbox_dio_ca = {
struct cfdriver rbox_cd = {
NULL, "rbox", DV_DULL
};
-#endif /* NEWCONFIG */
/* Renaissance grf switch */
struct grfsw rbox_grfsw = {
@@ -120,12 +118,10 @@ struct itesw rbox_itesw = {
};
#endif /* NITE > 0 */
-#ifdef NEWCONFIG
int
rbox_intio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct intio_attach_args *ia = aux;
struct grfreg *grf;
@@ -160,8 +156,7 @@ rbox_intio_attach(parent, self, aux)
int
rbox_dio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -195,7 +190,6 @@ rbox_dio_attach(parent, self, aux)
grfdev_attach(sc, rb_init, grf, &rbox_grfsw);
}
-#endif /* NEWCONFIG */
/*
* Initialize hardware.
diff --git a/sys/arch/hp300/dev/grf_subr.c b/sys/arch/hp300/dev/grf_subr.c
index 3f2b845daf0..6349ebc3ca7 100644
--- a/sys/arch/hp300/dev/grf_subr.c
+++ b/sys/arch/hp300/dev/grf_subr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_subr.c,v 1.1 1997/01/12 15:12:38 downsj Exp $ */
-/* $NetBSD: grf_subr.c,v 1.1 1996/12/17 08:41:11 thorpej Exp $ */
+/* $OpenBSD: grf_subr.c,v 1.2 1997/02/03 04:47:30 downsj Exp $ */
+/* $NetBSD: grf_subr.c,v 1.2 1997/01/30 09:18:49 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
diff --git a/sys/arch/hp300/dev/grf_tc.c b/sys/arch/hp300/dev/grf_tc.c
index 65eae4683d5..c44b6d04967 100644
--- a/sys/arch/hp300/dev/grf_tc.c
+++ b/sys/arch/hp300/dev/grf_tc.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_tc.c,v 1.3 1997/01/12 15:12:38 downsj Exp $ */
-/* $NetBSD: grf_tc.c,v 1.9 1996/12/17 08:41:12 thorpej Exp $ */
+/* $OpenBSD: grf_tc.c,v 1.4 1997/02/03 04:47:31 downsj Exp $ */
+/* $NetBSD: grf_tc.c,v 1.10 1997/01/30 09:18:50 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -78,13 +78,12 @@
int tc_init __P((struct grf_data *, int, caddr_t));
int tc_mode __P((struct grf_data *, int, caddr_t));
-#ifdef NEWCONFIG
void topcat_common_attach __P((struct grfdev_softc *, caddr_t, u_int8_t));
-int topcat_intio_match __P((struct device *, struct cfdata *, void *));
+int topcat_intio_match __P((struct device *, void *, void *));
void topcat_intio_attach __P((struct device *, struct device *, void *));
-int topcat_dio_match __P((struct device *, struct cfdata *, void *));
+int topcat_dio_match __P((struct device *, void *, void *));
void topcat_dio_attach __P((struct device *, struct device *, void *));
struct cfattach topcat_intio_ca = {
@@ -98,7 +97,6 @@ struct cfattach topcat_dio_ca = {
struct cfdriver topcat_cd = {
NULL, "topcat", DV_DULL
};
-#endif /* NEWCONFIG */
/* Topcat (bobcat) grf switch */
struct grfsw topcat_grfsw = {
@@ -137,12 +135,10 @@ struct itesw topcat_itesw = {
};
#endif /* NITE > 0 */
-#ifdef NEWCONFIG
int
topcat_intio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct intio_attach_args *ia = aux;
struct grfreg *grf;
@@ -186,8 +182,7 @@ topcat_intio_attach(parent, self, aux)
int
topcat_dio_match(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -268,7 +263,6 @@ topcat_common_attach(sc, grf, secid)
grfdev_attach(sc, tc_init, grf, sw);
}
-#endif /* NEWCONFIG */
/*
* Initialize hardware.
diff --git a/sys/arch/hp300/dev/grfvar.h b/sys/arch/hp300/dev/grfvar.h
index ac6a5d51db9..d3f5c6b47e3 100644
--- a/sys/arch/hp300/dev/grfvar.h
+++ b/sys/arch/hp300/dev/grfvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: grfvar.h,v 1.3 1997/01/12 15:12:41 downsj Exp $ */
-/* $NetBSD: grfvar.h,v 1.8 1996/12/17 08:41:12 thorpej Exp $ */
+/* $OpenBSD: grfvar.h,v 1.4 1997/02/03 04:47:32 downsj Exp $ */
+/* $NetBSD: grfvar.h,v 1.9 1997/01/30 09:18:51 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -124,15 +124,8 @@ struct grfdev_attach_args {
#ifdef _KERNEL
extern struct grf_data grf_cn; /* grf_data for console device */
-#ifndef NEWCONFIG
-extern struct grf_softc grf_softc[];
-extern struct grfsw *grfsw[];
-extern int ngrfsw;
-#endif /* ! NEWCONFIG */
-#ifdef NEWCONFIG
void grfdev_attach __P((struct grfdev_softc *,
int (*init)(struct grf_data *, int, caddr_t),
caddr_t, struct grfsw *));
-#endif /* NEWCONFIG */
#endif /* _KERNEL */
diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c
index fd8f0b969c8..a55c7f44ca9 100644
--- a/sys/arch/hp300/dev/hpib.c
+++ b/sys/arch/hp300/dev/hpib.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: hpib.c,v 1.5 1997/01/12 15:12:45 downsj Exp $ */
-/* $NetBSD: hpib.c,v 1.12 1996/12/09 03:16:27 thorpej Exp $ */
+/* $OpenBSD: hpib.c,v 1.6 1997/02/03 04:47:33 downsj Exp $ */
+/* $NetBSD: hpib.c,v 1.13 1997/01/30 09:06:51 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -37,144 +38,254 @@
*/
/*
- * HPIB driver
+ * HP-IB bus driver
*/
-#include "hpib.h"
-#if NHPIB > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
-#include <hp300/dev/device.h>
-#include <hp300/dev/hpibvar.h>
#include <hp300/dev/dmavar.h>
+#include <hp300/dev/hpibvar.h>
+
#include <machine/cpu.h>
#include <hp300/hp300/isr.h>
-int hpibmatch __P((struct hp_ctlr *));
-void hpibattach __P((struct hp_ctlr *));
-void hpibstart __P((int));
-void hpibgo __P((int, int, int, void *, int, int, int));
-void hpibdone __P((int));
-int hpibintr __P((void *));
-
-struct driver hpibdriver = {
- hpibmatch,
- hpibattach,
- "hpib",
- (int(*)())hpibstart, /* XXX */
- (int(*)())hpibgo, /* XXX */
- hpibintr,
- (int(*)())hpibdone, /* XXX */
+int hpibbusmatch __P((struct device *, void *, void *));
+void hpibbusattach __P((struct device *, struct device *, void *));
+
+struct cfattach hpibbus_ca = {
+ sizeof(struct hpibbus_softc), hpibbusmatch, hpibbusattach
};
-struct hpib_softc hpib_softc[NHPIB];
+struct cfdriver hpibbus_cd = {
+ NULL, "hpibbus", DV_DULL
+};
-extern int nhpibtype __P((struct hp_ctlr *)); /* XXX */
-extern int fhpibtype __P((struct hp_ctlr *)); /* XXX */
-extern void nhpibattach __P((struct hp_ctlr *)); /* XXX */
-extern void fhpibattach __P((struct hp_ctlr *)); /* XXX */
+void hpibbus_attach_children __P((struct hpibbus_softc *));
+int hpibbussearch __P((struct device *, void *, 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 *));
int hpibtimeout = 100000; /* # of status tests before we give up */
int hpibidtimeout = 10000; /* # of status tests for hpibid() calls */
int hpibdmathresh = 3; /* byte count beyond which to attempt dma */
+/*
+ * 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?
+ */
+
int
-hpibmatch(hc)
- register struct hp_ctlr *hc;
+hpibbusmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- struct hp_hw *hw = hc->hp_args;
- extern caddr_t internalhpib;
-
- /* Special case for internal HP-IB. */
- if ((hw->hw_sc == 7) && internalhpib)
- goto hwid_ok;
-
- switch (hw->hw_id) {
- case 8: /* 98625B */
- case 128: /* 98624A */
- hwid_ok:
- if (nhpibtype(hc) || fhpibtype(hc))
- return (1);
- }
- return (0);
+ return (1);
}
void
-hpibattach(hc)
- struct hp_ctlr *hc;
+hpibbusattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
+ 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 */
/*
- * Call the appropriate "attach" routine for this controller.
- * The type is set in the "type" routine.
- *
- * XXX This is, by the way, exactly backwards.
+ * Initialize the DMA queue entry.
*/
- switch (hs->sc_type) {
- case HPIBA:
- case HPIBB:
- nhpibattach(hc);
- break;
-
- case HPIBC:
- fhpibattach(hc);
- break;
-
- default:
- panic("hpibattach: unknown type 0x%x", hs->sc_type);
- /* NOTREACHED */
+ 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;
}
+ 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, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct cfdata *cf = match;
+ 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.
+ */
+ if (cf->hpibbuscf_slave != HPIBBUS_SLAVE_UNK &&
+ cf->hpibbuscf_slave != ha->ha_slave)
+ goto out;
+ if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK &&
+ 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);
+}
- hs->sc_hc = hc;
- hs->sc_dq.dq_unit = hc->hp_unit;
- hs->sc_dq.dq_driver = &hpibdriver;
- hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq;
+int
+hpibbusprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct hpibbus_attach_args *ha = aux;
- /* Establish the interrupt handler. */
- (void) isrlink(hpibintr, hs, hc->hp_ipl, ISRPRI_BIO);
- dmacomputeipl();
+ printf(" slave %d punit %d", ha->ha_slave, ha->ha_punit);
+ return (UNCONF);
+}
- /* Reset the controller, display what we've seen, and we're done. */
- hpibreset(hc->hp_unit);
- printf(": %s\n", hs->sc_descrip);
+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);
}
void
hpibreset(unit)
register int unit;
{
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- (hpib_softc[unit].sc_controller->hpib_reset)(unit);
+ (*sc->sc_ops->hpib_reset)(sc);
}
int
-hpibreq(dq)
- register struct devqueue *dq;
+hpibreq(pdev, hq)
+ struct device *pdev;
+ struct hpibqueue *hq;
{
- register struct devqueue *hq;
+ struct hpibbus_softc *sc = (struct hpibbus_softc *)pdev;
+ int s;
- hq = &hpib_softc[dq->dq_ctlr].sc_sq;
- insque(dq, hq->dq_back);
- if (dq->dq_back == hq)
- return(1);
- return(0);
+ 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);
}
void
-hpibfree(dq)
- register struct devqueue *dq;
+hpibfree(pdev, hq)
+ struct device *pdev;
+ struct hpibqueue *hq;
{
- register struct devqueue *hq;
+ struct hpibbus_softc *sc = (struct hpibbus_softc *)pdev;
+ int s;
- hq = &hpib_softc[dq->dq_ctlr].sc_sq;
- remque(dq);
- if ((dq = hq->dq_forw) != hq)
- (dq->dq_driver->d_start)(dq->dq_unit);
+ 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);
}
int
@@ -201,9 +312,9 @@ hpibsend(unit, slave, sec, addr, cnt)
int unit, slave, sec, cnt;
void *addr;
{
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- return ((hpib_softc[unit].sc_controller->hpib_send)(unit, slave,
- sec, addr, cnt));
+ return ((*sc->sc_ops->hpib_send)(sc, slave, sec, addr, cnt));
}
int
@@ -211,9 +322,9 @@ hpibrecv(unit, slave, sec, addr, cnt)
int unit, slave, sec, cnt;
void *addr;
{
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- return ((hpib_softc[unit].sc_controller->hpib_recv)(unit, slave,
- sec, addr, cnt));
+ return ((*sc->sc_ops->hpib_recv)(sc, slave, sec, addr, cnt));
}
int
@@ -221,25 +332,27 @@ hpibpptest(unit, slave)
register int unit;
int slave;
{
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- return ((hpib_softc[unit].sc_controller->hpib_ppoll)(unit) &
- (0x80 >> slave));
+ return ((*sc->sc_ops->hpib_ppoll)(sc) & (0x80 >> slave));
}
void
hpibppclear(unit)
int unit;
{
- hpib_softc[unit].sc_flags &= ~HPIBF_PPOLL;
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
+
+ sc->sc_flags &= ~HPIBF_PPOLL;
}
hpibawait(unit)
int unit;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- hs->sc_flags |= HPIBF_PPOLL;
- (hs->sc_controller->hpib_ppwatch)((void *)unit);
+ sc->sc_flags |= HPIBF_PPOLL;
+ (*sc->sc_ops->hpib_ppwatch)(sc);
}
int
@@ -247,17 +360,18 @@ hpibswait(unit, slave)
register int unit;
int slave;
{
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
register int timo = hpibtimeout;
- register int mask, (*ppoll) __P((int));
+ register int mask, (*ppoll) __P((struct hpibbus_softc *));
- ppoll = hpib_softc[unit].sc_controller->hpib_ppoll;
+ ppoll = sc->sc_ops->hpib_ppoll;
mask = 0x80 >> slave;
- while (((ppoll)(unit) & mask) == 0)
+ while (((*ppoll)(sc) & mask) == 0) {
if (--timo == 0) {
- printf("%s: swait timeout\n",
- hpib_softc[unit].sc_hc->hp_xname);
+ printf("%s: swait timeout\n", sc->sc_dev.dv_xname);
return(-1);
}
+ }
return(0);
}
@@ -265,51 +379,88 @@ int
hpibustart(unit)
int unit;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- if (hs->sc_type == HPIBA)
- hs->sc_dq.dq_ctlr = DMA0;
+ if (sc->sc_type == HPIBA)
+ sc->sc_dq->dq_chan = DMA0;
else
- hs->sc_dq.dq_ctlr = DMA0 | DMA1;
- if (dmareq(&hs->sc_dq))
+ sc->sc_dq->dq_chan = DMA0 | DMA1;
+ if (dmareq(sc->sc_dq))
return(1);
return(0);
}
void
-hpibstart(unit)
- int unit;
+hpibstart(arg)
+ void *arg;
{
- register struct devqueue *dq;
-
- dq = hpib_softc[unit].sc_sq.dq_forw;
- (dq->dq_driver->d_go)(dq->dq_unit);
+ struct hpibbus_softc *sc = arg;
+ register struct hpibqueue *hq;
+
+ hq = sc->sc_queue.tqh_first;
+ (*hq->hq_go)(hq->hq_softc);
}
void
-hpibgo(unit, slave, sec, addr, count, rw, timo)
- int unit, slave, sec, count, rw, timo;
- void *addr;
+hpibgo(unit, slave, sec, vbuf, count, rw, timo)
+ int unit, slave, sec;
+ void *vbuf;
+ int count, rw, timo;
{
+ struct hpibbus_softc *sc = hpibbus_cd.cd_devs[unit];
- (hpib_softc[unit].sc_controller->hpib_go)(unit, slave, sec,
- addr, count, rw, timo);
+ (*sc->sc_ops->hpib_go)(sc, slave, sec, vbuf, count, rw, timo);
}
void
-hpibdone(unit)
- register int unit;
+hpibdone(arg)
+ void *arg;
{
+ struct hpibbus_softc *sc = arg;
- (hpib_softc[unit].sc_controller->hpib_done)(unit);
+ (*sc->sc_ops->hpib_done)(sc);
}
int
hpibintr(arg)
void *arg;
{
- struct hpib_softc *hs = arg;
+ 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
- return ((hs->sc_controller->hpib_intr)(arg));
+ sc->sc_rmap[slave][punit] = 0;
}
-#endif /* NHPIB > 0 */
diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h
index 81bf17c5579..310881a85de 100644
--- a/sys/arch/hp300/dev/hpibvar.h
+++ b/sys/arch/hp300/dev/hpibvar.h
@@ -1,7 +1,8 @@
-/* $OpenBSD: hpibvar.h,v 1.4 1997/01/12 15:12:45 downsj Exp $ */
-/* $NetBSD: hpibvar.h,v 1.8 1996/02/14 02:44:31 thorpej Exp $ */
+/* $OpenBSD: hpibvar.h,v 1.5 1997/02/03 04:47:34 downsj Exp $ */
+/* $NetBSD: hpibvar.h,v 1.9 1997/01/30 09:06:52 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -36,6 +37,8 @@
* @(#)hpibvar.h 8.1 (Berkeley) 6/10/93
*/
+#include <sys/queue.h>
+
#define HPIB_IPL(x) ((((x) >> 4) & 0x3) + 3)
#define HPIBA 32
@@ -67,35 +70,96 @@
#define C_UNT_P 0xdf /* with odd parity */
#define C_SCG 0x60 /* Secondary group commands */
-struct hpib_softc {
- struct hp_ctlr *sc_hc;
- struct hpib_controller *sc_controller;
- char *sc_descrip;
- int sc_flags;
- struct devqueue sc_dq;
- struct devqueue sc_sq;
- int sc_ba;
- int sc_type;
- char *sc_addr;
- int sc_count;
- int sc_curcnt;
-};
+struct hpibbus_softc;
/*
* Each of the HP-IB controller drivers fills in this structure, which
* is used by the indirect driver to call controller-specific functions.
*/
struct hpib_controller {
- void (*hpib_reset) __P((int));
- int (*hpib_send) __P((int, int, int, void *, int));
- int (*hpib_recv) __P((int, int, int, void *, int));
- int (*hpib_ppoll) __P((int));
+ void (*hpib_reset) __P((struct hpibbus_softc *));
+ int (*hpib_send) __P((struct hpibbus_softc *,
+ int, int, void *, int));
+ int (*hpib_recv) __P((struct hpibbus_softc *,
+ int, int, void *, int));
+ int (*hpib_ppoll) __P((struct hpibbus_softc *));
void (*hpib_ppwatch) __P((void *));
- void (*hpib_go) __P((int, int, int, void *, int, int, int));
- void (*hpib_done) __P((int));
+ void (*hpib_go) __P((struct hpibbus_softc *,
+ int, int, void *, int, int, int));
+ void (*hpib_done) __P((struct hpibbus_softc *));
int (*hpib_intr) __P((void *));
};
+/*
+ * Attach an HP-IB bus to an HP-IB controller.
+ */
+struct hpibdev_attach_args {
+ struct hpib_controller *ha_ops; /* controller ops vector */
+ int ha_type; /* XXX */
+ int ha_ba;
+ struct hpibbus_softc **ha_softcpp; /* XXX */
+};
+
+/*
+ * Attach an HP-IB device to an HP-IB bus.
+ */
+struct hpibbus_attach_args {
+ u_int16_t ha_id; /* device id */
+ int ha_slave; /* HP-IB bus slave */
+ int ha_punit; /* physical unit on slave */
+};
+
+/* Locator short-hand */
+#define hpibbuscf_slave cf_loc[0]
+#define hpibbuscf_punit cf_loc[1]
+
+#define HPIBBUS_SLAVE_UNK -1
+#define HPIBBUS_PUNIT_UNK -1
+
+#define HPIB_NSLAVES 8 /* number of slaves on a bus */
+#define HPIB_NPUNITS 2 /* number of punits per slave */
+
+/*
+ * An HP-IB job queue entry. Slave drivers have one of these used
+ * to queue requests with the controller.
+ */
+struct hpibqueue {
+ TAILQ_ENTRY(hpibqueue) hq_list; /* entry on queue */
+ void *hq_softc; /* slave's softc */
+ int hq_slave; /* slave on bus */
+
+ /*
+ * Callbacks used to start and stop the slave driver.
+ */
+ void (*hq_start) __P((void *));
+ void (*hq_go) __P((void *));
+ void (*hq_intr) __P((void *));
+};
+
+struct dmaqueue;
+
+/*
+ * Software state per HP-IB bus.
+ */
+struct hpibbus_softc {
+ struct device sc_dev; /* generic device glue */
+ struct hpib_controller *sc_ops; /* controller ops vector */
+ volatile int sc_flags; /* misc flags */
+ struct dmaqueue *sc_dq;
+ TAILQ_HEAD(, hpibqueue) sc_queue;
+ int sc_ba;
+ int sc_type;
+ char *sc_addr;
+ int sc_count;
+ int sc_curcnt;
+
+ /*
+ * HP-IB is an indirect bus; this cheezy resource map
+ * keeps track of slave/punit allocations.
+ */
+ char sc_rmap[HPIB_NSLAVES][HPIB_NPUNITS];
+};
+
/* sc_flags */
#define HPIBF_IO 0x1
#define HPIBF_DONE 0x2
@@ -105,7 +169,6 @@ struct hpib_controller {
#define HPIBF_DMA16 0x8000
#ifdef _KERNEL
-extern struct hpib_softc hpib_softc[];
extern caddr_t internalhpib;
extern int hpibtimeout;
extern int hpibdmathresh;
@@ -113,4 +176,12 @@ extern int hpibdmathresh;
void hpibreset __P((int));
int hpibsend __P((int, int, int, void *, int));
int hpibrecv __P((int, int, int, void *, int));
+void hpibgo __P((int, int, int, void *, int, int, int));
+void hpibppclear __P((int));
+
+int hpibreq __P((struct device *, struct hpibqueue *));
+void hpibfree __P((struct device *, struct hpibqueue *));
+
+int hpibintr __P((void *));
+int hpibdevprint __P((void *, const char *));
#endif
diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c
index 14e6a47e5c5..643a4fabc10 100644
--- a/sys/arch/hp300/dev/if_le.c
+++ b/sys/arch/hp300/dev/if_le.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_le.c,v 1.6 1997/01/12 15:12:46 downsj Exp $ */
-/* $NetBSD: if_le.c,v 1.36 1996/12/17 08:41:13 thorpej Exp $ */
+/* $OpenBSD: if_le.c,v 1.7 1997/02/03 04:47:35 downsj Exp $ */
+/* $NetBSD: if_le.c,v 1.37 1997/01/30 09:18:53 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -66,10 +66,6 @@
#include <hp300/hp300/led.h>
#endif
-#ifndef NEWCONFIG
-#include <hp300/dev/device.h>
-#endif
-
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
@@ -79,24 +75,12 @@
#include <hp300/dev/if_lereg.h>
#include <hp300/dev/if_levar.h>
-#ifdef NEWCONFIG
-int lematch __P((struct device *, struct cfdata *, void *));
+int lematch __P((struct device *, void *, void *));
void leattach __P((struct device *, struct device *, void *));
struct cfattach le_ca = {
sizeof(struct le_softc), lematch, leattach
};
-#else /* ! NEWCONFIG */
-#include "le.h"
-struct le_softc le_softc[NLE];
-
-int lematch __P((struct hp_device *));
-void leattach __P((struct hp_device *));
-
-struct driver ledriver = {
- lematch, leattach, "le",
-};
-#endif /* NEWCONFIG */
int leintr __P((void *));
@@ -140,12 +124,10 @@ lerdcsr(sc, port)
return (val);
}
-#ifdef NEWCONFIG
int
lematch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
struct dio_attach_args *da = aux;
@@ -153,76 +135,38 @@ lematch(parent, match, aux)
return (1);
return (0);
}
-#else /* ! NEWCONFIG */
-int
-lematch(hd)
- struct hp_device *hd;
-{
- register struct lereg0 *ler0;
- struct le_softc *lesc = &le_softc[hd->hp_unit];
-
- ler0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr);
- if (ler0->ler0_id != LEID)
- return (0);
-
- hd->hp_ipl = LE_IPL(ler0->ler0_status);
- lesc->sc_hd = hd;
-
- return (1);
-}
-#endif /* NEWCONFIG */
/*
* Interface exists: make available by filling in network interface
* record. System will initialize the interface when it is ready
* to accept packets.
*/
-#ifdef NEWCONFIG
void
leattach(parent, self, aux)
struct device *parent, *self;
void *aux;
-#else /* ! NEWCONFIG */
-void
-leattach(hd)
- struct hp_device *hd;
-#endif /* NEWCONFIG */
{
register struct lereg0 *ler0;
-#ifdef NEWCONFIG
struct dio_attach_args *da = aux;
struct le_softc *lesc = (struct le_softc *)self;
caddr_t addr;
-#else
- struct le_softc *lesc = &le_softc[hd->hp_unit];
- caddr_t addr = hd->hp_addr;
-#endif /* NEWCONFIG */
struct am7990_softc *sc = &lesc->sc_am7990;
char *cp;
int i, ipl;
-#ifdef NEWCONFIG
addr = iomap(dio_scodetopa(da->da_scode), da->da_size);
if (addr == 0) {
printf("\n%s: can't map LANCE registers\n",
sc->sc_dev.dv_xname);
return;
}
-#endif /* NEWCONFIG */
ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)addr);
ler0->ler0_id = 0xFF;
DELAY(100);
-#ifdef NEWCONFIG
ipl = DIO_IPL(addr);
printf(" ipl %d", ipl);
-#else /* ! NEWCONFIG */
- /* XXXX kluge for now */
- hd->hp_dev.dv_class = DV_IFNET;
- bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device));
- ipl = hd->hp_ipl;
-#endif /* NEWCONFIG */
lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)addr);
sc->sc_mem = (void *)(lestd[2] + (int)addr);
diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h
index 7e1f2f7523f..1c07c11f143 100644
--- a/sys/arch/hp300/dev/if_levar.h
+++ b/sys/arch/hp300/dev/if_levar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_levar.h,v 1.3 1997/01/12 15:12:47 downsj Exp $ */
-/* $NetBSD: if_levar.h,v 1.5 1996/12/17 08:41:14 thorpej Exp $ */
+/* $OpenBSD: if_levar.h,v 1.4 1997/02/03 04:47:36 downsj Exp $ */
+/* $NetBSD: if_levar.h,v 1.6 1997/01/30 09:18:54 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -50,9 +50,6 @@
struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
-#ifndef NEWCONFIG
- struct hp_device *sc_hd;
-#endif
struct isr sc_isr;
struct lereg0 *sc_r0; /* DIO registers */
struct lereg1 *sc_r1; /* LANCE registers */
diff --git a/sys/arch/hp300/dev/intio.c b/sys/arch/hp300/dev/intio.c
index af6a5a1bb02..80b0401e8e0 100644
--- a/sys/arch/hp300/dev/intio.c
+++ b/sys/arch/hp300/dev/intio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: intio.c,v 1.1 1997/01/12 15:12:47 downsj Exp $ */
-/* $NetBSD: intio.c,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */
+/* $OpenBSD: intio.c,v 1.2 1997/02/03 04:47:36 downsj Exp $ */
+/* $NetBSD: intio.c,v 1.2 1997/01/30 09:18:54 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -47,10 +47,10 @@
#include <hp300/dev/intiovar.h>
-int intiomatch __P((struct device *, struct cfdata *, void *));
+int intiomatch __P((struct device *, void *, void *));
void intioattach __P((struct device *, struct device *, void *));
int intioprint __P((void *, const char *));
-int intiosearch __P((struct device *, struct cfdata *, void *));
+int intiosearch __P((struct device *, void *, void *));
struct cfattach intio_ca = {
sizeof(struct device), intiomatch, intioattach
@@ -63,8 +63,7 @@ struct cfdriver intio_cd = {
int
intiomatch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
static int intio_matched = 0;
@@ -101,11 +100,11 @@ intioprint(aux, pnp)
}
int
-intiosearch(parent, cf, aux)
+intiosearch(parent, match, aux)
struct device *parent;
- struct cfdata *cf;
- void *aux;
+ void *match, *aux;
{
+ struct cfdata *cf = match;
struct intio_attach_args ia;
bzero(&ia, sizeof(ia));
diff --git a/sys/arch/hp300/dev/intiovar.h b/sys/arch/hp300/dev/intiovar.h
index e6dc6dbc0e2..a2b34f7f566 100644
--- a/sys/arch/hp300/dev/intiovar.h
+++ b/sys/arch/hp300/dev/intiovar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: intiovar.h,v 1.1 1997/01/12 15:12:48 downsj Exp $ */
-/* $NetBSD: intiovar.h,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */
+/* $OpenBSD: intiovar.h,v 1.2 1997/02/03 04:47:37 downsj Exp $ */
+/* $NetBSD: intiovar.h,v 1.2 1997/01/30 09:18:55 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c
index 4217dce8d07..66e5263410e 100644
--- a/sys/arch/hp300/dev/ite.c
+++ b/sys/arch/hp300/dev/ite.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ite.c,v 1.6 1997/01/12 15:12:49 downsj Exp $ */
-/* $NetBSD: ite.c,v 1.34 1996/12/17 08:41:16 thorpej Exp $ */
+/* $OpenBSD: ite.c,v 1.7 1997/02/03 04:47:38 downsj Exp $ */
+/* $NetBSD: ite.c,v 1.35 1997/01/30 09:18:56 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -88,8 +88,7 @@ int iteburst = 64;
struct ite_data *kbd_ite = NULL;
-#ifdef NEWCONFIG
-int itematch __P((struct device *, struct cfdata *, void *));
+int itematch __P((struct device *, void *, void *));
void iteattach __P((struct device *, struct device *, void *));
struct cfattach ite_ca = {
@@ -99,10 +98,6 @@ struct cfattach ite_ca = {
struct cfdriver ite_cd = {
NULL, "ite", DV_TTY
};
-#else /* ! NEWCONFIG */
-#include "grf.h"
-struct ite_softc ite_softc[NGRF];
-#endif /* NEWCONFIG */
/*
* Terminal emulator state information, statically allocated
@@ -141,12 +136,10 @@ u_char ite_console_attributes[0x2200];
(*(sp)->ite_cursor)((ip), MOVE_CURSOR); \
}
-#ifdef NEWCONFIG
int
itematch(parent, match, aux)
struct device *parent;
- struct cfdata *match;
- void *aux;
+ void *match, *aux;
{
return (1);
@@ -191,59 +184,6 @@ iteattach(parent, self, aux)
printf("\n");
}
-#else /* ! NEWCONFIG */
-/*
- * Dummy for pseudo-device config.
- */
-/*ARGSUSED*/
-void
-iteattach(n)
- int n;
-{
-}
-
-/*
- * Allocate storage for ite data structures.
- * XXX This is a kludge and will go away with new config.
- */
-void
-ite_attach_grf(unit, isconsole)
- int unit, isconsole;
-{
- struct ite_softc *ite = &ite_softc[unit];
- struct grf_softc *grf = &grf_softc[unit];
-
- /*
- * Check to see if our structure is pre-allocated.
- */
- if (isconsole) {
- ite->sc_data = &ite_cn;
-
- /*
- * We didn't know which unit this would be during
- * the console probe, so we have to fixup cn_dev here.
- */
- cn_tab->cn_dev = makedev(ite_major(), unit);
- } else {
- ite->sc_data =
- (struct ite_data *)malloc(sizeof(struct ite_data),
- M_DEVBUF, M_NOWAIT);
- if (ite->sc_data == NULL) {
- printf("ite_attach_grf: malloc for ite_data failed\n");
- return;
- }
- bzero(ite->sc_data, sizeof(struct ite_data));
- }
-
- /*
- * Cross-reference the ite and the grf.
- */
- ite->sc_grf = grf;
- grf->sc_ite = ite;
-
- printf("ite%d at grf%d: attached\n", unit, unit);
-}
-#endif /* NEWCONFIG */
/*
* Perform functions necessary to setup device as a terminal emulator.
@@ -357,15 +297,9 @@ iteopen(dev, mode, devtype, p)
int error;
int first = 0;
-#ifdef NEWCONFIG
if (unit >= ite_cd.cd_ndevs ||
(sc = ite_cd.cd_devs[unit]) == NULL)
return (ENXIO);
-#else
- if (unit >= NGRF)
- return (ENXIO);
- sc = &ite_softc[unit];
-#endif
ip = sc->sc_data;
if (ip->tty == NULL) {
@@ -411,11 +345,7 @@ iteclose(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
-#ifdef NEWCONFIG
struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
-#else
- struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
-#endif
struct ite_data *ip = sc->sc_data;
struct tty *tp = ip->tty;
@@ -436,11 +366,7 @@ iteread(dev, uio, flag)
struct uio *uio;
int flag;
{
-#ifdef NEWCONFIG
struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
-#else
- struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
-#endif
struct tty *tp = sc->sc_data->tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
@@ -452,11 +378,7 @@ itewrite(dev, uio, flag)
struct uio *uio;
int flag;
{
-#ifdef NEWCONFIG
struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
-#else
- struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
-#endif
struct tty *tp = sc->sc_data->tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
@@ -466,11 +388,7 @@ struct tty *
itetty(dev)
dev_t dev;
{
-#ifdef NEWCONFIG
struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
-#else
- struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
-#endif
return (sc->sc_data->tty);
}
@@ -483,11 +401,7 @@ iteioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
-#ifdef NEWCONFIG
struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
-#else
- struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
-#endif
struct ite_data *ip = sc->sc_data;
struct tty *tp = ip->tty;
int error;
@@ -510,11 +424,7 @@ itestart(tp)
struct ite_softc *sc;
struct ite_data *ip;
-#ifdef NEWCONFIG
sc = ite_cd.cd_devs[ITEUNIT(tp->t_dev)];
-#else
- sc = &ite_softc[ITEUNIT(tp->t_dev)];
-#endif
ip = sc->sc_data;
/*
diff --git a/sys/arch/hp300/dev/itevar.h b/sys/arch/hp300/dev/itevar.h
index 2bff7f73c50..db168bf8631 100644
--- a/sys/arch/hp300/dev/itevar.h
+++ b/sys/arch/hp300/dev/itevar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: itevar.h,v 1.5 1997/01/12 15:12:52 downsj Exp $ */
-/* $NetBSD: itevar.h,v 1.12 1997/01/09 01:07:59 scottr Exp $ */
+/* $OpenBSD: itevar.h,v 1.6 1997/02/03 04:47:39 downsj Exp $ */
+/* $NetBSD: itevar.h,v 1.13 1997/01/30 09:18:57 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -94,7 +94,7 @@ struct ite_softc {
struct ite_data *sc_data; /* terminal state info */
struct grf_softc *sc_grf; /* pointer to framebuffer */
};
-#endif
+#endif /* _KERNEL */
/* Flags */
#define ITE_ALIVE 0x01 /* hardware exists */
diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c
index a1bd5d77b1c..df2514a0171 100644
--- a/sys/arch/hp300/dev/mt.c
+++ b/sys/arch/hp300/dev/mt.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: mt.c,v 1.4 1997/01/12 15:12:54 downsj Exp $ */
-/* $NetBSD: mt.c,v 1.6 1996/10/14 07:14:18 thorpej Exp $ */
+/* $OpenBSD: mt.c,v 1.5 1997/02/03 04:47:39 downsj Exp $ */
+/* $NetBSD: mt.c,v 1.7 1997/01/30 09:14:14 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1992, The University of Utah and
* the Computer Systems Laboratory at the University of Utah (CSL).
* All rights reserved.
@@ -30,8 +31,6 @@
* Modified for 4.4BSD by Mark Davies and Andrew Vignaux, Department of
* Computer Science, Victoria University of Wellington
*/
-#include "mt.h"
-#if NMT > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -45,11 +44,12 @@
#include <sys/tty.h>
#include <sys/kernel.h>
#include <sys/tprintf.h>
+#include <sys/device.h>
+#include <sys/conf.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/hpibvar.h>
-#include <hp300/dev/mtreg.h>
+#include <hp300/dev/mtreg.h>
struct mtinfo {
u_short hwid;
@@ -63,9 +63,9 @@ struct mtinfo {
int nmtinfo = sizeof(mtinfo) / sizeof(mtinfo[0]);
struct mt_softc {
- struct hp_device *sc_hd;
- short sc_hpibno; /* logical HPIB this slave it attached to */
- short sc_slave; /* HPIB slave address (0-6) */
+ struct device sc_dev;
+ int sc_hpibno; /* logical HPIB this slave it attached to */
+ int sc_slave; /* HPIB slave address (0-6) */
short sc_flags; /* see below */
u_char sc_lastdsj; /* place for DSJ in mtreaddsj() */
u_char sc_lastecmd; /* place for End Command in mtreaddsj() */
@@ -74,11 +74,11 @@ struct mt_softc {
struct mt_stat sc_stat;/* status bytes last read from device */
short sc_density; /* current density of tape (mtio.h format) */
short sc_type; /* tape drive model (hardware IDs) */
- struct devqueue sc_dq; /* HPIB device queue member */
+ struct hpibqueue sc_hq; /* HPIB device queue member */
tpr_t sc_ttyp;
-} mt_softc[NMT];
-struct buf mttab[NMT];
-struct buf mtbuf[NMT];
+ struct buf sc_tab; /* buf queue */
+ struct buf sc_bufstore; /* XXX buffer storage */
+};
#ifdef DEBUG
int mtdebug = 0;
@@ -92,67 +92,90 @@ int mtdebug = 0;
#define B_CMD B_XXX /* command buf instead of data */
#define b_cmd b_blkno /* blkno holds cmd when B_CMD */
-int mtmatch(), mtintr();
-void mtattach(), mtustart(), mtstart(), mtgo(), mtstrategy();
-struct driver mtdriver = {
- mtmatch, mtattach, "mt", (int (*)()) mtstart, (int (*)()) mtgo, mtintr,
+int mtmatch __P((struct device *, void *, void *));
+void mtattach __P((struct device *, struct device *, void *));
+
+struct cfattach mt_ca = {
+ sizeof(struct mt_softc), mtmatch, mtattach
};
+struct cfdriver mt_cd = {
+ NULL, "mt", DV_TAPE
+};
+
+int mtident __P((struct mt_softc *, struct hpibbus_attach_args *));
+void mtustart __P((struct mt_softc *));
+int mtreaddsj __P((struct mt_softc *, int));
+int mtcommand __P((dev_t, int, int));
+void spl_mtintr __P((void *));
+void spl_mtstart __P((void *));
+
+void mtstart __P((void *));
+void mtgo __P((void *));
+void mtintr __P((void *));
+
+bdev_decl(mt);
+cdev_decl(mt);
+
int
-mtmatch(hd)
- register struct hp_device *hd;
+mtmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register int unit;
- register int hpibno = hd->hp_ctlr;
- register int slave = hd->hp_slave;
- register struct mt_softc *sc = &mt_softc[hd->hp_unit];
- register int id;
- register struct buf *bp;
-
- sc->sc_hd = hd;
+ struct hpibbus_attach_args *ha = aux;
- for (bp = mttab; bp < &mttab[NMT]; bp++)
- bp->b_actb = &bp->b_actf;
- unit = hpibid(hpibno, slave);
- for (id = 0; id < nmtinfo; id++)
- if (unit == mtinfo[id].hwid)
- return (1);
- return (0); /* not a known HP magtape */
+ return (mtident(NULL, ha));
}
void
-mtattach(hd)
- register struct hp_device *hd;
+mtattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- register int unit;
- register int hpibno = hd->hp_ctlr;
- register int slave = hd->hp_slave;
- register struct mt_softc *sc;
- register int id;
- register struct buf *bp;
+ struct mt_softc *sc = (struct mt_softc *)self;
+ struct hpibbus_attach_args *ha = aux;
+ int unit, hpibno, slave;
- /* XXX Ick. */
- unit = hpibid(hpibno, slave);
- for (id = 0; id < nmtinfo; id++)
- if (unit == mtinfo[id].hwid)
- break;
+ if (mtident(sc, ha) == 0) {
+ printf("\n%s: impossible!\n", sc->sc_dev.dv_xname);
+ return;
+ }
+
+ unit = self->dv_unit;
+ hpibno = parent->dv_unit;
+ slave = ha->ha_slave;
- unit = hd->hp_unit;
- sc = &mt_softc[unit];
- sc->sc_type = mtinfo[id].hwid;
- printf(": %s tape\n", mtinfo[id].desc);
+ sc->sc_tab.b_actb = &sc->sc_tab.b_actf;
sc->sc_hpibno = hpibno;
sc->sc_slave = slave;
sc->sc_flags = MTF_EXISTS;
- sc->sc_dq.dq_softc = sc;
- sc->sc_dq.dq_ctlr = hpibno;
- sc->sc_dq.dq_unit = unit;
- sc->sc_dq.dq_slave = slave;
- sc->sc_dq.dq_driver = &mtdriver;
-
- /* XXX Set device class. */
- hd->hp_dev.dv_class = DV_TAPE;
+
+ /* Initialize hpib job queue entry. */
+ sc->sc_hq.hq_softc = sc;
+ sc->sc_hq.hq_slave = sc->sc_slave;
+ sc->sc_hq.hq_start = mtstart;
+ sc->sc_hq.hq_go = mtgo;
+ sc->sc_hq.hq_intr = mtintr;
+}
+
+int
+mtident(sc, ha)
+ struct mt_softc *sc;
+ struct hpibbus_attach_args *ha;
+{
+ int i;
+
+ for (i = 0; i < nmtinfo; i++) {
+ if (ha->ha_id == mtinfo[i].hwid) {
+ if (sc != NULL) {
+ sc->sc_type = mtinfo[i].hwid;
+ printf(": %s tape\n", mtinfo[i].desc);
+ }
+ return (1);
+ }
+ }
+ return (0);
}
/*
@@ -161,21 +184,22 @@ mtattach(hd)
* performed, unless "ecmd" is zero. Returns DSJ value, -1 on failure
* and -2 on "temporary" failure.
*/
-mtreaddsj(unit, ecmd)
- register int unit;
+int
+mtreaddsj(sc, ecmd)
+ struct mt_softc *sc;
int ecmd;
{
- register struct mt_softc *sc = &mt_softc[unit];
int retval;
if (sc->sc_flags & MTF_STATTIMEO)
goto getstats;
retval = hpibrecv(sc->sc_hpibno,
- (sc->sc_flags & MTF_DSJTIMEO) ? -1 : sc->sc_slave,
- MTT_DSJ, &(sc->sc_lastdsj), 1);
+ (sc->sc_flags & MTF_DSJTIMEO) ? -1 : sc->sc_slave,
+ MTT_DSJ, &(sc->sc_lastdsj), 1);
sc->sc_flags &= ~MTF_DSJTIMEO;
if (retval != 1) {
- dlog(LOG_DEBUG, "mt%d can't hpibrecv DSJ\n", unit);
+ dlog(LOG_DEBUG, "%s can't hpibrecv DSJ",
+ sc->sc_dev.dv_xname);
if (sc->sc_recvtimeo == 0)
sc->sc_recvtimeo = hz;
if (--sc->sc_recvtimeo == 0)
@@ -186,7 +210,8 @@ mtreaddsj(unit, ecmd)
}
sc->sc_recvtimeo = 0;
sc->sc_statindex = 0;
- dlog(LOG_DEBUG, "mt%d readdsj: 0x%x\n", unit, sc->sc_lastdsj);
+ dlog(LOG_DEBUG, "%s readdsj: 0x%x", sc->sc_dev.dv_xname,
+ sc->sc_lastdsj);
sc->sc_lastecmd = ecmd;
switch (sc->sc_lastdsj) {
case 0:
@@ -200,14 +225,15 @@ mtreaddsj(unit, ecmd)
break;
default:
- log(LOG_ERR, "mt%d readdsj: DSJ 0x%x\n", unit, sc->sc_lastdsj);
+ log(LOG_ERR, "%s readdsj: DSJ 0x%x\n", sc->sc_dev.dv_xname,
+ sc->sc_lastdsj);
return (-1);
}
getstats:
retval = hpibrecv(sc->sc_hpibno,
- (sc->sc_flags & MTF_STATCONT) ? -1 : sc->sc_slave,
- MTT_STAT, ((char *)&(sc->sc_stat)) + sc->sc_statindex,
- sizeof(sc->sc_stat) - sc->sc_statindex);
+ (sc->sc_flags & MTF_STATCONT) ? -1 : sc->sc_slave,
+ MTT_STAT, ((char *)&(sc->sc_stat)) + sc->sc_statindex,
+ sizeof(sc->sc_stat) - sc->sc_statindex);
sc->sc_flags &= ~(MTF_STATTIMEO | MTF_STATCONT);
if (retval != sizeof(sc->sc_stat) - sc->sc_statindex) {
if (sc->sc_recvtimeo == 0)
@@ -220,33 +246,40 @@ mtreaddsj(unit, ecmd)
sc->sc_flags |= MTF_STATTIMEO;
return (-2);
}
- log(LOG_ERR, "mt%d readdsj: can't read status\n", unit);
+ log(LOG_ERR, "%s readdsj: can't read status",
+ sc->sc_dev.dv_xname);
return (-1);
}
sc->sc_recvtimeo = 0;
sc->sc_statindex = 0;
- dlog(LOG_DEBUG, "mt%d readdsj: status is %x %x %x %x %x %x\n", unit,
- sc->sc_stat1, sc->sc_stat2, sc->sc_stat3,
- sc->sc_stat4, sc->sc_stat5, sc->sc_stat6);
+ dlog(LOG_DEBUG, "%s readdsj: status is %x %x %x %x %x %x",
+ sc->sc_dev.dv_xname,
+ sc->sc_stat1, sc->sc_stat2, sc->sc_stat3,
+ sc->sc_stat4, sc->sc_stat5, sc->sc_stat6);
if (sc->sc_lastecmd)
(void) hpibsend(sc->sc_hpibno, sc->sc_slave,
- MTL_ECMD, &(sc->sc_lastecmd), 1);
+ MTL_ECMD, &(sc->sc_lastecmd), 1);
return ((int) sc->sc_lastdsj);
}
+int
mtopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
register int unit = UNIT(dev);
- register struct mt_softc *sc = &mt_softc[unit];
+ struct mt_softc *sc;
register int req_den;
int error;
- dlog(LOG_DEBUG, "mt%d open: flags 0x%x\n", unit, sc->sc_flags);
- if (unit >= NMT || (sc->sc_flags & MTF_EXISTS) == 0)
+ if (unit >= mt_cd.cd_ndevs ||
+ (sc = mt_cd.cd_devs[unit]) == NULL ||
+ (sc->sc_flags & MTF_EXISTS) == 0)
return (ENXIO);
+
+ dlog(LOG_DEBUG, "%s open: flags 0x%x", sc->sc_dev.dv_xname,
+ sc->sc_flags);
if (sc->sc_flags & MTF_OPEN)
return (EBUSY);
sc->sc_flags |= MTF_OPEN;
@@ -263,7 +296,8 @@ mtopen(dev, flag, mode, p)
goto errout;
if (!(sc->sc_flags & MTF_REW))
break;
- if (tsleep((caddr_t) &lbolt, PCATCH | (PZERO + 1), "mt", 0) != 0) {
+ if (tsleep((caddr_t) &lbolt, PCATCH | (PZERO + 1),
+ "mt", 0) != 0) {
error = EINTR;
goto errout;
}
@@ -273,7 +307,7 @@ mtopen(dev, flag, mode, p)
goto errout;
}
if (!(sc->sc_stat1 & SR1_ONLINE)) {
- uprintf("%s: not online\n", sc->sc_hd->hp_xname);
+ uprintf("%s: not online\n", sc->sc_dev.dv_xname);
error = EIO;
goto errout;
}
@@ -311,7 +345,7 @@ mtopen(dev, flag, mode, p)
if (!(sc->sc_stat1 & SR1_BOT)) {
if (sc->sc_density != req_den) {
uprintf("%s: can't change density mid-tape\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
error = EIO;
goto errout;
}
@@ -334,11 +368,13 @@ errout:
return (error);
}
-mtclose(dev, flag)
+int
+mtclose(dev, flag, fmt, p)
dev_t dev;
- int flag;
+ int flag, fmt;
+ struct proc *p;
{
- register struct mt_softc *sc = &mt_softc[UNIT(dev)];
+ struct mt_softc *sc = mt_cd.cd_devs[UNIT(dev)];
if (sc->sc_flags & MTF_WRT) {
(void) mtcommand(dev, MTWEOF, 2);
@@ -351,12 +387,14 @@ mtclose(dev, flag)
return (0);
}
+int
mtcommand(dev, cmd, cnt)
dev_t dev;
int cmd;
int cnt;
{
- register struct buf *bp = &mtbuf[UNIT(dev)];
+ struct mt_softc *sc = mt_cd.cd_devs[UNIT(dev)];
+ struct buf *bp = &sc->sc_bufstore;
int error = 0;
#if 1
@@ -395,15 +433,15 @@ mtstrategy(bp)
register int s;
unit = UNIT(bp->b_dev);
- sc = &mt_softc[unit];
- dlog(LOG_DEBUG, "mt%d strategy\n", unit);
+ sc = mt_cd.cd_devs[unit];
+ dlog(LOG_DEBUG, "%s strategy", sc->sc_dev.dv_xname);
if ((bp->b_flags & (B_CMD | B_READ)) == 0) {
#define WRITE_BITS_IGNORED 8
#if 0
if (bp->b_bcount & ((1 << WRITE_BITS_IGNORED) - 1)) {
tprintf(sc->sc_ttyp,
"%s: write record must be multiple of %d\n",
- sc->sc_hd->hp_xname, 1 << WRITE_BITS_IGNORED);
+ sc->sc_dev.dv_xname, 1 << WRITE_BITS_IGNORED);
goto error;
}
#endif
@@ -423,7 +461,7 @@ mtstrategy(bp)
if (bp->b_bcount > s) {
tprintf(sc->sc_ttyp,
"%s: write record (%d) too big: limit (%d)\n",
- sc->sc_hd->hp_xname, bp->b_bcount, s);
+ sc->sc_dev.dv_xname, bp->b_bcount, s);
error:
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
@@ -431,7 +469,7 @@ mtstrategy(bp)
return;
}
}
- dp = &mttab[unit];
+ dp = &sc->sc_tab;
bp->b_actf = NULL;
s = splbio();
bp->b_actb = dp->b_actb;
@@ -439,24 +477,21 @@ mtstrategy(bp)
dp->b_actb = &bp->b_actf;
if (dp->b_active == 0) {
dp->b_active = 1;
- mtustart(unit);
+ mtustart(sc);
}
splx(s);
}
void
-mtustart(unit)
- register int unit;
+mtustart(sc)
+ struct mt_softc *sc;
{
- dlog(LOG_DEBUG, "mt%d ustart\n", unit);
- if (hpibreq(&(mt_softc[unit].sc_dq)))
- mtstart(unit);
+ dlog(LOG_DEBUG, "%s ustart", sc->sc_dev.dv_xname);
+ if (hpibreq(sc->sc_dev.dv_parent, &sc->sc_hq))
+ mtstart(sc);
}
-#define hpibppclear(unit) \
- { hpib_softc[unit].sc_flags &= ~HPIBF_PPOLL; }
-
void
spl_mtintr(arg)
void *arg;
@@ -470,27 +505,27 @@ spl_mtintr(arg)
}
void
-spl_mtstart(unit)
- int unit;
+spl_mtstart(arg)
+ void *arg;
{
int s = splbio();
- mtstart(unit);
+ mtstart(arg);
(void) splx(s);
}
void
-mtstart(unit)
- register int unit;
+mtstart(arg)
+ void *arg;
{
- register struct mt_softc *sc = &mt_softc[unit];
+ struct mt_softc *sc = arg;
register struct buf *bp, *dp;
short cmdcount = 1;
u_char cmdbuf[2];
- dlog(LOG_DEBUG, "mt%d start\n", unit);
+ dlog(LOG_DEBUG, "%s start", sc->sc_dev.dv_xname);
sc->sc_flags &= ~MTF_WRT;
- bp = mttab[unit].b_actf;
+ bp = sc->sc_tab.b_actf;
if ((sc->sc_flags & MTF_ALIVE) == 0 &&
((bp->b_flags & B_CMD) == 0 || bp->b_cmd != MTRESET))
goto fatalerror;
@@ -498,7 +533,7 @@ mtstart(unit)
if (sc->sc_flags & MTF_REW) {
if (!hpibpptest(sc->sc_hpibno, sc->sc_slave))
goto stillrew;
- switch (mtreaddsj(unit, MTE_DSJ_FORCE|MTE_COMPLETE|MTE_IDLE)) {
+ switch (mtreaddsj(sc, MTE_DSJ_FORCE|MTE_COMPLETE|MTE_IDLE)) {
case 0:
case 1:
stillrew:
@@ -514,7 +549,7 @@ mtstart(unit)
* but not otherwise.
*/
if (sc->sc_flags & (MTF_DSJTIMEO | MTF_STATTIMEO)) {
- timeout(spl_mtstart, (void *)unit, hz >> 5);
+ timeout(spl_mtstart, sc, hz >> 5);
return;
}
case 2:
@@ -585,8 +620,8 @@ mtstart(unit)
* NOP is supposed to set status bits.
* Force readdsj to do it.
*/
- switch (mtreaddsj(unit,
- MTE_DSJ_FORCE | MTE_COMPLETE | MTE_IDLE)) {
+ switch (mtreaddsj(sc,
+ MTE_DSJ_FORCE | MTE_COMPLETE | MTE_IDLE)) {
default:
goto done;
@@ -600,7 +635,7 @@ mtstart(unit)
break;
case -2:
- timeout(spl_mtstart, (void *)unit, hz >> 5);
+ timeout(spl_mtstart, sc, hz >> 5);
return;
}
@@ -611,10 +646,11 @@ mtstart(unit)
* 3) interrupt will read DSJ (and END COMPLETE-IDLE)
*/
if (hpibsend(sc->sc_hpibno, sc->sc_slave, -2, NULL, 0)){
- log(LOG_ERR, "mt%d can't reset\n", unit);
+ log(LOG_ERR, "%s can't reset",
+ sc->sc_dev.dv_xname);
goto fatalerror;
}
- timeout(spl_mtintr, (void *)sc, 4 * hz);
+ timeout(spl_mtintr, sc, 4 * hz);
hpibawait(sc->sc_hpibno, sc->sc_slave);
return;
@@ -672,13 +708,13 @@ done:
if (dp = bp->b_actf)
dp->b_actb = bp->b_actb;
else
- mttab[unit].b_actb = bp->b_actb;
+ sc->sc_tab.b_actb = bp->b_actb;
*bp->b_actb = dp;
- hpibfree(&(sc->sc_dq));
+ hpibfree(sc->sc_dev.dv_parent, &sc->sc_hq);
if ((bp = dp) == NULL)
- mttab[unit].b_active = 0;
+ sc->sc_tab.b_active = 0;
else
- mtustart(unit);
+ mtustart(sc);
}
/*
@@ -687,36 +723,37 @@ done:
* -- ajv@comp.vuw.ac.nz
*/
void
-mtgo(unit)
- register int unit;
+mtgo(arg)
+ void *arg;
{
- register struct mt_softc *sc = &mt_softc[unit];
- register struct buf *bp;
+ struct mt_softc *sc = arg;
+ struct buf *bp;
int rw;
- dlog(LOG_DEBUG, "mt%d go\n", unit);
- bp = mttab[unit].b_actf;
+ dlog(LOG_DEBUG, "%s go", sc->sc_dev.dv_xname);
+ bp = sc->sc_tab.b_actf;
rw = bp->b_flags & B_READ;
hpibgo(sc->sc_hpibno, sc->sc_slave, rw ? MTT_READ : MTL_WRITE,
- bp->b_un.b_addr, bp->b_bcount, rw, rw != 0);
+ bp->b_un.b_addr, bp->b_bcount, rw, rw != 0);
}
-int
+void
mtintr(arg)
void *arg;
{
- register struct mt_softc *sc = arg;
- register struct buf *bp, *dp;
- register int i;
- int unit = sc->sc_hd->hp_unit;
- u_char cmdbuf[4];
+ struct mt_softc *sc = arg;
+ struct buf *bp, *dp;
+ int i;
+ u_char cmdbuf[4];
- bp = mttab[unit].b_actf;
+ bp = sc->sc_tab.b_actf;
if (bp == NULL) {
- log(LOG_ERR, "mt%d intr: bp == NULL\n", unit);
+ log(LOG_ERR, "%s intr: bp == NULL", sc->sc_dev.dv_xname);
return;
}
- dlog(LOG_DEBUG, "mt%d intr\n", unit);
+
+ dlog(LOG_DEBUG, "%s intr", sc->sc_dev.dv_xname);
+
/*
* Some operation completed. Read status bytes and report errors.
* Clear EOF flags here `cause they're set once on specific conditions
@@ -730,7 +767,7 @@ mtintr(arg)
cmdbuf[0] = MTE_STOP;
(void) hpibsend(sc->sc_hpibno, sc->sc_slave, MTL_ECMD,cmdbuf,1);
}
- switch (mtreaddsj(unit, 0)) {
+ switch (mtreaddsj(sc, 0)) {
case 0:
break;
@@ -752,24 +789,25 @@ mtintr(arg)
* to the request for DSJ. It's probably just "busy" figuring
* it out and will know in a little bit...
*/
- timeout(spl_mtintr, (void *)sc, hz >> 5);
+ timeout(spl_mtintr, sc, hz >> 5);
return;
default:
- log(LOG_ERR, "mt%d intr: can't get drive stat\n", unit);
+ log(LOG_ERR, "%s intr: can't get drive stat",
+ sc->sc_dev.dv_xname);
goto error;
}
if (sc->sc_stat1 & (SR1_ERR | SR1_REJECT)) {
i = sc->sc_stat4 & SR4_ERCLMASK;
- log(LOG_ERR, "%s: %s error, retry %d, SR2/3 %x/%x, code %d\n",
- sc->sc_hd->hp_xname, i == SR4_DEVICE ? "device" :
+ log(LOG_ERR, "%s: %s error, retry %d, SR2/3 %x/%x, code %d",
+ sc->sc_dev.dv_xname, i == SR4_DEVICE ? "device" :
(i == SR4_PROTOCOL ? "protocol" :
(i == SR4_SELFTEST ? "selftest" : "unknown")),
sc->sc_stat4 & SR4_RETRYMASK, sc->sc_stat2,
sc->sc_stat3, sc->sc_stat5);
if ((bp->b_flags & B_CMD) && bp->b_cmd == MTRESET)
- untimeout(spl_mtintr, (void *)sc);
+ untimeout(spl_mtintr, sc);
if (sc->sc_stat3 & SR3_POWERUP)
sc->sc_flags &= MTF_OPEN | MTF_EXISTS;
goto error;
@@ -779,7 +817,7 @@ mtintr(arg)
*/
if (sc->sc_stat1 & SR1_SOFTERR) {
log(LOG_WARNING, "%s: soft error, retry %d\n",
- sc->sc_hd->hp_xname, sc->sc_stat4 & SR4_RETRYMASK);
+ sc->sc_dev.dv_xname, sc->sc_stat4 & SR4_RETRYMASK);
sc->sc_stat1 &= ~SR1_SOFTERR;
}
/*
@@ -789,7 +827,7 @@ mtintr(arg)
if (sc->sc_flags & MTF_IO) {
sc->sc_flags &= ~MTF_IO;
if (hpibustart(sc->sc_hpibno))
- mtgo(unit);
+ mtgo(sc);
return;
}
/*
@@ -821,7 +859,7 @@ mtintr(arg)
sc->sc_flags |= MTF_HITBOF;
}
if (bp->b_cmd == MTRESET) {
- untimeout(spl_mtintr, (void *)sc);
+ untimeout(spl_mtintr, sc);
sc->sc_flags |= MTF_ALIVE;
}
} else {
@@ -835,12 +873,12 @@ mtintr(arg)
if (i == 0)
sc->sc_flags |= MTF_HITEOF;
bp->b_resid = bp->b_bcount - i;
- dlog(LOG_DEBUG, "mt%d intr: bcount %d, resid %d\n",
- unit, bp->b_bcount, bp->b_resid);
+ dlog(LOG_DEBUG, "%s intr: bcount %d, resid %d",
+ sc->sc_dev.dv_xname, bp->b_bcount, bp->b_resid);
} else {
tprintf(sc->sc_ttyp,
"%s: record (%d) larger than wanted (%d)\n",
- sc->sc_hd->hp_xname, i, bp->b_bcount);
+ sc->sc_dev.dv_xname, i, bp->b_bcount);
error:
sc->sc_flags &= ~MTF_IO;
bp->b_error = EIO;
@@ -858,38 +896,50 @@ mtintr(arg)
if (dp = bp->b_actf)
dp->b_actb = bp->b_actb;
else
- mttab[unit].b_actb = bp->b_actb;
+ sc->sc_tab.b_actb = bp->b_actb;
*bp->b_actb = dp;
- hpibfree(&(sc->sc_dq));
+ hpibfree(sc->sc_dev.dv_parent, &sc->sc_hq);
#if 0
- if (bp /*mttab[unit].b_actf*/ == NULL)
+ if (bp /*sc->sc_tab.b_actf*/ == NULL)
#else
- if (mttab[unit].b_actf == NULL)
+ if (sc->sc_tab.b_actf == NULL)
#endif
- mttab[unit].b_active = 0;
+ sc->sc_tab.b_active = 0;
else
- mtustart(unit);
+ mtustart(sc);
}
-mtread(dev, uio)
+int
+mtread(dev, uio, flags)
dev_t dev;
struct uio *uio;
+ int flags;
{
- return(physio(mtstrategy, &mtbuf[UNIT(dev)], dev, B_READ, minphys, uio));
+ struct mt_softc *sc = mt_cd.cd_devs[UNIT(dev)];
+
+ return(physio(mtstrategy, &sc->sc_bufstore,
+ dev, B_READ, minphys, uio));
}
-mtwrite(dev, uio)
+int
+mtwrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
+ int flags;
{
- return(physio(mtstrategy, &mtbuf[UNIT(dev)], dev, B_WRITE, minphys, uio));
+ struct mt_softc *sc = mt_cd.cd_devs[UNIT(dev)];
+
+ return(physio(mtstrategy, &sc->sc_bufstore,
+ dev, B_WRITE, minphys, uio));
}
-mtioctl(dev, cmd, data, flag)
+int
+mtioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
caddr_t data;
int flag;
+ struct proc *p;
{
register struct mtop *op;
int cnt;
@@ -927,10 +977,12 @@ mtioctl(dev, cmd, data, flag)
}
/*ARGSUSED*/
-mtdump(dev)
+int
+mtdump(dev, blkno, va, size)
dev_t dev;
+ daddr_t blkno;
+ caddr_t va;
+ size_t size;
{
- return(ENXIO);
+ return (ENODEV);
}
-
-#endif /* NMT > 0 */
diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c
index edf606177d7..ee635cceb2f 100644
--- a/sys/arch/hp300/dev/nhpib.c
+++ b/sys/arch/hp300/dev/nhpib.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: nhpib.c,v 1.5 1997/01/12 15:12:56 downsj Exp $ */
-/* $NetBSD: nhpib.c,v 1.13 1996/10/13 03:14:19 christos Exp $ */
+/* $OpenBSD: nhpib.c,v 1.6 1997/02/03 04:47:40 downsj Exp $ */
+/* $NetBSD: nhpib.c,v 1.14 1997/01/30 09:06:54 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -39,18 +40,25 @@
/*
* Internal/98624 HPIB driver
*/
-#include "hpib.h"
-#if NHPIB > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/buf.h>
+#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>
-#include <hp300/dev/device.h>
#include <hp300/dev/nhpibreg.h>
#include <hp300/dev/hpibvar.h>
-#include <hp300/dev/dmavar.h>
/*
* ODD parity table for listen and talk addresses and secondary commands.
@@ -75,13 +83,17 @@ static u_char sec_par[] = {
0370,0171,0172,0373,0174,0375,0376,0177
};
-void nhpibreset __P((int));
-int nhpibsend __P((int, int, int, void *, int));
-int nhpibrecv __P((int, int, int, void *, int));
-int nhpibppoll __P((int));
+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 *));
void nhpibppwatch __P((void *));
-void nhpibgo __P((int, int, int, void *, int, int, int));
-void nhpibdone __P((int));
+void nhpibgo __P((struct hpibbus_softc *, int, int, void *, int, int, int));
+void nhpibdone __P((struct hpibbus_softc *));
int nhpibintr __P((void *));
/*
@@ -98,60 +110,92 @@ struct hpib_controller nhpib_controller = {
nhpibintr
};
+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 *, void *, 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
+};
+
int
-nhpibtype(hc)
- register struct hp_ctlr *hc;
+nhpibmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
- register struct nhpibdevice *hd = (struct nhpibdevice *)hc->hp_addr;
+ struct dio_attach_args *da = aux;
- if (hc->hp_addr == internalhpib) {
- hs->sc_type = HPIBA;
- hc->hp_ipl = HPIBA_IPL;
+ /*
+ * Internal HP-IB doesn't always return a device ID,
+ * so we rely on the sysflags.
+ */
+ if (da->da_scode == 7 && internalhpib)
return (1);
- } else if (hd->hpib_cid == HPIBB) {
- hs->sc_type = HPIBB;
- hc->hp_ipl = HPIB_IPL(hd->hpib_ids);
+
+ if (da->da_id == DIO_DEVICE_ID_NHPIB)
return (1);
- }
- return(0);
+ return (0);
}
void
-nhpibattach(hc)
- register struct hp_ctlr *hc;
+nhpibattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
- register struct nhpibdevice *hd = (struct nhpibdevice *)hc->hp_addr;
-
- switch (hs->sc_type) {
- case HPIBA:
- hs->sc_ba = HPIBA_BA;
- hs->sc_descrip = "Internal HP-IB";
- break;
-
- case HPIBB:
- hs->sc_ba = hd->hpib_csa & CSA_BA;
- hs->sc_descrip = "98624 HP-IB";
- break;
-
- default:
- panic("nhpibattach: unknown type 0x%x", hs->sc_type);
- /* NOTREACHED */
+ 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;
}
- hs->sc_controller = &nhpib_controller;
+ 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);
}
void
-nhpibreset(unit)
- int unit;
+nhpibreset(hs)
+ struct hpibbus_softc *hs;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct nhpibdevice *hd;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
+ struct nhpibdevice *hd = sc->sc_regs;
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_acr = AUX_SSWRST;
hd->hpib_ar = hs->sc_ba;
hd->hpib_lim = LIS_ERR;
@@ -171,6 +215,7 @@ nhpibreset(unit)
DELAY(100000);
}
+void
nhpibifc(hd)
register struct nhpibdevice *hd;
{
@@ -183,16 +228,16 @@ nhpibifc(hd)
}
int
-nhpibsend(unit, slave, sec, ptr, origcnt)
- int unit, slave, sec, origcnt;
+nhpibsend(hs, slave, sec, ptr, origcnt)
+ struct hpibbus_softc *hs;
+ int slave, sec, origcnt;
void *ptr;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct nhpibdevice *hd;
- register int cnt = origcnt;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
+ struct nhpibdevice *hd = sc->sc_regs;
+ int cnt = origcnt;
char *addr = ptr;
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_acr = AUX_TCA;
hd->hpib_data = C_UNL_P;
if (nhpibwait(hd, MIS_BO))
@@ -241,16 +286,16 @@ senderror:
}
int
-nhpibrecv(unit, slave, sec, ptr, origcnt)
- int unit, slave, sec, origcnt;
+nhpibrecv(hs, slave, sec, ptr, origcnt)
+ struct hpibbus_softc *hs;
+ int slave, sec, origcnt;
void *ptr;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct nhpibdevice *hd;
- register int cnt = origcnt;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
+ struct nhpibdevice *hd = sc->sc_regs;
+ int cnt = origcnt;
char *addr = ptr;
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
/*
* Slave < 0 implies continuation of a previous receive
* that probably timed out.
@@ -294,15 +339,15 @@ recvbyteserror:
}
void
-nhpibgo(unit, slave, sec, ptr, count, rw, timo)
- int unit, slave, sec, count, rw, timo;
+nhpibgo(hs, slave, sec, ptr, count, rw, timo)
+ struct hpibbus_softc *hs;
+ int slave, sec, count, rw, timo;
void *ptr;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct nhpibdevice *hd;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
+ struct nhpibdevice *hd = sc->sc_regs;
char *addr = ptr;
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
hs->sc_flags |= HPIBF_IO;
if (timo)
hs->sc_flags |= HPIBF_TIMO;
@@ -318,22 +363,22 @@ nhpibgo(unit, slave, sec, ptr, count, rw, timo)
hs->sc_addr = addr;
if (hs->sc_flags & HPIBF_READ) {
hs->sc_curcnt = count;
- dmago(hs->sc_dq.dq_ctlr, addr, count, DMAGO_BYTE|DMAGO_READ);
- nhpibrecv(unit, slave, sec, 0, 0);
+ dmago(hs->sc_dq->dq_chan, addr, count, DMAGO_BYTE|DMAGO_READ);
+ nhpibrecv(hs, slave, sec, 0, 0);
hd->hpib_mim = MIS_END;
} else {
hd->hpib_mim = 0;
if (count < hpibdmathresh) {
hs->sc_curcnt = count;
- nhpibsend(unit, slave, sec, addr, count);
- nhpibdone(unit);
+ nhpibsend(hs, slave, sec, addr, count);
+ nhpibdone(hs);
return;
}
hs->sc_curcnt = --count;
- dmago(hs->sc_dq.dq_ctlr, addr, count, DMAGO_BYTE);
- nhpibsend(unit, slave, sec, 0, 0);
+ dmago(hs->sc_dq->dq_chan, addr, count, DMAGO_BYTE);
+ nhpibsend(hs, slave, sec, 0, 0);
}
- hd->hpib_ie = IDS_IE | IDS_DMA(hs->sc_dq.dq_ctlr);
+ hd->hpib_ie = IDS_IE | IDS_DMA(hs->sc_dq->dq_chan);
}
/*
@@ -347,36 +392,33 @@ void
nhpibreadtimo(arg)
void *arg;
{
- int unit;
- register struct hpib_softc *hs;
+ struct hpibbus_softc *hs = arg;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
int s = splbio();
- unit = (int)arg;
- hs = &hpib_softc[unit];
if (hs->sc_flags & HPIBF_IO) {
- register struct nhpibdevice *hd;
- register struct devqueue *dq;
+ register struct nhpibdevice *hd = sc->sc_regs;
+ register struct hpibqueue *hq;
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_mim = 0;
hd->hpib_acr = AUX_TCA;
hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO);
- dmafree(&hs->sc_dq);
- dq = hs->sc_sq.dq_forw;
- (dq->dq_driver->d_intr)(dq->dq_softc);
+ dmafree(hs->sc_dq);
+
+ hq = hs->sc_queue.tqh_first;
+ (hq->hq_intr)(hq->hq_softc);
}
- (void) splx(s);
+ splx(s);
}
void
-nhpibdone(unit)
- register int unit;
+nhpibdone(hs)
+ struct hpibbus_softc *hs;
{
- register struct hpib_softc *hs = &hpib_softc[unit];
- register struct nhpibdevice *hd;
- register int cnt;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
+ struct nhpibdevice *hd = sc->sc_regs;
+ int cnt;
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
cnt = hs->sc_curcnt;
hs->sc_addr += cnt;
hs->sc_count -= cnt;
@@ -385,7 +427,7 @@ nhpibdone(unit)
if (hs->sc_flags & HPIBF_READ) {
if ((hs->sc_flags & HPIBF_TIMO) &&
(hd->hpib_ids & IDS_IR) == 0)
- timeout(nhpibreadtimo, (void *)unit, hz >> 2);
+ timeout(nhpibreadtimo, hs, hz >> 2);
} else {
if (hs->sc_count == 1) {
(void) nhpibwait(hd, MIS_BO);
@@ -404,56 +446,59 @@ int
nhpibintr(arg)
void *arg;
{
- register struct hpib_softc *hs = arg;
- register struct nhpibdevice *hd;
- register struct devqueue *dq;
- register int stat0;
- int stat1, unit = hs->sc_hc->hp_unit;
+ 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;
#ifdef lint
if (stat1 = unit) return(1);
#endif
- hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
if ((hd->hpib_ids & IDS_IR) == 0)
return(0);
stat0 = hd->hpib_mis;
stat1 = hd->hpib_lis;
- dq = hs->sc_sq.dq_forw;
+
+ hq = hs->sc_queue.tqh_first;
+
if (hs->sc_flags & HPIBF_IO) {
hd->hpib_mim = 0;
if ((hs->sc_flags & HPIBF_DONE) == 0) {
hs->sc_flags &= ~HPIBF_TIMO;
- dmastop(hs->sc_dq.dq_ctlr);
+ dmastop(hs->sc_dq->dq_chan);
} else if (hs->sc_flags & HPIBF_TIMO)
- untimeout(nhpibreadtimo, (void *)unit);
+ untimeout(nhpibreadtimo, hs);
hd->hpib_acr = AUX_TCA;
hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO);
- dmafree(&hs->sc_dq);
- (dq->dq_driver->d_intr)(dq->dq_softc);
+
+ dmafree(hs->sc_dq);
+ (hq->hq_intr)(hq->hq_softc);
} else if (hs->sc_flags & HPIBF_PPOLL) {
hd->hpib_mim = 0;
- stat0 = nhpibppoll(unit);
- if (stat0 & (0x80 >> dq->dq_slave)) {
+ stat0 = nhpibppoll(hs);
+ if (stat0 & (0x80 >> hq->hq_slave)) {
hs->sc_flags &= ~HPIBF_PPOLL;
- (dq->dq_driver->d_intr)(dq->dq_softc);
+ (hq->hq_intr)(hq->hq_softc);
}
#ifdef DEBUG
else
printf("%s: PPOLL intr bad status %x\n",
- hs->sc_hc->hp_xname, stat0);
+ hs->sc_dev.dv_xname, stat0);
#endif
}
return(1);
}
int
-nhpibppoll(unit)
- int unit;
+nhpibppoll(hs)
+ struct hpibbus_softc *hs;
{
- register struct nhpibdevice *hd;
- register int ppoll;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
+ struct nhpibdevice *hd = sc->sc_regs;
+ int ppoll;
- hd = (struct nhpibdevice *)hpib_softc[unit].sc_hc->hp_addr;
hd->hpib_acr = AUX_SPP;
DELAY(25);
ppoll = hd->hpib_cpt;
@@ -488,21 +533,18 @@ void
nhpibppwatch(arg)
void *arg;
{
- register struct hpib_softc *hs;
- register int unit;
+ struct hpibbus_softc *hs = arg;
+ struct nhpib_softc *sc = (struct nhpib_softc *)hs->sc_dev.dv_parent;
extern int cold;
- unit = (int)arg;
- hs = &hpib_softc[unit];
if ((hs->sc_flags & HPIBF_PPOLL) == 0)
return;
again:
- if (nhpibppoll(unit) & (0x80 >> hs->sc_sq.dq_forw->dq_slave))
- ((struct nhpibdevice *)hs->sc_hc->hp_addr)->hpib_mim = MIS_BO;
+ if (nhpibppoll(hs) & (0x80 >> hs->sc_queue.tqh_first->hq_slave))
+ sc->sc_regs->hpib_mim = MIS_BO;
else if (cold)
/* timeouts not working yet */
goto again;
else
- timeout(nhpibppwatch, (void *)unit, 1);
+ timeout(nhpibppwatch, hs, 1);
}
-#endif /* NHPIB > 0 */
diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c
index 8a3a5cddc57..318b1b9ebe0 100644
--- a/sys/arch/hp300/dev/ppi.c
+++ b/sys/arch/hp300/dev/ppi.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: ppi.c,v 1.4 1997/01/12 15:12:57 downsj Exp $ */
-/* $NetBSD: ppi.c,v 1.10 1996/10/13 03:14:20 christos Exp $ */
+/* $OpenBSD: ppi.c,v 1.5 1997/02/03 04:47:41 downsj Exp $ */
+/* $NetBSD: ppi.c,v 1.11 1997/01/30 09:14:16 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -40,34 +41,29 @@
* Printer/Plotter HPIB interface
*/
-#include "ppi.h"
-#if NPPI > 0
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/malloc.h>
+#include <sys/device.h>
+#include <sys/conf.h>
-#include <hp300/dev/device.h>
-#include <hp300/dev/ppiioctl.h>
+#include <hp300/dev/hpibvar.h>
-int ppimatch(), ppistart();
-void ppiattach(), ppitimo();
-struct driver ppidriver = {
- ppimatch, ppiattach, "ppi", ppistart,
-};
+#include <hp300/dev/ppiioctl.h>
struct ppi_softc {
+ struct device sc_dev;
int sc_flags;
- struct devqueue sc_dq;
- struct hp_device *sc_hd;
+ struct hpibqueue sc_hq; /* HP-IB job queue entry */
struct ppiparam sc_param;
#define sc_burst sc_param.burst
#define sc_timo sc_param.timo
#define sc_delay sc_param.delay
int sc_sec;
-} ppi_softc[NPPI];
+ int sc_slave; /* HP-IB slave address */
+};
/* sc_flags values */
#define PPIF_ALIVE 0x01
@@ -76,6 +72,28 @@ struct ppi_softc {
#define PPIF_TIMO 0x08
#define PPIF_DELAY 0x10
+int ppimatch __P((struct device *, void *, void *));
+void ppiattach __P((struct device *, struct device *, void *));
+
+struct cfattach ppi_ca = {
+ sizeof(struct ppi_softc), ppimatch, ppiattach
+};
+
+struct cfdriver ppi_cd = {
+ NULL, "ppi", DV_DULL
+};
+
+void ppistart __P((void *));
+void ppinoop __P((void *));
+
+void ppitimo __P((void *));
+int ppirw __P((dev_t, struct uio *));
+int ppihztoms __P((int));
+int ppimstohz __P((int));
+
+bdev_decl(ppi);
+cdev_decl(ppi);
+
#define UNIT(x) minor(x)
#ifdef DEBUG
@@ -86,57 +104,82 @@ int ppidebug = 0x80;
#endif
int
-ppimatch(hd)
- register struct hp_device *hd;
+ppimatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct ppi_softc *sc = &ppi_softc[hd->hp_unit];
+ struct cfdata *cf = match;
+ struct hpibbus_attach_args *ha = aux;
+
+ /*
+ * The printer/plotter doesn't return an ID tag.
+ * The check below prevents us from matching a CS80
+ * device by mistake.
+ */
+ if (ha->ha_id & 0x200)
+ return (0);
-#ifdef DEBUG
- if ((ppidebug & PDB_NOCHECK) == 0)
-#endif
/*
- * XXX: the printer/plotter doesn't seem to really return
- * an ID but this will at least prevent us from mistaking
- * a cs80 disk or tape for a ppi device.
+ * To prevent matching all unused slots on the bus, we
+ * don't allow wildcarded locators.
*/
- if (hpibid(hd->hp_ctlr, hd->hp_slave) & 0x200)
+ if (cf->hpibbuscf_slave == HPIBBUS_SLAVE_UNK ||
+ cf->hpibbuscf_punit == HPIBBUS_PUNIT_UNK)
return (0);
- sc->sc_hd = hd;
return (1);
}
void
-ppiattach(hd)
- register struct hp_device *hd;
+ppiattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- struct ppi_softc *sc = &ppi_softc[hd->hp_unit];
+ struct ppi_softc *sc = (struct ppi_softc *)self;
+ struct hpibbus_attach_args *ha = aux;
printf("\n");
+ sc->sc_slave = ha->ha_slave;
+
+ /* Initialize the hpib queue entry. */
+ sc->sc_hq.hq_softc = sc;
+ sc->sc_hq.hq_slave = sc->sc_slave;
+ sc->sc_hq.hq_start = ppistart;
+ sc->sc_hq.hq_go = ppinoop;
+ sc->sc_hq.hq_intr = ppinoop;
+
sc->sc_flags = PPIF_ALIVE;
- sc->sc_dq.dq_softc = sc;
- sc->sc_dq.dq_ctlr = hd->hp_ctlr;
- sc->sc_dq.dq_unit = hd->hp_unit;
- sc->sc_dq.dq_slave = hd->hp_slave;
- sc->sc_dq.dq_driver = &ppidriver;
}
-ppiopen(dev, flags)
+void
+ppinoop(arg)
+ void *arg;
+{
+ /* Noop! */
+}
+
+int
+ppiopen(dev, flags, fmt, p)
dev_t dev;
+ int flags, fmt;
+ struct proc *p;
{
register int unit = UNIT(dev);
- register struct ppi_softc *sc = &ppi_softc[unit];
+ struct ppi_softc *sc;
+
+ if (unit >= ppi_cd.cd_ndevs ||
+ (sc = ppi_cd.cd_devs[unit]) == NULL ||
+ (sc->sc_flags & PPIF_ALIVE) == 0)
+ return (ENXIO);
- if (unit >= NPPI || (sc->sc_flags & PPIF_ALIVE) == 0)
- return(ENXIO);
#ifdef DEBUG
if (ppidebug & PDB_FOLLOW)
printf("ppiopen(%x, %x): flags %x\n",
dev, flags, sc->sc_flags);
#endif
if (sc->sc_flags & PPIF_OPEN)
- return(EBUSY);
+ return (EBUSY);
sc->sc_flags |= PPIF_OPEN;
sc->sc_burst = PPI_BURST;
sc->sc_timo = ppimstohz(PPI_TIMO);
@@ -145,11 +188,14 @@ ppiopen(dev, flags)
return(0);
}
-ppiclose(dev, flags)
+int
+ppiclose(dev, flags, fmt, p)
dev_t dev;
+ int flags, fmt;
+ struct proc *p;
{
register int unit = UNIT(dev);
- register struct ppi_softc *sc = &ppi_softc[unit];
+ struct ppi_softc *sc = ppi_cd.cd_devs[unit];
#ifdef DEBUG
if (ppidebug & PDB_FOLLOW)
@@ -160,33 +206,39 @@ ppiclose(dev, flags)
return(0);
}
-ppistart(unit)
- int unit;
+void
+ppistart(arg)
+ void *arg;
{
+ struct ppi_softc *sc = arg;
+
#ifdef DEBUG
if (ppidebug & PDB_FOLLOW)
printf("ppistart(%x)\n", unit);
#endif
- ppi_softc[unit].sc_flags &= ~PPIF_DELAY;
- wakeup(&ppi_softc[unit]);
- return (0);
+ sc->sc_flags &= ~PPIF_DELAY;
+ wakeup(sc);
}
void
-ppitimo(unit)
- int unit;
+ppitimo(arg)
+ void *arg;
{
+ struct ppi_softc *sc = arg;
+
#ifdef DEBUG
if (ppidebug & PDB_FOLLOW)
- printf("ppitimo(%x)\n", unit);
+ printf("ppitimo(%x)\n", sc->sc_dev.dv_unit);
#endif
- ppi_softc[unit].sc_flags &= ~(PPIF_UIO|PPIF_TIMO);
- wakeup(&ppi_softc[unit]);
+ sc->sc_flags &= ~(PPIF_UIO|PPIF_TIMO);
+ wakeup(sc);
}
-ppiread(dev, uio)
+int
+ppiread(dev, uio, flags)
dev_t dev;
struct uio *uio;
+ int flags;
{
#ifdef DEBUG
@@ -196,9 +248,11 @@ ppiread(dev, uio)
return (ppirw(dev, uio));
}
-ppiwrite(dev, uio)
+int
+ppiwrite(dev, uio, flags)
dev_t dev;
struct uio *uio;
+ int flags;
{
#ifdef DEBUG
@@ -208,21 +262,25 @@ ppiwrite(dev, uio)
return (ppirw(dev, uio));
}
+int
ppirw(dev, uio)
dev_t dev;
register struct uio *uio;
{
int unit = UNIT(dev);
- register struct ppi_softc *sc = &ppi_softc[unit];
+ struct ppi_softc *sc = ppi_cd.cd_devs[unit];
register int s, len, cnt;
register char *cp;
int error = 0, gotdata = 0;
- int buflen;
+ int buflen, ctlr, slave;
char *buf;
if (uio->uio_resid == 0)
return(0);
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_slave;
+
#ifdef DEBUG
if (ppidebug & (PDB_FOLLOW|PDB_IO))
printf("ppirw(%x, %x, %c): burst %d, timo %d, resid %x\n",
@@ -234,7 +292,7 @@ ppirw(dev, uio)
sc->sc_flags |= PPIF_UIO;
if (sc->sc_timo > 0) {
sc->sc_flags |= PPIF_TIMO;
- timeout(ppitimo, (void *)unit, sc->sc_timo);
+ timeout(ppitimo, sc, sc->sc_timo);
}
while (uio->uio_resid > 0) {
len = min(buflen, uio->uio_resid);
@@ -246,7 +304,8 @@ ppirw(dev, uio)
}
again:
s = splbio();
- if ((sc->sc_flags & PPIF_UIO) && hpibreq(&sc->sc_dq) == 0)
+ if ((sc->sc_flags & PPIF_UIO) &&
+ hpibreq(sc->sc_dev.dv_parent, &sc->sc_hq) == 0)
sleep(sc, PRIBIO+1);
/*
* Check if we timed out during sleep or uiomove
@@ -259,7 +318,7 @@ again:
sc->sc_flags);
#endif
if (sc->sc_flags & PPIF_TIMO) {
- untimeout(ppitimo, (void *)unit);
+ untimeout(ppitimo, sc);
sc->sc_flags &= ~PPIF_TIMO;
}
splx(s);
@@ -270,19 +329,16 @@ again:
* Perform the operation
*/
if (uio->uio_rw == UIO_WRITE)
- cnt = hpibsend(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- sc->sc_sec, cp, len);
+ cnt = hpibsend(ctlr, slave, sc->sc_sec, cp, len);
else
- cnt = hpibrecv(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- sc->sc_sec, cp, len);
+ cnt = hpibrecv(ctlr, slave, sc->sc_sec, cp, len);
s = splbio();
- hpibfree(&sc->sc_dq);
+ hpibfree(sc->sc_dev.dv_parent, &sc->sc_hq);
#ifdef DEBUG
if (ppidebug & PDB_IO)
printf("ppirw: %s(%d, %d, %x, %x, %d) -> %d\n",
uio->uio_rw == UIO_READ ? "recv" : "send",
- sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
- sc->sc_sec, cp, len, cnt);
+ ctlr, slave, sc->sc_sec, cp, len, cnt);
#endif
splx(s);
if (uio->uio_rw == UIO_READ) {
@@ -316,8 +372,7 @@ again:
*/
if (sc->sc_delay > 0) {
sc->sc_flags |= PPIF_DELAY;
- timeout((void (*)__P((void *)))ppistart, (void *)unit,
- sc->sc_delay);
+ timeout(ppistart, sc, sc->sc_delay);
error = tsleep(sc, PCATCH|PZERO+1, "hpib", 0);
if (error) {
splx(s);
@@ -338,11 +393,11 @@ again:
}
s = splsoftclock();
if (sc->sc_flags & PPIF_TIMO) {
- untimeout(ppitimo, (void *)unit);
+ untimeout(ppitimo, sc);
sc->sc_flags &= ~PPIF_TIMO;
}
if (sc->sc_flags & PPIF_DELAY) {
- untimeout((void (*)__P((void *)))ppistart, (void *)unit);
+ untimeout(ppistart, sc);
sc->sc_flags &= ~PPIF_DELAY;
}
splx(s);
@@ -365,14 +420,15 @@ again:
return (error);
}
+int
ppiioctl(dev, cmd, data, flag, p)
dev_t dev;
- int cmd;
+ u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{
- struct ppi_softc *sc = &ppi_softc[UNIT(dev)];
+ struct ppi_softc *sc = ppi_cd.cd_devs[UNIT(dev)];
struct ppiparam *pp, *upp;
int error = 0;
@@ -403,6 +459,7 @@ ppiioctl(dev, cmd, data, flag, p)
return (error);
}
+int
ppihztoms(h)
int h;
{
@@ -414,6 +471,7 @@ ppihztoms(h)
return(m);
}
+int
ppimstohz(m)
int m;
{
@@ -427,4 +485,3 @@ ppimstohz(m)
}
return(h);
}
-#endif
diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c
index e34026ff1b3..7af83b52b3d 100644
--- a/sys/arch/hp300/dev/rd.c
+++ b/sys/arch/hp300/dev/rd.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: rd.c,v 1.7 1997/01/12 15:12:58 downsj Exp $ */
-/* $NetBSD: rd.c,v 1.26 1997/01/07 09:29:32 thorpej Exp $ */
+/* $OpenBSD: rd.c,v 1.8 1997/02/03 04:47:42 downsj Exp $ */
+/* $NetBSD: rd.c,v 1.27 1997/01/30 09:14:17 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -46,8 +47,6 @@
/*
* CS80/SS80 disk driver
*/
-#include "rd.h"
-#if NRD > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -57,10 +56,14 @@
#include <sys/disk.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+
+#include <hp300/dev/hpibvar.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/rdreg.h>
#include <hp300/dev/rdvar.h>
+
#ifdef USELEDS
#include <hp300/hp300/led.h>
#endif
@@ -70,14 +73,32 @@
#include <vm/vm_prot.h>
#include <vm/pmap.h>
-int rdmatch(), rdstart(), rdgo(), rdintr();
-void rdattach(), rdstrategy();
-struct driver rddriver = {
- rdmatch, rdattach, "rd", rdstart, rdgo, rdintr,
+int rdmatch __P((struct device *, void *, void *));
+void rdattach __P((struct device *, struct device *, void *));
+
+struct cfattach rd_ca = {
+ sizeof(struct rd_softc), rdmatch, rdattach
+};
+
+struct cfdriver rd_cd = {
+ NULL, "rd", DV_DISK
};
-struct rd_softc rd_softc[NRD];
-struct buf rdtab[NRD];
+int rdident __P((struct device *, struct rd_softc *,
+ struct hpibbus_attach_args *));
+void rdreset __P((struct rd_softc *));
+void rdustart __P((struct rd_softc *));
+int rdgetinfo __P((dev_t));
+void rdrestart __P((void *));
+struct buf *rdfinish __P((struct rd_softc *, struct buf *));
+
+void rdstart __P((void *));
+void rdintr __P((void *));
+void rdgo __P((void *));
+
+bdev_decl(rd);
+cdev_decl(rd);
+
int rderrthresh = RDRETRY-1; /* when to start reporting errors */
#ifdef DEBUG
@@ -148,7 +169,6 @@ char *err_info[] = {
0, 0
};
-struct rdstats rdstats[NRD];
int rddebug = 0x80;
#define RDB_FOLLOW 0x01
#define RDB_STATUS 0x02
@@ -223,144 +243,153 @@ struct rdidentinfo rdidentinfo[] = {
int numrdidentinfo = sizeof(rdidentinfo) / sizeof(rdidentinfo[0]);
int
-rdmatch(hd)
- register struct hp_device *hd;
+rdmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct rd_softc *rs = &rd_softc[hd->hp_unit];
+ struct cfdata *cf = match;
+ struct hpibbus_attach_args *ha = aux;
- rs->sc_hd = hd;
- rs->sc_punit = rdpunit(hd->hp_flags);
- rs->sc_type = rdident(rs, hd, 0);
- if (rs->sc_type < 0) {
+ /*
+ * Set punit if operator specified one in the kernel
+ * configuration file.
+ */
+ if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK &&
+ cf->hpibbuscf_punit < HPIB_NPUNITS)
+ ha->ha_punit = cf->hpibbuscf_punit;
+
+ if (rdident(parent, NULL, ha) == 0) {
/*
- * XXX Some ancient drives may be slow to respond, so
- * probe them again.
+ * XXX Some aging HP-IB drives are slow to
+ * XXX respond; give them a chance to catch
+ * XXX up and probe them again.
*/
- DELAY(10000);
- rs->sc_type = rdident(rs, hd, 0);
- if (rs->sc_type < 0)
- return (0);
+ delay(10000);
+ ha->ha_id = hpibid(parent->dv_unit, ha->ha_slave);
+ return (rdident(parent, NULL, ha));
}
+ return (1);
+}
- /* XXX set up the external name */
- bzero(rs->sc_xname, sizeof(rs->sc_xname));
- sprintf(rs->sc_xname, "rd%d", hd->hp_unit);
+void
+rdattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct rd_softc *sc = (struct rd_softc *)self;
+ struct hpibbus_attach_args *ha = aux;
+
+ if (rdident(parent, sc, ha) == 0) {
+ printf("\n%s: didn't respond to describe command!\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
/*
* Initialize and attach the disk structure.
*/
- bzero(&rs->sc_dkdev, sizeof(rs->sc_dkdev));
- rs->sc_dkdev.dk_name = rs->sc_xname;
- disk_attach(&rs->sc_dkdev);
-
- return (1);
-}
+ bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
+ sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
+ disk_attach(&sc->sc_dkdev);
-void
-rdattach(hd)
- register struct hp_device *hd;
-{
- register struct rd_softc *rs = &rd_softc[hd->hp_unit];
+ sc->sc_slave = ha->ha_slave;
+ sc->sc_punit = ha->ha_punit;
- (void)rdident(rs, hd, 1); /* XXX Ick. */
+ /* Initialize the hpib job queue entry */
+ sc->sc_hq.hq_softc = sc;
+ sc->sc_hq.hq_slave = sc->sc_slave;
+ sc->sc_hq.hq_start = rdstart;
+ sc->sc_hq.hq_go = rdgo;
+ sc->sc_hq.hq_intr = rdintr;
- rs->sc_dq.dq_softc = rs;
- rs->sc_dq.dq_ctlr = hd->hp_ctlr;
- rs->sc_dq.dq_unit = hd->hp_unit;
- rs->sc_dq.dq_slave = hd->hp_slave;
- rs->sc_dq.dq_driver = &rddriver;
- rs->sc_flags = RDF_ALIVE;
+ sc->sc_flags = RDF_ALIVE;
#ifdef DEBUG
/* always report errors */
if (rddebug & RDB_ERROR)
rderrthresh = 0;
#endif
- /* XXX Set device class. */
- hd->hp_dev.dv_class = DV_DISK;
+ dk_establish(&sc->sc_dkdev, &sc->sc_dev); /* XXX */
}
int
-rdident(rs, hd, verbose)
- struct rd_softc *rs;
- struct hp_device *hd;
- int verbose;
+rdident(parent, sc, ha)
+ struct device *parent;
+ struct rd_softc *sc;
+ struct hpibbus_attach_args *ha;
{
- struct rd_describe *desc = &rs->sc_rddesc;
+ struct rd_softc rsc;
+ struct rd_describe *desc = sc != NULL ? &sc->sc_rddesc : NULL;
u_char stat, cmd[3];
- int unit, lunit;
char name[7];
- register int ctlr, slave, id, i;
+ int i, id, n, ctlr, slave;
+
+ ctlr = parent->dv_unit;
+ slave = ha->ha_slave;
- ctlr = hd->hp_ctlr;
- slave = hd->hp_slave;
- unit = rs->sc_punit;
- lunit = hd->hp_unit;
+ /* Verify that we have a CS80 device. */
+ if ((ha->ha_id & 0x200) == 0)
+ return (0);
+
+ /* Is it one of the disks we support? */
+ for (id = 0; id < numrdidentinfo; id++)
+ if (ha->ha_id == rdidentinfo[id].ri_hwid)
+ break;
+ if (id == numrdidentinfo || ha->ha_punit > rdidentinfo[id].ri_maxunum)
+ return (0);
/*
- * Grab device id and make sure:
- * 1. It is a CS80 device.
- * 2. It is one of the types we support.
- * 3. If it is a 7946, we are accessing the disk unit (0)
+ * If we're just probing for the device, that's all the
+ * work we need to do.
*/
- id = hpibid(ctlr, slave);
-#ifdef DEBUG
- if (rddebug & RDB_IDENT)
- printf("hpibid(%d, %d) -> %x\n", ctlr, slave, id);
-#endif
- if ((id & 0x200) == 0)
- return(-1);
- for (i = 0; i < numrdidentinfo; i++)
- if (id == rdidentinfo[i].ri_hwid)
- break;
- if (i == numrdidentinfo || unit > rdidentinfo[i].ri_maxunum)
- return(-1);
- id = i;
+ if (sc == NULL)
+ return (1);
/*
- * Reset drive and collect device description.
- * Don't really use the description info right now but
- * might come in handy in the future (for disk labels).
+ * Reset device and collect description
*/
- rdreset(rs, hd);
- cmd[0] = C_SUNIT(unit);
+ rdreset(sc);
+ cmd[0] = C_SUNIT(ha->ha_punit);
cmd[1] = C_SVOL(0);
cmd[2] = C_DESC;
hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd));
hpibrecv(ctlr, slave, C_EXEC, desc, 37);
hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
- bzero(name, sizeof(name));
- if (!stat) {
- register int n = desc->d_name;
+ bzero(name, sizeof(name));
+ if (stat == 0) {
+ n = desc->d_name;
for (i = 5; i >= 0; i--) {
name[i] = (n & 0xf) + '0';
n >>= 4;
}
}
+
#ifdef DEBUG
if (rddebug & RDB_IDENT) {
- printf("rd%d: name: %x ('%s')\n",
- lunit, desc->d_name, name);
+ printf("\n%s: name: %x ('%s')\n",
+ sc->sc_dev.dv_xname, desc->d_name, name);
printf(" iuw %x, maxxfr %d, ctype %d\n",
- desc->d_iuw, desc->d_cmaxxfr, desc->d_ctype);
+ desc->d_iuw, desc->d_cmaxxfr, desc->d_ctype);
printf(" utype %d, bps %d, blkbuf %d, burst %d, blktime %d\n",
- desc->d_utype, desc->d_sectsize,
- desc->d_blkbuf, desc->d_burstsize, desc->d_blocktime);
+ desc->d_utype, desc->d_sectsize,
+ desc->d_blkbuf, desc->d_burstsize, desc->d_blocktime);
printf(" avxfr %d, ort %d, atp %d, maxint %d, fv %x, rv %x\n",
- desc->d_uavexfr, desc->d_retry, desc->d_access,
- desc->d_maxint, desc->d_fvbyte, desc->d_rvbyte);
+ desc->d_uavexfr, desc->d_retry, desc->d_access,
+ desc->d_maxint, desc->d_fvbyte, desc->d_rvbyte);
printf(" maxcyl/head/sect %d/%d/%d, maxvsect %d, inter %d\n",
- desc->d_maxcyl, desc->d_maxhead, desc->d_maxsect,
- desc->d_maxvsectl, desc->d_interleave);
+ desc->d_maxcyl, desc->d_maxhead, desc->d_maxsect,
+ desc->d_maxvsectl, desc->d_interleave);
+ printf("%s", sc->sc_dev.dv_xname);
}
#endif
+
/*
* Take care of a couple of anomolies:
* 1. 7945A and 7946A both return same HW id
* 2. 9122S and 9134D both return same HW id
* 3. 9122D and 9134L both return same HW id
*/
- switch (rdidentinfo[id].ri_hwid) {
+ switch (ha->ha_id) {
case RD7946AID:
if (bcmp(name, "079450", 6) == 0)
id = RD7945A;
@@ -382,53 +411,56 @@ rdident(rs, hd, verbose)
id = RD9134D;
break;
}
+
+ sc->sc_type = id;
+
/*
* XXX We use DEV_BSIZE instead of the sector size value pulled
- * off the driver because all of this code assumes 512 byte
- * blocks. ICK!
+ * XXX off the driver because all of this code assumes 512 byte
+ * XXX blocks. ICK!
*/
- if (verbose) {
- printf(": %s\n", rdidentinfo[id].ri_desc);
- printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n",
- rs->sc_hd->hp_xname, rdidentinfo[id].ri_ncyl,
- rdidentinfo[id].ri_ntpc, rdidentinfo[id].ri_nblocks,
- DEV_BSIZE);
- }
- return(id);
+ printf(": %s\n", rdidentinfo[id].ri_desc);
+ printf("%s: %d cylinders, %d heads, %d blocks, %d bytes/block\n",
+ sc->sc_dev.dv_xname, rdidentinfo[id].ri_ncyl,
+ rdidentinfo[id].ri_ntpc, rdidentinfo[id].ri_nblocks,
+ DEV_BSIZE);
+
+ return (1);
}
-rdreset(rs, hd)
+void
+rdreset(rs)
register struct rd_softc *rs;
- register struct hp_device *hd;
{
+ int ctlr = rs->sc_dev.dv_parent->dv_unit;
+ int slave = rs->sc_slave;
u_char stat;
rs->sc_clear.c_unit = C_SUNIT(rs->sc_punit);
rs->sc_clear.c_cmd = C_CLEAR;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_TCMD, &rs->sc_clear,
- sizeof(rs->sc_clear));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_TCMD, &rs->sc_clear, sizeof(rs->sc_clear));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
+
rs->sc_src.c_unit = C_SUNIT(RDCTLR);
rs->sc_src.c_nop = C_NOP;
rs->sc_src.c_cmd = C_SREL;
rs->sc_src.c_param = C_REL;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &rs->sc_src,
- sizeof(rs->sc_src));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_CMD, &rs->sc_src, sizeof(rs->sc_src));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
+
rs->sc_ssmc.c_unit = C_SUNIT(rs->sc_punit);
rs->sc_ssmc.c_cmd = C_SSM;
rs->sc_ssmc.c_refm = REF_MASK;
rs->sc_ssmc.c_fefm = FEF_MASK;
rs->sc_ssmc.c_aefm = AEF_MASK;
rs->sc_ssmc.c_iefm = IEF_MASK;
- hpibsend(hd->hp_ctlr, hd->hp_slave, C_CMD, &rs->sc_ssmc,
- sizeof(rs->sc_ssmc));
- hpibswait(hd->hp_ctlr, hd->hp_slave);
- hpibrecv(hd->hp_ctlr, hd->hp_slave, C_QSTAT, &stat, sizeof(stat));
+ hpibsend(ctlr, slave, C_CMD, &rs->sc_ssmc, sizeof(rs->sc_ssmc));
+ hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
#ifdef DEBUG
- rdstats[hd->hp_unit].rdresets++;
+ rs->sc_stats.rdresets++;
#endif
}
@@ -440,7 +472,7 @@ rdgetinfo(dev)
dev_t dev;
{
int unit = rdunit(dev);
- register struct rd_softc *rs = &rd_softc[unit];
+ struct rd_softc *rs = rd_cd.cd_devs[unit];
register struct disklabel *lp = rs->sc_dkdev.dk_label;
register struct partition *pi;
char *msg, *readdisklabel();
@@ -468,7 +500,7 @@ rdgetinfo(dev)
return(0);
pi = lp->d_partitions;
- printf("%s: WARNING: %s, ", rs->sc_hd->hp_xname, msg);
+ printf("%s: WARNING: %s, ", rs->sc_dev.dv_xname, msg);
#ifdef COMPAT_NOLABEL
printf("using old default partitioning\n");
rdmakedisklabel(unit, lp);
@@ -489,11 +521,13 @@ rdopen(dev, flags, mode, p)
struct proc *p;
{
register int unit = rdunit(dev);
- register struct rd_softc *rs = &rd_softc[unit];
+ register struct rd_softc *rs;
int error, mask, part;
- if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
- return(ENXIO);
+ if (unit >= rd_cd.cd_ndevs ||
+ (rs = rd_cd.cd_devs[unit]) == NULL ||
+ (rs->sc_flags & RDF_ALIVE) == 0)
+ return (ENXIO);
/*
* Wait for any pending opens/closes to complete
@@ -546,7 +580,7 @@ rdclose(dev, flag, mode, p)
struct proc *p;
{
int unit = rdunit(dev);
- register struct rd_softc *rs = &rd_softc[unit];
+ struct rd_softc *rs = rd_cd.cd_devs[unit];
register struct disk *dk = &rs->sc_dkdev;
int mask, s;
@@ -566,9 +600,9 @@ rdclose(dev, flag, mode, p)
if (dk->dk_openmask == 0) {
rs->sc_flags |= RDF_CLOSING;
s = splbio();
- while (rdtab[unit].b_active) {
+ while (rs->sc_tab.b_active) {
rs->sc_flags |= RDF_WANTED;
- sleep((caddr_t)&rdtab[unit], PRIBIO);
+ sleep((caddr_t)&rs->sc_tab, PRIBIO);
}
splx(s);
rs->sc_flags &= ~(RDF_CLOSING|RDF_WLABEL);
@@ -582,8 +616,8 @@ rdstrategy(bp)
register struct buf *bp;
{
int unit = rdunit(bp->b_dev);
- register struct rd_softc *rs = &rd_softc[unit];
- register struct buf *dp = &rdtab[unit];
+ struct rd_softc *rs = rd_cd.cd_devs[unit];
+ register struct buf *dp = &rs->sc_tab;
register struct partition *pinfo;
register daddr_t bn;
register int sz, s;
@@ -637,7 +671,7 @@ rdstrategy(bp)
disksort(dp, bp);
if (dp->b_active == 0) {
dp->b_active = 1;
- rdustart(unit);
+ rdustart(rs);
}
splx(s);
return;
@@ -655,58 +689,60 @@ rdrestart(arg)
void *arg;
{
int s = splbio();
- rdustart((int)arg);
+ rdustart((struct rd_softc *)arg);
splx(s);
}
-rdustart(unit)
- register int unit;
+void
+rdustart(rs)
+ struct rd_softc *rs;
{
register struct buf *bp;
- register struct rd_softc *rs = &rd_softc[unit];
- bp = rdtab[unit].b_actf;
+ bp = rs->sc_tab.b_actf;
rs->sc_addr = bp->b_un.b_addr;
rs->sc_resid = bp->b_bcount;
- if (hpibreq(&rs->sc_dq))
- rdstart(unit);
+ if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq))
+ rdstart(rs);
}
struct buf *
-rdfinish(unit, rs, bp)
- int unit;
+rdfinish(rs, bp)
register struct rd_softc *rs;
register struct buf *bp;
{
- register struct buf *dp = &rdtab[unit];
+ register struct buf *dp = &rs->sc_tab;
dp->b_errcnt = 0;
dp->b_actf = bp->b_actf;
bp->b_resid = 0;
biodone(bp);
- hpibfree(&rs->sc_dq);
+ hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq);
if (dp->b_actf)
- return(dp->b_actf);
+ return (dp->b_actf);
dp->b_active = 0;
if (rs->sc_flags & RDF_WANTED) {
rs->sc_flags &= ~RDF_WANTED;
wakeup((caddr_t)dp);
}
- return(NULL);
+ return (NULL);
}
-rdstart(unit)
- register int unit;
+void
+rdstart(arg)
+ void *arg;
{
- register struct rd_softc *rs = &rd_softc[unit];
- register struct buf *bp = rdtab[unit].b_actf;
- register struct hp_device *hp = rs->sc_hd;
- register int part;
+ struct rd_softc *rs = arg;
+ register struct buf *bp = rs->sc_tab.b_actf;
+ register int part, ctlr, slave;
+
+ ctlr = rs->sc_dev.dv_parent->dv_unit;
+ slave = rs->sc_slave;
again:
#ifdef DEBUG
if (rddebug & RDB_FOLLOW)
- printf("rdstart(%d): bp %x, %c\n", unit, bp,
+ printf("rdstart(%s): bp %x, %c\n", sc->sc_dev.dv_xname, bp,
(bp->b_flags & B_READ) ? 'R' : 'W');
#endif
part = rdpart(bp->b_dev);
@@ -723,10 +759,10 @@ again:
#ifdef DEBUG
if (rddebug & RDB_IO)
printf("rdstart: hpibsend(%x, %x, %x, %x, %x)\n",
- hp->hp_ctlr, hp->hp_slave, C_CMD,
+ ctlr, slave, C_CMD,
&rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2);
#endif
- if (hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD, &rs->sc_ioc.c_unit,
+ if (hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit,
sizeof(rs->sc_ioc)-2) == sizeof(rs->sc_ioc)-2) {
/* Instrumentation. */
@@ -735,9 +771,9 @@ again:
#ifdef DEBUG
if (rddebug & RDB_IO)
- printf("rdstart: hpibawait(%x)\n", hp->hp_ctlr);
+ printf("rdstart: hpibawait(%x)\n", ctlr);
#endif
- hpibawait(hp->hp_ctlr);
+ hpibawait(ctlr);
return;
}
/*
@@ -749,35 +785,38 @@ again:
#ifdef DEBUG
if (rddebug & RDB_ERROR)
printf("%s: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n",
- rs->sc_hd->hp_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
- bp->b_blkno, rs->sc_resid, rdtab[unit].b_errcnt);
- rdstats[unit].rdretries++;
+ rs->sc_dev.dv_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
+ bp->b_blkno, rs->sc_resid, rs->sc_tab.b_errcnt);
+ rs->sc_stats.rdretries++;
#endif
rs->sc_flags &= ~RDF_SEEK;
- rdreset(rs, hp);
- if (rdtab[unit].b_errcnt++ < RDRETRY)
+ rdreset(rs);
+ if (rs->sc_tab.b_errcnt++ < RDRETRY)
goto again;
printf("%s: rdstart err: cmd 0x%x sect %d blk %d len %d\n",
- rs->sc_hd->hp_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
+ rs->sc_dev.dv_xname, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
bp->b_blkno, rs->sc_resid);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
- bp = rdfinish(unit, rs, bp);
+ bp = rdfinish(rs, bp);
if (bp) {
rs->sc_addr = bp->b_un.b_addr;
rs->sc_resid = bp->b_bcount;
- if (hpibreq(&rs->sc_dq))
+ if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq))
goto again;
}
}
-rdgo(unit)
- register int unit;
+void
+rdgo(arg)
+ void *arg;
{
- register struct rd_softc *rs = &rd_softc[unit];
- register struct hp_device *hp = rs->sc_hd;
- struct buf *bp = rdtab[unit].b_actf;
- int rw;
+ struct rd_softc *rs = arg;
+ struct buf *bp = rs->sc_tab.b_actf;
+ int rw, ctlr, slave;
+
+ ctlr = rs->sc_dev.dv_parent->dv_unit;
+ slave = rs->sc_slave;
rw = bp->b_flags & B_READ;
@@ -788,26 +827,29 @@ rdgo(unit)
if (inledcontrol == 0)
ledcontrol(0, 0, LED_DISK);
#endif
- hpibgo(hp->hp_ctlr, hp->hp_slave, C_EXEC,
- rs->sc_addr, rs->sc_resid, rw, rw != 0);
+ hpibgo(ctlr, slave, C_EXEC, rs->sc_addr, rs->sc_resid, rw, rw != 0);
}
+/* ARGSUSED */
+void
rdintr(arg)
void *arg;
{
register struct rd_softc *rs = arg;
- int unit = rs->sc_hd->hp_unit;
- register struct buf *bp = rdtab[unit].b_actf;
- register struct hp_device *hp = rs->sc_hd;
+ int unit = rs->sc_dev.dv_unit;
+ register struct buf *bp = rs->sc_tab.b_actf;
u_char stat = 13; /* in case hpibrecv fails */
- int rv, restart;
-
+ int rv, restart, ctlr, slave;
+
+ ctlr = rs->sc_dev.dv_parent->dv_unit;
+ slave = rs->sc_slave;
+
#ifdef DEBUG
if (rddebug & RDB_FOLLOW)
printf("rdintr(%d): bp %x, %c, flags %x\n", unit, bp,
(bp->b_flags & B_READ) ? 'R' : 'W', rs->sc_flags);
if (bp == NULL) {
- printf("%s: bp == NULL\n", rs->sc_hd->hp_xname);
+ printf("%s: bp == NULL\n", rs->sc_dev.dv_xname);
return;
}
#endif
@@ -815,28 +857,28 @@ rdintr(arg)
if (rs->sc_flags & RDF_SEEK) {
rs->sc_flags &= ~RDF_SEEK;
- if (hpibustart(hp->hp_ctlr))
- rdgo(unit);
+ if (hpibustart(ctlr))
+ rdgo(rs);
return;
}
if ((rs->sc_flags & RDF_SWAIT) == 0) {
#ifdef DEBUG
- rdstats[unit].rdpolltries++;
+ rs->sc_stats.rdpolltries++;
#endif
- if (hpibpptest(hp->hp_ctlr, hp->hp_slave) == 0) {
+ if (hpibpptest(ctlr, slave) == 0) {
#ifdef DEBUG
- rdstats[unit].rdpollwaits++;
+ rs->sc_stats.rdpollwaits++;
#endif
/* Instrumentation. */
disk_busy(&rs->sc_dkdev);
rs->sc_flags |= RDF_SWAIT;
- hpibawait(hp->hp_ctlr);
+ hpibawait(ctlr);
return;
}
} else
rs->sc_flags &= ~RDF_SWAIT;
- rv = hpibrecv(hp->hp_ctlr, hp->hp_slave, C_QSTAT, &stat, 1);
+ rv = hpibrecv(ctlr, slave, C_QSTAT, &stat, 1);
if (rv != 1 || stat) {
#ifdef DEBUG
if (rddebug & RDB_ERROR)
@@ -844,20 +886,21 @@ rdintr(arg)
#endif
restart = rderror(unit);
#ifdef DEBUG
- rdstats[unit].rdretries++;
+ rs->sc_stats.rdretries++;
#endif
- if (rdtab[unit].b_errcnt++ < RDRETRY) {
+ if (rs->sc_tab.b_errcnt++ < RDRETRY) {
if (restart)
- rdstart(unit);
+ rdstart(rs);
return;
}
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
}
- if (rdfinish(unit, rs, bp))
- rdustart(unit);
+ if (rdfinish(rs, bp))
+ rdustart(rs);
}
+int
rdstatus(rs)
register struct rd_softc *rs;
{
@@ -865,8 +908,8 @@ rdstatus(rs)
u_char stat;
int rv;
- c = rs->sc_hd->hp_ctlr;
- s = rs->sc_hd->hp_slave;
+ c = rs->sc_dev.dv_parent->dv_unit;
+ s = rs->sc_slave;
rs->sc_rsc.c_unit = C_SUNIT(rs->sc_punit);
rs->sc_rsc.c_sram = C_SRAM;
rs->sc_rsc.c_ram = C_RAM;
@@ -907,26 +950,27 @@ rdstatus(rs)
* Returns 1 if request should be restarted,
* 0 if we should just quietly give up.
*/
+int
rderror(unit)
int unit;
{
- struct rd_softc *rs = &rd_softc[unit];
+ struct rd_softc *rs = rd_cd.cd_devs[unit];
register struct rd_stat *sp;
struct buf *bp;
daddr_t hwbn, pbn;
if (rdstatus(rs)) {
#ifdef DEBUG
- printf("%s: couldn't get status\n", rs->sc_hd->hp_xname);
+ printf("%s: couldn't get status\n", rs->sc_dev.dv_xname);
#endif
- rdreset(rs, rs->sc_hd);
+ rdreset(rs);
return(1);
}
sp = &rs->sc_stat;
if (sp->c_fef & FEF_REXMT)
return(1);
if (sp->c_fef & FEF_PF) {
- rdreset(rs, rs->sc_hd);
+ rdreset(rs);
return(1);
}
/*
@@ -938,14 +982,14 @@ rderror(unit)
*/
if (sp->c_fef & FEF_IMR) {
extern int hz;
- int rdtimo = RDWAITC << rdtab[unit].b_errcnt;
+ int rdtimo = RDWAITC << rs->sc_tab.b_errcnt;
#ifdef DEBUG
printf("%s: internal maintenance, %d second timeout\n",
- rs->sc_hd->hp_xname, rdtimo);
- rdstats[unit].rdtimeouts++;
+ rs->sc_dev.dv_xname, rdtimo);
+ rs->sc_stats.rdtimeouts++;
#endif
- hpibfree(&rs->sc_dq);
- timeout(rdrestart, (void *)unit, rdtimo * hz);
+ hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq);
+ timeout(rdrestart, rs, rdtimo * hz);
return(0);
}
/*
@@ -953,7 +997,7 @@ rderror(unit)
* threshhold. By default, this will only report after the
* retry limit has been exceeded.
*/
- if (rdtab[unit].b_errcnt < rderrthresh)
+ if (rs->sc_tab.b_errcnt < rderrthresh)
return(1);
/*
@@ -961,7 +1005,7 @@ rderror(unit)
* Note that not all errors report a block number, in that case
* we just use b_blkno.
*/
- bp = rdtab[unit].b_actf;
+ bp = rs->sc_tab.b_actf;
pbn = rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)].p_offset;
if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) ||
(sp->c_ief & IEF_RRMASK)) {
@@ -977,14 +1021,14 @@ rderror(unit)
* out b_blkno which is just the beginning block number
* of the transfer, not necessary where the error occured.
*/
- printf("rd%d%c: hard error sn%d\n",
- rdunit(bp->b_dev), 'a'+rdpart(bp->b_dev), pbn);
+ printf("%s%c: hard error sn%d\n", rs->sc_dev.dv_xname,
+ 'a'+rdpart(bp->b_dev), pbn);
/*
* Now report the status as returned by the hardware with
* attempt at interpretation (unless debugging).
*/
- printf("rd%d %s error:",
- unit, (bp->b_flags & B_READ) ? "read" : "write");
+ printf("%s %s error:", rs->sc_dev.dv_xname,
+ (bp->b_flags & B_READ) ? "read" : "write");
#ifdef DEBUG
if (rddebug & RDB_ERROR) {
/* status info */
@@ -1042,13 +1086,13 @@ rdwrite(dev, uio, flags)
int
rdioctl(dev, cmd, data, flag, p)
dev_t dev;
- int cmd;
+ u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{
int unit = rdunit(dev);
- register struct rd_softc *sc = &rd_softc[unit];
+ struct rd_softc *sc = rd_cd.cd_devs[unit];
register struct disklabel *lp = sc->sc_dkdev.dk_label;
int error, flags;
@@ -1104,11 +1148,13 @@ rdsize(dev)
dev_t dev;
{
register int unit = rdunit(dev);
- register struct rd_softc *rs = &rd_softc[unit];
+ struct rd_softc *rs;
int psize, didopen = 0;
- if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
- return(-1);
+ if (unit >= rd_cd.cd_ndevs ||
+ (rs = rd_cd.cd_devs[unit]) == NULL ||
+ (rs->sc_flags & RDF_ALIVE) == 0)
+ return (-1);
/*
* We get called very early on (via swapconf)
@@ -1164,8 +1210,8 @@ rddump(dev, blkno, va, size)
int totwrt; /* total number of sectors left to write */
int nwrt; /* current number of sectors to write */
int unit, part;
+ int ctlr, slave;
struct rd_softc *rs;
- struct hp_device *hp;
struct disklabel *lp;
char stat;
@@ -1179,12 +1225,13 @@ rddump(dev, blkno, va, size)
part = rdpart(dev);
/* Make sure dump device is ok. */
- if (unit >= NRD)
- return (ENXIO);
- rs = &rd_softc[unit];
- if ((rs->sc_flags & RDF_ALIVE) == 0)
+ if (unit >= rd_cd.cd_ndevs ||
+ (rs = rd_cd.cd_devs[unit]) == NULL ||
+ (rs->sc_flags & RDF_ALIVE) == 0)
return (ENXIO);
- hp = rs->sc_hd;
+
+ ctlr = rs->sc_dev.dv_parent->dv_unit;
+ slave = rs->sc_slave;
/*
* Convert to disk sectors. Request must be a multiple of size.
@@ -1221,23 +1268,22 @@ rddump(dev, blkno, va, size)
rs->sc_ioc.c_slen = C_SLEN;
rs->sc_ioc.c_len = nwrt * sectorsize;
rs->sc_ioc.c_cmd = C_WRITE;
- hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD,
- &rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2);
- if (hpibswait(hp->hp_ctlr, hp->hp_slave))
+ hpibsend(ctlr, slave, C_CMD, &rs->sc_ioc.c_unit,
+ sizeof(rs->sc_ioc)-2);
+ if (hpibswait(ctlr, slave))
return (EIO);
/*
* Send the data.
*/
- hpibsend(hp->hp_ctlr, hp->hp_slave, C_EXEC, va,
- nwrt * sectorsize);
- (void) hpibswait(hp->hp_ctlr, hp->hp_slave);
- hpibrecv(hp->hp_ctlr, hp->hp_slave, C_QSTAT, &stat, 1);
+ hpibsend(ctlr, slave, C_EXEC, va, nwrt * sectorsize);
+ (void) hpibswait(ctlr, slave);
+ hpibrecv(ctlr, slave, C_QSTAT, &stat, 1);
if (stat)
return (EIO);
#else /* RD_DUMP_NOT_TRUSTED */
/* Let's just talk about this first... */
- printf("%s: dump addr %p, blk %d\n", hp->hp_xname,
+ printf("%s: dump addr %p, blk %d\n", sc->sc_dev.dv_xname,
va, blkno);
delay(500 * 1000); /* half a second */
#endif /* RD_DUMP_NOT_TRUSTED */
@@ -1250,4 +1296,3 @@ rddump(dev, blkno, va, size)
rddoingadump = 0;
return (0);
}
-#endif
diff --git a/sys/arch/hp300/dev/rd_compat.c b/sys/arch/hp300/dev/rd_compat.c
index ed607f2dbbc..6eec8ff55a0 100644
--- a/sys/arch/hp300/dev/rd_compat.c
+++ b/sys/arch/hp300/dev/rd_compat.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: rd_compat.c,v 1.4 1997/01/12 15:12:59 downsj Exp $ */
-/* $NetBSD: rd_compat.c,v 1.5 1996/01/07 22:02:14 thorpej Exp $ */
+/* $OpenBSD: rd_compat.c,v 1.5 1997/02/03 04:47:43 downsj Exp $ */
+/* $NetBSD: rd_compat.c,v 1.6 1997/01/30 09:14:18 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -46,13 +46,15 @@
/*
* Compatibility for CS80 disks without disklabels.
*/
-#include "rd.h"
-#if NRD > 0
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
-#include <hp300/dev/device.h>
+#include <sys/device.h>
+#include <sys/buf.h> /* XXX */
+
+#include <hp300/dev/hpibvar.h>
+
#include <hp300/dev/rdreg.h>
#include <hp300/dev/rdvar.h>
@@ -258,7 +260,8 @@ rdmakedisklabel(unit, lp)
int unit;
struct disklabel *lp;
{
- register struct rd_softc *rs = &rd_softc[unit];
+ extern struct cfdriver rd_cd;
+ register struct rd_softc *rs = rd_cd.cd_devs[unit];
register struct rdcompatinfo *ci = &rdcompatinfo[rs->sc_type];
struct rdidentinfo *ri = &rdidentinfo[rs->sc_type];
register struct partition *pi;
@@ -288,4 +291,3 @@ rdmakedisklabel(unit, lp)
pi++;
}
}
-#endif
diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h
index 064a544503d..04fd3adeb5f 100644
--- a/sys/arch/hp300/dev/rdvar.h
+++ b/sys/arch/hp300/dev/rdvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: rdvar.h,v 1.5 1997/01/12 15:13:00 downsj Exp $ */
-/* $NetBSD: rdvar.h,v 1.5 1996/06/06 16:17:42 thorpej Exp $ */
+/* $OpenBSD: rdvar.h,v 1.6 1997/02/03 04:47:43 downsj Exp $ */
+/* $NetBSD: rdvar.h,v 1.6 1997/01/30 09:14:19 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -53,23 +53,33 @@ struct rdidentinfo {
int ri_nblocks; /* DEV_BSIZE blocks on disk */
};
+struct rdstats {
+ long rdretries;
+ long rdresets;
+ long rdtimeouts;
+ long rdpolltries;
+ long rdpollwaits;
+};
+
struct rd_softc {
- struct hp_device *sc_hd;
+ struct device sc_dev;
struct disk sc_dkdev;
- char sc_xname[8];
+ int sc_slave; /* HP-IB slave */
+ int sc_punit; /* physical unit on slave */
int sc_flags;
short sc_type;
- short sc_punit;
char *sc_addr;
int sc_resid;
struct rd_describe sc_rddesc;
- struct devqueue sc_dq;
+ struct hpibqueue sc_hq; /* hpib job queue entry */
struct rd_iocmd sc_ioc;
struct rd_rscmd sc_rsc;
struct rd_stat sc_stat;
struct rd_ssmcmd sc_ssmc;
struct rd_srcmd sc_src;
struct rd_clearcmd sc_clear;
+ struct buf sc_tab; /* buffer queue */
+ struct rdstats sc_stats;
};
/* sc_flags values */
@@ -81,14 +91,6 @@ struct rd_softc {
#define RDF_WANTED 0x20
#define RDF_WLABEL 0x40
-struct rdstats {
- long rdretries;
- long rdresets;
- long rdtimeouts;
- long rdpolltries;
- long rdpollwaits;
-};
-
#define rdunit(x) (minor(x) >> 3)
#define rdpart(x) (minor(x) & 0x7)
#define rdpunit(x) ((x) & 7)
@@ -101,5 +103,4 @@ struct rdstats {
#ifdef _KERNEL
extern struct rdidentinfo rdidentinfo[];
-extern struct rd_softc rd_softc[];
#endif
diff --git a/sys/arch/hp300/dev/scsi.c b/sys/arch/hp300/dev/scsi.c
index ba9d7c0f1a8..12060f29f0e 100644
--- a/sys/arch/hp300/dev/scsi.c
+++ b/sys/arch/hp300/dev/scsi.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: scsi.c,v 1.5 1997/01/12 15:13:01 downsj Exp $ */
-/* $NetBSD: scsi.c,v 1.13 1996/12/09 03:16:26 thorpej Exp $ */
+/* $OpenBSD: scsi.c,v 1.6 1997/02/03 04:47:44 downsj Exp $ */
+/* $NetBSD: scsi.c,v 1.15 1997/01/30 09:08:55 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -45,22 +46,47 @@
/*
* HP9000/3xx 98658 SCSI host adaptor driver.
*/
-#include "scsi.h"
-#if NSCSI > 0
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
+#include <sys/device.h>
#include <machine/cpu.h>
-#include <hp300/dev/device.h>
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+
+#include <hp300/dev/dmavar.h>
+
#include <hp300/dev/scsivar.h>
#include <hp300/dev/scsireg.h>
-#include <hp300/dev/dmavar.h>
#include <hp300/hp300/isr.h>
+struct scsi_softc {
+ struct device sc_dev; /* generic device glue */
+ volatile struct scsidevice *sc_regs; /* card registers */
+ struct dmaqueue sc_dq; /* our entry in DMA job queue */
+ TAILQ_HEAD(, scsiqueue) sc_queue; /* job queue */
+ u_char sc_flags;
+ u_char sc_sync;
+ u_char sc_scsi_addr;
+ u_char sc_scsiid; /* XXX unencoded copy of sc_scsi_addr */
+ u_char sc_stat[2];
+ u_char sc_msg[7];
+};
+
+/* sc_flags */
+#define SCSI_IO 0x80 /* DMA I/O in progress */
+#define SCSI_DMA32 0x40 /* 32-bit DMA should be used */
+#define SCSI_HAVEDMA 0x04 /* controller has DMA channel */
+#ifdef DEBUG
+#define SCSI_PAD 0x02 /* 'padded' transfer in progress */
+#endif
+#define SCSI_ALIVE 0x01 /* controller initialized */
+
/*
* SCSI delays
* In u-seconds, primarily for state changes on the SPC.
@@ -69,18 +95,23 @@
#define SCSI_DATA_WAIT 10000 /* wait per data in/out step */
#define SCSI_INIT_WAIT 50000 /* wait per step (both) during init */
-extern void _insque();
-extern void _remque();
-
-int scsimatch(), scsigo(), scsixfer();
-void scsiattach(), scsistart(), scsidone(), scsifree(), scsireset();
+void scsidone __P((void *));
+void scsistart __P((void *));
int scsiintr __P((void *));
-struct driver scsidriver = {
- scsimatch, scsiattach, "scsi", (int (*)())scsistart, scsigo, scsiintr,
- (int (*)())scsidone,
+
+int scsimatch __P((struct device *, void *, void *));
+void scsiattach __P((struct device *, struct device *, void *));
+
+struct cfattach oscsi_ca = {
+ sizeof(struct scsi_softc), scsimatch, scsiattach
};
-struct scsi_softc scsi_softc[NSCSI];
+struct cfdriver oscsi_cd = {
+ NULL, "oscsi", DV_DULL
+};
+
+int scsisubmatch __P((struct device *, void *, void *));
+void scsi_attach_children __P((struct scsi_softc *));
int scsi_cmd_wait = SCSI_CMD_WAIT;
int scsi_data_wait = SCSI_DATA_WAIT;
@@ -123,7 +154,7 @@ scsiabort(target, hs, hd, where)
int startlen; /* XXX - kludge till I understand whats *supposed* to happen */
u_char junk;
- printf("%s: ", hs->sc_hc->hp_xname);
+ printf("%s: ", hs->sc_dev.dv_xname);
if (target != -1)
printf("targ %d ", target);
printf("abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n",
@@ -182,7 +213,7 @@ out:
*/
if (len < 0 && hs)
printf("%s: abort failed. phase=0x%x, ssts=0x%x\n",
- hs->sc_hc->hp_xname, hd->scsi_psns, hd->scsi_ssts);
+ hs->sc_dev.dv_xname, hd->scsi_psns, hd->scsi_ssts);
if (! ((junk = hd->scsi_ints) & INTS_RESEL)) {
hd->scsi_sctl |= SCTL_CTRLRST;
@@ -223,50 +254,60 @@ scsi_delay(delay)
}
int
-scsimatch(hc)
- register struct hp_ctlr *hc;
+scsimatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct scsi_softc *hs = &scsi_softc[hc->hp_unit];
- register struct scsidevice *hd = (struct scsidevice *)hc->hp_addr;
- struct hp_hw *hw = hc->hp_args;
-
- /*
- * This is probably a little redundant, but what the heck.
- */
- switch (hw->hw_id) {
- case 7:
- case 7+32:
- case 7+64:
- case 7+96:
- if ((hd->scsi_id & ID_MASK) != SCSI_ID)
- return (0);
+ struct dio_attach_args *da = aux;
- hc->hp_ipl = SCSI_IPL(hd->scsi_csr);
+ switch (da->da_id) {
+ case DIO_DEVICE_ID_SCSI0:
+ case DIO_DEVICE_ID_SCSI1:
+ case DIO_DEVICE_ID_SCSI2:
+ case DIO_DEVICE_ID_SCSI3:
return (1);
- /* NOTREACHED */
}
return (0);
}
void
-scsiattach(hc)
- struct hp_ctlr *hc;
+scsiattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- register struct scsi_softc *hs = &scsi_softc[hc->hp_unit];
- register struct scsidevice *hd = (struct scsidevice *)hc->hp_addr;
+ struct scsi_softc *hs = (struct scsi_softc *)self;
+ struct dio_attach_args *da = aux;
+ struct scsidevice *hd;
+ int ipl, unit = self->dv_unit;
- hs->sc_hc = hc;
- hs->sc_dq.dq_unit = hc->hp_unit;
- hs->sc_dq.dq_driver = &scsidriver;
- hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq;
+ /*
+ * Set up DMA job queue entry.
+ */
+ hs->sc_dq.dq_softc = hs;
+ hs->sc_dq.dq_start = scsistart;
+ hs->sc_dq.dq_done = scsidone;
+
+ /* Initialize request queue. */
+ TAILQ_INIT(&hs->sc_queue);
+
+ /* Map the device. */
+ hd = (struct scsidevice *)iomap(dio_scodetopa(da->da_scode),
+ da->da_size);
+ if (hd == NULL) {
+ printf("\n%s: can't map registers\n", self->dv_xname);
+ return;
+ }
+ ipl = DIO_IPL(hd);
+
+ hs->sc_regs = hd;
/* Establish the interrupt handler. */
- (void) isrlink(scsiintr, hs, hc->hp_ipl, ISRPRI_BIO);
+ (void) isrlink(scsiintr, hs, ipl, ISRPRI_BIO);
dmacomputeipl();
/* Reset the controller. */
- scsireset(hc->hp_unit);
+ scsireset(unit);
/*
* Print information about what we've found.
@@ -306,15 +347,121 @@ scsiattach(hc)
* Should we do this for all wait? Should we do this at all?
*/
scsi_init_wait *= (cpuspeed / 8);
+
+ /*
+ * Find and attach devices on the SCSI bus.
+ */
+ scsi_attach_children(hs);
+}
+
+void
+scsi_attach_children(sc)
+ struct scsi_softc *sc;
+{
+ struct oscsi_attach_args osa;
+ struct scsi_inquiry inqbuf;
+ int target, lun;
+
+ /*
+ * Look for devices on the SCSI bus.
+ */
+
+ for (target = 0; target < 8; target++) {
+ /* Skip target used by controller. */
+ if (target == sc->sc_scsiid)
+ continue;
+
+ for (lun = 0; lun < 1 /* XXX */; lun++) {
+ bzero(&inqbuf, sizeof(inqbuf));
+ if (scsi_probe_device(sc->sc_dev.dv_unit,
+ target, lun, &inqbuf, sizeof(inqbuf))) {
+ /*
+ * XXX First command on some tapes
+ * XXX always fails. (Or, at least,
+ * XXX that's what the old Utah "st"
+ * XXX driver claimed.)
+ */
+ bzero(&inqbuf, sizeof(inqbuf));
+ if (scsi_probe_device(sc->sc_dev.dv_unit,
+ target, lun, &inqbuf, sizeof(inqbuf)))
+ continue;
+ }
+
+ /*
+ * There is a device here; find a driver
+ * to match it.
+ */
+ osa.osa_target = target;
+ osa.osa_lun = lun;
+ osa.osa_inqbuf = &inqbuf;
+ (void)config_found_sm(&sc->sc_dev, &osa,
+ scsi_print, scsisubmatch);
+ }
+ }
+}
+
+int
+scsisubmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct cfdata *cf = match;
+ struct oscsi_attach_args *osa = aux;
+
+ if (cf->cf_loc[0] != -1 &&
+ cf->cf_loc[0] != osa->osa_target)
+ return (0);
+
+ if (cf->cf_loc[1] != -1 &&
+ cf->cf_loc[1] != osa->osa_lun)
+ return (0);
+
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
+}
+
+int
+scsi_print(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct oscsi_attach_args *osa = aux;
+ struct scsi_inquiry *inqbuf = osa->osa_inqbuf;
+ char vendor[9], product[17], revision[5];
+
+ if (pnp == NULL)
+ printf(" targ %d lun %d: ", osa->osa_target, osa->osa_lun);
+
+ bzero(vendor, sizeof(vendor));
+ bzero(product, sizeof(product));
+ bzero(revision, sizeof(revision));
+ switch (inqbuf->version) {
+ case 1:
+ case 2:
+ scsi_str(inqbuf->vendor_id, vendor, sizeof(inqbuf->vendor_id));
+ scsi_str(inqbuf->product_id, product,
+ sizeof(inqbuf->product_id));
+ scsi_str(inqbuf->rev, revision, sizeof(inqbuf->rev));
+ printf("<%s, %s, %s>", vendor, product, revision);
+ if (inqbuf->version == 2)
+ printf(" (SCSI-2)");
+ break;
+ default:
+ printf("type 0x%x, qual 0x%x, ver %d",
+ inqbuf->type, inqbuf->qual, inqbuf->version);
+ }
+ if (pnp != NULL)
+ printf(" at %s targ %d lun %d",
+ pnp, osa->osa_target, osa->osa_lun);
+
+ return (UNCONF);
}
void
scsireset(unit)
- register int unit;
+ int unit;
{
- register struct scsi_softc *hs = &scsi_softc[unit];
- volatile register struct scsidevice *hd =
- (struct scsidevice *)hs->sc_hc->hp_addr;
+ struct scsi_softc *hs = oscsi_cd.cd_devs[unit];
+ volatile register struct scsidevice *hd = hs->sc_regs;
u_int i;
if (hs->sc_flags & SCSI_ALIVE)
@@ -386,10 +533,10 @@ scsierror(hs, hd, ints)
volatile register struct scsidevice *hd;
u_char ints;
{
- int unit = hs->sc_hc->hp_unit;
+ int unit = hs->sc_dev.dv_unit;
char *sep = "";
- printf("%s: ", hs->sc_hc->hp_xname);
+ printf("%s: ", hs->sc_dev.dv_xname);
if (ints & INTS_RST) {
DELAY(100);
if (hd->scsi_hconf & HCONF_SD)
@@ -650,8 +797,7 @@ scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
int len;
u_char xferphase;
{
- volatile register struct scsidevice *hd =
- (struct scsidevice *)hs->sc_hc->hp_addr;
+ volatile register struct scsidevice *hd = hs->sc_regs;
u_char phase, ints;
register int wait;
@@ -721,7 +867,7 @@ scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
default:
printf("%s: unexpected phase %d in icmd from %d\n",
- hs->sc_hc->hp_xname, phase, target);
+ hs->sc_dev.dv_xname, phase, target);
goto abort;
}
/* wait for last command to complete */
@@ -826,7 +972,7 @@ finishxfer(hs, hd, target)
default:
printf("%s: unexpected phase %d in finishxfer from %d\n",
- hs->sc_hc->hp_xname, phase, target);
+ hs->sc_dev.dv_xname, phase, target);
goto abort;
}
if (ints = hd->scsi_ints) {
@@ -850,7 +996,7 @@ int
scsi_test_unit_rdy(ctlr, slave, unit)
int ctlr, slave, unit;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
static struct scsi_cdb6 cdb = { CMD_TEST_UNIT_READY };
cdb.lun = unit;
@@ -864,7 +1010,7 @@ scsi_request_sense(ctlr, slave, unit, buf, len)
u_char *buf;
unsigned len;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
static struct scsi_cdb6 cdb = { CMD_REQUEST_SENSE };
cdb.lun = unit;
@@ -879,7 +1025,7 @@ scsi_immed_command(ctlr, slave, unit, cdb, buf, len, rd)
u_char *buf;
u_int len;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
cdb->cdb[1] |= unit << 5;
return (scsiicmd(hs, slave, cdb->cdb, cdb->len, buf, len,
@@ -900,7 +1046,7 @@ scsi_tt_read(ctlr, slave, unit, buf, len, blk, bshift)
daddr_t blk;
int bshift;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
struct scsi_cdb10 cdb;
int stat;
int old_wait = scsi_data_wait;
@@ -929,7 +1075,7 @@ scsi_tt_write(ctlr, slave, unit, buf, len, blk, bshift)
daddr_t blk;
int bshift;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
struct scsi_cdb10 cdb;
int stat;
int old_wait = scsi_data_wait;
@@ -952,25 +1098,30 @@ scsi_tt_write(ctlr, slave, unit, buf, len, blk, bshift)
}
int
-scsireq(dq)
- register struct devqueue *dq;
+scsireq(pdev, sq)
+ struct device *pdev;
+ struct scsiqueue *sq;
{
- register struct devqueue *hq;
+ struct scsi_softc *hs = (struct scsi_softc *)pdev;
+ int s;
- hq = &scsi_softc[dq->dq_ctlr].sc_sq;
- insque(dq, hq->dq_back);
- if (dq->dq_back == hq)
- return(1);
- return(0);
+ s = splhigh(); /* XXXthorpej */
+ TAILQ_INSERT_TAIL(&hs->sc_queue, sq, sq_list);
+ splx(s);
+
+ if (hs->sc_queue.tqh_first == sq)
+ return (1);
+
+ return (0);
}
int
scsiustart(unit)
int unit;
{
- register struct scsi_softc *hs = &scsi_softc[unit];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[unit];
- hs->sc_dq.dq_ctlr = DMA0 | DMA1;
+ hs->sc_dq.dq_chan = DMA0 | DMA1;
hs->sc_flags |= SCSI_HAVEDMA;
if (dmareq(&hs->sc_dq))
return(1);
@@ -978,13 +1129,14 @@ scsiustart(unit)
}
void
-scsistart(unit)
- int unit;
+scsistart(arg)
+ void *arg;
{
- register struct devqueue *dq;
-
- dq = scsi_softc[unit].sc_sq.dq_forw;
- (dq->dq_driver->d_go)(dq->dq_unit);
+ struct scsi_softc *hs = arg;
+ struct scsiqueue *sq;
+
+ sq = hs->sc_queue.tqh_first;
+ (sq->sq_go)(sq->sq_softc);
}
int
@@ -994,9 +1146,8 @@ scsigo(ctlr, slave, unit, bp, cdb, pad)
struct scsi_fmt_cdb *cdb;
int pad;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
- volatile register struct scsidevice *hd =
- (struct scsidevice *)hs->sc_hc->hp_addr;
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
+ volatile register struct scsidevice *hd = hs->sc_regs;
int i, dmaflags;
u_char phase, ints, cmd;
@@ -1049,7 +1200,7 @@ scsigo(ctlr, slave, unit, bp, cdb, pad)
default:
printf("%s: unexpected phase %d in go from %d\n",
- hs->sc_hc->hp_xname, phase, slave);
+ hs->sc_dev.dv_xname, phase, slave);
goto abort;
}
while ((ints = hd->scsi_ints) == 0) {
@@ -1088,7 +1239,7 @@ out:
dmaflags |= DMAGO_LWORD;
} else
dmaflags |= DMAGO_WORD;
- dmago(hs->sc_dq.dq_ctlr, bp->b_un.b_addr, bp->b_bcount, dmaflags);
+ dmago(hs->sc_dq.dq_chan, bp->b_un.b_addr, bp->b_bcount, dmaflags);
if (bp->b_flags & B_READ) {
cmd |= CSR_DMAIN;
@@ -1099,7 +1250,7 @@ out:
* DMA enable bits must be set after size and direction bits.
*/
hd->scsi_csr = cmd;
- hd->scsi_csr |= (CSR_DE0 << hs->sc_dq.dq_ctlr);
+ hd->scsi_csr |= (CSR_DE0 << hs->sc_dq.dq_chan);
/*
* Setup the SPC for the transfer. We don't want to take
* first a command complete then a service required interrupt
@@ -1126,7 +1277,7 @@ out:
hs->sc_flags |= SCSI_PAD;
if (i & 1)
printf("%s: odd byte count: %d bytes @ %d\n",
- hs->sc_hc->hp_xname, i, bp->b_cylin);
+ hs->sc_dev.dv_xname, i, bp->b_cylin);
#endif
} else
i += 4;
@@ -1146,15 +1297,15 @@ abort:
}
void
-scsidone(unit)
- register int unit;
+scsidone(arg)
+ void *arg;
{
- volatile register struct scsidevice *hd =
- (struct scsidevice *)scsi_softc[unit].sc_hc->hp_addr;
+ struct scsi_softc *hs = arg;
+ volatile register struct scsidevice *hd = hs->sc_regs;
#ifdef DEBUG
if (scsi_debug)
- printf("%s: done called!\n", scsi_softc[unit].sc_hc->hp_xname);
+ printf("%s: done called!\n", hs->sc_dev.dv_xname);
#endif
/* dma operation is done -- turn off card dma */
hd->scsi_csr &=~ (CSR_DE1|CSR_DE0);
@@ -1165,15 +1316,16 @@ scsiintr(arg)
void *arg;
{
register struct scsi_softc *hs = arg;
- volatile register struct scsidevice *hd =
- (struct scsidevice *)hs->sc_hc->hp_addr;
+ volatile register struct scsidevice *hd = hs->sc_regs;
register u_char ints;
- register struct devqueue *dq;
- int unit = hs->sc_hc->hp_unit;
+ register struct scsiqueue *sq;
+ int unit = hs->sc_dev.dv_unit;
if ((hd->scsi_csr & (CSR_IE|CSR_IR)) != (CSR_IE|CSR_IR))
return (0);
+ sq = hs->sc_queue.tqh_first;
+
ints = hd->scsi_ints;
if ((ints & INTS_SRV_REQ) && (hs->sc_flags & SCSI_IO)) {
/*
@@ -1188,37 +1340,39 @@ scsiintr(arg)
len -= 4;
hs->sc_flags &=~ SCSI_PAD;
#endif
- dq = hs->sc_sq.dq_forw;
- finishxfer(hs, hd, dq->dq_slave);
+ finishxfer(hs, hd, sq->sq_target);
hs->sc_flags &=~ (SCSI_IO|SCSI_HAVEDMA);
dmafree(&hs->sc_dq);
- (dq->dq_driver->d_intr)(dq->dq_softc, hs->sc_stat[0]);
+ (sq->sq_intr)(sq->sq_softc, hs->sc_stat[0]);
} else {
/* Something unexpected happened -- deal with it. */
hd->scsi_ints = ints;
hd->scsi_csr = 0;
scsierror(hs, hd, ints);
- scsiabort(dq->dq_slave, hs, hd, "intr");
+ scsiabort(sq->sq_target, hs, hd, "intr");
if (hs->sc_flags & SCSI_IO) {
hs->sc_flags &=~ (SCSI_IO|SCSI_HAVEDMA);
dmafree(&hs->sc_dq);
- dq = hs->sc_sq.dq_forw;
- (dq->dq_driver->d_intr)(dq->dq_softc, -1);
+ (sq->sq_intr)(sq->sq_softc, -1);
}
}
return(1);
}
void
-scsifree(dq)
- register struct devqueue *dq;
+scsifree(pdev, sq)
+ struct device *pdev;
+ struct scsiqueue *sq;
{
- register struct devqueue *hq;
+ struct scsi_softc *hs = (struct scsi_softc *)pdev;
+ int s;
+
+ s = splhigh(); /* XXXthorpej */
+ TAILQ_REMOVE(&hs->sc_queue, sq, sq_list);
+ splx(s);
- hq = &scsi_softc[dq->dq_ctlr].sc_sq;
- remque(dq);
- if ((dq = hq->dq_forw) != hq)
- (dq->dq_driver->d_start)(dq->dq_unit);
+ if ((sq = hs->sc_queue.tqh_first) != NULL)
+ (*sq->sq_start)(sq->sq_softc);
}
/*
@@ -1234,7 +1388,7 @@ scsi_tt_oddio(ctlr, slave, unit, buf, len, b_flags, freedma)
u_char *buf;
u_int len;
{
- register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_softc *hs = oscsi_cd.cd_devs[ctlr];
struct scsi_cdb6 cdb;
u_char iphase;
int stat;
@@ -1302,4 +1456,76 @@ scsi_str(src, dst, len)
bcopy(src, dst, len);
dst[len] = '\0';
}
-#endif
+
+/*
+ * Probe for a device at the given ctlr/target/lun, and fill in the inqbuf.
+ */
+int
+scsi_probe_device(ctlr, targ, lun, inqbuf, inqlen)
+ int ctlr, targ, lun;
+ struct scsi_inquiry *inqbuf;
+ int inqlen;
+{
+ static struct scsi_fmt_cdb inq = {
+ 6, CMD_INQUIRY, 0, 0, 0, 0, 0
+ };
+ int i, tries = 10, isrm = 0;
+
+ inq.cdb[4] = inqlen & 0xff;
+
+ scsi_delay(-1);
+
+ /*
+ * See if the unit exists.
+ */
+ while ((i = scsi_test_unit_rdy(ctlr, targ, lun)) != 0) {
+ if (i == -1 || --tries < 0) {
+ if (isrm)
+ break;
+ /* doesn't exist or not a CCS device */
+ goto failed;
+ }
+ if (i == STS_CHECKCOND) {
+ u_char sensebuf[128];
+ struct scsi_xsense *sp =
+ (struct scsi_xsense *)sensebuf;
+
+ scsi_request_sense(ctlr, targ, lun, sensebuf,
+ sizeof(sensebuf));
+ if (sp->class == 7) {
+ switch (sp->key) {
+ /*
+ * Not ready -- might be removable media
+ * device with no media. Assume as much,
+ * if it really isn't, the inquiry command
+ * below will fail.
+ */
+ case 2:
+ isrm = 1;
+ break;
+ /* drive doing an RTZ -- give it a while */
+ case 6:
+ delay(1000000);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ delay(1000);
+ }
+
+ /*
+ * Find out about the device.
+ */
+ if (scsi_immed_command(ctlr, targ, lun, &inq, (u_char *)inqbuf,
+ inqlen, B_READ))
+ goto failed;
+
+ scsi_delay(0);
+ return (0);
+
+ failed:
+ scsi_delay(0);
+ return (-1);
+}
diff --git a/sys/arch/hp300/dev/scsivar.h b/sys/arch/hp300/dev/scsivar.h
index a9226295744..ecc618d4de3 100644
--- a/sys/arch/hp300/dev/scsivar.h
+++ b/sys/arch/hp300/dev/scsivar.h
@@ -1,7 +1,8 @@
-/* $OpenBSD: scsivar.h,v 1.3 1997/01/12 15:13:02 downsj Exp $ */
-/* $NetBSD: scsivar.h,v 1.5 1995/12/02 18:22:14 thorpej Exp $ */
+/* $OpenBSD: scsivar.h,v 1.4 1997/02/03 04:47:45 downsj Exp $ */
+/* $NetBSD: scsivar.h,v 1.6 1997/01/30 09:08:56 thorpej Exp $ */
/*
+ * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -39,23 +40,48 @@
* @(#)scsivar.h 8.1 (Berkeley) 6/10/93
*/
-struct scsi_softc {
- struct hp_ctlr *sc_hc;
- struct devqueue sc_dq;
- struct devqueue sc_sq;
- u_char sc_flags;
- u_char sc_sync;
- u_char sc_scsi_addr;
- u_char sc_scsiid; /* XXX unencoded copy of sc_scsi_addr */
- u_char sc_stat[2];
- u_char sc_msg[7];
+#include <sys/queue.h>
+
+/*
+ * A SCSI job queue entry. Target drivers each have of of these,
+ * used to queue requests with the initiator.
+ */
+struct scsiqueue {
+ TAILQ_ENTRY(scsiqueue) sq_list; /* entry on queue */
+ void *sq_softc; /* target's softc */
+ int sq_target; /* target on bus */
+ int sq_lun; /* lun on target */
+
+ /*
+ * Callbacks used to start and stop the target driver.
+ */
+ void (*sq_start) __P((void *));
+ void (*sq_go) __P((void *));
+ void (*sq_intr) __P((void *, int));
};
-/* sc_flags */
-#define SCSI_IO 0x80 /* DMA I/O in progress */
-#define SCSI_DMA32 0x40 /* 32-bit DMA should be used */
-#define SCSI_HAVEDMA 0x04 /* controller has DMA channel */
-#ifdef DEBUG
-#define SCSI_PAD 0x02 /* 'padded' transfer in progress */
-#endif
-#define SCSI_ALIVE 0x01 /* controller initialized */
+struct scsi_inquiry;
+struct scsi_fmt_cdb;
+
+struct oscsi_attach_args {
+ int osa_target; /* target */
+ int osa_lun; /* logical unit */
+ /* inquiry data */
+ struct scsi_inquiry *osa_inqbuf;
+};
+
+int scsi_probe_device __P((int, int, int, struct scsi_inquiry *, int));
+int scsi_print __P((void *, const char *));
+
+void scsireset __P((int));
+int scsireq __P((struct device *, struct scsiqueue *));
+void scsifree __P((struct device *, struct scsiqueue *));
+int scsigo __P((int, int, int, struct buf *, struct scsi_fmt_cdb *, int));
+int scsi_request_sense __P((int, int, int, u_char *, u_int));
+int scsiustart __P((int));
+int scsi_tt_write __P((int, int, int, u_char *, u_int, daddr_t, int));
+int scsi_tt_oddio __P((int, int, int, u_char *, u_int, int, int));
+int scsi_immed_command __P((int, int, int, struct scsi_fmt_cdb *,
+ u_char *, u_int, int));
+void scsi_str __P((char *, char *, size_t));
+int scsi_test_unit_rdy __P((int, int, int));
diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c
index 713833396f3..ecc87b4d639 100644
--- a/sys/arch/hp300/dev/sd.c
+++ b/sys/arch/hp300/dev/sd.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: sd.c,v 1.6 1997/01/12 15:13:03 downsj Exp $ */
-/* $NetBSD: sd.c,v 1.28 1997/01/07 09:29:30 thorpej Exp $ */
+/* $OpenBSD: sd.c,v 1.7 1997/02/03 04:47:47 downsj Exp $ */
+/* $NetBSD: sd.c,v 1.29 1997/01/30 09:14:20 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -42,8 +43,6 @@
/*
* SCSI CCS (Command Command Set) disk driver.
*/
-#include "sd.h"
-#if NSD > 0
#include <sys/param.h>
#include <sys/systm.h>
@@ -55,10 +54,13 @@
#include <sys/proc.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
+#include <sys/device.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/scsireg.h>
+#include <hp300/dev/scsivar.h>
+
#include <hp300/dev/sdvar.h>
+
#ifdef USELEDS
#include <hp300/hp300/led.h>
#endif
@@ -68,32 +70,33 @@
#include <vm/vm_prot.h>
#include <vm/pmap.h>
-extern int scsi_test_unit_rdy();
-extern int scsi_request_sense();
-extern int scsi_inquiry();
-extern int scsi_read_capacity();
-extern int scsi_tt_write();
-extern int scsireq();
-extern int scsiustart();
-extern int scsigo();
-extern void scsifree();
-extern void scsireset();
-extern void scsi_delay();
-extern void scsi_str __P((char *, char *, size_t));
-
extern void disksort();
extern void biodone();
extern int physio();
extern void TBIS();
-int sdmatch();
-void sdattach(), sdstrategy(), sdstart(), sdustart(), sdgo(), sdintr();
+int sdmatch __P((struct device *, void *, void *));
+void sdattach __P((struct device *, struct device *, void *));
-struct driver sddriver = {
- sdmatch, sdattach, "sd", (int (*)())sdstart,
- (int (*)())sdgo, (int (*)())sdintr,
+struct cfattach sd_ca = {
+ sizeof(struct sd_softc), sdmatch, sdattach
};
+struct cfdriver sd_cd = {
+ NULL, "sd", DV_DISK
+};
+
+void sdstrategy __P((struct buf *));
+void sdustart __P((int));
+
+void sdstart __P((void *));
+void sdgo __P((void *));
+void sdintr __P((void *, int));
+
+int sdgetcapacity __P((struct sd_softc *, dev_t));
+
+static void sdgetgeom __P((struct sd_softc *));
+
#ifdef DEBUG
int sddebug = 1;
#define SDB_ERROR 0x01
@@ -101,12 +104,6 @@ int sddebug = 1;
#define SDB_CAPACITY 0x04
#endif
-struct sd_softc sd_softc[NSD];
-struct sdstats sdstats[NSD];
-struct buf sdtab[NSD];
-struct scsi_fmt_cdb sdcmd[NSD];
-struct scsi_fmt_sense sdsense[NSD];
-
static struct scsi_fmt_cdb sd_read_cmd = { 10, CMD_READ_EXT };
static struct scsi_fmt_cdb sd_write_cmd = { 10, CMD_WRITE_EXT };
@@ -135,19 +132,12 @@ static char legal_cmds[256] = {
/*f0*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-static struct scsi_inquiry inqbuf;
-static struct scsi_fmt_cdb inq = {
- 6,
- CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0
-};
-
/*
* Perform a mode-sense on page 0x04 (rigid geometry).
*/
static void
-sdgetgeom(sc, hd)
+sdgetgeom(sc)
struct sd_softc *sc;
- struct hp_device *hd;
{
struct scsi_mode_sense_geom {
struct scsi_modesense_hdr header;
@@ -159,225 +149,120 @@ sdgetgeom(sc, hd)
};
int ctlr, slave, unit;
- ctlr = hd->hp_ctlr;
- slave = hd->hp_slave;
- unit = sc->sc_punit;
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_target;
+ unit = sc->sc_lun;
+ scsi_delay(-1); /* XXX */
(void)scsi_immed_command(ctlr, slave, unit, &modesense_geom,
(u_char *)&sensebuf, sizeof(sensebuf), B_READ);
+ scsi_delay(0); /* XXX */
sc->sc_heads = sensebuf.geom.heads;
sc->sc_cyls = (sensebuf.geom.cyl_ub << 16) |
(sensebuf.geom.cyl_mb << 8) | sensebuf.geom.cyl_lb;
}
-static int
-sdident(sc, hd, verbose)
- struct sd_softc *sc;
- struct hp_device *hd;
- int verbose;
+int
+sdmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- int unit;
- register int ctlr, slave;
- register int i;
- register int tries = 10;
- char vendor[9], product[17], revision[5];
- int isrm = 0;
-
- ctlr = hd->hp_ctlr;
- slave = hd->hp_slave;
- unit = sc->sc_punit;
- scsi_delay(-1);
+ struct oscsi_attach_args *osa = aux;
- /*
- * See if unit exists and is a disk then read block size & nblocks.
- */
- while ((i = scsi_test_unit_rdy(ctlr, slave, unit)) != 0) {
- if (i == -1 || --tries < 0) {
- if (isrm)
- break;
- /* doesn't exist or not a CCS device */
- goto failed;
- }
- if (i == STS_CHECKCOND) {
- u_char sensebuf[128];
- struct scsi_xsense *sp = (struct scsi_xsense *)sensebuf;
-
- scsi_request_sense(ctlr, slave, unit, sensebuf,
- sizeof(sensebuf));
- if (sp->class == 7)
- switch (sp->key) {
- /*
- * Not ready -- might be removable media
- * device with no media. Assume as much,
- * if it really isn't, the inquiry commmand
- * below will fail.
- */
- case 2:
- isrm = 1;
- break;
- /* drive doing an RTZ -- give it a while */
- case 6:
- DELAY(1000000);
- break;
- default:
- break;
- }
- }
- DELAY(1000);
- }
- /*
- * Find out about device
- */
- if (scsi_immed_command(ctlr, slave, unit, &inq,
- (u_char *)&inqbuf, sizeof(inqbuf), B_READ))
- goto failed;
- switch (inqbuf.type) {
+ switch (osa->osa_inqbuf->type) {
case 0: /* disk */
case 4: /* WORM */
case 5: /* CD-ROM */
case 7: /* Magneto-optical */
break;
default: /* not a disk */
- goto failed;
+ return 0;
}
- /*
- * Get a usable id string
- */
- bzero(vendor, sizeof(vendor));
- bzero(product, sizeof(product));
- bzero(revision, sizeof(revision));
- switch (inqbuf.version) {
- case 1:
- case 2:
- scsi_str(inqbuf.vendor_id, vendor, sizeof(inqbuf.vendor_id));
- scsi_str(inqbuf.product_id, product,
- sizeof(inqbuf.product_id));
- scsi_str(inqbuf.rev, revision, sizeof(inqbuf.rev));
- break;
- default:
- bcopy("UNKNOWN", vendor, 8);
- bcopy("DRIVE TYPE", product, 11);
- }
- if (inqbuf.qual & 0x80)
- sc->sc_flags |= SDF_RMEDIA;
- if (sdgetcapacity(sc, hd, NODEV) < 0)
- goto failed;
-
- switch (inqbuf.version) {
- case 1:
- case 2:
- if (verbose) {
- printf(": <%s, %s, %s>", vendor, product, revision);
- if (inqbuf.version == 2)
- printf(" (SCSI-2)");
- }
- break;
- default:
- if (verbose)
- printf(": type 0x%x, qual 0x%x, ver %d",
- inqbuf.type, inqbuf.qual, inqbuf.version);
- break;
- }
- if (verbose)
- printf("\n");
-
- if (verbose) {
- /*
- * Print out some additional information.
- */
- printf("%s: ", hd->hp_xname);
- switch (inqbuf.type) {
- case 4:
- printf("WORM, ");
- break;
-
- case 5:
- printf("CD-ROM, ");
- break;
+ return (1);
+}
- case 7:
- printf("Magneto-optical, ");
- break;
+void
+sdattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct sd_softc *sc = (struct sd_softc *)self;
+ struct oscsi_attach_args *osa = aux;
- default:
- printf("%d cylinders, %d heads, ",
- sc->sc_cyls, sc->sc_heads);
- }
+ /*
+ * XXX formerly 0 meant unused but now pid 0 can legitimately
+ * use this interface (sdgetcapacity).
+ */
+ sc->sc_format_pid = -1;
+ sc->sc_flags = 0;
- if (sc->sc_blks)
- printf("%d blocks, %d bytes/block\n",
- sc->sc_blks >> sc->sc_bshift, sc->sc_blksize);
- else
- printf("drive empty\n");
- }
+ sc->sc_target = osa->osa_target;
+ sc->sc_lun = osa->osa_lun;
+ sc->sc_type = osa->osa_inqbuf->type;
- scsi_delay(0);
- return(inqbuf.type);
-failed:
- scsi_delay(0);
- return(-1);
-}
+ if (osa->osa_inqbuf->qual & 0x80)
+ sc->sc_flags |= SDF_RMEDIA;
-int
-sdmatch(hd)
- register struct hp_device *hd;
-{
- register struct sd_softc *sc = &sd_softc[hd->hp_unit];
+ printf("\n");
- /* XXX set up external name */
- bzero(sc->sc_xname, sizeof(sc->sc_xname));
- sprintf(sc->sc_xname, "sd%d", hd->hp_unit);
+ /* Initialize the SCSI queue entry. */
+ sc->sc_sq.sq_softc = sc;
+ sc->sc_sq.sq_target = sc->sc_target;
+ sc->sc_sq.sq_lun = sc->sc_lun;
+ sc->sc_sq.sq_start = sdstart;
+ sc->sc_sq.sq_go = sdgo;
+ sc->sc_sq.sq_intr = sdintr;
- /* Initialize the disk structure. */
- bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev));
- sc->sc_dkdev.dk_name = sc->sc_xname;
+ if (sdgetcapacity(sc, NODEV) < 0) {
+ printf("%s: getcapacity failed!\n", sc->sc_dev.dv_xname);
+ return;
+ }
- sc->sc_hd = hd;
- sc->sc_flags = 0;
/*
- * XXX formerly 0 meant unused but now pid 0 can legitimately
- * use this interface (sdgetcapacity).
+ * Print out some additional information.
*/
- sc->sc_format_pid = -1;
- sc->sc_punit = sdpunit(hd->hp_flags);
- sc->sc_type = sdident(sc, hd, 0);
- if (sc->sc_type < 0)
- return (0);
+ printf("%s: ", sc->sc_dev.dv_xname);
+ switch (sc->sc_type) {
+ case 4:
+ printf("WORM, ");
+ break;
- return (1);
-}
+ case 5:
+ printf("CD-ROM, ");
+ break;
-void
-sdattach(hd)
- register struct hp_device *hd;
-{
- struct sd_softc *sc = &sd_softc[hd->hp_unit];
+ case 7:
+ printf("Magneto-optical, ");
+ break;
- (void)sdident(sc, hd, 1); /* XXX Ick. */
+ default:
+ printf("%d cylinders, %d heads, ",
+ sc->sc_cyls, sc->sc_heads);
+ }
+ if (sc->sc_blks)
+ printf("%d blocks, %d bytes/block\n",
+ sc->sc_blks >> sc->sc_bshift, sc->sc_blksize);
+ else
+ printf("drive empty\n");
- sc->sc_dq.dq_softc = sc;
- sc->sc_dq.dq_ctlr = hd->hp_ctlr;
- sc->sc_dq.dq_unit = hd->hp_unit;
- sc->sc_dq.dq_slave = hd->hp_slave;
- sc->sc_dq.dq_driver = &sddriver;
+ /* Initialize the disk structure. */
+ sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
/* Attach the disk. */
disk_attach(&sc->sc_dkdev);
- sc->sc_flags |= SDF_ALIVE;
+ dk_establish(&sc->sc_dkdev, &sc->sc_dev); /* XXX */
- /* XXX Set device class. */
- hd->hp_dev.dv_class = DV_DISK;
+ sc->sc_flags |= SDF_ALIVE;
}
void
-sdreset(sc, hd)
+sdreset(sc)
register struct sd_softc *sc;
- register struct hp_device *hd;
{
- sdstats[hd->hp_unit].sdresets++;
+ sc->sc_stats.sdresets++;
}
/*
@@ -386,9 +271,8 @@ sdreset(sc, hd)
* due to missing media.
*/
int
-sdgetcapacity(sc, hd, dev)
+sdgetcapacity(sc, dev)
struct sd_softc *sc;
- struct hp_device *hd;
dev_t dev;
{
static struct scsi_fmt_cdb cap = {
@@ -407,8 +291,11 @@ sdgetcapacity(sc, hd, dev)
capbuf = malloc(capbufsize, M_DEVBUF, M_WAITOK);
if (dev == NODEV) {
- i = scsi_immed_command(hd->hp_ctlr, hd->hp_slave, sc->sc_punit,
- &cap, capbuf, capbufsize, B_READ);
+ scsi_delay(-1); /* XXX */
+ i = scsi_immed_command(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, &cap, capbuf,
+ capbufsize, B_READ);
+ scsi_delay(0); /* XXX */
} else {
struct buf *bp;
@@ -419,13 +306,13 @@ sdgetcapacity(sc, hd, dev)
panic("sdgetcapacity");
bp = malloc(sizeof *bp, M_DEVBUF, M_WAITOK);
sc->sc_format_pid = curproc->p_pid;
- bcopy((caddr_t)&cap, (caddr_t)&sdcmd[hd->hp_unit], sizeof cap);
+ bcopy(&cap, &sc->sc_cmdstore, sizeof cap);
bp->b_dev = dev;
bp->b_flags = B_READ | B_BUSY;
bp->b_un.b_addr = (caddr_t)capbuf;
bp->b_bcount = capbufsize;
sdstrategy(bp);
- i = biowait(bp) ? sdsense[hd->hp_unit].status : 0;
+ i = biowait(bp) ? sc->sc_sensestore.status : 0;
free(bp, M_DEVBUF);
sc->sc_format_pid = -1;
}
@@ -434,7 +321,7 @@ sdgetcapacity(sc, hd, dev)
#ifdef DEBUG
if (sddebug & SDB_CAPACITY)
printf("%s: read_capacity returns %d\n",
- hd->hp_xname, i);
+ sc->sc_dev.dv_xname, i);
#endif
free(capbuf, M_DEVBUF);
return (-1);
@@ -448,7 +335,7 @@ sdgetcapacity(sc, hd, dev)
#ifdef DEBUG
if (sddebug & SDB_CAPACITY)
printf("%s: removable media not present\n",
- hd->hp_xname);
+ sc->sc_dev.dv_xname);
#endif
free(capbuf, M_DEVBUF);
return (1);
@@ -464,7 +351,7 @@ sdgetcapacity(sc, hd, dev)
if (sc->sc_blksize != DEV_BSIZE) {
if (sc->sc_blksize < DEV_BSIZE) {
printf("%s: need at least %d byte blocks - %s\n",
- hd->hp_xname, DEV_BSIZE, "drive ignored");
+ sc->sc_dev.dv_xname, DEV_BSIZE, "drive ignored");
return (-1);
}
for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1)
@@ -473,10 +360,11 @@ sdgetcapacity(sc, hd, dev)
}
#ifdef DEBUG
if (sddebug & SDB_CAPACITY)
- printf("%s: blks=%d, blksize=%d, bshift=%d\n", hd->hp_xname,
- sc->sc_blks, sc->sc_blksize, sc->sc_bshift);
+ printf("%s: blks=%d, blksize=%d, bshift=%d\n",
+ sc->sc_dev.dv_xname, sc->sc_blks, sc->sc_blksize,
+ sc->sc_bshift);
#endif
- sdgetgeom(sc, hd);
+ sdgetgeom(sc);
return (0);
}
@@ -488,7 +376,7 @@ sdgetinfo(dev)
dev_t dev;
{
int unit = sdunit(dev);
- register struct sd_softc *sc = &sd_softc[unit];
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
register struct disklabel *lp = sc->sc_dkdev.dk_label;
register struct partition *pi;
char *msg, *readdisklabel();
@@ -511,7 +399,7 @@ sdgetinfo(dev)
* now.
*/
if ((sc->sc_flags & SDF_RMEDIA) || sc->sc_blks == 0) {
- switch (sdgetcapacity(sc, sc->sc_hd, dev)) {
+ switch (sdgetcapacity(sc, dev)) {
case 0:
break;
case -1:
@@ -559,7 +447,7 @@ sdgetinfo(dev)
}
pi = lp->d_partitions;
- printf("%s: WARNING: %s, ", sc->sc_hd->hp_xname, msg);
+ printf("%s: WARNING: %s, ", sc->sc_dev.dv_xname, msg);
#ifdef COMPAT_NOLABEL
if (usedefault) {
printf("using old default partitioning\n");
@@ -582,11 +470,13 @@ sdopen(dev, flags, mode, p)
struct proc *p;
{
register int unit = sdunit(dev);
- register struct sd_softc *sc = &sd_softc[unit];
+ struct sd_softc *sc;
int error, mask, part;
- if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0)
- return(ENXIO);
+ if (unit >= sd_cd.cd_ndevs ||
+ (sc = sd_cd.cd_devs[unit]) == NULL ||
+ (sc->sc_flags & SDF_ALIVE) == 0)
+ return (ENXIO);
/*
* Wait for any pending opens/closes to complete
@@ -639,7 +529,7 @@ sdclose(dev, flag, mode, p)
struct proc *p;
{
int unit = sdunit(dev);
- register struct sd_softc *sc = &sd_softc[unit];
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
register struct disk *dk = &sc->sc_dkdev;
int mask, s;
@@ -659,9 +549,9 @@ sdclose(dev, flag, mode, p)
if (dk->dk_openmask == 0) {
sc->sc_flags |= SDF_CLOSING;
s = splbio();
- while (sdtab[unit].b_active) {
+ while (sc->sc_tab.b_active) {
sc->sc_flags |= SDF_WANTED;
- sleep((caddr_t)&sdtab[unit], PRIBIO);
+ sleep((caddr_t)&sc->sc_tab, PRIBIO);
}
splx(s);
sc->sc_flags &= ~(SDF_CLOSING|SDF_WLABEL|SDF_ERROR);
@@ -685,6 +575,7 @@ sdlblkstrat(bp, bsize)
register struct buf *bp;
register int bsize;
{
+ struct sd_softc *sc = sd_cd.cd_devs[sdunit(bp->b_dev)];
register struct buf *cbp = (struct buf *)malloc(sizeof(struct buf),
M_DEVBUF, M_WAITOK);
caddr_t cbuf = (caddr_t)malloc(bsize, M_DEVBUF, M_WAITOK);
@@ -708,7 +599,7 @@ sdlblkstrat(bp, bsize)
register int count;
if (boff || resid < bsize) {
- sdstats[sdunit(bp->b_dev)].sdpartials++;
+ sc->sc_stats.sdpartials++;
count = min(resid, bsize - boff);
cbp->b_flags = B_BUSY | B_PHYS | B_READ;
cbp->b_blkno = bn - btodb(boff);
@@ -774,8 +665,8 @@ sdstrategy(bp)
register struct buf *bp;
{
int unit = sdunit(bp->b_dev);
- register struct sd_softc *sc = &sd_softc[unit];
- register struct buf *dp = &sdtab[unit];
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
+ register struct buf *dp = &sc->sc_tab;
register struct partition *pinfo;
register daddr_t bn;
register int sz, s;
@@ -858,8 +749,10 @@ void
sdustart(unit)
register int unit;
{
- if (scsireq(&sd_softc[unit].sc_dq))
- sdstart(unit);
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
+
+ if (scsireq(sc->sc_dev.dv_parent, &sc->sc_sq))
+ sdstart(sc);
}
/*
@@ -869,22 +762,21 @@ sdustart(unit)
* >0 if a fatal error
*/
static int
-sderror(unit, sc, hp, stat)
- int unit, stat;
- register struct sd_softc *sc;
- register struct hp_device *hp;
+sderror(sc, stat)
+ struct sd_softc *sc;
+ int stat;
{
int cond = 1;
- sdsense[unit].status = stat;
+ sc->sc_sensestore.status = stat;
if (stat & STS_CHECKCOND) {
struct scsi_xsense *sp;
- scsi_request_sense(hp->hp_ctlr, hp->hp_slave,
- sc->sc_punit, sdsense[unit].sense,
- sizeof(sdsense[unit].sense));
- sp = (struct scsi_xsense *)sdsense[unit].sense;
- printf("%s: scsi sense class %d, code %d", hp->hp_xname,
+ scsi_request_sense(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, sc->sc_sensestore.sense,
+ sizeof(sc->sc_sensestore.sense));
+ sp = (struct scsi_xsense *)(sc->sc_sensestore.sense);
+ printf("%s: scsi sense class %d, code %d", sc->sc_dev.dv_xname,
sp->class, sp->code);
if (sp->class == 7) {
printf(", key %d", sp->key);
@@ -924,20 +816,19 @@ sderror(unit, sc, hp, stat)
}
static void
-sdfinish(unit, sc, bp)
- int unit;
- register struct sd_softc *sc;
- register struct buf *bp;
+sdfinish(sc, bp)
+ struct sd_softc *sc;
+ struct buf *bp;
{
- register struct buf *dp = &sdtab[unit];
+ register struct buf *dp = &sc->sc_tab;
dp->b_errcnt = 0;
dp->b_actf = bp->b_actf;
bp->b_resid = 0;
biodone(bp);
- scsifree(&sc->sc_dq);
+ scsifree(sc->sc_dev.dv_parent, &sc->sc_sq);
if (dp->b_actf)
- sdustart(unit);
+ sdustart(sc->sc_dev.dv_unit);
else {
dp->b_active = 0;
if (sc->sc_flags & SDF_WANTED) {
@@ -948,54 +839,52 @@ sdfinish(unit, sc, bp)
}
void
-sdstart(unit)
- register int unit;
+sdstart(arg)
+ void *arg;
{
- register struct sd_softc *sc = &sd_softc[unit];
- register struct hp_device *hp = sc->sc_hd;
+ struct sd_softc *sc = arg;
/*
* we have the SCSI bus -- in format mode, we may or may not need dma
* so check now.
*/
- if (sc->sc_format_pid >= 0 && legal_cmds[sdcmd[unit].cdb[0]] > 0) {
- register struct buf *bp = sdtab[unit].b_actf;
+ if (sc->sc_format_pid >= 0 && legal_cmds[sc->sc_cmdstore.cdb[0]] > 0) {
+ register struct buf *bp = sc->sc_tab.b_actf;
register int sts;
- sdtab[unit].b_errcnt = 0;
+ sc->sc_tab.b_errcnt = 0;
while (1) {
- sts = scsi_immed_command(hp->hp_ctlr, hp->hp_slave,
- sc->sc_punit, &sdcmd[unit],
- bp->b_un.b_addr, bp->b_bcount,
- bp->b_flags & B_READ);
- sdsense[unit].status = sts;
+ sts = scsi_immed_command(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, &sc->sc_cmdstore,
+ bp->b_un.b_addr, bp->b_bcount,
+ bp->b_flags & B_READ);
+ sc->sc_sensestore.status = sts;
if ((sts & 0xfe) == 0 ||
- (sts = sderror(unit, sc, hp, sts)) == 0)
+ (sts = sderror(sc, sts)) == 0)
break;
- if (sts > 0 || sdtab[unit].b_errcnt++ >= SDRETRY) {
+ if (sts > 0 || sc->sc_tab.b_errcnt++ >= SDRETRY) {
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
}
}
- sdfinish(unit, sc, bp);
+ sdfinish(sc, bp);
- } else if (scsiustart(hp->hp_ctlr))
- sdgo(unit);
+ } else if (scsiustart(sc->sc_dev.dv_parent->dv_unit))
+ sdgo(sc);
}
void
-sdgo(unit)
- register int unit;
+sdgo(arg)
+ void *arg;
{
- register struct sd_softc *sc = &sd_softc[unit];
- register struct hp_device *hp = sc->sc_hd;
- register struct buf *bp = sdtab[unit].b_actf;
+ struct sd_softc *sc = arg;
+ register struct buf *bp = sc->sc_tab.b_actf;
register int pad;
register struct scsi_fmt_cdb *cmd;
if (sc->sc_format_pid >= 0) {
- cmd = &sdcmd[unit];
+ cmd = &sc->sc_cmdstore;
pad = 0;
} else {
/*
@@ -1004,7 +893,7 @@ sdgo(unit)
if (sc->sc_flags & SDF_ERROR) {
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
- sdfinish(unit, sc, bp);
+ sdfinish(sc, bp);
return;
}
cmd = bp->b_flags & B_READ? &sd_read_cmd : &sd_write_cmd;
@@ -1015,15 +904,15 @@ sdgo(unit)
#ifdef DEBUG
if (pad)
printf("%s: partial block xfer -- %x bytes\n",
- sc->sc_hd->hp_xname, bp->b_bcount);
+ sc->sc_dev.dv_xname, bp->b_bcount);
#endif
- sdstats[unit].sdtransfers++;
+ sc->sc_stats.sdtransfers++;
}
#ifdef USELEDS
if (inledcontrol == 0)
ledcontrol(0, 0, LED_DISK);
#endif
- if (scsigo(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
+ if (scsigo(sc->sc_dev.dv_parent->dv_unit, sc->sc_target, sc->sc_lun,
bp, cmd, pad) == 0) {
/* Instrumentation. */
disk_busy(&sc->sc_dkdev);
@@ -1033,14 +922,14 @@ sdgo(unit)
#ifdef DEBUG
if (sddebug & SDB_ERROR)
printf("%s: sdstart: %s adr %d blk %d len %d ecnt %d\n",
- sc->sc_hd->hp_xname,
+ sc->sc_dev.dv_xname,
bp->b_flags & B_READ? "read" : "write",
bp->b_un.b_addr, bp->b_cylin, bp->b_bcount,
- sdtab[unit].b_errcnt);
+ sc->sc_tab.b_errcnt);
#endif
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
- sdfinish(unit, sc, bp);
+ sdfinish(sc, bp);
}
void
@@ -1049,13 +938,12 @@ sdintr(arg, stat)
int stat;
{
register struct sd_softc *sc = arg;
- int unit = sc->sc_hd->hp_unit;
- register struct buf *bp = sdtab[unit].b_actf;
- register struct hp_device *hp = sc->sc_hd;
+ int unit = sc->sc_dev.dv_unit;
+ register struct buf *bp = sc->sc_tab.b_actf;
int cond;
if (bp == NULL) {
- printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
+ printf("%s: bp == NULL\n", sc->sc_dev.dv_xname);
return;
}
@@ -1065,25 +953,25 @@ sdintr(arg, stat)
#ifdef DEBUG
if (sddebug & SDB_ERROR)
printf("%s: sdintr: bad scsi status 0x%x\n",
- sc->sc_hd->hp_xname, stat);
+ sc->sc_dev.dv_xname, stat);
#endif
- cond = sderror(unit, sc, hp, stat);
+ cond = sderror(sc, stat);
if (cond) {
- if (cond < 0 && sdtab[unit].b_errcnt++ < SDRETRY) {
+ if (cond < 0 && sc->sc_tab.b_errcnt++ < SDRETRY) {
#ifdef DEBUG
if (sddebug & SDB_ERROR)
printf("%s: retry #%d\n",
- sc->sc_hd->hp_xname,
- sdtab[unit].b_errcnt);
+ sc->sc_dev.dv_xname,
+ sc->sc_tab.b_errcnt);
#endif
- sdstart(unit);
+ sdstart(sc);
return;
}
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
}
}
- sdfinish(unit, sc, bp);
+ sdfinish(sc, bp);
}
int
@@ -1093,9 +981,10 @@ sdread(dev, uio, flags)
int flags;
{
register int unit = sdunit(dev);
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
register int pid;
- if ((pid = sd_softc[unit].sc_format_pid) >= 0 &&
+ if ((pid = sc->sc_format_pid) >= 0 &&
pid != uio->uio_procp->p_pid)
return (EPERM);
@@ -1109,9 +998,10 @@ sdwrite(dev, uio, flags)
int flags;
{
register int unit = sdunit(dev);
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
register int pid;
- if ((pid = sd_softc[unit].sc_format_pid) >= 0 &&
+ if ((pid = sc->sc_format_pid) >= 0 &&
pid != uio->uio_procp->p_pid)
return (EPERM);
@@ -1127,7 +1017,7 @@ sdioctl(dev, cmd, data, flag, p)
struct proc *p;
{
int unit = sdunit(dev);
- register struct sd_softc *sc = &sd_softc[unit];
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
register struct disklabel *lp = sc->sc_dkdev.dk_label;
int error, flags;
@@ -1206,7 +1096,7 @@ sdioctl(dev, cmd, data, flag, p)
return (EPERM);
if (legal_cmds[((struct scsi_fmt_cdb *)data)->cdb[0]] == 0)
return (EINVAL);
- bcopy(data, (caddr_t)&sdcmd[unit], sizeof(sdcmd[0]));
+ bcopy(data, &sc->sc_cmdstore, sizeof(struct scsi_fmt_cdb));
return (0);
case SDIOCSENSE:
@@ -1214,7 +1104,7 @@ sdioctl(dev, cmd, data, flag, p)
* return the SCSI sense data saved after the last
* operation that completed with "check condition" status.
*/
- bcopy((caddr_t)&sdsense[unit], data, sizeof(sdsense[0]));
+ bcopy(&sc->sc_sensestore, data, sizeof(sc->sc_sensestore));
return (0);
}
@@ -1226,11 +1116,13 @@ sdsize(dev)
dev_t dev;
{
register int unit = sdunit(dev);
- register struct sd_softc *sc = &sd_softc[unit];
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
int psize, didopen = 0;
- if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0)
- return(-1);
+ if (unit >= sd_cd.cd_ndevs ||
+ (sc = sd_cd.cd_devs[unit]) == NULL ||
+ (sc->sc_flags & SDF_ALIVE) == 0)
+ return (-1);
/*
* We get called very early on (via swapconf)
@@ -1267,7 +1159,6 @@ sddump(dev, blkno, va, size)
int nwrt; /* current number of sectors to write */
int unit, part;
struct sd_softc *sc;
- struct hp_device *hp;
struct disklabel *lp;
daddr_t baddr;
char stat;
@@ -1282,12 +1173,10 @@ sddump(dev, blkno, va, size)
part = sdpart(dev);
/* Make sure device is ok. */
- if (unit >= NSD)
- return (ENXIO);
- sc = &sd_softc[unit];
- if ((sc->sc_flags & SDF_ALIVE) == 0)
+ if (unit >= sd_cd.cd_ndevs ||
+ (sc = sd_cd.cd_devs[unit]) == NULL ||
+ (sc->sc_flags & SDF_ALIVE) == 0)
return (ENXIO);
- hp = sc->sc_hd;
/*
* Convert to disk sectors. Request must be a multiple of size.
@@ -1316,15 +1205,16 @@ sddump(dev, blkno, va, size)
* Send the data. Note the `0' argument for bshift;
* we've done the necessary conversion above.
*/
- stat = scsi_tt_write(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
- va, nwrt * sectorsize, blkno, 0);
+ stat = scsi_tt_write(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, va, nwrt * sectorsize,
+ blkno, 0);
if (stat) {
printf("\nsddump: scsi write error 0x%x\n", stat);
return (EIO);
}
#else /* SD_DUMP_NOT_TRUSTED */
/* Lets just talk about it first. */
- printf("%s: dump addr %p, blk %d\n", hp->hp_xname,
+ printf("%s: dump addr %p, blk %d\n", sc->sc_dev.dv_xname,
va, blkno);
delay(500 * 1000); /* half a second */
#endif /* SD_DUMP_NOT_TRUSTED */
@@ -1337,4 +1227,3 @@ sddump(dev, blkno, va, size)
sddoingadump = 0;
return (0);
}
-#endif
diff --git a/sys/arch/hp300/dev/sd_compat.c b/sys/arch/hp300/dev/sd_compat.c
index a05e9e5f663..58052e85a25 100644
--- a/sys/arch/hp300/dev/sd_compat.c
+++ b/sys/arch/hp300/dev/sd_compat.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: sd_compat.c,v 1.3 1997/01/12 15:13:04 downsj Exp $ */
-/* $NetBSD: sd_compat.c,v 1.4 1996/01/07 22:02:20 thorpej Exp $ */
+/* $OpenBSD: sd_compat.c,v 1.4 1997/02/03 04:47:47 downsj Exp $ */
+/* $NetBSD: sd_compat.c,v 1.5 1997/01/30 09:14:21 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -42,13 +42,15 @@
/*
* Compatibility for SCSI disks without labels.
*/
-#include "sd.h"
-#if NSD > 0
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
-#include <hp300/dev/device.h>
+#include <sys/device.h>
+#include <sys/buf.h> /* XXX */
+
+#include <hp300/dev/scsireg.h> /* XXX */
+#include <hp300/dev/scsivar.h>
#include <hp300/dev/sdvar.h>
/*
@@ -77,13 +79,12 @@ struct partition sddefaultpart[] = {
};
int sdnumdefaultpart = sizeof(sddefaultpart)/sizeof(sddefaultpart[0]);
-extern struct sd_softc sd_softc[];
-
sdmakedisklabel(unit, lp)
int unit;
register struct disklabel *lp;
{
- register struct sd_softc *sc = &sd_softc[unit];
+ extern struct cfdriver sd_cd;
+ struct sd_softc *sc = sd_cd.cd_devs[unit];
register struct partition *pi, *dpi;
register int dcount;
@@ -124,4 +125,3 @@ sdmakedisklabel(unit, lp)
pi[5].p_offset = pi[5].p_size = 0;
}
}
-#endif
diff --git a/sys/arch/hp300/dev/sdvar.h b/sys/arch/hp300/dev/sdvar.h
index a91895cf127..c3d9921798c 100644
--- a/sys/arch/hp300/dev/sdvar.h
+++ b/sys/arch/hp300/dev/sdvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: sdvar.h,v 1.5 1997/01/12 15:13:04 downsj Exp $ */
-/* $NetBSD: sdvar.h,v 1.5 1996/06/06 16:17:45 thorpej Exp $ */
+/* $OpenBSD: sdvar.h,v 1.6 1997/02/03 04:47:48 downsj Exp $ */
+/* $NetBSD: sdvar.h,v 1.6 1997/01/30 09:14:22 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -39,20 +39,30 @@
* @(#)sdvar.h 8.1 (Berkeley) 6/10/93
*/
+struct sdstats {
+ long sdresets;
+ long sdtransfers;
+ long sdpartials;
+};
+
struct sd_softc {
- struct hp_device *sc_hd;
+ struct device sc_dev;
struct disk sc_dkdev;
- char sc_xname[8];
- struct devqueue sc_dq;
+ struct scsiqueue sc_sq;
int sc_format_pid; /* process using "format" mode */
short sc_flags;
short sc_type; /* drive type */
- short sc_punit; /* physical unit (scsi lun) */
+ int sc_target; /* SCSI target */
+ int sc_lun; /* SCSI lun */
u_short sc_bshift; /* convert device blocks to DEV_BSIZE blks */
u_int sc_blks; /* number of blocks on device */
int sc_blksize; /* device block size in bytes */
u_int sc_heads; /* number of heads (tracks) */
u_int sc_cyls; /* number of cylinders */
+ struct buf sc_tab; /* buffer queue */
+ struct sdstats sc_stats; /* debugging stats */
+ struct scsi_fmt_cdb sc_cmdstore;
+ struct scsi_fmt_sense sc_sensestore;
};
/* sc_flags values */
@@ -64,12 +74,6 @@ struct sd_softc {
#define SDF_RMEDIA 0x20
#define SDF_ERROR 0x40
-struct sdstats {
- long sdresets;
- long sdtransfers;
- long sdpartials;
-};
-
#define sdunit(x) (minor(x) >> 3)
#define sdpart(x) (minor(x) & 0x7)
#define sdpunit(x) ((x) & 7)
diff --git a/sys/arch/hp300/dev/st.c b/sys/arch/hp300/dev/st.c
index 2a9f5d19ec2..bd31da2aca8 100644
--- a/sys/arch/hp300/dev/st.c
+++ b/sys/arch/hp300/dev/st.c
@@ -1,7 +1,8 @@
-/* $OpenBSD: st.c,v 1.5 1997/01/12 15:13:05 downsj Exp $ */
-/* $NetBSD: st.c,v 1.18 1996/10/14 07:14:21 thorpej Exp $ */
+/* $OpenBSD: st.c,v 1.6 1997/02/03 04:47:49 downsj Exp $ */
+/* $NetBSD: st.c,v 1.19 1997/01/30 09:14:23 thorpej Exp $ */
/*
+ * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1990 University of Utah.
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -75,9 +76,6 @@
* support for the block device not implemented
*/
-#include "st.h"
-#if NST > 0
-
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
@@ -88,32 +86,21 @@
#include <sys/mtio.h>
#include <sys/kernel.h>
#include <sys/tprintf.h>
+#include <sys/device.h>
-#include <hp300/dev/device.h>
#include <hp300/dev/scsireg.h>
+#include <hp300/dev/scsivar.h>
+
#include <hp300/dev/stvar.h>
-extern int scsi_test_unit_rdy();
-extern int scsi_request_sense();
-extern int scsiustart();
-extern int scsigo();
-extern void scsifree();
-extern void scsireset();
-extern void scsi_delay();
-extern int scsi_tt_oddio();
-extern void scsi_str __P((char *, char *, size_t));
-
-extern int scsi_immed_command();
-
-int stmatch(), ststart(), stgo(), stintr();
-void stattach();
-struct driver stdriver = {
- stmatch, stattach, "st", ststart, stgo, stintr,
+struct st_xsense {
+ struct scsi_xsense sc_xsense; /* data from sense */
+ struct exb_xsense exb_xsense; /* additional info from exabyte */
};
struct st_softc {
- struct hp_device *sc_hd;
- struct devqueue sc_dq;
+ struct device sc_dev;
+ struct scsiqueue sc_sq;
long sc_blkno; /* (possible block device support?) */
long sc_resid; /* (possible block device support?) */
int sc_flags;
@@ -121,14 +108,19 @@ struct st_softc {
int sc_filepos; /* file position on tape */
long sc_numblks; /* number of blocks on tape */
short sc_type; /* ansi scsi type */
- short sc_punit; /* physical unit (scsi lun) */
+ int sc_target;
+ int sc_lun;
short sc_tapeid; /* tape drive id */
char sc_datalen[32]; /* additional data length on some commands */
short sc_tticntdwn; /* interrupts between TTi display updates */
tpr_t sc_ctty;
struct buf *sc_bp;
u_char sc_cmd;
-} st_softc[NST];
+ struct st_xsense sc_sense;
+ struct scsi_fmt_cdb sc_cmdstore;
+ struct buf sc_tab; /* buffer queue */
+ struct buf sc_bufstore; /* XXX buffer storage */
+};
/* softc flags */
#define STF_ALIVE 0x0001
@@ -139,25 +131,26 @@ struct st_softc {
#define STF_LEOT 0x0020
#define STF_MOVED 0x0040
-struct st_mode st_mode[NST];
+int stmatch __P((struct device *, void *, void *));
+void stattach __P((struct device *, struct device *, void *));
-/*
- * Maybe this should not be global, but gives chance to get
- * tape remaining, Rewrites/ECC, etc outside the driver
- */
-static struct st_xsense {
- struct scsi_xsense sc_xsense; /* data from sense */
- struct exb_xsense exb_xsense; /* additional info from exabyte */
-} st_xsense[NST];
+struct cfattach st_ca = {
+ sizeof(struct st_softc), stmatch, stattach
+};
-static struct scsi_fmt_cdb stcmd[NST];
+struct cfdriver st_cd = {
+ NULL, "st", DV_TAPE
+};
+
+void stustart __P((int));
+
+void ststart __P((void *));
+void stgo __P((void *));
+void stintr __P((void *, int));
static struct scsi_fmt_cdb st_read_cmd = { 6, CMD_READ };
static struct scsi_fmt_cdb st_write_cmd = { 6, CMD_WRITE };
-struct buf sttab[NST];
-struct buf stbuf[NST];
-
#define UNIT(x) (minor(x) & 3)
#define stpunit(x) ((x) & 7)
@@ -226,123 +219,66 @@ int st_extti = 0x01; /* bitmask of unit numbers, do extra */
#endif
int
-stmatch(hd)
- register struct hp_device *hd;
+stmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
{
- register struct st_softc *sc = &st_softc[hd->hp_unit];
- register struct buf *bp;
+ struct oscsi_attach_args *osa = aux;
- for (bp = sttab; bp < &sttab[NST]; bp++)
- bp->b_actb = &bp->b_actf;
- sc->sc_hd = hd;
- sc->sc_punit = stpunit(hd->hp_flags);
- sc->sc_type = stident(sc, hd, 0);
- if (sc->sc_type < 0)
+ if ((osa->osa_inqbuf->type != 0x01 || /* sequential access device */
+ osa->osa_inqbuf->qual != 0x80 || /* removable media */
+ (osa->osa_inqbuf->version != 0x01 &&
+ osa->osa_inqbuf->version != 0x02)) &&
+ (osa->osa_inqbuf->type != 0x01 || /* M4 ??! */
+ /*
+ * the M4 is a little too smart (ass?) for its own good:
+ * qual codes:
+ * 0x80: you can take the tape out (unit not online)
+ * 0xf8: online and at 6250bpi
+ * 0xf9: online and at 1600bpi
+ */
+ osa->osa_inqbuf->version != 0x09)) /* M4 tape */
return (0);
return (1);
}
void
-stattach(hd)
- register struct hp_device *hd;
-{
- struct st_softc *sc = &st_softc[hd->hp_unit];
-
- (void)stident(sc, hd, 1); /* XXX Ick. */
-
- sc->sc_dq.dq_softc = sc;
- sc->sc_dq.dq_ctlr = hd->hp_ctlr;
- sc->sc_dq.dq_unit = hd->hp_unit;
- sc->sc_dq.dq_slave = hd->hp_slave;
- sc->sc_dq.dq_driver = &stdriver;
- sc->sc_blkno = 0;
- sc->sc_flags = STF_ALIVE;
-
- /* XXX Set device class. */
- hd->hp_dev.dv_class = DV_TAPE;
-}
-
-int
-stident(sc, hd, verbose)
- register struct st_softc *sc;
- register struct hp_device *hd;
- int verbose;
+stattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- int unit;
- int ctlr, slave;
- int i, stat, inqlen;
+ struct st_softc *sc = (struct st_softc *)self;
+ struct oscsi_attach_args *osa = aux;
char vendor[9], product[17], revision[5];
+ int stat;
static int havest = 0;
- struct st_inquiry {
- struct scsi_inquiry inqbuf;
- struct exb_inquiry exb_inquiry;
- } st_inqbuf;
- static struct scsi_fmt_cdb st_inq = {
- 6,
- CMD_INQUIRY, 0, 0, 0, sizeof(st_inqbuf), 0
- };
- ctlr = hd->hp_ctlr;
- slave = hd->hp_slave;
- unit = sc->sc_punit;
- scsi_delay(-1);
+ printf("\n");
- inqlen = 0x05; /* min */
- st_inq.cdb[4] = 0x05;
- stat = scsi_immed_command(ctlr, slave, unit, &st_inq,
- (u_char *)&st_inqbuf, inqlen, B_READ);
- /* do twice as first command on some scsi tapes always fails */
- stat = scsi_immed_command(ctlr, slave, unit, &st_inq,
- (u_char *)&st_inqbuf, inqlen, B_READ);
- if (stat == -1)
- goto failed;
-
- if ((st_inqbuf.inqbuf.type != 0x01 || /* sequential access device */
- st_inqbuf.inqbuf.qual != 0x80 || /* removable media */
- (st_inqbuf.inqbuf.version != 0x01 && /* current ANSI SCSI spec */
- st_inqbuf.inqbuf.version != 0x02)) /* 0x02 is for HP DAT */
- &&
- (st_inqbuf.inqbuf.type != 0x01 || /* M4 ??! */
- /*
- * the M4 is a little too smart (ass?) for its own good:
- * qual codes:
- * 0x80: you can take the tape out (unit not online)
- * 0xf8: online and at 6250bpi
- * 0xf9: online and at 1600bpi
- */
- st_inqbuf.inqbuf.version != 0x09)) /* M4 tape */
-{
-printf("st: wrong specs: type %x qual %x version %d\n", st_inqbuf.inqbuf.type,
-st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version);
- goto failed;
-}
-
- /* now get additonal info */
- inqlen = 0x05 + st_inqbuf.inqbuf.len;
- st_inq.cdb[4] = inqlen;
- bzero(&st_inqbuf, sizeof(st_inqbuf));
- stat = scsi_immed_command(ctlr, slave, unit, &st_inq,
- (u_char *)&st_inqbuf, inqlen, B_READ);
+ sc->sc_tab.b_actb = &sc->sc_tab.b_actf;
bzero(vendor, sizeof(vendor));
bzero(product, sizeof(product));
bzero(revision, sizeof(revision));
- if (st_inqbuf.inqbuf.len >= 28) {
- scsi_str(st_inqbuf.inqbuf.vendor_id, vendor,
- sizeof(st_inqbuf.inqbuf.vendor_id));
- scsi_str(st_inqbuf.inqbuf.product_id, product,
- sizeof(st_inqbuf.inqbuf.product_id));
- scsi_str(st_inqbuf.inqbuf.rev, revision,
- sizeof(st_inqbuf.inqbuf.rev));
- if (verbose)
- printf(": <%s, %s, %s>\n", vendor, product, revision);
- }
- if (stat == 0xff) {
- printf("st%d: Can't handle this tape drive\n", hd->hp_unit);
- goto failed;
- }
+ scsi_str(osa->osa_inqbuf->vendor_id, vendor,
+ sizeof(osa->osa_inqbuf->vendor_id));
+ scsi_str(osa->osa_inqbuf->product_id, product,
+ sizeof(osa->osa_inqbuf->product_id));
+ scsi_str(osa->osa_inqbuf->rev, revision,
+ sizeof(osa->osa_inqbuf->rev));
+
+ sc->sc_target = osa->osa_target;
+ sc->sc_lun = osa->osa_lun;
+
+ /* Initialize SCSI queue entry. */
+ sc->sc_sq.sq_softc = sc;
+ sc->sc_sq.sq_target = sc->sc_target;
+ sc->sc_sq.sq_lun = sc->sc_lun;
+ sc->sc_sq.sq_start = ststart;
+ sc->sc_sq.sq_go = stgo;
+ sc->sc_sq.sq_intr = stintr;
if (bcmp("EXB-8200", product, 8) == 0) {
sc->sc_tapeid = MT_ISEXABYTE;
@@ -366,7 +302,8 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version);
sc->sc_datalen[CMD_MODE_SENSE] = 12;
} else if (bcmp("HP35450A", product, 8) == 0) {
/* XXX "extra" stat makes the HP drive happy at boot time */
- stat = scsi_test_unit_rdy(ctlr, slave, unit);
+ stat = scsi_test_unit_rdy(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun);
sc->sc_tapeid = MT_ISHPDAT;
sc->sc_datalen[CMD_REQUEST_SENSE] = 14;
sc->sc_datalen[CMD_INQUIRY] = 36;
@@ -380,9 +317,8 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version);
sc->sc_datalen[CMD_MODE_SELECT] = 12;
sc->sc_datalen[CMD_MODE_SENSE] = 12;
} else {
- if (verbose)
- printf("%s: Unsupported tape device, faking it\n",
- sc->sc_hd->hp_xname);
+ printf("%s: Unsupported tape device, faking it\n",
+ sc->sc_dev.dv_xname);
sc->sc_tapeid = MT_ISAR;
sc->sc_datalen[CMD_REQUEST_SENSE] = 8;
sc->sc_datalen[CMD_INQUIRY] = 5;
@@ -393,18 +329,18 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version);
sc->sc_filepos = 0;
/* load xsense */
- stxsense(ctlr, slave, unit, sc);
-
+ scsi_delay(-1);
+ stxsense(sc->sc_dev.dv_parent->dv_unit, sc->sc_target, sc->sc_lun, sc);
scsi_delay(0);
+
/* XXX if we have a tape, we must up the delays in the HA driver */
if (!havest) {
havest = 1;
scsi_delay(20000);
}
- return(st_inqbuf.inqbuf.type);
-failed:
- scsi_delay(0);
- return(-1);
+
+ sc->sc_blkno = 0;
+ sc->sc_flags = STF_ALIVE;
}
stopen(dev, flag, type, p)
@@ -412,7 +348,7 @@ stopen(dev, flag, type, p)
int flag, type;
struct proc *p;
{
- register struct st_softc *sc = &st_softc[UNIT(dev)];
+ register struct st_softc *sc;
register struct st_xsense *xsense;
register int count;
register int stat;
@@ -430,15 +366,18 @@ stopen(dev, flag, type, p)
CMD_MODE_SENSE, 0, 0, 0, sizeof(mode), 0
};
- ctlr = sc->sc_dq.dq_ctlr;
- slave = sc->sc_dq.dq_slave;
- unit = sc->sc_punit;
- xsense = &st_xsense[UNIT(dev)];
+ if (UNIT(dev) > st_cd.cd_ndevs ||
+ (sc = st_cd.cd_devs[UNIT(dev)]) == NULL ||
+ (sc->sc_flags & STF_ALIVE) == 0)
+ return (ENXIO);
- if (UNIT(dev) > NST || (sc->sc_flags & STF_ALIVE) == 0)
- return(ENXIO);
if (sc->sc_flags & STF_OPEN)
- return(EBUSY);
+ return (EBUSY);
+
+ ctlr = sc->sc_dev.dv_parent->dv_unit;
+ slave = sc->sc_target;
+ unit = sc->sc_lun;
+ xsense = &sc->sc_sense;
/*
* Be prepared to print error messages
@@ -569,7 +508,7 @@ retryselect:
#endif
if (stat == STS_CHECKCOND) {
stxsense(ctlr, slave, unit, sc);
- prtkey(UNIT(dev), sc);
+ prtkey(sc);
}
if (stat)
return(EIO);
@@ -613,7 +552,7 @@ retryselect:
xsense->exb_xsense.tnp)
uprintf("cartridge unloading\n");
else
- prtkey(UNIT(dev), sc);
+ prtkey(sc);
break;
case MT_ISMFOUR:
case MT_ISAR:
@@ -622,7 +561,7 @@ retryselect:
if (stat == STS_CHECKCOND) {
stxsense(ctlr, slave, unit, sc);
if (xsense->sc_xsense.key)
- prtkey(UNIT(dev), sc);
+ prtkey(sc);
} else {
sc->sc_filepos = 0; /* new tape */
stat = 0;
@@ -636,12 +575,12 @@ retryselect:
if (stat == STS_CHECKCOND) {
stxsense(ctlr, slave, unit, sc);
if (xsense->sc_xsense.key)
- prtkey(UNIT(dev), sc);
+ prtkey(sc);
}
break;
default:
- uprintf("%s: not ready\n", sc->sc_hd->hp_xname);
- prtkey(UNIT(dev), sc);
+ uprintf("%s: not ready\n", sc->sc_dev.dv_xname);
+ prtkey(sc);
break;
}
}
@@ -682,7 +621,7 @@ retryselect:
sc->sc_filepos = 0;
#ifdef DEBUG
if (st_debug & ST_FMKS)
- printf("%s: open filepos = %d\n", sc->sc_hd->hp_xname,
+ printf("%s: open filepos = %d\n", sc->sc_dev.dv_xname,
sc->sc_filepos);
#endif
@@ -705,7 +644,7 @@ stclose(dev, flag)
dev_t dev;
int flag;
{
- register struct st_softc *sc = &st_softc[UNIT(dev)];
+ struct st_softc *sc = st_cd.cd_devs[UNIT(dev)];
register int hit = 0;
if ((sc->sc_flags & (STF_WMODE|STF_WRTTN)) == (STF_WMODE|STF_WRTTN)) {
@@ -731,7 +670,7 @@ stclose(dev, flag)
stcommand(dev, MTFSR, 0);
#endif
/* make stats available */
- stxsense(sc->sc_dq.dq_ctlr, sc->sc_dq.dq_slave, sc->sc_punit, sc);
+ stxsense(sc->sc_dev.dv_parent->dv_unit, sc->sc_target, sc->sc_lun, sc);
sc->sc_flags &= ~(STF_OPEN|STF_WMODE|STF_WRTTN);
tprintf_close(sc->sc_ctty);
@@ -742,11 +681,14 @@ void
ststrategy(bp)
register struct buf *bp;
{
+ struct st_softc *sc;
struct buf *dp;
int unit, s;
unit = UNIT(bp->b_dev);
- dp = &sttab[unit];
+ sc = st_cd.cd_devs[unit];
+
+ dp = &sc->sc_tab;
bp->b_actf = NULL;
s = splbio();
bp->b_actb = dp->b_actb;
@@ -759,34 +701,38 @@ ststrategy(bp)
splx(s);
}
+void
stustart(unit)
int unit;
{
- if (scsireq(&st_softc[unit].sc_dq))
- ststart(unit);
+ struct st_softc *sc = st_cd.cd_devs[unit];
+
+ if (scsireq(sc->sc_dev.dv_parent, &sc->sc_sq))
+ ststart(sc);
}
-ststart(unit)
- int unit;
+void
+ststart(arg)
+ void *arg;
{
- struct hp_device *hp = st_softc[unit].sc_hd;
+ struct st_softc *sc = arg;
- if (scsiustart(hp->hp_ctlr))
- stgo(unit);
+ if (scsiustart(sc->sc_dev.dv_parent->dv_unit))
+ stgo(arg);
}
-stgo(unit)
- int unit;
+void
+stgo(arg)
+ void *arg;
{
- register struct st_softc *sc = &st_softc[unit];
+ struct st_softc *sc = arg;
register struct scsi_fmt_cdb *cmd;
- register struct buf *bp = sttab[unit].b_actf;
- struct hp_device *hp = sc->sc_hd;
+ register struct buf *bp = sc->sc_tab.b_actf;
int pad, stat;
long nblks;
if (sc->sc_flags & STF_CMD) {
- cmd = &stcmd[unit];
+ cmd = &sc->sc_cmdstore;
pad = 0;
} else {
cmd = bp->b_flags & B_READ ? &st_read_cmd : &st_write_cmd;
@@ -804,7 +750,7 @@ stgo(unit)
if (bp->b_bcount % sc->sc_blklen) {
tprintf(sc->sc_ctty,
"%s: I/O not block aligned %d/%ld\n",
- sc->sc_hd->hp_xname, sc->sc_blklen,
+ sc->sc_dev.dv_xname, sc->sc_blklen,
bp->b_bcount);
cmd->cdb[1] &= 0xfe; /* force error */
}
@@ -835,47 +781,46 @@ stgo(unit)
#ifdef DEBUG
if (st_debug & ST_ODDIO)
printf("%s: stgo: odd count %d using manual transfer\n",
- sc->sc_hd->hp_xname, bp->b_bcount);
+ sc->sc_dev.dv_xname, bp->b_bcount);
#endif
- stat = scsi_tt_oddio(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
- bp->b_un.b_addr, bp->b_bcount,
- bp->b_flags, 1);
+ stat = scsi_tt_oddio(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, bp->b_un.b_addr, bp->b_bcount,
+ bp->b_flags, 1);
if (stat == 0) {
bp->b_resid = 0;
- stfinish(unit, sc, bp);
+ stfinish(sc, bp);
}
} else
- stat = scsigo(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
- bp, cmd, pad);
+ stat = scsigo(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, bp, cmd, pad);
if (stat) {
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
- stxsense(sc->sc_dq.dq_ctlr, sc->sc_dq.dq_slave,
- sc->sc_punit, sc);
- sterror(unit, sc, stat);
- stfinish(unit, sc, bp);
+ stxsense(sc->sc_dev.dv_parent->dv_unit, sc->sc_target,
+ sc->sc_lun, sc);
+ sterror(sc, stat);
+ stfinish(sc, bp);
}
}
-stfinish(unit, sc, bp)
- int unit;
+stfinish(sc, bp)
struct st_softc *sc;
struct buf *bp;
{
register struct buf *dp;
- sttab[unit].b_errcnt = 0;
+ sc->sc_tab.b_errcnt = 0;
if (dp = bp->b_actf)
dp->b_actb = bp->b_actb;
else
- sttab[unit].b_actb = bp->b_actb;
+ sc->sc_tab.b_actb = bp->b_actb;
*bp->b_actb = dp;
iodone(bp);
- scsifree(&sc->sc_dq);
- if (sttab[unit].b_actf)
- stustart(unit);
+ scsifree(sc->sc_dev.dv_parent, &sc->sc_sq);
+ if (sc->sc_tab.b_actf)
+ stustart(sc->sc_dev.dv_unit);
else
- sttab[unit].b_active = 0;
+ sc->sc_tab.b_active = 0;
}
int
@@ -914,10 +859,10 @@ stioctl(dev, cmd, data, flag, p)
int flag;
struct proc *p;
{
- register struct st_softc *sc = &st_softc[UNIT(dev)];
+ struct st_softc *sc = st_cd.cd_devs[UNIT(dev)];
register int cnt;
register struct mtget *mtget;
- register struct st_xsense *xp = &st_xsense[UNIT(dev)];
+ register struct st_xsense *xp = &sc->sc_sense;
register struct mtop *op;
long resid;
@@ -956,8 +901,8 @@ stioctl(dev, cmd, data, flag, p)
/* drive status */
case MTIOCGET:
mtget = (struct mtget *)data;
- stxsense(sc->sc_dq.dq_ctlr, sc->sc_dq.dq_slave,
- sc->sc_punit, sc);
+ stxsense(sc->sc_dev.dv_parent->dv_unit, sc->sc_target,
+ sc->sc_lun, sc);
mtget->mt_type = sc->sc_tapeid;
mtget->mt_dsreg = 0;
mtget->mt_erreg = ((xp->sc_xsense.valid << 15) |
@@ -994,19 +939,19 @@ stioctl(dev, cmd, data, flag, p)
return(0);
}
+void
stintr(arg, stat)
void *arg;
int stat;
{
register struct st_softc *sc = arg;
- int unit = sc->sc_hd->hp_unit;
- register struct st_xsense *xp = &st_xsense[unit];
- register struct buf *bp = sttab[unit].b_actf;
- struct hp_device *hp = sc->sc_hd;
+ int unit = sc->sc_dev.dv_unit;
+ register struct st_xsense *xp = &sc->sc_sense;
+ register struct buf *bp = sc->sc_tab.b_actf;
#ifdef DEBUG
if (bp == NULL) {
- printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
+ printf("%s: bp == NULL\n", sc->sc_dev.dv_xname);
return;
}
#endif
@@ -1018,8 +963,8 @@ stintr(arg, stat)
/* more status */
case STS_CHECKCOND:
- stxsense(sc->sc_dq.dq_ctlr, sc->sc_dq.dq_slave,
- sc->sc_punit, sc);
+ stxsense(sc->sc_dev.dv_parent->dv_unit, sc->sc_target,
+ sc->sc_lun, sc);
if (xp->sc_xsense.valid) {
bp->b_resid = (u_long)((xp->sc_xsense.info1 << 24) |
(xp->sc_xsense.info2 << 16) |
@@ -1036,7 +981,7 @@ stintr(arg, stat)
&& xp->sc_xsense.key != XSK_NOTUSED1
&& xp->sc_xsense.key != XSK_NOTUSEDC
&& xp->sc_xsense.key != XSK_NOTUSEDE) {
- sterror(unit, sc, stat);
+ sterror(sc, stat);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
@@ -1048,7 +993,7 @@ stintr(arg, stat)
if (sc->sc_blklen) {
tprintf(sc->sc_ctty,
"%s: Incorrect Length Indicator, blkcnt diff %d\n",
- sc->sc_hd->hp_xname,
+ sc->sc_dev.dv_xname,
sc->sc_blklen - bp->b_resid);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
@@ -1075,7 +1020,7 @@ stintr(arg, stat)
if (!st_dmaoddretry) {
tprintf(sc->sc_ctty,
"%s: Odd length read %d\n",
- sc->sc_hd->hp_xname,
+ sc->sc_dev.dv_xname,
bp->b_bcount - bp->b_resid);
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
@@ -1087,24 +1032,25 @@ stintr(arg, stat)
#ifdef DEBUG
if (st_debug & ST_ODDIO)
printf("%s: stintr odd count %d, do BSR then oddio\n",
- sc->sc_hd->hp_xname,
+ sc->sc_dev.dv_xname,
bp->b_bcount - bp->b_resid);
#endif
- stat = scsi_tt_oddio(hp->hp_ctlr, hp->hp_slave,
- sc->sc_punit, 0, -1, 0, 0);
+ stat =
+ scsi_tt_oddio(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, 0, -1, 0, 0);
if (stat == 0)
- stat = scsi_tt_oddio(hp->hp_ctlr,
- hp->hp_slave,
- sc->sc_punit,
- bp->b_un.b_addr,
- bp->b_bcount - bp->b_resid,
- bp->b_flags, 0);
+ stat = scsi_tt_oddio(
+ sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun,
+ bp->b_un.b_addr,
+ bp->b_bcount - bp->b_resid,
+ bp->b_flags, 0);
if (stat) {
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
- stxsense(sc->sc_dq.dq_ctlr, sc->sc_dq.dq_slave,
- sc->sc_punit, sc);
- sterror(unit, sc, stat);
+ stxsense(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, sc);
+ sterror(sc, stat);
}
}
break;
@@ -1115,13 +1061,13 @@ stintr(arg, stat)
break;
}
tprintf(sc->sc_ctty, "%s: unknown scsi error\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
default:
- printf("%s: stintr unknown stat 0x%x\n", sc->sc_hd->hp_xname,
+ printf("%s: stintr unknown stat 0x%x\n", sc->sc_dev.dv_xname,
stat);
break;
}
@@ -1147,8 +1093,8 @@ stintr(arg, stat)
* Mostly for TTi we, get a stxsense call in open and close.
*/
if (sc->sc_tticntdwn-- == 0) {
- stxsense(sc->sc_dq.dq_ctlr, sc->sc_dq.dq_slave,
- sc->sc_punit, sc);
+ stxsense(sc->sc_dev.dv_parent->dv_unit,
+ sc->sc_target, sc->sc_lun, sc);
sc->sc_tticntdwn = 100;
}
#endif
@@ -1161,14 +1107,14 @@ stcommand(dev, command, cnt)
u_int command;
int cnt;
{
- register struct st_softc *sc = &st_softc[UNIT(dev)];
- register struct buf *bp = &stbuf[UNIT(dev)];
- register struct scsi_fmt_cdb *cmd = &stcmd[UNIT(dev)];
+ struct st_softc *sc = st_cd.cd_devs[UNIT(dev)];
+ register struct buf *bp = &sc->sc_bufstore;
+ register struct scsi_fmt_cdb *cmd = &sc->sc_cmdstore;
register cmdcnt;
int s;
cmd->len = 6; /* all tape commands are cdb6 */
- cmd->cdb[1] = sc->sc_punit;
+ cmd->cdb[1] = sc->sc_lun;
cmd->cdb[2] = cmd->cdb[3] = cmd->cdb[4] = cmd->cdb[5] = 0;
cmdcnt = 0;
@@ -1235,7 +1181,7 @@ stcommand(dev, command, cnt)
break;
default:
printf("%s: stcommand bad command 0x%x\n",
- sc->sc_hd->hp_xname, command);
+ sc->sc_dev.dv_xname, command);
}
sc->sc_flags |= STF_CMD;
@@ -1246,7 +1192,7 @@ again:
#ifdef DEBUG
if (st_debug & ST_FMKS)
printf("%s: stcommand filepos %d cmdcnt %d cnt %d\n",
- sc->sc_hd->hp_xname, sc->sc_filepos, cmdcnt, cnt);
+ sc->sc_dev.dv_xname, sc->sc_filepos, cmdcnt, cnt);
#endif
s = splbio();
while (bp->b_flags & B_BUSY) {
@@ -1278,16 +1224,16 @@ again:
sc->sc_flags &= ~(STF_CMD|STF_WRTTN);
}
-sterror(unit, sc, stat)
- int unit, stat;
+sterror(sc, stat)
struct st_softc *sc;
+ int stat;
{
/* stxsense must have been called before sterror() */
if (stat & STS_CHECKCOND)
- prtkey(unit, sc);
+ prtkey(sc);
else if (stat)
tprintf(sc->sc_ctty,
- "%s: bad scsi status 0x%x\n", sc->sc_hd->hp_xname,
+ "%s: bad scsi status 0x%x\n", sc->sc_dev.dv_xname,
stat);
if ((sc->sc_flags & STF_CMD) && sc->sc_cmd == CMD_SPACE) /* fsf */
@@ -1301,16 +1247,15 @@ stxsense(ctlr, slave, unit, sc)
u_char *sensebuf;
unsigned len;
- sensebuf = (u_char *)&st_xsense[sc->sc_dq.dq_unit];
+ sensebuf = (u_char *)&sc->sc_sense;
len = sc->sc_datalen[CMD_REQUEST_SENSE];
scsi_request_sense(ctlr, slave, unit, sensebuf, len);
}
-prtkey(unit, sc)
- int unit;
+prtkey(sc)
struct st_softc *sc;
{
- register struct st_xsense *xp = &st_xsense[unit];
+ register struct st_xsense *xp = &sc->sc_sense;
switch (xp->sc_xsense.key) {
case XSK_NOSENCE:
@@ -1321,35 +1266,35 @@ prtkey(unit, sc)
break;
case XSK_REVERVED:
tprintf(sc->sc_ctty, "%s: Reserved sense key 0x%x\n",
- sc->sc_hd->hp_xname, xp->sc_xsense.key);
+ sc->sc_dev.dv_xname, xp->sc_xsense.key);
break;
case XSK_NOTRDY:
- tprintf(sc->sc_ctty, "%s: NOT READY\n", sc->sc_hd->hp_xname);
+ tprintf(sc->sc_ctty, "%s: NOT READY\n", sc->sc_dev.dv_xname);
break;
case XSK_MEDERR:
- tprintf(sc->sc_ctty, "%s: MEDIUM ERROR\n", sc->sc_hd->hp_xname);
+ tprintf(sc->sc_ctty, "%s: MEDIUM ERROR\n", sc->sc_dev.dv_xname);
break;
case XSK_HRDWERR:
tprintf(sc->sc_ctty, "%s: HARDWARE ERROR\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
break;
case XSK_ILLREQ:
tprintf(sc->sc_ctty, "%s: ILLEGAL REQUEST\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
break;
case XSK_UNTATTEN:
tprintf(sc->sc_ctty, "%s: UNIT ATTENTION\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
break;
case XSK_DATAPROT:
- tprintf(sc->sc_ctty, "%s: DATA PROTECT\n", sc->sc_hd->hp_xname);
+ tprintf(sc->sc_ctty, "%s: DATA PROTECT\n", sc->sc_dev.dv_xname);
break;
case XSK_BLNKCHK:
- tprintf(sc->sc_ctty, "%s: BLANK CHECK\n", sc->sc_hd->hp_xname);
+ tprintf(sc->sc_ctty, "%s: BLANK CHECK\n", sc->sc_dev.dv_xname);
break;
case XSK_VENDOR:
tprintf(sc->sc_ctty, "%s: VENDER UNIQUE SENSE KEY ",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
switch (sc->sc_tapeid) {
case MT_ISEXABYTE:
tprintf(sc->sc_ctty, "Exabyte: ");
@@ -1365,58 +1310,58 @@ prtkey(unit, sc)
}
break;
case XSK_CPYABORT:
- tprintf(sc->sc_ctty, "%s: COPY ABORTED\n", sc->sc_hd->hp_xname);
+ tprintf(sc->sc_ctty, "%s: COPY ABORTED\n", sc->sc_dev.dv_xname);
break;
case XSK_ABORTCMD:
tprintf(sc->sc_ctty, "%s: ABORTED COMMAND\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
break;
case XSK_VOLOVER:
tprintf(sc->sc_ctty, "%s: VOLUME OVERFLOW\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
break;
default:
tprintf(sc->sc_ctty, "%s: unknown sense key 0x%x\n",
- sc->sc_hd->hp_xname, xp->sc_xsense.key);
+ sc->sc_dev.dv_xname, xp->sc_xsense.key);
}
if (sc->sc_tapeid == MT_ISEXABYTE) {
if (xp->exb_xsense.bpe)
tprintf(sc->sc_ctty, "%s: Bus Parity Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.fpe)
tprintf(sc->sc_ctty,
"%s: Formatted Buffer Parity Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.eco)
tprintf(sc->sc_ctty, "%s: Error Counter Overflow",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.tme)
tprintf(sc->sc_ctty, "%s: Tape Motion Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.xfr)
tprintf(sc->sc_ctty, "%s: Transfer About Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.tmd)
tprintf(sc->sc_ctty, "%s: Tape Mark Detect Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.fmke)
tprintf(sc->sc_ctty, "%s: Filemark Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.ure)
tprintf(sc->sc_ctty, "%s: Under Run Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.sse)
tprintf(sc->sc_ctty, "%s: Servo System Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.fe)
tprintf(sc->sc_ctty, "%s: Formatter Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.wseb)
tprintf(sc->sc_ctty, "%s: WSEB Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
if (xp->exb_xsense.wseo)
tprintf(sc->sc_ctty, "%s: WSEO Error",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
}
}
@@ -1495,5 +1440,3 @@ prtmodstat(mode)
mode->ex.motionthres, mode->ex.reconthres, mode->ex.gapthres);
}
#endif /* DEBUG */
-
-#endif