summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/hp300/dev')
-rw-r--r--sys/arch/hp300/dev/ac.c68
-rw-r--r--sys/arch/hp300/dev/ct.c72
-rw-r--r--sys/arch/hp300/dev/dca.c389
-rw-r--r--sys/arch/hp300/dev/dcm.c631
-rw-r--r--sys/arch/hp300/dev/device.h29
-rw-r--r--sys/arch/hp300/dev/dma.c206
-rw-r--r--sys/arch/hp300/dev/dmareg.h35
-rw-r--r--sys/arch/hp300/dev/fhpib.c92
-rw-r--r--sys/arch/hp300/dev/grf.c6
-rw-r--r--sys/arch/hp300/dev/grf_machdep.c27
-rw-r--r--sys/arch/hp300/dev/hil.c91
-rw-r--r--sys/arch/hp300/dev/hil_keymaps.c86
-rw-r--r--sys/arch/hp300/dev/hilvar.h4
-rw-r--r--sys/arch/hp300/dev/hpib.c165
-rw-r--r--sys/arch/hp300/dev/hpibvar.h25
-rw-r--r--sys/arch/hp300/dev/if_le.c1010
-rw-r--r--sys/arch/hp300/dev/if_lereg.h116
-rw-r--r--sys/arch/hp300/dev/if_levar.h85
-rw-r--r--sys/arch/hp300/dev/ite.c2
-rw-r--r--sys/arch/hp300/dev/itevar.h2
-rw-r--r--sys/arch/hp300/dev/kbdmap.h3
-rw-r--r--sys/arch/hp300/dev/mt.c67
-rw-r--r--sys/arch/hp300/dev/nhpib.c96
-rw-r--r--sys/arch/hp300/dev/ppi.c28
-rw-r--r--sys/arch/hp300/dev/rd.c165
-rw-r--r--sys/arch/hp300/dev/rd_compat.c56
-rw-r--r--sys/arch/hp300/dev/rdvar.h11
-rw-r--r--sys/arch/hp300/dev/scsi.c123
-rw-r--r--sys/arch/hp300/dev/scsivar.h3
-rw-r--r--sys/arch/hp300/dev/sd.c136
-rw-r--r--sys/arch/hp300/dev/sdvar.h2
-rw-r--r--sys/arch/hp300/dev/st.c164
32 files changed, 1926 insertions, 2069 deletions
diff --git a/sys/arch/hp300/dev/ac.c b/sys/arch/hp300/dev/ac.c
index ed0d149d57d..89e9241d213 100644
--- a/sys/arch/hp300/dev/ac.c
+++ b/sys/arch/hp300/dev/ac.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ac.c,v 1.2 1994/10/26 07:23:23 cgd Exp $ */
+/* $NetBSD: ac.c,v 1.3 1995/12/02 18:21:49 thorpej Exp $ */
/*
* Copyright (c) 1991 University of Utah.
@@ -73,13 +73,15 @@ extern int scsigo();
extern void scsifree();
extern void scsireset();
extern void scsi_delay();
+extern void scsi_str __P((char *, char *, size_t));
extern int scsi_immed_command();
-int acinit(), acstart(), acgo(), acintr();
+int acmatch(), acstart(), acgo(), acintr();
+void acattach();
struct driver acdriver = {
- acinit, "ac", acstart, acgo, acintr,
+ acmatch, acattach, "ac", acstart, acgo, acintr,
};
struct ac_softc ac_softc[NAC];
@@ -92,7 +94,8 @@ int ac_debug = 0x0000;
#define ACD_OPEN 0x0002
#endif
-acinit(hd)
+int
+acmatch(hd)
register struct hp_device *hd;
{
int unit = hd->hp_unit;
@@ -100,8 +103,21 @@ acinit(hd)
sc->sc_hd = hd;
sc->sc_punit = hd->hp_flags & 7;
- if (acident(sc, hd) < 0)
- return(0);
+ if (acident(sc, hd, 0) < 0)
+ 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_unit = unit;
sc->sc_dq.dq_ctlr = hd->hp_ctlr;
sc->sc_dq.dq_slave = hd->hp_slave;
@@ -109,19 +125,19 @@ acinit(hd)
sc->sc_bp = &acbuf[unit];
sc->sc_cmd = &accmd[unit];
sc->sc_flags = ACF_ALIVE;
- return(1);
}
-acident(sc, hd)
+acident(sc, hd, verbose)
register struct ac_softc *sc;
register struct hp_device *hd;
+ int verbose;
{
int unit;
register int ctlr, slave;
int i, stat;
int tries = 5;
- char idstr[32];
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
@@ -162,21 +178,18 @@ acident(sc, hd)
if (inqbuf.type != 8 || inqbuf.qual != 0x80 || inqbuf.version != 2)
goto failed;
- bcopy((caddr_t)&inqbuf.vendor_id, (caddr_t)idstr, 28);
- for (i = 27; i > 23; --i)
- if (idstr[i] != ' ')
- break;
- idstr[i+1] = 0;
- for (i = 23; i > 7; --i)
- if (idstr[i] != ' ')
- break;
- idstr[i+1] = 0;
- for (i = 7; i >= 0; --i)
- if (idstr[i] != ' ')
- break;
- idstr[i+1] = 0;
- printf("ac%d: %s %s rev %s\n", hd->hp_unit,
- &idstr[0], &idstr[8], &idstr[24]);
+ /*
+ * 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);
@@ -429,13 +442,14 @@ acintr(unit, stat)
scsi_request_sense(sc->sc_hd->hp_ctlr, sc->sc_hd->hp_slave,
sc->sc_punit, sensebuf, sizeof sensebuf);
sp = (struct scsi_xsense *)sensebuf;
- printf("ac%d: acintr sense key=%x, ac=%x, acq=%x\n",
- unit, sp->key, sp->info4, sp->len);
+ printf("%s: acintr sense key=%x, ac=%x, acq=%x\n",
+ sc->sc_hd->hp_xname, sp->key, sp->info4, sp->len);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
default:
- printf("ac%d: acintr unknown status 0x%x\n", unit, stat);
+ printf("%s: acintr unknown status 0x%x\n", sc->sc_hd->hp_xname,
+ stat);
break;
}
(void) biodone(sc->sc_bp);
diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c
index dfab8c0f353..e3ad6174909 100644
--- a/sys/arch/hp300/dev/ct.c
+++ b/sys/arch/hp300/dev/ct.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ct.c,v 1.12 1995/10/09 07:57:43 thorpej Exp $ */
+/* $NetBSD: ct.c,v 1.13 1995/12/02 18:21:52 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -64,10 +64,10 @@
/* number of eof marks to remember */
#define EOFS 128
-int ctinit(), ctstart(), ctgo(), ctintr();
-void ctstrategy(), ctdone();
+int ctmatch(), ctstart(), ctgo(), ctintr();
+void ctattach(), ctstrategy(), ctdone();
struct driver ctdriver = {
- ctinit, "ct", ctstart, ctgo, ctintr,
+ ctmatch, ctattach, "ct", ctstart, ctgo, ctintr,
};
struct ct_softc {
@@ -135,7 +135,8 @@ int ctdebug = 0;
#define CT_BSF 0x02
#endif
-ctinit(hd)
+int
+ctmatch(hd)
register struct hp_device *hd;
{
register struct ct_softc *sc = &ct_softc[hd->hp_unit];
@@ -145,20 +146,33 @@ ctinit(hd)
bp->b_actb = &bp->b_actf;
sc->sc_hd = hd;
sc->sc_punit = ctpunit(hd->hp_flags);
- if (ctident(sc, hd) < 0)
- return(0);
+ if (ctident(sc, hd, 0) < 0)
+ return (0);
+
+ return (1);
+}
+
+void
+ctattach(hd)
+ register struct hp_device *hd;
+{
+ struct ct_softc *sc = &ct_softc[hd->hp_unit];
+
+ (void)ctident(sc, hd, 1); /* XXX Ick. */
+
ctreset(sc, hd);
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;
- return(1);
}
-ctident(sc, hd)
+int
+ctident(sc, hd, verbose)
register struct ct_softc *sc;
register struct hp_device *hd;
+ int verbose;
{
struct ct_describe desc;
u_char stat, cmd[3];
@@ -216,8 +230,9 @@ ctident(sc, hd)
sc->sc_type = CT88140;
break;
}
- printf("ct%d: %s %stape\n", hd->hp_unit, ctinfo[id].desc,
- (sc->sc_flags & CTF_CANSTREAM) ? "streaming " : " ");
+ if (verbose)
+ printf(": %s %stape\n", ctinfo[id].desc,
+ (sc->sc_flags & CTF_CANSTREAM) ? "streaming " : " ");
return(id);
}
@@ -318,8 +333,9 @@ ctclose(dev, flag)
sc->sc_eofp--;
#ifdef DEBUG
if(ctdebug & CT_BSF)
- printf("ct%d: ctclose backup eofs prt %d blk %d\n",
- UNIT(dev), sc->sc_eofp, sc->sc_eofs[sc->sc_eofp]);
+ printf("%s: ctclose backup eofs prt %d blk %d\n",
+ sc->sc_hd->hp_xname, sc->sc_eofp,
+ sc->sc_eofs[sc->sc_eofp]);
#endif
}
if ((minor(dev) & CT_NOREW) == 0)
@@ -371,8 +387,8 @@ again:
sc->sc_eofp--;
#ifdef DEBUG
if (ctdebug & CT_BSF)
- printf("ct%d: backup eof pos %d blk %d\n",
- UNIT(dev), sc->sc_eofp,
+ printf("%s: backup eof pos %d blk %d\n",
+ sc->sc_hd->hp_xname, sc->sc_eofp,
sc->sc_eofs[sc->sc_eofp]);
#endif
}
@@ -469,7 +485,8 @@ again:
sc->sc_blkno = 0;
#ifdef DEBUG
if(ctdebug & CT_BSF)
- printf("ct%d: clearing eofs\n", unit);
+ printf("%s: clearing eofs\n",
+ sc->sc_hd->hp_xname);
#endif
for (i=0; i<EOFS; i++)
sc->sc_eofs[i] = 0;
@@ -628,7 +645,7 @@ ctintr(unit)
bp = cttab[unit].b_actf;
if (bp == NULL) {
- printf("ct%d: bp == NULL\n", unit);
+ printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
return;
}
if (sc->sc_flags & CTF_IO) {
@@ -683,17 +700,19 @@ ctintr(unit)
if (sc->sc_stat.c_aef & 0x5800) {
if (sc->sc_stat.c_aef & 0x4000)
tprintf(sc->sc_tpr,
- "ct%d: uninitialized media\n",
- unit);
+ "%s: uninitialized media\n",
+ sc->sc_hd->hp_xname);
if (sc->sc_stat.c_aef & 0x1000)
tprintf(sc->sc_tpr,
- "ct%d: not ready\n", unit);
+ "%s: not ready\n",
+ sc->sc_hd->hp_xname);
if (sc->sc_stat.c_aef & 0x0800)
tprintf(sc->sc_tpr,
- "ct%d: write protect\n", unit);
+ "%s: write protect\n",
+ sc->sc_hd->hp_xname);
} else {
- printf("ct%d err: v%d u%d ru%d bn%d, ",
- unit,
+ printf("%s err: v%d u%d ru%d bn%d, ",
+ sc->sc_hd->hp_xname,
(sc->sc_stat.c_vu>>4)&0xF,
sc->sc_stat.c_vu&0xF,
sc->sc_stat.c_pend,
@@ -705,7 +724,8 @@ ctintr(unit)
sc->sc_stat.c_ief);
}
} else
- printf("ct%d: request status failed\n", unit);
+ printf("%s: request status failed\n",
+ sc->sc_hd->hp_xname);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
goto done;
@@ -867,8 +887,8 @@ ctaddeof(unit)
}
#ifdef DEBUG
if (ctdebug & CT_BSF)
- printf("ct%d: add eof pos %d blk %d\n",
- unit, sc->sc_eofp,
+ printf("%s: add eof pos %d blk %d\n",
+ sc->sc_hd->hp_xname, sc->sc_eofp,
sc->sc_eofs[sc->sc_eofp]);
#endif
}
diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c
index b82e145e1f9..af741cf74ac 100644
--- a/sys/arch/hp300/dev/dca.c
+++ b/sys/arch/hp300/dev/dca.c
@@ -1,6 +1,7 @@
-/* $NetBSD: dca.c,v 1.17 1995/10/04 17:46:08 thorpej Exp $ */
+/* $NetBSD: dca.c,v 1.18 1995/12/02 18:15:50 thorpej Exp $ */
/*
+ * Copyright (c) 1995 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -37,11 +38,10 @@
#include "dca.h"
#if NDCA > 0
+
/*
- * Driver for National Semiconductor INS8250/NS16550AF/WD16C552 UARTs.
- * Includes:
- * 98626/98644/internal serial interface on hp300/hp400
- * internal serial ports on hp700
+ * Driver for the 98626/98644/internal serial interface on hp300/hp400,
+ * based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs.
*
* N.B. On the hp700 and some hp300s, there is a "secret bit" with
* undocumented behavior. The third bit of the Modem Control Register
@@ -50,6 +50,7 @@
* be any harmful side-effects from setting this bit on non-affected
* machines.
*/
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
@@ -65,23 +66,33 @@
#include <hp300/dev/dcareg.h>
#include <machine/cpu.h>
-#ifdef hp300
#include <hp300/hp300/isr.h>
-#endif
-#ifdef hp700
-#include <machine/asp.h>
-#endif
-int dcaprobe();
+int dcamatch();
+void dcaattach();
struct driver dcadriver = {
- dcaprobe, "dca",
+ dcamatch, dcaattach, "dca",
};
+struct dca_softc {
+ struct hp_device *sc_hd; /* device info */
+ struct dcadevice *sc_dca; /* pointer to hardware */
+ struct tty *sc_tty; /* our tty instance */
+ struct isr sc_isr; /* interrupt handler */
+ int sc_oflows; /* overflow counter */
+ short sc_flags; /* state flags */
+
+ /*
+ * Bits for sc_flags.
+ */
+#define DCA_ACTIVE 0x0001 /* indicates live unit */
+#define DCA_SOFTCAR 0x0002 /* indicates soft-carrier */
+#define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */
+
+} dca_softc[NDCA];
+
void dcastart();
int dcaparam(), dcaintr();
-int dcasoftCAR;
-int dca_active;
-int dca_hasfifo;
int ndca = NDCA;
#ifdef DCACONSOLE
int dcaconsole = DCACONSOLE;
@@ -91,13 +102,7 @@ int dcaconsole = -1;
int dcaconsinit;
int dcadefaultrate = TTYDEF_SPEED;
int dcamajor;
-struct dcadevice *dca_addr[NDCA];
-struct tty *dca_tty[NDCA];
-#ifdef hp300
-struct isr dcaisr[NDCA];
int dcafastservice;
-#endif
-int dcaoflows[NDCA];
struct speedtab dcaspeedtab[] = {
0, 0,
@@ -127,7 +132,7 @@ extern int kgdb_rate;
extern int kgdb_debug_init;
#endif
-#define UNIT(x) minor(x)
+#define DCAUNIT(x) minor(x)
#ifdef DEBUG
long fifoin[17];
@@ -136,87 +141,96 @@ long dcaintrcount[16];
long dcamintcount[16];
#endif
-dcaprobe(hd)
+int
+dcamatch(hd)
register struct hp_device *hd;
{
- register struct dcadevice *dca;
- register int unit;
+ struct dcadevice *dca = (struct dcadevice *)hd->hp_addr;
+ struct dca_softc *sc = &dca_softc[hd->hp_unit];
- dca = (struct dcadevice *)hd->hp_addr;
-#ifdef hp300
if (dca->dca_id != DCAID0 &&
dca->dca_id != DCAREMID0 &&
dca->dca_id != DCAID1 &&
dca->dca_id != DCAREMID1)
return (0);
-#endif
- unit = hd->hp_unit;
+
+ hd->hp_ipl = DCAIPL(dca->dca_ic);
+ sc->sc_hd = hd;
+
+ return (1);
+}
+
+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];
if (unit == dcaconsole)
DELAY(100000);
-#ifdef hp300
dca->dca_reset = 0xFF;
DELAY(100);
-#endif
/* look for a NS 16550AF UART with FIFOs */
dca->dca_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14;
DELAY(100);
if ((dca->dca_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK)
- dca_hasfifo |= 1 << unit;
+ sc->sc_flags |= DCA_HASFIFO;
- dca_addr[unit] = dca;
-#ifdef hp300
- hd->hp_ipl = DCAIPL(dca->dca_ic);
- dcaisr[unit].isr_ipl = hd->hp_ipl;
- dcaisr[unit].isr_arg = unit;
- dcaisr[unit].isr_intr = dcaintr;
- isrlink(&dcaisr[unit]);
-#endif
- dca_active |= 1 << unit;
+ sc->sc_dca = dca;
+
+ /* Establish interrupt handler. */
+ sc->sc_isr.isr_ipl = hd->hp_ipl;
+ sc->sc_isr.isr_arg = unit;
+ sc->sc_isr.isr_intr = dcaintr;
+ isrlink(&sc->sc_isr);
+
+ sc->sc_flags |= DCA_ACTIVE;
if (hd->hp_flags)
- dcasoftCAR |= (1 << unit);
+ sc->sc_flags |= DCA_SOFTCAR;
+
+ /* Enable interrupts. */
+ dca->dca_ic = IC_IE;
+
+ /*
+ * Need to reset baud rate, etc. of next print so reset dcaconsinit.
+ * Also make sure console is always "hardwired."
+ */
+ if (unit == dcaconsole) {
+ dcaconsinit = 0;
+ sc->sc_flags |= DCA_SOFTCAR;
+ printf(": console, ");
+ } else
+ printf(": ");
+
+ if (sc->sc_flags & DCA_HASFIFO)
+ printf("working fifo\n");
+ else
+ printf("no fifo\n");
+
#ifdef KGDB
if (kgdb_dev == makedev(dcamajor, unit)) {
if (dcaconsole == unit)
kgdb_dev = NODEV; /* can't debug over console port */
else {
- (void) dcainit(unit, kgdb_rate);
+ (void) dcainit(sc, kgdb_rate);
dcaconsinit = 1; /* don't re-init in dcaputc */
if (kgdb_debug_init) {
/*
* Print prefix of device name,
* let kgdb_connect print the rest.
*/
- printf("dca%d: ", unit);
+ printf("%s: ", sc->sc_hd->hp_xname);
kgdb_connect(1);
} else
- printf("dca%d: kgdb enabled\n", unit);
+ printf("%s: kgdb enabled\n",
+ sc->sc_hd->hp_xname);
}
}
#endif
-#ifdef hp300
- dca->dca_ic = IC_IE;
-#endif
-
- /*
- * Need to reset baud rate, etc. of next print so reset dcaconsinit.
- * Also make sure console is always "hardwired."
- */
- if (unit == dcaconsole) {
- dcaconsinit = 0;
- dcasoftCAR |= (1 << unit);
- printf("dca%d: console, ", unit);
- } else
- printf("dca%d: ", unit);
-
- if (dca_hasfifo & (1 << unit))
- printf("working fifo\n");
- else
- printf("no fifo\n");
-
- return (1);
}
/* ARGSUSED */
@@ -226,32 +240,37 @@ dcaopen(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
- register struct tty *tp;
- register int unit;
+ int unit = DCAUNIT(dev);
+ struct dca_softc *sc;
+ struct tty *tp;
struct dcadevice *dca;
u_char code;
int s, error = 0;
- unit = UNIT(dev);
- if (unit >= NDCA || (dca_active & (1 << unit)) == 0)
+ if (unit >= NDCA)
+ return (ENXIO);
+
+ sc = &dca_softc[unit];
+ if ((sc->sc_flags & DCA_ACTIVE) == 0)
return (ENXIO);
- if (!dca_tty[unit])
- tp = dca_tty[unit] = ttymalloc();
+
+ dca = sc->sc_dca;
+
+ if (sc->sc_tty == NULL)
+ tp = sc->sc_tty = ttymalloc();
else
- tp = dca_tty[unit];
+ tp = sc->sc_tty;
tp->t_oproc = dcastart;
tp->t_param = dcaparam;
tp->t_dev = dev;
- dca = dca_addr[unit];
-
if ((tp->t_state & TS_ISOPEN) == 0) {
/*
* Sanity clause: reset the card on first open.
* The card might be left in an inconsistent state
* if card memory is read inadvertently.
*/
- dcainit(unit, dcadefaultrate);
+ dcainit(sc, dcadefaultrate);
tp->t_state |= TS_WOPEN;
ttychars(tp);
@@ -267,7 +286,7 @@ dcaopen(dev, flag, mode, p)
ttsetwater(tp);
/* Set the FIFO threshold based on the receive speed. */
- if (dca_hasfifo & (1 << unit))
+ if (sc->sc_flags & DCA_HASFIFO)
dca->dca_fifo = FIFO_ENABLE | FIFO_RCV_RST |
FIFO_XMT_RST |
(tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 :
@@ -283,10 +302,10 @@ dcaopen(dev, flag, mode, p)
s = spltty();
/* Set modem control state. */
- (void) dcamctl(dev, MCR_DTR | MCR_RTS, DMSET);
+ (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMSET);
/* Set soft-carrier if so configured. */
- if ((dcasoftCAR & (1 << unit)) || (dcamctl(dev, 0, DMGET) & MSR_DCD))
+ if ((sc->sc_flags & DCA_SOFTCAR) || (dcamctl(sc, 0, DMGET) & MSR_DCD))
tp->t_state |= TS_CARR_ON;
/* Wait for carrier if necessary. */
@@ -305,15 +324,14 @@ dcaopen(dev, flag, mode, p)
if (error == 0)
error = (*linesw[tp->t_line].l_open)(dev, tp);
-#ifdef hp300
/*
* XXX hack to speed up unbuffered builtin port.
* If dca_fastservice is set, a level 5 interrupt
* will be directed to dcaintr first.
*/
- if (error == 0 && unit == 0 && (dca_hasfifo & 1) == 0)
+ if (error == 0 && unit == 0 && (sc->sc_flags & DCA_HASFIFO) == 0)
dcafastservice = 1;
-#endif
+
return (error);
}
@@ -324,18 +342,20 @@ dcaclose(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
+ struct dca_softc *sc;
register struct tty *tp;
register struct dcadevice *dca;
register int unit;
int s;
- unit = UNIT(dev);
-#ifdef hp300
+ unit = DCAUNIT(dev);
+
if (unit == 0)
dcafastservice = 0;
-#endif
- dca = dca_addr[unit];
- tp = dca_tty[unit];
+
+ sc = &dca_softc[unit];
+ dca = sc->sc_dca;
+ tp = sc->sc_tty;
(*linesw[tp->t_line].l_close)(tp, flag);
s = spltty();
@@ -346,16 +366,16 @@ dcaclose(dev, flag, mode, p)
if (dev != kgdb_dev)
#endif
dca->dca_ier = 0;
- if (tp->t_cflag & HUPCL && (dcasoftCAR & (1 << unit)) == 0) {
+ if (tp->t_cflag & HUPCL && (sc->sc_flags & DCA_SOFTCAR) == 0) {
/* XXX perhaps only clear DTR */
- (void) dcamctl(dev, 0, DMSET);
+ (void) dcamctl(sc, 0, DMSET);
}
tp->t_state &= ~(TS_BUSY | TS_FLUSH);
splx(s);
ttyclose(tp);
#if 0
ttyfree(tp);
- dca_tty[unit] = (struct tty *)0;
+ sc->sc_tty = NULL;
#endif
return (0);
}
@@ -366,18 +386,19 @@ dcaread(dev, uio, flag)
struct uio *uio;
int flag;
{
- int unit = UNIT(dev);
- register struct tty *tp = dca_tty[unit];
+ int unit = DCAUNIT(dev);
+ struct dca_softc *sc = &dca_softc[unit];
+ struct tty *tp = sc->sc_tty;
int error, of;
- of = dcaoflows[unit];
+ of = sc->sc_oflows;
error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
/*
* XXX hardly a reasonable thing to do, but reporting overflows
* at interrupt time just exacerbates the problem.
*/
- if (dcaoflows[unit] != of)
- log(LOG_WARNING, "dca%d: silo overflow\n", unit);
+ if (sc->sc_oflows != of)
+ log(LOG_WARNING, "%s: silo overflow\n", sc->sc_hd->hp_xname);
return (error);
}
@@ -387,7 +408,7 @@ dcawrite(dev, uio, flag)
struct uio *uio;
int flag;
{
- register struct tty *tp = dca_tty[UNIT(dev)];
+ struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}
@@ -397,24 +418,26 @@ dcatty(dev)
dev_t dev;
{
- return (dca_tty[UNIT(dev)]);
+ return (dca_softc[DCAUNIT(dev)].sc_tty);
}
int
dcaintr(unit)
register int unit;
{
- register struct dcadevice *dca;
+ struct dca_softc *sc = &dca_softc[unit];
+ register struct dcadevice *dca = sc->sc_dca;
+ register struct tty *tp = sc->sc_tty;
register u_char code;
- register struct tty *tp;
int iflowdone = 0;
- dca = dca_addr[unit];
-#ifdef hp300
+ /*
+ * If interrupts aren't enabled, then the interrupt can't
+ * be for us.
+ */
if ((dca->dca_ic & (IC_IR|IC_IE)) != (IC_IR|IC_IE))
return (0);
-#endif
- tp = dca_tty[unit];
+
for (;;) {
code = dca->dca_iir;
#ifdef DEBUG
@@ -445,7 +468,7 @@ dcaintr(unit)
(*linesw[tp->t_line].l_rint)(code, tp)
#endif
RCVBYTE();
- if (dca_hasfifo & (1 << unit)) {
+ if (sc->sc_flags & DCA_HASFIFO) {
#ifdef DEBUG
register int fifocnt = 1;
#endif
@@ -453,7 +476,7 @@ dcaintr(unit)
if (code == LSR_RXRDY) {
RCVBYTE();
} else
- dcaeint(unit, code, dca);
+ dcaeint(sc, code);
#ifdef DEBUG
fifocnt++;
#endif
@@ -479,35 +502,36 @@ dcaintr(unit)
dcastart(tp);
break;
case IIR_RLS:
- dcaeint(unit, dca->dca_lsr, dca);
+ dcaeint(sc, dca->dca_lsr);
break;
default:
if (code & IIR_NOPEND)
return (1);
- log(LOG_WARNING, "dca%d: weird interrupt: 0x%x\n",
- unit, code);
+ log(LOG_WARNING, "%s: weird interrupt: 0x%x\n",
+ sc->sc_hd->hp_xname, code);
/* fall through */
case IIR_MLSC:
- dcamint(unit, dca);
+ dcamint(sc);
break;
}
}
}
-dcaeint(unit, stat, dca)
- register int unit, stat;
- register struct dcadevice *dca;
+dcaeint(sc, stat)
+ struct dca_softc *sc;
+ int stat;
{
- register struct tty *tp;
- register int c;
+ struct tty *tp = sc->sc_tty;
+ struct dcadevice *dca = sc->sc_dca;
+ int c;
- tp = dca_tty[unit];
c = dca->dca_data;
if ((tp->t_state & TS_ISOPEN) == 0) {
#ifdef KGDB
/* we don't care about parity errors */
if (((stat & (LSR_BI|LSR_FE|LSR_PE)) == LSR_PE) &&
- kgdb_dev == makedev(dcamajor, unit) && c == FRAME_END)
+ kgdb_dev == makedev(dcamajor, sc->sc_hd->hp_unit)
+ && c == FRAME_END)
kgdb_connect(0); /* trap into kgdb */
#endif
return;
@@ -517,24 +541,23 @@ dcaeint(unit, stat, dca)
else if (stat & LSR_PE)
c |= TTY_PE;
else if (stat & LSR_OE)
- dcaoflows[unit]++;
+ sc->sc_oflows++;
(*linesw[tp->t_line].l_rint)(c, tp);
}
-dcamint(unit, dca)
- register int unit;
- register struct dcadevice *dca;
+dcamint(sc)
+ struct dca_softc *sc;
{
- register struct tty *tp;
- register u_char stat;
+ struct tty *tp = sc->sc_tty;
+ struct dcadevice *dca = sc->sc_dca;
+ u_char stat;
- tp = dca_tty[unit];
stat = dca->dca_msr;
#ifdef DEBUG
dcamintcount[stat & 0xf]++;
#endif
if ((stat & MSR_DDCD) &&
- (dcasoftCAR & (1 << unit)) == 0) {
+ (sc->sc_flags & DCA_SOFTCAR) == 0) {
if (stat & MSR_DCD)
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
@@ -563,12 +586,12 @@ dcaioctl(dev, cmd, data, flag, p)
int flag;
struct proc *p;
{
- register struct tty *tp;
- register int unit = UNIT(dev);
- register struct dcadevice *dca;
- register int error;
+ int unit = DCAUNIT(dev);
+ struct dca_softc *sc = &dca_softc[unit];
+ struct tty *tp = sc->sc_tty;
+ struct dcadevice *dca = sc->sc_dca;
+ int error;
- tp = dca_tty[unit];
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error >= 0)
return (error);
@@ -576,8 +599,6 @@ dcaioctl(dev, cmd, data, flag, p)
if (error >= 0)
return (error);
- dca = dca_addr[unit];
-
switch (cmd) {
case TIOCSBRK:
dca->dca_cfcr |= CFCR_SBREAK;
@@ -588,33 +609,33 @@ dcaioctl(dev, cmd, data, flag, p)
break;
case TIOCSDTR:
- (void) dcamctl(dev, MCR_DTR | MCR_RTS, DMBIS);
+ (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMBIS);
break;
case TIOCCDTR:
- (void) dcamctl(dev, MCR_DTR | MCR_RTS, DMBIC);
+ (void) dcamctl(sc, MCR_DTR | MCR_RTS, DMBIC);
break;
case TIOCMSET:
- (void) dcamctl(dev, *(int *)data, DMSET);
+ (void) dcamctl(sc, *(int *)data, DMSET);
break;
case TIOCMBIS:
- (void) dcamctl(dev, *(int *)data, DMBIS);
+ (void) dcamctl(sc, *(int *)data, DMBIS);
break;
case TIOCMBIC:
- (void) dcamctl(dev, *(int *)data, DMBIC);
+ (void) dcamctl(sc, *(int *)data, DMBIC);
break;
case TIOCMGET:
- *(int *)data = dcamctl(dev, 0, DMGET);
+ *(int *)data = dcamctl(sc, 0, DMGET);
break;
case TIOCGFLAGS: {
int bits = 0;
- if (dcasoftCAR & (1 << unit))
+ if (sc->sc_flags & DCA_SOFTCAR)
bits |= TIOCFLAG_SOFTCAR;
if (tp->t_cflag & CLOCAL)
@@ -634,7 +655,7 @@ dcaioctl(dev, cmd, data, flag, p)
userbits = *(int *)data;
if ((userbits & TIOCFLAG_SOFTCAR) || (unit == dcaconsole))
- dcasoftCAR |= (1 << unit);
+ sc->sc_flags |= DCA_SOFTCAR;
if (userbits & TIOCFLAG_CLOCAL)
tp->t_cflag |= CLOCAL;
@@ -653,9 +674,10 @@ dcaparam(tp, t)
register struct tty *tp;
register struct termios *t;
{
- register struct dcadevice *dca;
- register int cfcr, cflag = t->c_cflag;
- int unit = UNIT(tp->t_dev);
+ int unit = DCAUNIT(tp->t_dev);
+ struct dca_softc *sc = &dca_softc[unit];
+ struct dcadevice *dca = sc->sc_dca;
+ int cfcr, cflag = t->c_cflag;
int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab);
int s;
@@ -663,8 +685,6 @@ dcaparam(tp, t)
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
return (EINVAL);
- dca = dca_addr[unit];
-
switch (cflag & CSIZE) {
case CS5:
cfcr = CFCR_5BITS;
@@ -693,14 +713,14 @@ dcaparam(tp, t)
s = spltty();
if (ospeed == 0)
- (void) dcamctl(unit, 0, DMSET); /* hang up line */
+ (void) dcamctl(sc, 0, DMSET); /* hang up line */
/*
* Set the FIFO threshold based on the recieve speed, if we
* are changing it.
*/
if (tp->t_ispeed != t->c_ispeed) {
- if (dca_hasfifo & (1 << unit))
+ if (sc->sc_flags & DCA_HASFIFO)
dca->dca_fifo = FIFO_ENABLE |
(t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 :
FIFO_TRIGGER_14);
@@ -730,12 +750,10 @@ void
dcastart(tp)
register struct tty *tp;
{
- register struct dcadevice *dca;
- int s, unit, c;
+ int s, c, unit = DCAUNIT(tp->t_dev);
+ struct dca_softc *sc = &dca_softc[unit];
+ struct dcadevice *dca = sc->sc_dca;
- unit = UNIT(tp->t_dev);
- dca = dca_addr[unit];
-
s = spltty();
if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
@@ -751,7 +769,7 @@ dcastart(tp)
}
if (dca->dca_lsr & LSR_TXRDY) {
tp->t_state |= TS_BUSY;
- if (dca_hasfifo & (1 << unit)) {
+ if (sc->sc_flags & DCA_HASFIFO) {
for (c = 0; c < 16 && tp->t_outq.c_cc; ++c)
dca->dca_data = getc(&tp->t_outq);
#ifdef DEBUG
@@ -786,21 +804,18 @@ dcastop(tp, flag)
splx(s);
}
-dcamctl(dev, bits, how)
- dev_t dev;
+dcamctl(sc, bits, how)
+ struct dca_softc *sc;
int bits, how;
{
- register struct dcadevice *dca;
- register int unit;
+ struct dcadevice *dca = sc->sc_dca;
int s;
- unit = UNIT(dev);
- dca = dca_addr[unit];
/*
* Always make sure MCR_IEN is set (unless setting to 0)
*/
#ifdef KGDB
- if (how == DMSET && kgdb_dev == makedev(dcamajor, unit))
+ if (how == DMSET && kgdb_dev == makedev(dcamajor, sc->sc_hd->hp_unit))
bits |= MCR_IEN;
else
#endif
@@ -809,8 +824,8 @@ dcamctl(dev, bits, how)
else if (how == DMBIC)
bits &= ~MCR_IEN;
s = spltty();
- switch (how) {
+ switch (how) {
case DMSET:
dca->dca_mcr = bits;
break;
@@ -840,6 +855,7 @@ void
dcacnprobe(cp)
struct consdev *cp;
{
+ struct dca_softc *sc;
int unit;
/* locate the major number */
@@ -849,23 +865,20 @@ dcacnprobe(cp)
/* XXX: ick */
unit = CONUNIT;
-#ifdef hp300
- dca_addr[CONUNIT] = (struct dcadevice *) sctova(CONSCODE);
+ sc = &dca_softc[unit];
+
+ sc->sc_dca = (struct dcadevice *) sctova(CONSCODE);
/* make sure hardware exists */
- if (badaddr((short *)dca_addr[unit])) {
+ if (badaddr((short *)sc->sc_dca)) {
cp->cn_pri = CN_DEAD;
return;
}
-#endif
-#ifdef hp700
- dca_addr[CONUNIT] = CONPORT;
-#endif
/* initialize required fields */
cp->cn_dev = makedev(dcamajor, unit);
-#ifdef hp300
- switch (dca_addr[unit]->dca_id) {
+
+ switch (sc->sc_dca->dca_id) {
case DCAID0:
case DCAID1:
cp->cn_pri = CN_NORMAL;
@@ -878,10 +891,7 @@ dcacnprobe(cp)
cp->cn_pri = CN_DEAD;
break;
}
-#endif
-#ifdef hp700
- cp->cn_pri = CN_NORMAL;
-#endif
+
/*
* If dcaconsole is initialized, raise our priority.
*/
@@ -897,32 +907,31 @@ void
dcacninit(cp)
struct consdev *cp;
{
- int unit = UNIT(cp->cn_dev);
+ int unit = DCAUNIT(cp->cn_dev);
+ struct dca_softc *sc = &dca_softc[unit];
- dcainit(unit, dcadefaultrate);
+ dcainit(sc, dcadefaultrate);
dcaconsole = unit;
dcaconsinit = 1;
}
-dcainit(unit, rate)
- int unit, rate;
+dcainit(sc, rate)
+ struct dca_softc *sc;
+ int rate;
{
- register struct dcadevice *dca;
+ struct dcadevice *dca = sc->sc_dca;
int s;
short stat;
#ifdef lint
- stat = unit; if (stat) return;
+ stat = sc->sc_hd->hp_unit; if (stat) return;
#endif
- dca = dca_addr[unit];
s = splhigh();
-#ifdef hp300
dca->dca_reset = 0xFF;
DELAY(100);
dca->dca_ic = IC_IE;
-#endif
dca->dca_cfcr = CFCR_DLAB;
rate = ttspeedtab(rate, dcaspeedtab);
@@ -941,8 +950,9 @@ int
dcacngetc(dev)
dev_t dev;
{
- register struct dcadevice *dca = dca_addr[UNIT(dev)];
- register u_char stat;
+ struct dca_softc *sc = &dca_softc[DCAUNIT(dev)];
+ struct dcadevice *dca = sc->sc_dca;
+ u_char stat;
int c, s;
#ifdef lint
@@ -965,16 +975,17 @@ dcacnputc(dev, c)
dev_t dev;
register int c;
{
- register struct dcadevice *dca = dca_addr[UNIT(dev)];
- register int timo;
- register u_char stat;
+ struct dca_softc *sc = &dca_softc[DCAUNIT(dev)];
+ struct dcadevice *dca = sc->sc_dca;
+ int timo;
+ u_char stat;
int s = splhigh();
#ifdef lint
stat = dev; if (stat) return;
#endif
if (dcaconsinit == 0) {
- (void) dcainit(UNIT(dev), dcadefaultrate);
+ (void) dcainit(sc, dcadefaultrate);
dcaconsinit = 1;
}
/* wait for any pending transmission to finish */
@@ -991,7 +1002,7 @@ dcacnputc(dev, c)
* we must let our interrupt through to keep things moving.
* Otherwise, we clear the interrupt that we have caused.
*/
- if ((dca_tty[UNIT(dev)]->t_state & TS_BUSY) == 0)
+ if ((sc->sc_tty->t_state & TS_BUSY) == 0)
stat = dca->dca_iir;
splx(s);
}
diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c
index 3e7a886ab62..11f424db983 100644
--- a/sys/arch/hp300/dev/dcm.c
+++ b/sys/arch/hp300/dev/dcm.c
@@ -1,6 +1,7 @@
-/* $NetBSD: dcm.c,v 1.19 1995/10/04 08:39:14 thorpej Exp $ */
+/* $NetBSD: dcm.c,v 1.20 1995/12/02 18:18:50 thorpej Exp $ */
/*
+ * Copyright (c) 1995 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -75,24 +76,12 @@
#define DEFAULT_BAUD_RATE 9600
#endif
-int dcmprobe(), dcmintr(), dcmparam();
-void dcmstart();
+int dcmmatch(), dcmintr(), dcmparam();
+void dcmattach(), dcmstart();
struct driver dcmdriver = {
- dcmprobe, "dcm",
+ dcmmatch, dcmattach, "dcm",
};
-#define NDCMLINE (NDCM*4)
-
-struct tty *dcm_tty[NDCMLINE];
-struct modemreg *dcm_modem[NDCMLINE];
-char mcndlast[NDCMLINE]; /* XXX last modem status for line */
-int ndcm = NDCMLINE;
-
-int dcm_active;
-int dcmsoftCAR[NDCM];
-struct dcmdevice *dcm_addr[NDCM];
-struct isr dcmisr[NDCM];
-
struct speedtab dcmspeedtab[] = {
0, BR_0,
50, BR_50,
@@ -130,7 +119,7 @@ struct dcmischeme {
long dis_time; /* last time examined */
int dis_intr; /* recv interrupts during last interval */
int dis_char; /* characters read during last interval */
-} dcmischeme[NDCM];
+};
/*
* Console support
@@ -184,13 +173,12 @@ struct dcmstats {
long rchars; /* # of recv chars */
long xsilo[DCMXBSIZE+2]; /* times this many chars xmit on one int */
long rsilo[DCMRBSIZE+2]; /* times this many chars read on one int */
-} dcmstats[NDCM];
+};
#endif
-#define UNIT(x) minor(x)
-#define BOARD(x) (((x) >> 2) & 0x3f)
-#define PORT(x) ((x) & 3)
-#define MKUNIT(b,p) (((b) << 2) | (p))
+#define DCMUNIT(x) minor(x)
+#define DCMBOARD(x) (((x) >> 2) & 0x3f)
+#define DCMPORT(x) ((x) & 3)
/*
* Conversion from "HP DCE" to almost-normal DCE: on the 638 8-port mux,
@@ -217,7 +205,6 @@ struct dcmstats {
* "RTS" 8 20 DTR
* "SR" 23 4 RTS (often not needed)
*/
-#define FLAG_STDDCE 0x10 /* map inputs if this bit is set in flags */
#define hp2dce_in(ibits) (iconv[(ibits) & 0xf])
static char iconv[16] = {
0, MI_DM, MI_CTS, MI_CTS|MI_DM,
@@ -227,28 +214,66 @@ static char iconv[16] = {
MI_RI|MI_CD|MI_CTS|MI_DM
};
-dcmprobe(hd)
+#define NDCMPORT 4 /* XXX what about 8-port cards? */
+
+struct dcm_softc {
+ struct hp_device *sc_hd; /* device info */
+ struct dcmdevice *sc_dcm; /* pointer to hardware */
+ struct tty *sc_tty[NDCMPORT]; /* our tty instances */
+ struct modemreg *sc_modem[NDCMPORT]; /* modem control */
+ char sc_mcndlast[NDCMPORT]; /* XXX last modem status for port */
+ struct isr sc_isr; /* interrupt handler */
+ short sc_softCAR; /* mask of ports with soft-carrier */
+ struct dcmischeme sc_scheme; /* interrupt scheme for board */
+
+ /*
+ * Mask of soft-carrier bits in config flags.
+ * XXX What about 8-port cards?
+ */
+#define DCM_SOFTCAR 0x0000000f
+
+ int sc_flags; /* misc. configuration info */
+
+ /*
+ * Bits for sc_flags
+ */
+#define DCM_ACTIVE 0x00000001 /* indicates board is alive */
+#define DCM_STDDCE 0x00000010 /* re-map DCE to standard */
+#define DCM_FLAGMASK (DCM_STDDCE) /* mask of valid bits in config flags */
+
+#ifdef DCMSTATS
+ struct dcmstats sc_stats; /* metrics gathering */
+#endif
+} dcm_softc[NDCM];
+
+int
+dcmmatch(hd)
register struct hp_device *hd;
{
- register struct dcmdevice *dcm;
- register int i;
- register int timo = 0;
+ struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
+ struct dcmdevice *dcm;
+ int i, timo = 0;
int s, brd, isconsole, mbits;
dcm = (struct dcmdevice *)hd->hp_addr;
if ((dcm->dcm_rsid & 0x1f) != DCMID)
return (0);
+
brd = hd->hp_unit;
- isconsole = (brd == BOARD(dcmconsole));
+ isconsole = (brd == DCMBOARD(dcmconsole));
+
/*
* XXX selected console device (CONSUNIT) as determined by
* dcmcnprobe does not agree with logical numbering imposed
* by the config file (i.e. lowest address DCM is not unit
* CONSUNIT). Don't recognize this card.
*/
- if (isconsole && dcm != dcm_addr[BOARD(dcmconsole)])
+ if (isconsole && (dcm != sc->sc_dcm))
return (0);
+ sc->sc_hd = hd;
+ hd->hp_ipl = DCMIPL(dcm->dcm_ic);
+
/*
* Empirically derived self-test magic
*/
@@ -275,64 +300,94 @@ dcmprobe(hd)
dcm->dcm_ic = IC_ID;
splx(s);
- hd->hp_ipl = DCMIPL(dcm->dcm_ic);
- dcm_addr[brd] = dcm;
- dcm_active |= 1 << brd;
- dcmsoftCAR[brd] = hd->hp_flags;
- dcmisr[brd].isr_ipl = hd->hp_ipl;
- dcmisr[brd].isr_arg = brd;
- dcmisr[brd].isr_intr = dcmintr;
- isrlink(&dcmisr[brd]);
-#ifdef KGDB
- if (major(kgdb_dev) == dcmmajor && BOARD(kgdb_dev) == brd) {
- if (dcmconsole == UNIT(kgdb_dev))
- kgdb_dev = NODEV; /* can't debug over console port */
-#ifndef KGDB_CHEAT
- /*
- * The following could potentially be replaced
- * by the corresponding code in dcmcnprobe.
- */
- else {
- (void) dcminit(kgdb_dev, kgdb_rate);
- if (kgdb_debug_init) {
- printf("dcm%d: ", UNIT(kgdb_dev));
- kgdb_connect(1);
- } else
- printf("dcm%d: kgdb enabled\n", UNIT(kgdb_dev));
- }
- /* end could be replaced */
-#endif
- }
-#endif
+ return (1);
+}
+
+void
+dcmattach(hd)
+ register struct hp_device *hd;
+{
+ struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
+ struct dcmdevice *dcm;
+ int i, timo = 0;
+ int s, brd, isconsole, mbits;
+
+ dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr;
+
+ brd = hd->hp_unit;
+ isconsole = (brd == DCMBOARD(dcmconsole));
+
+ /* Extract configuration info from flags. */
+ sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR);
+ sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK);
+
+ /* Mark our unit as configured. */
+ sc->sc_flags |= DCM_ACTIVE;
+
+ /* Establish the interrupt handler. */
+ sc->sc_isr.isr_ipl = hd->hp_ipl;
+ sc->sc_isr.isr_arg = brd;
+ sc->sc_isr.isr_intr = dcmintr;
+ isrlink(&sc->sc_isr);
+
if (dcmistype == DIS_TIMER)
dcmsetischeme(brd, DIS_RESET|DIS_TIMER);
else
dcmsetischeme(brd, DIS_RESET|DIS_PERCHAR);
/* load pointers to modem control */
- dcm_modem[MKUNIT(brd, 0)] = &dcm->dcm_modem0;
- dcm_modem[MKUNIT(brd, 1)] = &dcm->dcm_modem1;
- dcm_modem[MKUNIT(brd, 2)] = &dcm->dcm_modem2;
- dcm_modem[MKUNIT(brd, 3)] = &dcm->dcm_modem3;
+ sc->sc_modem[0] = &dcm->dcm_modem0;
+ sc->sc_modem[1] = &dcm->dcm_modem1;
+ sc->sc_modem[2] = &dcm->dcm_modem2;
+ sc->sc_modem[3] = &dcm->dcm_modem3;
+
/* set DCD (modem) and CTS (flow control) on all ports */
- if (dcmsoftCAR[brd] & FLAG_STDDCE)
+ if (sc->sc_flags & DCM_STDDCE)
mbits = hp2dce_in(MI_CD|MI_CTS);
else
mbits = MI_CD|MI_CTS;
- for (i = 0; i < 4; i++)
- dcm_modem[MKUNIT(brd, i)]->mdmmsk = mbits;
+
+ for (i = 0; i < NDCMPORT; i++)
+ sc->sc_modem[i]->mdmmsk = mbits;
dcm->dcm_ic = IC_IE; /* turn all interrupts on */
+
/*
* Need to reset baud rate, etc. of next print so reset dcmconsole.
* Also make sure console is always "hardwired"
*/
if (isconsole) {
dcmconsinit = 0;
- dcmsoftCAR[brd] |= (1 << PORT(dcmconsole));
- printf("dcm%d: console on port %d\n", brd, PORT(dcmconsole));
+ sc->sc_softCAR |= (1 << DCMPORT(dcmconsole));
+ printf(": console on port %d\n", DCMPORT(dcmconsole));
+ } else
+ printf("\n");
+
+#ifdef KGDB
+ if (major(kgdb_dev) == dcmmajor &&
+ DCMBOARD(DCMUNIT(kgdb_dev)) == brd) {
+ if (dcmconsole == DCMUNIT(kgdb_dev))
+ kgdb_dev = NODEV; /* can't debug over console port */
+#ifndef KGDB_CHEAT
+ /*
+ * The following could potentially be replaced
+ * by the corresponding code in dcmcnprobe.
+ */
+ else {
+ (void) dcminit(kgdb_dev, kgdb_rate);
+ if (kgdb_debug_init) {
+ printf("%s port %d: ", sc->sc_hd->hp_xname,
+ DCMPORT(DCMUNIT(kgdb_dev)));
+ kgdb_connect(1);
+ } else
+ printf("%s port %d: kgdb enabled\n",
+ sc->sc_hd->hp_xname,
+ DCMPORT(DCMUNIT(kgdb_dev)));
+ }
+ /* end could be replaced */
+#endif
}
- return (1);
+#endif
}
/* ARGSUSED */
@@ -342,18 +397,27 @@ dcmopen(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
- register struct tty *tp;
- register int unit, brd;
+ struct dcm_softc *sc;
+ struct tty *tp;
+ int unit, brd, port;
int error = 0, mbits, s;
- unit = UNIT(dev);
- brd = BOARD(unit);
- if (unit >= NDCMLINE || (dcm_active & (1 << brd)) == 0)
+ unit = DCMUNIT(dev);
+ brd = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ if ((brd >= NDCM) || (port >= NDCMPORT))
return (ENXIO);
- if (!dcm_tty[unit])
- tp = dcm_tty[unit] = ttymalloc();
+
+ sc = &dcm_softc[brd];
+ if ((sc->sc_flags & DCM_ACTIVE) == 0)
+ return (ENXIO);
+
+ if (sc->sc_tty[port] == NULL)
+ tp = sc->sc_tty[port] = ttymalloc();
else
- tp = dcm_tty[unit];
+ tp = sc->sc_tty[port];
+
tp->t_oproc = dcmstart;
tp->t_param = dcmparam;
tp->t_dev = dev;
@@ -385,19 +449,21 @@ dcmopen(dev, flag, mode, p)
/* Set modem control state. */
mbits = MO_ON;
- if (dcmsoftCAR[brd] & FLAG_STDDCE)
+ if (sc->sc_flags & DCM_STDDCE)
mbits |= MO_SR; /* pin 23, could be used as RTS */
+
(void) dcmmctl(dev, mbits, DMSET); /* enable port */
/* Set soft-carrier if so configured. */
- if ((dcmsoftCAR[brd] & (1 << PORT(unit))) ||
+ if ((sc->sc_softCAR & (1 << port)) ||
(dcmmctl(dev, MO_OFF, DMGET) & MI_CD))
tp->t_state |= TS_CARR_ON;
#ifdef DEBUG
if (dcmdebug & DDB_MODEM)
- printf("dcm%d: dcmopen port %d softcarr %c\n",
- brd, unit, (tp->t_state & TS_CARR_ON) ? '1' : '0');
+ printf("%s: dcmopen port %d softcarr %c\n",
+ sc->sc_hd->hp_xname, port,
+ (tp->t_state & TS_CARR_ON) ? '1' : '0');
#endif
/* Wait for carrier if necessary. */
@@ -417,8 +483,8 @@ dcmopen(dev, flag, mode, p)
#ifdef DEBUG
if (dcmdebug & DDB_OPENCLOSE)
- printf("dcmopen: u %x st %x fl %x\n",
- unit, tp->t_state, tp->t_flags);
+ printf("%s port %d: dcmopen: st %x fl %x\n",
+ sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags);
#endif
if (error == 0)
error = (*linesw[tp->t_line].l_open)(dev, tp);
@@ -433,11 +499,17 @@ dcmclose(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
- register struct tty *tp;
- int s, unit;
+ int s, unit, board, port;
+ struct dcm_softc *sc;
+ struct tty *tp;
- unit = UNIT(dev);
- tp = dcm_tty[unit];
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ tp = sc->sc_tty[port];
+
(*linesw[tp->t_line].l_close)(tp, flag);
s = spltty();
@@ -447,14 +519,14 @@ dcmclose(dev, flag, mode, p)
(void) dcmmctl(dev, MO_OFF, DMSET);
#ifdef DEBUG
if (dcmdebug & DDB_OPENCLOSE)
- printf("dcmclose: u %x st %x fl %x\n",
- unit, tp->t_state, tp->t_flags);
+ printf("%s port %d: dcmclose: st %x fl %x\n",
+ sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags);
#endif
splx(s);
ttyclose(tp);
#if 0
ttyfree(tp);
- dcm_tty[unit] = (struct tty *)0;
+ sc->sc_tty[port] == NULL;
#endif
return (0);
}
@@ -465,7 +537,16 @@ dcmread(dev, uio, flag)
struct uio *uio;
int flag;
{
- register struct tty *tp = dcm_tty[UNIT(dev)];
+ int unit, board, port;
+ struct dcm_softc *sc;
+ register struct tty *tp;
+
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ tp = sc->sc_tty[port];
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
}
@@ -476,7 +557,16 @@ dcmwrite(dev, uio, flag)
struct uio *uio;
int flag;
{
- register struct tty *tp = dcm_tty[UNIT(dev)];
+ int unit, board, port;
+ struct dcm_softc *sc;
+ register struct tty *tp;
+
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ tp = sc->sc_tty[port];
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}
@@ -485,18 +575,26 @@ struct tty *
dcmtty(dev)
dev_t dev;
{
+ int unit, board, port;
+ struct dcm_softc *sc;
- return (dcm_tty[UNIT(dev)]);
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+
+ return (sc->sc_tty[port]);
}
int
dcmintr(brd)
register int brd;
{
- register struct dcmdevice *dcm = dcm_addr[brd];
- register struct dcmischeme *dis;
- register int unit = MKUNIT(brd, 0);
- register int code, i;
+ struct dcm_softc *sc = &dcm_softc[brd];
+ struct dcmdevice *dcm = sc->sc_dcm;
+ struct dcmischeme *dis = &sc->sc_scheme;
+ int code, i;
int pcnd[4], mcode, mcnd[4];
/*
@@ -511,8 +609,8 @@ dcmintr(brd)
for (i = 0; i < 4; i++) {
pcnd[i] = dcm->dcm_icrtab[i].dcm_data;
dcm->dcm_icrtab[i].dcm_data = 0;
- code = dcm_modem[unit+i]->mdmin;
- if (dcmsoftCAR[brd] & FLAG_STDDCE)
+ code = sc->sc_modem[i]->mdmin;
+ if (sc->sc_flags & DCM_STDDCE)
code = hp2dce_in(code);
mcnd[i] = code;
}
@@ -524,34 +622,34 @@ dcmintr(brd)
#ifdef DEBUG
if (dcmdebug & DDB_INTR) {
- printf("dcmintr(%d): iir %x pc %x/%x/%x/%x ",
- brd, code, pcnd[0], pcnd[1], pcnd[2], pcnd[3]);
+ printf("%s: dcmintr: iir %x pc %x/%x/%x/%x ",
+ sc->sc_hd->hp_xname, code, pcnd[0], pcnd[1],
+ pcnd[2], pcnd[3]);
printf("miir %x mc %x/%x/%x/%x\n",
mcode, mcnd[0], mcnd[1], mcnd[2], mcnd[3]);
}
#endif
if (code & IIR_TIMEO)
- dcmrint(brd, dcm);
+ dcmrint(sc);
if (code & IIR_PORT0)
- dcmpint(unit+0, pcnd[0], dcm);
+ dcmpint(sc, 0, pcnd[0]);
if (code & IIR_PORT1)
- dcmpint(unit+1, pcnd[1], dcm);
+ dcmpint(sc, 1, pcnd[1]);
if (code & IIR_PORT2)
- dcmpint(unit+2, pcnd[2], dcm);
+ dcmpint(sc, 2, pcnd[2]);
if (code & IIR_PORT3)
- dcmpint(unit+3, pcnd[3], dcm);
+ dcmpint(sc, 3, pcnd[3]);
if (code & IIR_MODM) {
if (mcode == 0 || mcode & 0x1) /* mcode==0 -> 98642 board */
- dcmmint(unit+0, mcnd[0], dcm);
+ dcmmint(sc, 0, mcnd[0]);
if (mcode & 0x2)
- dcmmint(unit+1, mcnd[1], dcm);
+ dcmmint(sc, 1, mcnd[1]);
if (mcode & 0x4)
- dcmmint(unit+2, mcnd[2], dcm);
+ dcmmint(sc, 2, mcnd[2]);
if (mcode & 0x8)
- dcmmint(unit+3, mcnd[3], dcm);
+ dcmmint(sc, 3, mcnd[3]);
}
- dis = &dcmischeme[brd];
/*
* Chalk up a receiver interrupt if the timer running or one of
* the ports reports a special character interrupt.
@@ -584,7 +682,7 @@ dcmintr(brd)
*/
else if (!dis->dis_perchar && dis->dis_intr > dis->dis_char) {
dcmsetischeme(brd, DIS_PERCHAR);
- dcmrint(brd, dcm);
+ dcmrint(sc);
}
dis->dis_intr = dis->dis_char = 0;
dis->dis_time = time.tv_sec;
@@ -597,50 +695,45 @@ dcmintr(brd)
* First, it might be a special character (exception interrupt);
* Second, it may be a buffer empty (transmit interrupt);
*/
-dcmpint(unit, code, dcm)
- int unit, code;
- struct dcmdevice *dcm;
+dcmpint(sc, port, code)
+ struct dcm_softc *sc;
+ int port, code;
{
- struct tty *tp = dcm_tty[unit];
if (code & IT_SPEC)
- dcmreadbuf(unit, dcm, tp);
+ dcmreadbuf(sc, port);
if (code & IT_TX)
- dcmxint(unit, dcm, tp);
+ dcmxint(sc, port);
}
-dcmrint(brd, dcm)
- int brd;
- register struct dcmdevice *dcm;
+dcmrint(sc)
+ struct dcm_softc *sc;
{
- register int i, unit;
- register struct tty *tp;
+ int port;
- unit = MKUNIT(brd, 0);
- tp = dcm_tty[unit];
- for (i = 0; i < 4; i++, tp++, unit++)
- dcmreadbuf(unit, dcm, tp);
+ for (port = 0; port < NDCMPORT; port++)
+ dcmreadbuf(sc, port);
}
-dcmreadbuf(unit, dcm, tp)
- int unit;
- register struct dcmdevice *dcm;
- register struct tty *tp;
+dcmreadbuf(sc, port)
+ struct dcm_softc *sc;
+ int port;
{
- int port = PORT(unit);
- register struct dcmpreg *pp = dcm_preg(dcm, port);
- register struct dcmrfifo *fifo;
- register int c, stat;
- register unsigned head;
+ struct dcmdevice *dcm = sc->sc_dcm;
+ struct tty *tp = sc->sc_tty[port];
+ struct dcmpreg *pp = dcm_preg(dcm, port);
+ struct dcmrfifo *fifo;
+ int c, stat;
+ u_int head;
int nch = 0;
#ifdef DCMSTATS
- struct dcmstats *dsp = &dcmstats[BOARD(unit)];
+ struct dcmstats *dsp = &sc->sc_stats;
dsp->rints++;
#endif
if ((tp->t_state & TS_ISOPEN) == 0) {
#ifdef KGDB
- if ((makedev(dcmmajor, unit) == kgdb_dev) &&
+ if ((makedev(dcmmajor, minor(tp->t_dev)) == kgdb_dev) &&
(head = pp->r_head & RX_MASK) != (pp->r_tail & RX_MASK) &&
dcm->dcm_rfifos[3-port][head>>1].data_char == FRAME_START) {
pp->r_head = (head + 2) & RX_MASK;
@@ -671,8 +764,9 @@ dcmreadbuf(unit, dcm, tp)
#ifdef DEBUG
if (dcmdebug & DDB_INPUT)
- printf("dcmreadbuf(%d): c%x('%c') s%x f%x h%x t%x\n",
- unit, c&0xFF, c, stat&0xFF,
+ printf("%s port %d: dcmreadbuf: c%x('%c') s%x f%x h%x t%x\n",
+ sc->sc_hd->hp_xname, port,
+ c&0xFF, c, stat&0xFF,
tp->t_flags, head, pp->r_tail);
#endif
/*
@@ -681,8 +775,9 @@ dcmreadbuf(unit, dcm, tp)
if (stat & RD_MASK) {
#ifdef DEBUG
if (dcmdebug & (DDB_INPUT|DDB_SIOERR))
- printf("dcmreadbuf(%d): err: c%x('%c') s%x\n",
- unit, stat, c&0xFF, c);
+ printf("%s port %d: dcmreadbuf: err: c%x('%c') s%x\n",
+ sc->sc_hd->hp_xname, port,
+ stat, c&0xFF, c);
#endif
if (stat & (RD_BD | RD_FE))
c |= TTY_FE;
@@ -690,14 +785,17 @@ dcmreadbuf(unit, dcm, tp)
c |= TTY_PE;
else if (stat & RD_OVF)
log(LOG_WARNING,
- "dcm%d: silo overflow\n", unit);
+ "%s port %d: silo overflow\n",
+ sc->sc_hd->hp_xname, port);
else if (stat & RD_OE)
log(LOG_WARNING,
- "dcm%d: uart overflow\n", unit);
+ "%s port %d: uart overflow\n",
+ sc->sc_hd->hp_xname, port);
}
(*linesw[tp->t_line].l_rint)(c, tp);
}
- dcmischeme[BOARD(unit)].dis_char += nch;
+ sc->sc_scheme.dis_char += nch;
+
#ifdef DCMSTATS
dsp->rchars += nch;
if (nch <= DCMRBSIZE)
@@ -707,33 +805,35 @@ dcmreadbuf(unit, dcm, tp)
#endif
}
-dcmxint(unit, dcm, tp)
- int unit;
- struct dcmdevice *dcm;
- register struct tty *tp;
+dcmxint(sc, port)
+ struct dcm_softc *sc;
+ int port;
{
+ struct tty *tp = sc->sc_tty[port];
+
tp->t_state &= ~TS_BUSY;
if (tp->t_state & TS_FLUSH)
tp->t_state &= ~TS_FLUSH;
(*linesw[tp->t_line].l_start)(tp);
}
-dcmmint(unit, mcnd, dcm)
- register int unit;
- register struct dcmdevice *dcm;
- int mcnd;
+dcmmint(sc, port, mcnd)
+ struct dcm_softc *sc;
+ int port, mcnd;
{
- register struct tty *tp;
int delta;
+ struct tty *tp;
+ struct dcmdevice *dcm = sc->sc_dcm;
+
+ tp = sc->sc_tty[port];
#ifdef DEBUG
if (dcmdebug & DDB_MODEM)
- printf("dcmmint: port %d mcnd %x mcndlast %x\n",
- unit, mcnd, mcndlast[unit]);
+ printf("%s port %d: dcmmint: mcnd %x mcndlast %x\n",
+ sc->sc_hd->hp_xname, port, mcnd, sc->sc_mcndlast[port]);
#endif
- tp = dcm_tty[unit];
- delta = mcnd ^ mcndlast[unit];
- mcndlast[unit] = mcnd;
+ delta = mcnd ^ sc->sc_mcndlast[port];
+ sc->sc_mcndlast[port] = mcnd;
if ((delta & MI_CTS) && (tp->t_state & TS_ISOPEN) &&
(tp->t_flags & CCTS_OFLOW)) {
if (mcnd & MI_CTS) {
@@ -745,11 +845,11 @@ dcmmint(unit, mcnd, dcm)
if (delta & MI_CD) {
if (mcnd & MI_CD)
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
- else if ((dcmsoftCAR[BOARD(unit)] & (1 << PORT(unit))) == 0 &&
+ else if ((sc->sc_softCAR & (1 << port)) == 0 &&
(*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
- dcm_modem[unit]->mdmout = MO_OFF;
+ sc->sc_modem[port]->mdmout = MO_OFF;
SEM_LOCK(dcm);
- dcm->dcm_modemchng |= 1<<(unit & 3);
+ dcm->dcm_modemchng |= (1 << port);
dcm->dcm_cr |= CR_MODM;
SEM_UNLOCK(dcm);
DELAY(10); /* time to change lines */
@@ -765,18 +865,24 @@ dcmioctl(dev, cmd, data, flag, p)
int flag;
struct proc *p;
{
- register struct tty *tp;
- register int unit = UNIT(dev);
- register struct dcmdevice *dcm;
- register int board, port;
+ struct dcm_softc *sc;
+ struct tty *tp;
+ struct dcmdevice *dcm;
+ int board, port, unit = DCMUNIT(dev);
int error, s;
+
+ port = DCMPORT(unit);
+ board = DCMBOARD(unit);
+
+ sc = &dcm_softc[board];
+ dcm = sc->sc_dcm;
+ tp = sc->sc_tty[port];
#ifdef DEBUG
if (dcmdebug & DDB_IOCTL)
- printf("dcmioctl: unit %d cmd %x data %x flag %x\n",
- unit, cmd, *data, flag);
+ printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n",
+ sc->sc_hd->hp_xname, port, cmd, *data, flag);
#endif
- tp = dcm_tty[unit];
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error >= 0)
return (error);
@@ -784,9 +890,6 @@ dcmioctl(dev, cmd, data, flag, p)
if (error >= 0)
return (error);
- port = PORT(unit);
- board = BOARD(unit);
- dcm = dcm_addr[board];
switch (cmd) {
case TIOCSBRK:
/*
@@ -836,7 +939,7 @@ dcmioctl(dev, cmd, data, flag, p)
case TIOCGFLAGS: {
int bits = 0;
- if ((dcmsoftCAR[board] & (1 << port)))
+ if ((sc->sc_softCAR & (1 << port)))
bits |= TIOCFLAG_SOFTCAR;
if (tp->t_cflag & CLOCAL)
@@ -856,9 +959,9 @@ dcmioctl(dev, cmd, data, flag, p)
userbits = *(int *)data;
if ((userbits & TIOCFLAG_SOFTCAR) ||
- ((board == BOARD(dcmconsole)) &&
- (port == PORT(dcmconsole))))
- dcmsoftCAR[board] |= (1 << port);
+ ((board == DCMBOARD(dcmconsole)) &&
+ (port == DCMPORT(dcmconsole))))
+ sc->sc_softCAR |= (1 << port);
if (userbits & TIOCFLAG_CLOCAL)
tp->t_cflag |= CLOCAL;
@@ -877,10 +980,18 @@ dcmparam(tp, t)
register struct tty *tp;
register struct termios *t;
{
- register struct dcmdevice *dcm;
- register int port, mode, cflag = t->c_cflag;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ int unit, board, port, mode, cflag = t->c_cflag;
int ospeed = ttspeedtab(t->c_ospeed, dcmspeedtab);
+ unit = DCMUNIT(tp->t_dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ dcm = sc->sc_dcm;
+
/* check requested parameters */
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
return (EINVAL);
@@ -889,7 +1000,7 @@ dcmparam(tp, t)
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = cflag;
if (ospeed == 0) {
- (void) dcmmctl(UNIT(tp->t_dev), MO_OFF, DMSET);
+ (void) dcmmctl(DCMUNIT(tp->t_dev), MO_OFF, DMSET);
return (0);
}
@@ -916,13 +1027,11 @@ dcmparam(tp, t)
mode |= LC_1STOP;
#ifdef DEBUG
if (dcmdebug & DDB_PARAM)
- printf("dcmparam(%d): cflag %x mode %x speed %d uperch %d\n",
- UNIT(tp->t_dev), cflag, mode, tp->t_ospeed,
+ printf("%s port %d: dcmparam: cflag %x mode %x speed %d uperch %d\n",
+ sc->sc_hd->hp_xname, port, cflag, mode, tp->t_ospeed,
DCM_USPERCH(tp->t_ospeed));
#endif
- port = PORT(tp->t_dev);
- dcm = dcm_addr[BOARD(tp->t_dev)];
/*
* Wait for transmitter buffer to empty.
*/
@@ -949,28 +1058,35 @@ void
dcmstart(tp)
register struct tty *tp;
{
- register struct dcmdevice *dcm;
- register struct dcmpreg *pp;
- register struct dcmtfifo *fifo;
- register char *bp;
- register unsigned tail, next;
- register int port, nch;
- unsigned head;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ struct dcmpreg *pp;
+ struct dcmtfifo *fifo;
+ char *bp;
+ u_int head, tail, next;
+ int unit, board, port, nch;
char buf[16];
int s;
#ifdef DCMSTATS
- struct dcmstats *dsp = &dcmstats[BOARD(tp->t_dev)];
+ struct dcmstats *dsp = &sc->sc_stats;
int tch = 0;
#endif
+ unit = DCMUNIT(tp->t_dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ dcm = sc->sc_dcm;
+
s = spltty();
#ifdef DCMSTATS
dsp->xints++;
#endif
#ifdef DEBUG
if (dcmdebug & DDB_OUTPUT)
- printf("dcmstart(%d): state %x flags %x outcc %d\n",
- UNIT(tp->t_dev), tp->t_state, tp->t_flags,
+ printf("%s port %d: dcmstart: state %x flags %x outcc %d\n",
+ sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags,
tp->t_outq.c_cc);
#endif
if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
@@ -989,8 +1105,6 @@ dcmstart(tp)
goto out;
}
- dcm = dcm_addr[BOARD(tp->t_dev)];
- port = PORT(tp->t_dev);
pp = dcm_preg(dcm, port);
tail = pp->t_tail & TX_MASK;
next = (tail + 1) & TX_MASK;
@@ -1053,8 +1167,8 @@ again:
}
#ifdef DEBUG
if (dcmdebug & DDB_INTR)
- printf("dcmstart(%d): head %x tail %x outqcc %d\n",
- UNIT(tp->t_dev), head, tail, tp->t_outq.c_cc);
+ printf("%s port %d: dcmstart(%d): head %x tail %x outqcc %d\n",
+ sc->sc_hd->hp_xname, port, head, tail, tp->t_outq.c_cc);
#endif
out:
#ifdef DCMSTATS
@@ -1093,39 +1207,43 @@ dcmmctl(dev, bits, how)
dev_t dev;
int bits, how;
{
- register struct dcmdevice *dcm;
- int s, unit, brd, hit = 0;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ int s, unit, brd, port, hit = 0;
+
+ unit = DCMUNIT(dev);
+ brd = DCMBOARD(unit);
+ port = DCMPORT(unit);
+ sc = &dcm_softc[brd];
+ dcm = sc->sc_dcm;
- unit = UNIT(dev);
#ifdef DEBUG
if (dcmdebug & DDB_MODEM)
- printf("dcmmctl(%d) unit %d bits 0x%x how %x\n",
- BOARD(unit), unit, bits, how);
+ printf("%s port %d: dcmmctl: bits 0x%x how %x\n",
+ sc->sc_hd->hp_xname, port, bits, how);
#endif
- brd = BOARD(unit);
- dcm = dcm_addr[brd];
s = spltty();
- switch (how) {
+ switch (how) {
case DMSET:
- dcm_modem[unit]->mdmout = bits;
+ sc->sc_modem[port]->mdmout = bits;
hit++;
break;
case DMBIS:
- dcm_modem[unit]->mdmout |= bits;
+ sc->sc_modem[port]->mdmout |= bits;
hit++;
break;
case DMBIC:
- dcm_modem[unit]->mdmout &= ~bits;
+ sc->sc_modem[port]->mdmout &= ~bits;
hit++;
break;
case DMGET:
- bits = dcm_modem[unit]->mdmin;
- if (dcmsoftCAR[brd] & FLAG_STDDCE)
+ bits = sc->sc_modem[port]->mdmin;
+ if (sc->sc_flags & DCM_STDDCE)
bits = hp2dce_in(bits);
break;
}
@@ -1146,20 +1264,21 @@ dcmmctl(dev, bits, how)
dcmsetischeme(brd, flags)
int brd, flags;
{
- register struct dcmdevice *dcm = dcm_addr[brd];
- register struct dcmischeme *dis = &dcmischeme[brd];
- register int i;
+ struct dcm_softc *sc = &dcm_softc[brd];
+ struct dcmdevice *dcm = sc->sc_dcm;
+ struct dcmischeme *dis = &sc->sc_scheme;
+ int i;
u_char mask;
int perchar = flags & DIS_PERCHAR;
#ifdef DEBUG
if (dcmdebug & DDB_INTSCHM)
- printf("dcmsetischeme(%d, %d): cur %d, ints %d, chars %d\n",
- brd, perchar, dis->dis_perchar,
+ printf("%s: dcmsetischeme(%d): cur %d, ints %d, chars %d\n",
+ sc->sc_hd->hp_xname, perchar, dis->dis_perchar,
dis->dis_intr, dis->dis_char);
if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) {
- printf("dcmsetischeme(%d): redundent request %d\n",
- brd, perchar);
+ printf("%s: dcmsetischeme: redundent request %d\n",
+ sc->sc_hd->hp_xname, perchar);
return;
}
#endif
@@ -1177,10 +1296,12 @@ dcmsetischeme(brd, flags)
* chars for any port on the board.
*/
if (!perchar) {
- register struct tty *tp = dcm_tty[MKUNIT(brd, 0)];
+ register struct tty *tp;
int c;
- for (i = 0; i < 4; i++, tp++) {
+ for (i = 0; i < NDCMPORT; i++) {
+ tp = sc->sc_tty[i];
+
if ((c = tp->t_cc[VSTART]) != _POSIX_VDISABLE)
dcm->dcm_bmap[c].data_data |= (1 << i);
if ((c = tp->t_cc[VSTOP]) != _POSIX_VDISABLE)
@@ -1213,7 +1334,9 @@ void
dcmcnprobe(cp)
struct consdev *cp;
{
- register struct hp_hw *hw;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ struct hp_hw *hw;
int unit;
/* locate the major number */
@@ -1233,33 +1356,39 @@ dcmcnprobe(cp)
cp->cn_pri = CN_DEAD;
return;
}
+
unit = CONUNIT;
- dcm_addr[BOARD(CONUNIT)] = (struct dcmdevice *)hw->hw_kva;
+ sc = &dcm_softc[DCMBOARD(CONUNIT)];
+ dcm = sc->sc_dcm = (struct dcmdevice *)hw->hw_kva;
/* initialize required fields */
cp->cn_dev = makedev(dcmmajor, unit);
- switch (dcm_addr[BOARD(unit)]->dcm_rsid) {
+ switch (dcm->dcm_rsid) {
case DCMID:
cp->cn_pri = CN_NORMAL;
break;
+
case DCMID|DCMCON:
cp->cn_pri = CN_REMOTE;
break;
+
default:
cp->cn_pri = CN_DEAD;
return;
}
+
/*
* If dcmconsole is initialized, raise our priority.
*/
- if (dcmconsole == UNIT(unit))
+ if (dcmconsole == unit)
cp->cn_pri = CN_REMOTE;
#ifdef KGDB_CHEAT
/*
* This doesn't currently work, at least not with ite consoles;
* the console hasn't been initialized yet.
*/
- if (major(kgdb_dev) == dcmmajor && BOARD(kgdb_dev) == BOARD(unit)) {
+ if (major(kgdb_dev) == dcmmajor &&
+ DCMBOARD(DCMUNIT(kgdb_dev)) == DCMBOARD(unit)) {
(void) dcminit(kgdb_dev, kgdb_rate);
if (kgdb_debug_init) {
/*
@@ -1268,7 +1397,7 @@ dcmcnprobe(cp)
* has been selected already and will init
* on the first putc.
*/
- printf("dcm%d: ", UNIT(kgdb_dev));
+ printf("dcm%d: ", DCMUNIT(kgdb_dev));
kgdb_connect(1);
}
}
@@ -1279,26 +1408,37 @@ void
dcmcninit(cp)
struct consdev *cp;
{
+
dcminit(cp->cn_dev, dcmdefaultrate);
dcmconsinit = 1;
- dcmconsole = UNIT(cp->cn_dev);
+ dcmconsole = DCMUNIT(cp->cn_dev);
}
dcminit(dev, rate)
dev_t dev;
int rate;
{
- register struct dcmdevice *dcm = dcm_addr[BOARD(dev)];
- int s, mode, port;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ int s, mode, unit, board, port;
+
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ dcm = sc->sc_dcm;
- port = PORT(dev);
mode = LC_8BITS | LC_1STOP;
+
s = splhigh();
+
/*
* Wait for transmitter buffer to empty.
*/
while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
DELAY(DCM_USPERCH(rate));
+
/*
* Make changes known to hardware.
*/
@@ -1308,6 +1448,7 @@ dcminit(dev, rate)
dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
dcm->dcm_cr |= (1 << port);
SEM_UNLOCK(dcm);
+
/*
* Delay for config change to take place. Weighted by baud.
* XXX why do we do this?
@@ -1320,14 +1461,21 @@ int
dcmcngetc(dev)
dev_t dev;
{
- register struct dcmdevice *dcm = dcm_addr[BOARD(dev)];
- register struct dcmrfifo *fifo;
- register struct dcmpreg *pp;
- register unsigned head;
- int s, c, stat, port;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ struct dcmrfifo *fifo;
+ struct dcmpreg *pp;
+ u_int head;
+ int s, c, stat, unit, board, port;
+
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
- port = PORT(dev);
+ sc = &dcm_softc[board];
+ dcm = sc->sc_dcm;
pp = dcm_preg(dcm, port);
+
s = splhigh();
head = pp->r_head & RX_MASK;
fifo = &dcm->dcm_rfifos[3-port][head>>1];
@@ -1357,13 +1505,20 @@ dcmcnputc(dev, c)
dev_t dev;
int c;
{
- register struct dcmdevice *dcm = dcm_addr[BOARD(dev)];
- register struct dcmpreg *pp;
+ struct dcm_softc *sc;
+ struct dcmdevice *dcm;
+ struct dcmpreg *pp;
unsigned tail;
- int s, port, stat;
+ int s, unit, board, port, stat;
- port = PORT(dev);
+ unit = DCMUNIT(dev);
+ board = DCMBOARD(unit);
+ port = DCMPORT(unit);
+
+ sc = &dcm_softc[board];
+ dcm = sc->sc_dcm;
pp = dcm_preg(dcm, port);
+
s = splhigh();
#ifdef KGDB
if (dev != kgdb_dev)
diff --git a/sys/arch/hp300/dev/device.h b/sys/arch/hp300/dev/device.h
index cb76e0c60ae..e1c87334a40 100644
--- a/sys/arch/hp300/dev/device.h
+++ b/sys/arch/hp300/dev/device.h
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.5 1995/03/28 18:15:55 jtc Exp $ */
+/* $NetBSD: device.h,v 1.6 1995/12/02 18:21:54 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -36,7 +36,8 @@
*/
struct driver {
- int (*d_init)();
+ int (*d_match)();
+ void (*d_attach)();
char *d_name;
int (*d_start)();
int (*d_go)();
@@ -44,6 +45,16 @@ struct driver {
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;
@@ -51,6 +62,8 @@ struct hp_ctlr {
char *hp_addr;
int hp_flags;
int hp_ipl;
+ struct hp_hw *hp_args;
+ char hp_xname[8];
};
struct hp_device {
@@ -64,6 +77,8 @@ struct hp_device {
int hp_flags;
int hp_alive;
int hp_ipl;
+ struct hp_hw *hp_args;
+ char hp_xname[8];
};
struct devqueue {
@@ -78,16 +93,6 @@ struct devqueue {
#define MAXCTLRS 16 /* Size of HW table (arbitrary) */
#define MAXSLAVES 8 /* Slaves per controller (HPIB/SCSI limit) */
-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) */
-};
-
/* bus types */
#define B_MASK 0xE000
#define B_DIO 0x2000
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c
index e788b4497e3..cb22512d334 100644
--- a/sys/arch/hp300/dev/dma.c
+++ b/sys/arch/hp300/dev/dma.c
@@ -1,6 +1,7 @@
-/* $NetBSD: dma.c,v 1.5 1994/10/26 07:23:40 cgd Exp $ */
+/* $NetBSD: dma.c,v 1.6 1995/12/02 02:46:45 thorpej Exp $ */
/*
+ * Copyright (c) 1995 Jason R. Thorpe.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -72,16 +73,23 @@ struct dma_chain {
char *dc_addr;
};
+struct dma_channel {
+ 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 */
+ struct dma_chain dm_chain[DMAMAXIO]; /* all segments */
+};
+
struct dma_softc {
- struct dmadevice *sc_hwaddr;
- struct dmaBdevice *sc_Bhwaddr;
- char sc_type;
- char sc_flags;
- u_short sc_cmd;
- struct dma_chain *sc_cur;
- struct dma_chain *sc_last;
- struct dma_chain sc_chain[DMAMAXIO];
-} dma_softc[NDMA];
+ char *sc_xname; /* XXX external name */
+ struct dmareg *sc_dmareg; /* pointer to our hardware */
+ struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */
+ char sc_type; /* A, B, or C */
+} Dma_softc;
/* types */
#define DMA_B 0
@@ -92,7 +100,7 @@ struct dma_softc {
#define DMAF_VCFLUSH 0x02
#define DMAF_NOINTR 0x04
-struct devqueue dmachan[NDMA + 1];
+struct devqueue dmachan[NDMACHAN + 1];
int dmaintr();
#ifdef DEBUG
@@ -103,54 +111,75 @@ int dmadebug = 0;
#define DDB_IO 0x08
void dmatimeout __P((void *));
-int dmatimo[NDMA];
+int dmatimo[NDMACHAN];
-long dmahits[NDMA];
-long dmamisses[NDMA];
-long dmabyte[NDMA];
-long dmaword[NDMA];
-long dmalword[NDMA];
+long dmahits[NDMACHAN];
+long dmamisses[NDMACHAN];
+long dmabyte[NDMACHAN];
+long dmaword[NDMACHAN];
+long dmalword[NDMACHAN];
#endif
void
dmainit()
{
- register struct dmareg *dma = (struct dmareg *)DMA_BASE;
- register struct dma_softc *dc;
- register int i;
+ struct dma_softc *sc = &Dma_softc;
+ struct dmareg *dma;
+ struct dma_channel *dc;
+ int i;
char rev;
+ /* There's just one. */
+ sc->sc_dmareg = (struct dmareg *)DMA_BASE;
+ dma = sc->sc_dmareg;
+ sc->sc_xname = "dma0";
+
/*
- * Determine the DMA type.
- * Don't know how to easily differentiate the A and B cards,
+ * Determine the DMA type. A DMA_A or DMA_B will fail the
+ * following probe.
+ *
+ * XXX Don't know how to easily differentiate the A and B cards,
* so we just hope nobody has an A card (A cards will work if
* DMAINTLVL is set to 3).
*/
- if (!badbaddr((char *)&dma->dma_id[2]))
- rev = dma->dma_id[2];
- else {
+ if (badbaddr((char *)&dma->dma_id[2])) {
rev = 'B';
#if !defined(HP320)
panic("dmainit: DMA card requires hp320 support");
#endif
- }
+ } else
+ rev = dma->dma_id[2];
- dc = &dma_softc[0];
- for (i = 0; i < NDMA; i++) {
- dc->sc_hwaddr = (i & 1) ? &dma->dma_chan1 : &dma->dma_chan0;
- dc->sc_Bhwaddr = (i & 1) ? &dma->dma_Bchan1 : &dma->dma_Bchan0;
- dc->sc_type = rev == 'B' ? DMA_B : DMA_C;
- dc++;
+ sc->sc_type = (rev == 'B') ? DMA_B : DMA_C;
+
+ for (i = 0; i < NDMACHAN; i++) {
+ dc = &sc->sc_chan[i];
+ dc->dm_softc = sc;
+ switch (i) {
+ case 0:
+ dc->dm_hwaddr = &dma->dma_chan0;
+ dc->dm_Bhwaddr = &dma->dma_Bchan0;
+ break;
+
+ case 1:
+ dc->dm_hwaddr = &dma->dma_chan1;
+ dc->dm_Bhwaddr = &dma->dma_Bchan1;
+ break;
+
+ default:
+ 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, (void *)0, 30 * hz);
+ timeout(dmatimeout, sc, 30 * hz);
#endif
- printf("dma: 98620%c with 2 channels, %d bit DMA\n",
- rev, rev == 'B' ? 16 : 32);
+ printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname,
+ rev, (rev == 'B') ? 16 : 32);
}
int
@@ -162,7 +191,7 @@ dmareq(dq)
register int s = splbio();
chan = dq->dq_ctlr;
- i = NDMA;
+ i = NDMACHAN;
while (--i >= 0) {
if ((chan & (1 << i)) == 0)
continue;
@@ -173,7 +202,7 @@ dmareq(dq)
splx(s);
return(1);
}
- insque(dq, dmachan[NDMA].dq_back);
+ insque(dq, dmachan[NDMACHAN].dq_back);
splx(s);
return(0);
}
@@ -183,7 +212,8 @@ dmafree(dq)
register struct devqueue *dq;
{
int unit = dq->dq_ctlr;
- register struct dma_softc *dc = &dma_softc[unit];
+ struct dma_softc *sc = &Dma_softc;
+ register struct dma_channel *dc = &sc->sc_chan[unit];
register struct devqueue *dn;
register int chan, s;
@@ -196,13 +226,13 @@ dmafree(dq)
/*
* XXX we may not always go thru the flush code in dmastop()
*/
- if (dc->sc_flags & DMAF_PCFLUSH) {
+ if (dc->dm_flags & DMAF_PCFLUSH) {
PCIA();
- dc->sc_flags &= ~DMAF_PCFLUSH;
+ dc->dm_flags &= ~DMAF_PCFLUSH;
}
#endif
#if defined(HP320) || defined(HP350)
- if (dc->sc_flags & DMAF_VCFLUSH) {
+ if (dc->dm_flags & DMAF_VCFLUSH) {
/*
* 320/350s have VACs that may also need flushing.
* In our case we only flush the supervisor side
@@ -213,13 +243,13 @@ dmafree(dq)
* mapping.
*/
DCIS();
- dc->sc_flags &= ~DMAF_VCFLUSH;
+ dc->dm_flags &= ~DMAF_VCFLUSH;
}
#endif
remque(dq);
chan = 1 << unit;
- for (dn = dmachan[NDMA].dq_forw;
- dn != &dmachan[NDMA]; dn = dn->dq_forw) {
+ 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);
@@ -239,7 +269,8 @@ dmago(unit, addr, count, flags)
register int count;
register int flags;
{
- register struct dma_softc *dc = &dma_softc[unit];
+ 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;
@@ -247,7 +278,7 @@ dmago(unit, addr, count, flags)
if (count > MAXPHYS)
panic("dmago: count > MAXPHYS");
#if defined(HP320)
- if (dc->sc_type == DMA_B && (flags & DMAGO_LWORD))
+ if (sc->sc_type == DMA_B && (flags & DMAGO_LWORD))
panic("dmago: no can do 32-bit DMA");
#endif
#ifdef DEBUG
@@ -264,7 +295,7 @@ dmago(unit, addr, count, flags)
/*
* Build the DMA chain
*/
- for (dcp = dc->sc_chain; count > 0; dcp++) {
+ for (dcp = dc->dm_chain; count > 0; dcp++) {
dcp->dc_addr = (char *) kvtop(addr);
#if defined(HP380)
/*
@@ -285,7 +316,7 @@ dmago(unit, addr, count, flags)
if (dcp->dc_addr == dmaend
#if defined(HP320)
/* only 16-bit count on 98620B */
- && (dc->sc_type != DMA_B ||
+ && (sc->sc_type != DMA_B ||
(dcp-1)->dc_count + tcount <= 65536)
#endif
) {
@@ -302,21 +333,21 @@ dmago(unit, addr, count, flags)
dcp->dc_count = tcount;
}
}
- dc->sc_cur = dc->sc_chain;
- dc->sc_last = --dcp;
- dc->sc_flags = 0;
+ dc->dm_cur = dc->dm_chain;
+ dc->dm_last = --dcp;
+ dc->dm_flags = 0;
/*
* Set up the command word based on flags
*/
- dc->sc_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START;
+ dc->dm_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START;
if ((flags & DMAGO_READ) == 0)
- dc->sc_cmd |= DMA_WRT;
+ dc->dm_cmd |= DMA_WRT;
if (flags & DMAGO_LWORD)
- dc->sc_cmd |= DMA_LWORD;
+ dc->dm_cmd |= DMA_LWORD;
else if (flags & DMAGO_WORD)
- dc->sc_cmd |= DMA_WORD;
+ dc->dm_cmd |= DMA_WORD;
if (flags & DMAGO_PRI)
- dc->sc_cmd |= DMA_PRI;
+ dc->dm_cmd |= DMA_PRI;
#if defined(HP380)
/*
* On the 68040 we need to flush (push) the data cache before a
@@ -326,7 +357,7 @@ dmago(unit, addr, count, flags)
* involved in the DMA we might purge some valid data.
*/
if (mmutype == MMU_68040 && (flags & DMAGO_READ))
- dc->sc_flags |= DMAF_PCFLUSH;
+ dc->dm_flags |= DMAF_PCFLUSH;
#endif
#if defined(HP360) || defined(HP370)
/*
@@ -334,30 +365,30 @@ dmago(unit, addr, count, flags)
* DMA is done. We only do this if we are reading (writing memory).
*/
if (ectype == EC_PHYS && (flags & DMAGO_READ))
- dc->sc_flags |= DMAF_PCFLUSH;
+ dc->dm_flags |= DMAF_PCFLUSH;
#endif
#if defined(HP320) || defined(HP350)
if (ectype == EC_VIRT && (flags & DMAGO_READ))
- dc->sc_flags |= DMAF_VCFLUSH;
+ dc->dm_flags |= DMAF_VCFLUSH;
#endif
/*
* Remember if we can skip the dma completion interrupt on
* the last segment in the chain.
*/
if (flags & DMAGO_NOINT) {
- if (dc->sc_cur == dc->sc_last)
- dc->sc_cmd &= ~DMA_ENAB;
+ if (dc->dm_cur == dc->dm_last)
+ dc->dm_cmd &= ~DMA_ENAB;
else
- dc->sc_flags |= DMAF_NOINTR;
+ dc->dm_flags |= DMAF_NOINTR;
}
#ifdef DEBUG
if (dmadebug & DDB_IO)
- if ((dmadebug&DDB_WORD) && (dc->sc_cmd&DMA_WORD) ||
- (dmadebug&DDB_LWORD) && (dc->sc_cmd&DMA_LWORD)) {
+ 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->sc_cmd, dc->sc_flags);
- for (dcp = dc->sc_chain; dcp <= dc->sc_last; dcp++)
- printf(" %d: %d@%x\n", dcp-dc->sc_chain,
+ 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);
}
dmatimo[unit] = 1;
@@ -369,7 +400,8 @@ void
dmastop(unit)
register int unit;
{
- register struct dma_softc *dc = &dma_softc[unit];
+ struct dma_softc *sc = &Dma_softc;
+ register struct dma_channel *dc = &sc->sc_chan[unit];
register struct devqueue *dq;
#ifdef DEBUG
@@ -379,13 +411,13 @@ dmastop(unit)
#endif
DMA_CLEAR(dc);
#if defined(HP360) || defined(HP370) || defined(HP380)
- if (dc->sc_flags & DMAF_PCFLUSH) {
+ if (dc->dm_flags & DMAF_PCFLUSH) {
PCIA();
- dc->sc_flags &= ~DMAF_PCFLUSH;
+ dc->dm_flags &= ~DMAF_PCFLUSH;
}
#endif
#if defined(HP320) || defined(HP350)
- if (dc->sc_flags & DMAF_VCFLUSH) {
+ if (dc->dm_flags & DMAF_VCFLUSH) {
/*
* 320/350s have VACs that may also need flushing.
* In our case we only flush the supervisor side
@@ -396,7 +428,7 @@ dmastop(unit)
* mapping.
*/
DCIS();
- dc->sc_flags &= ~DMAF_VCFLUSH;
+ dc->dm_flags &= ~DMAF_VCFLUSH;
}
#endif
/*
@@ -412,7 +444,8 @@ dmastop(unit)
int
dmaintr()
{
- register struct dma_softc *dc;
+ struct dma_softc *sc = &Dma_softc;
+ register struct dma_channel *dc;
register int i, stat;
int found = 0;
@@ -420,31 +453,33 @@ dmaintr()
if (dmadebug & DDB_FOLLOW)
printf("dmaintr\n");
#endif
- for (i = 0, dc = dma_softc; i < NDMA; i++, dc++) {
+ for (i = 0; i < NDMACHAN; i++) {
+ dc = &sc->sc_chan[i];
stat = DMA_STAT(dc);
if ((stat & DMA_INTR) == 0)
continue;
found++;
#ifdef DEBUG
if (dmadebug & DDB_IO) {
- if ((dmadebug&DDB_WORD) && (dc->sc_cmd&DMA_WORD) ||
- (dmadebug&DDB_LWORD) && (dc->sc_cmd&DMA_LWORD))
+ 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->sc_cur-dc->sc_chain)+1);
+ i, stat, (dc->dm_cur-dc->dm_chain)+1);
}
if (stat & DMA_ARMED)
- printf("dma%d: intr when armed\n", i);
+ printf("%s, chan %d: intr when armed\n",
+ sc->sc_xname, i);
#endif
- if (++dc->sc_cur <= dc->sc_last) {
+ if (++dc->dm_cur <= dc->dm_last) {
#ifdef DEBUG
dmatimo[i] = 1;
#endif
/*
* Last chain segment, disable DMA interrupt.
*/
- if (dc->sc_cur == dc->sc_last &&
- (dc->sc_flags & DMAF_NOINTR))
- dc->sc_cmd &= ~DMA_ENAB;
+ if (dc->dm_cur == dc->dm_last &&
+ (dc->dm_flags & DMAF_NOINTR))
+ dc->dm_cmd &= ~DMA_ENAB;
DMA_CLEAR(dc);
DMA_ARM(dc);
} else
@@ -459,17 +494,18 @@ dmatimeout(arg)
void *arg;
{
register int i, s;
+ struct dma_softc *sc = arg;
- for (i = 0; i < NDMA; i++) {
+ for (i = 0; i < NDMACHAN; i++) {
s = splbio();
if (dmatimo[i]) {
if (dmatimo[i] > 1)
- printf("dma%d: timeout #%d\n",
+ printf("%s: timeout #%d\n", sc->sc_xname,
i, dmatimo[i]-1);
dmatimo[i]++;
}
splx(s);
}
- timeout(dmatimeout, (void *)0, 30 * hz);
+ timeout(dmatimeout, sc, 30 * hz);
}
#endif
diff --git a/sys/arch/hp300/dev/dmareg.h b/sys/arch/hp300/dev/dmareg.h
index acd29276a64..3a6ae6538f9 100644
--- a/sys/arch/hp300/dev/dmareg.h
+++ b/sys/arch/hp300/dev/dmareg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: dmareg.h,v 1.5 1995/03/28 18:15:59 jtc Exp $ */
+/* $NetBSD: dmareg.h,v 1.6 1995/12/02 02:46:49 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -70,7 +70,8 @@ struct dmareg {
struct dmadevice dma_chan1;
};
-#define NDMA 2
+/* The hp300 has 2 DMA channels. */
+#define NDMACHAN 2
/* intr level must be >= level of any device using dma. i.e., splbio */
#define DMAINTLVL 5
@@ -110,29 +111,29 @@ struct dmareg {
* look at the 98620C status to get the extended bits.
* DMA_ARM: Load address, count and kick-off DMA.
*/
-#define DMA_CLEAR(dc) { v_int dmaclr = (int)dc->sc_Bhwaddr->dmaB_addr; }
-#define DMA_STAT(dc) dc->sc_Bhwaddr->dmaB_stat
+#define DMA_CLEAR(dc) { v_int dmaclr = (int) dc->dm_Bhwaddr->dmaB_addr; }
+#define DMA_STAT(dc) dc->dm_Bhwaddr->dmaB_stat
#if defined(HP320)
#define DMA_ARM(dc) \
- if (dc->sc_type == DMA_B) { \
- register struct dmaBdevice *dma = dc->sc_Bhwaddr; \
- dma->dmaB_addr = dc->sc_cur->dc_addr; \
- dma->dmaB_count = dc->sc_cur->dc_count - 1; \
- dma->dmaB_cmd = dc->sc_cmd; \
+ 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_cmd = dc->dm_cmd; \
} else { \
- register struct dmadevice *dma = dc->sc_hwaddr; \
- dma->dma_addr = dc->sc_cur->dc_addr; \
- dma->dma_count = dc->sc_cur->dc_count - 1; \
- dma->dma_cmd = dc->sc_cmd; \
+ 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_cmd = dc->dm_cmd; \
}
#else
#define DMA_ARM(dc) \
{ \
- register struct dmadevice *dma = dc->sc_hwaddr; \
- dma->dma_addr = dc->sc_cur->dc_addr; \
- dma->dma_count = dc->sc_cur->dc_count - 1; \
- dma->dma_cmd = dc->sc_cmd; \
+ 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_cmd = dc->dm_cmd; \
}
#endif
#endif
diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c
index 9cae78f1226..53e85c7e5f9 100644
--- a/sys/arch/hp300/dev/fhpib.c
+++ b/sys/arch/hp300/dev/fhpib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fhpib.c,v 1.6 1995/01/07 10:30:10 mycroft Exp $ */
+/* $NetBSD: fhpib.c,v 1.8 1995/12/02 18:21:56 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -79,6 +79,30 @@ long fhpibppollfail[NHPIB] = { 0 };
int fhpibcmd[NHPIB];
+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 fhpibppwatch __P((void *));
+void fhpibgo __P((int, int, int, void *, int, int, int));
+void fhpibdone __P((int));
+int fhpibintr __P((int));
+
+/*
+ * Our controller ops structure.
+ */
+struct hpib_controller fhpib_controller = {
+ fhpibreset,
+ fhpibsend,
+ fhpibrecv,
+ fhpibppoll,
+ fhpibppwatch,
+ fhpibgo,
+ fhpibdone,
+ fhpibintr
+};
+
+int
fhpibtype(hc)
register struct hp_ctlr *hc;
{
@@ -86,13 +110,30 @@ fhpibtype(hc)
register struct fhpibdevice *hd = (struct fhpibdevice *)hc->hp_addr;
if (hd->hpib_cid != HPIBC)
- return(0);
+ return (0);
+
hs->sc_type = HPIBC;
- hs->sc_ba = HPIBC_BA;
hc->hp_ipl = HPIB_IPL(hd->hpib_ids);
- return(1);
+
+ return (1);
}
+void
+fhpibattach(hc)
+ struct hp_ctlr *hc;
+{
+ register struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
+
+ if (hs->sc_type != HPIBC)
+ panic("fhpibattach: unknown type 0x%x", hs->sc_type);
+ /* NOTREACHED */
+
+ hs->sc_ba = HPIBC_BA;
+ hs->sc_descrip = "98625A or 98625B fast HP-IB";
+ hs->sc_controller = &fhpib_controller;
+}
+
+void
fhpibreset(unit)
int unit;
{
@@ -135,14 +176,16 @@ fhpibifc(hd)
hd->hpib_stat = ST_ATN;
}
-fhpibsend(unit, slave, sec, addr, origcnt)
+int
+fhpibsend(unit, slave, sec, ptr, origcnt)
int unit, slave, sec, origcnt;
- register char *addr;
+ void *ptr;
{
register struct hpib_softc *hs = &hpib_softc[unit];
register struct fhpibdevice *hd;
register int cnt = origcnt;
register int timo;
+ char *addr = ptr;
hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_stat = 0;
@@ -189,22 +232,24 @@ senderr:
fhpibifc(hd);
#ifdef DEBUG
if (fhpibdebug & FDB_FAIL) {
- printf("hpib%d: fhpibsend failed: slave %d, sec %x, ",
- unit, slave, sec);
+ printf("%s: fhpibsend failed: slave %d, sec %x, ",
+ hs->sc_hc->hp_xname, slave, sec);
printf("sent %d of %d bytes\n", origcnt-cnt-1, origcnt);
}
#endif
return (origcnt - cnt - 1);
}
-fhpibrecv(unit, slave, sec, addr, origcnt)
+int
+fhpibrecv(unit, slave, sec, ptr, origcnt)
int unit, slave, sec, origcnt;
- register char *addr;
+ void *ptr;
{
register struct hpib_softc *hs = &hpib_softc[unit];
register struct fhpibdevice *hd;
register int cnt = origcnt;
register int timo;
+ char *addr = ptr;
hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
/*
@@ -251,22 +296,23 @@ recvbyteserror:
hd->hpib_imask = 0;
#ifdef DEBUG
if (fhpibdebug & FDB_FAIL) {
- printf("hpib%d: fhpibrecv failed: slave %d, sec %x, ",
- unit, slave, sec);
+ printf("%s: fhpibrecv failed: slave %d, sec %x, ",
+ hs->sc_hc->hp_xname, slave, sec);
printf("got %d of %d bytes\n", origcnt-cnt-1, origcnt);
}
#endif
return (origcnt - cnt - 1);
}
-fhpibgo(unit, slave, sec, addr, count, rw, timo)
- register int unit;
- int slave, sec, count, rw;
- char *addr;
+void
+fhpibgo(unit, slave, sec, ptr, count, rw, timo)
+ int unit, slave, sec, count, rw, timo;
+ void *ptr;
{
register struct hpib_softc *hs = &hpib_softc[unit];
register struct fhpibdevice *hd;
register int i;
+ char *addr = ptr;
int flags = 0;
hd = (struct fhpibdevice *)hs->sc_hc->hp_addr;
@@ -381,6 +427,7 @@ fhpibdmadone(arg)
(void) splx(s);
}
+void
fhpibdone(unit)
int unit;
{
@@ -423,6 +470,7 @@ fhpibdone(unit)
hd->hpib_ie = IDS_IE;
}
+int
fhpibintr(unit)
register int unit;
{
@@ -437,8 +485,8 @@ fhpibintr(unit)
#ifdef DEBUG
if ((fhpibdebug & FDB_FAIL) && (stat0 & IDS_IR) &&
(hs->sc_flags & (HPIBF_IO|HPIBF_DONE)) != HPIBF_IO)
- printf("hpib%d: fhpibintr: bad status %x\n",
- unit, stat0);
+ printf("%s: fhpibintr: bad status %x\n",
+ hs->sc_hc->hp_xname, stat0);
fhpibbadint[0]++;
#endif
return(0);
@@ -471,8 +519,8 @@ fhpibintr(unit)
#ifdef DEBUG
if ((fhpibdebug & FDB_FAIL) &&
doppollint && (stat0 & IM_PPRESP) == 0)
- printf("hpib%d: fhpibintr: bad intr reg %x\n",
- unit, stat0);
+ printf("%s: fhpibintr: bad intr reg %x\n",
+ hs->sc_hc->hp_xname, stat0);
#endif
hd->hpib_stat = 0;
hd->hpib_imask = 0;
@@ -499,6 +547,7 @@ fhpibintr(unit)
return(1);
}
+int
fhpibppoll(unit)
int unit;
{
@@ -521,6 +570,7 @@ fhpibppoll(unit)
return(ppoll);
}
+int
fhpibwait(hd, x)
register struct fhpibdevice *hd;
int x;
@@ -576,4 +626,4 @@ fhpibppwatch(arg)
hd->hpib_imask = IM_PPRESP | IM_PABORT;
hd->hpib_ie = IDS_IE;
}
-#endif
+#endif /* NHPIB > 0 */
diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c
index 15f34e180a7..9594ded7fe0 100644
--- a/sys/arch/hp300/dev/grf.c
+++ b/sys/arch/hp300/dev/grf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: grf.c,v 1.14 1995/04/22 20:25:42 christos Exp $ */
+/* $NetBSD: grf.c,v 1.16 1995/11/28 08:14:30 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -66,7 +66,7 @@
#include <machine/cpu.h>
#ifdef COMPAT_HPUX
-#include <hp300/hpux/hpux.h>
+#include <compat/hpux/hpux.h>
extern struct emul emul_hpux;
#endif
@@ -77,7 +77,7 @@ extern struct emul emul_hpux;
#include <miscfs/specfs/specdev.h>
-#include <ite.h>
+#include "ite.h"
#if NITE == 0
#define iteon(u,f)
#define iteoff(u,f)
diff --git a/sys/arch/hp300/dev/grf_machdep.c b/sys/arch/hp300/dev/grf_machdep.c
index 3e6d0244b92..9a97a65e38c 100644
--- a/sys/arch/hp300/dev/grf_machdep.c
+++ b/sys/arch/hp300/dev/grf_machdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: grf_machdep.c,v 1.2 1994/10/26 07:23:59 cgd Exp $ */
+/* $NetBSD: grf_machdep.c,v 1.3 1995/12/02 18:21:58 thorpej Exp $ */
/*
* Copyright (c) 1991 University of Utah.
@@ -57,8 +57,9 @@
#include <hp300/dev/grfvar.h>
#include <hp300/dev/grfreg.h>
-int grfprobe();
-struct driver grfdriver = { grfprobe, "grf" };
+int grfmatch();
+void grfattach();
+struct driver grfdriver = { grfmatch, grfattach, "grf" };
/*
* XXX called from ite console init routine.
@@ -109,22 +110,32 @@ grfconfig()
/*
* Normal init routine called by configure() code
*/
-grfprobe(hd)
+int
+grfmatch(hd)
struct hp_device *hd;
{
struct grf_softc *gp = &grf_softc[hd->hp_unit];
if ((gp->g_flags & GF_ALIVE) == 0 &&
!grfinit(hd->hp_addr, hd->hp_unit))
- return(0);
- printf("grf%d: %d x %d ", hd->hp_unit,
- gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
+ return (0);
+
+ return(1);
+}
+
+void
+grfattach(hd)
+ struct hp_device *hd;
+{
+ struct grf_softc *gp = &grf_softc[hd->hp_unit];
+
+ 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\n", gp->g_sw->gd_desc);
- return(1);
}
grfinit(addr, unit)
diff --git a/sys/arch/hp300/dev/hil.c b/sys/arch/hp300/dev/hil.c
index 65d32dd9951..e29e171d7e0 100644
--- a/sys/arch/hp300/dev/hil.c
+++ b/sys/arch/hp300/dev/hil.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hil.c,v 1.19 1995/04/22 20:25:45 christos Exp $ */
+/* $NetBSD: hil.c,v 1.20 1995/12/02 02:48:47 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -72,7 +72,7 @@
#include "hil.h"
#endif
-struct hilloop hilloop[NHIL];
+struct hil_softc hil_softc[NHIL];
struct _hilbell default_bell = { BELLDUR, BELLFREQ };
#ifdef hp800
int hilspl;
@@ -100,7 +100,7 @@ hilsoftinit(unit, hilbase)
int unit;
struct hil_dev *hilbase;
{
- register struct hilloop *hilp = &hilloop[unit];
+ register struct hil_softc *hilp = &hil_softc[unit];
register int i;
#ifdef DEBUG
@@ -136,7 +136,7 @@ hilinit(unit, hilbase)
int unit;
struct hil_dev *hilbase;
{
- register struct hilloop *hilp = &hilloop[unit];
+ register struct hil_softc *hilp = &hil_softc[unit];
#ifdef DEBUG
if (hildebug & HDB_FOLLOW)
printf("hilinit(%d, %x)\n", unit, hilbase);
@@ -161,7 +161,7 @@ hilopen(dev, flags, mode, p)
int flags, mode;
struct proc *p;
{
- register struct hilloop *hilp = &hilloop[HILLOOP(dev)];
+ register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)];
register struct hilloopdev *dptr;
u_char device = HILUNIT(dev);
@@ -239,7 +239,7 @@ hilclose(dev, flags, mode, p)
int flags, mode;
struct proc *p;
{
- register struct hilloop *hilp = &hilloop[HILLOOP(dev)];
+ register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)];
register struct hilloopdev *dptr;
register int i;
u_char device = HILUNIT(dev);
@@ -263,7 +263,7 @@ hilclose(dev, flags, mode, p)
if (device == 0) {
for (i = 0; i < NHILQ; i++)
if (hilp->hl_queue[i].hq_procp == p)
- (void) hilqfree(hilp, i);
+ (void) hilqfree(hilp, i, p);
} else {
mask = ~hildevmask(device);
(void) splhil();
@@ -320,7 +320,7 @@ hilread(dev, uio)
dev_t dev;
register struct uio *uio;
{
- struct hilloop *hilp = &hilloop[HILLOOP(dev)];
+ struct hil_softc *hilp = &hil_softc[HILLOOP(dev)];
register struct hilloopdev *dptr;
register int cc;
u_char device = HILUNIT(dev);
@@ -373,7 +373,7 @@ hilioctl(dev, cmd, data, flag, p)
caddr_t data;
struct proc *p;
{
- register struct hilloop *hilp = &hilloop[HILLOOP(dev)];
+ register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)];
char device = HILUNIT(dev);
struct hilloopdev *dptr;
register int i;
@@ -503,19 +503,19 @@ hilioctl(dev, cmd, data, flag, p)
break;
case HILIOCALLOCQ:
- error = hilqalloc(hilp, (struct hilqinfo *)data);
+ error = hilqalloc(hilp, (struct hilqinfo *)data, p);
break;
case HILIOCFREEQ:
- error = hilqfree(hilp, ((struct hilqinfo *)data)->qid);
+ error = hilqfree(hilp, ((struct hilqinfo *)data)->qid, p);
break;
case HILIOCMAPQ:
- error = hilqmap(hilp, *(int *)data, device);
+ error = hilqmap(hilp, *(int *)data, device, p);
break;
case HILIOCUNMAPQ:
- error = hilqunmap(hilp, *(int *)data, device);
+ error = hilqunmap(hilp, *(int *)data, device, p);
break;
case HILIOCHPUX:
@@ -550,7 +550,7 @@ hpuxhilioctl(dev, cmd, data, flag)
int cmd, flag;
caddr_t data;
{
- register struct hilloop *hilp = &hilloop[HILLOOP(dev)];
+ register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)];
char device = HILUNIT(dev);
struct hilloopdev *dptr;
register int i;
@@ -684,7 +684,7 @@ hilselect(dev, rw, p)
int rw;
struct proc *p;
{
- register struct hilloop *hilp = &hilloop[HILLOOP(dev)];
+ register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)];
register struct hilloopdev *dptr;
register struct hiliqueue *qp;
register int mask;
@@ -749,9 +749,9 @@ hilint(unit)
int unit;
{
#ifdef hp300
- struct hilloop *hilp = &hilloop[0]; /* XXX how do we know on 300? */
+ struct hil_softc *hilp = &hil_softc[0]; /* XXX how do we know on 300? */
#else
- struct hilloop *hilp = &hilloop[unit];
+ struct hil_softc *hilp = &hil_softc[unit];
#endif
register struct hil_dev *hildevice = hilp->hl_addr;
u_char c, stat;
@@ -764,7 +764,7 @@ hilint(unit)
#include "ite.h"
hil_process_int(hilp, stat, c)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
register u_char stat, c;
{
#ifdef DEBUG
@@ -844,7 +844,7 @@ hil_process_int(hilp, stat, c)
((eq)->size == HEVQSIZE && (eq)->tail >= 0 && (eq)->tail < HEVQSIZE)
hilevent(hilp)
- struct hilloop *hilp;
+ struct hil_softc *hilp;
{
register struct hilloopdev *dptr = &hilp->hl_device[hilp->hl_actdev];
register int len, mask, qnum;
@@ -953,7 +953,7 @@ hilevent(hilp)
#undef HQFULL
hpuxhilevent(hilp, dptr)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
register struct hilloopdev *dptr;
{
register int len;
@@ -996,11 +996,11 @@ hpuxhilevent(hilp, dptr)
* Shared queue manipulation routines
*/
-hilqalloc(hilp, qip)
- register struct hilloop *hilp;
+hilqalloc(hilp, qip, p)
+ register struct hil_softc *hilp;
struct hilqinfo *qip;
+ struct proc *p;
{
- struct proc *p = curproc; /* XXX */
#ifdef DEBUG
if (hildebug & HDB_FOLLOW)
@@ -1009,11 +1009,10 @@ hilqalloc(hilp, qip)
return(EINVAL);
}
-hilqfree(hilp, qnum)
- register struct hilloop *hilp;
+hilqfree(hilp, qnum, p)
+ register struct hil_softc *hilp;
register int qnum;
{
- struct proc *p = curproc; /* XXX */
#ifdef DEBUG
if (hildebug & HDB_FOLLOW)
@@ -1022,11 +1021,11 @@ hilqfree(hilp, qnum)
return(EINVAL);
}
-hilqmap(hilp, qnum, device)
- register struct hilloop *hilp;
+hilqmap(hilp, qnum, device, p)
+ register struct hil_softc *hilp;
register int qnum, device;
+ struct proc *p;
{
- struct proc *p = curproc; /* XXX */
register struct hilloopdev *dptr = &hilp->hl_device[device];
int s;
@@ -1058,11 +1057,11 @@ hilqmap(hilp, qnum, device)
return(0);
}
-hilqunmap(hilp, qnum, device)
- register struct hilloop *hilp;
+hilqunmap(hilp, qnum, device, p)
+ register struct hil_softc *hilp;
register int qnum, device;
+ struct proc *p;
{
- struct proc *p = curproc; /* XXX */
int s;
#ifdef DEBUG
@@ -1096,7 +1095,7 @@ hilqunmap(hilp, qnum, device)
kbdbell(unit)
int unit;
{
- struct hilloop *hilp = &hilloop[unit];
+ struct hil_softc *hilp = &hil_softc[unit];
hilbeep(hilp, &default_bell);
}
@@ -1104,7 +1103,7 @@ kbdbell(unit)
kbdenable(unit)
int unit;
{
- struct hilloop *hilp = &hilloop[unit];
+ struct hil_softc *hilp = &hil_softc[unit];
register struct hil_dev *hildevice = hilp->hl_addr;
char db;
@@ -1133,7 +1132,7 @@ kbddisable(unit)
kbdgetc(unit, statp)
int unit, *statp;
{
- struct hilloop *hilp = &hilloop[unit];
+ struct hil_softc *hilp = &hil_softc[unit];
register struct hil_dev *hildevice = hilp->hl_addr;
register int c, stat;
int s;
@@ -1160,9 +1159,9 @@ kbdnmi(unit)
int unit;
{
#ifdef hp300
- struct hilloop *hilp = &hilloop[0]; /* XXX how do we know on 300? */
+ struct hil_softc *hilp = &hil_softc[0]; /* XXX how do we know on 300? */
#else
- struct hilloop *hilp = &hilloop[unit];
+ struct hil_softc *hilp = &hil_softc[unit];
#endif
#ifdef hp300
if ((*KBDNMISTAT & KBDNMI) == 0)
@@ -1186,7 +1185,7 @@ kbdnmi(unit)
hilinfo(unit)
int unit;
{
- register struct hilloop *hilp = &hilloop[unit];
+ register struct hil_softc *hilp = &hil_softc[unit];
register int id, len;
register struct kbdmap *km;
@@ -1244,7 +1243,7 @@ hilinfo(unit)
* we prefer to just assume people won't move things around.
*/
hilconfig(hilp)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
{
u_char db;
int s;
@@ -1348,7 +1347,7 @@ hilconfig(hilp)
}
hilreset(hilp)
- struct hilloop *hilp;
+ struct hil_softc *hilp;
{
register struct hil_dev *hildevice = hilp->hl_addr;
u_char db;
@@ -1388,7 +1387,7 @@ hilreset(hilp)
}
hilbeep(hilp, bp)
- struct hilloop *hilp;
+ struct hil_softc *hilp;
register struct _hilbell *bp;
{
u_char buf[2];
@@ -1402,7 +1401,7 @@ hilbeep(hilp, bp)
* Locate and return the address of the first ID module, 0 if none present.
*/
hiliddev(hilp)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
{
register int i, len;
@@ -1510,7 +1509,7 @@ send_hil_cmd(hildevice, cmd, data, dlen, rdata)
* splimp (clock only interrupts) seems to be good enough in practice.
*/
send_hildev_cmd(hilp, device, cmd)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
char device, cmd;
{
register struct hil_dev *hildevice = hilp->hl_addr;
@@ -1614,7 +1613,7 @@ pollon(hildevice)
#ifdef DEBUG
printhilpollbuf(hilp)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
{
register u_char *cp;
register int i, len;
@@ -1627,7 +1626,7 @@ printhilpollbuf(hilp)
}
printhilcmdbuf(hilp)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
{
register u_char *cp;
register int i, len;
@@ -1640,7 +1639,7 @@ printhilcmdbuf(hilp)
}
hilreport(hilp)
- register struct hilloop *hilp;
+ register struct hil_softc *hilp;
{
register int i, len;
int s = splhil();
diff --git a/sys/arch/hp300/dev/hil_keymaps.c b/sys/arch/hp300/dev/hil_keymaps.c
index e3d87394c70..03f8174dc95 100644
--- a/sys/arch/hp300/dev/hil_keymaps.c
+++ b/sys/arch/hp300/dev/hil_keymaps.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hil_keymaps.c,v 1.5 1994/10/26 07:24:13 cgd Exp $ */
+/* $NetBSD: hil_keymaps.c,v 1.6 1995/12/06 22:13:23 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -238,6 +238,84 @@ char uk_ctrlshiftmap[] = {
};
#endif
+#ifdef SE_KEYBOARD
+char se_keymap[] = {
+ NULL, '<', '\'', ESC, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', 'E', '(', ')', '^',
+ '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', '+', '`', '}', '~', '|', '{',
+ ',', '.', '-', '\040', 'o', 'p', 'k', 'l',
+ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
+ 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm',
+ 'z', 'x', 'c', 'v', 'b', 'n', NULL, NULL
+};
+
+char se_shiftmap[] = {
+ NULL, '>', '*', DEL, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '-', '`', '*', '\\', '>',
+ '!', '\"', '#', '$', '%', '&', '/', '(',
+ ')', '=', '?', '@', ']', '^', '\\', '[',
+ ';', ':', '_', '\040', 'O', 'P', 'K', 'L',
+ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
+ 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M',
+ 'Z', 'X', 'C', 'V', 'B', 'N', NULL, NULL
+};
+
+char se_ctrlmap[] = {
+ NULL, '`', '\034', ESC, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', 'E', '(', ')', '\036',
+ '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', '-', '=', '\033', '\035', ';', '\'',
+ ',', '.', '/', '\040', '\017', '\020', '\013', '\014',
+ '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011',
+ '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015',
+ '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL
+};
+
+char se_ctrlshiftmap[] = {
+ NULL, '~', '|', DEL, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', '`', '|', '\034', '~',
+ '!', '\000', '#', '$', '%', '\036', '&', '*',
+ '(', ')', '\037', '+', '{', '}', ':', '\"',
+ '<', '>', '?', '\040', '\017', '\020', '\013', '\014',
+ '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011',
+ '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015',
+ '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL
+};
+#endif
+
/*
* The keyboard map table.
* Lookup is by hardware returned language code.
@@ -253,6 +331,12 @@ struct kbdmap kbd_map[] = {
us_stringmap,
#endif
+#ifdef SE_KEYBOARD
+ KBD_SE, "Swedish",
+ se_keymap, se_shiftmap, se_ctrlmap, se_ctrlshiftmap,
+ us_stringmap,
+#endif
+
0, NULL,
NULL, NULL, NULL, NULL,
NULL,
diff --git a/sys/arch/hp300/dev/hilvar.h b/sys/arch/hp300/dev/hilvar.h
index a295d52a0d8..078268a514a 100644
--- a/sys/arch/hp300/dev/hilvar.h
+++ b/sys/arch/hp300/dev/hilvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hilvar.h,v 1.8 1994/10/26 07:24:16 cgd Exp $ */
+/* $NetBSD: hilvar.h,v 1.11 1995/12/11 19:41:47 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -95,7 +95,7 @@ struct hilloopdev {
#define HIL_ASLEEP 0x40 /* process awaiting input on device */
#define HIL_DERROR 0x80 /* loop has reconfigured, reality altered */
-struct hilloop {
+struct hil_softc {
struct hil_dev *hl_addr; /* base of hardware registers */
u_char hl_cmddone; /* */
u_char hl_cmdending; /* */
diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c
index 708a3f8fdd8..c6819ddc5bd 100644
--- a/sys/arch/hp300/dev/hpib.c
+++ b/sys/arch/hp300/dev/hpib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hpib.c,v 1.5 1995/01/07 10:30:12 mycroft Exp $ */
+/* $NetBSD: hpib.c,v 1.7 1995/12/02 18:22:01 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -52,47 +52,107 @@
#include <machine/cpu.h>
#include <hp300/hp300/isr.h>
-int hpibinit(), hpibstart(), hpibgo(), hpibintr(), hpibdone();
+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((int));
+
struct driver hpibdriver = {
- hpibinit, "hpib", hpibstart, hpibgo, hpibintr, hpibdone,
+ hpibmatch,
+ hpibattach,
+ "hpib",
+ (int(*)())hpibstart, /* XXX */
+ (int(*)())hpibgo, /* XXX */
+ hpibintr,
+ (int(*)())hpibdone, /* XXX */
};
struct hpib_softc hpib_softc[NHPIB];
struct isr hpib_isr[NHPIB];
-int nhpibppoll(), fhpibppoll();
+
+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 */
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 */
-hpibinit(hc)
+int
+hpibmatch(hc)
register struct hp_ctlr *hc;
{
- register struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
-
- if (!nhpibtype(hc) && !fhpibtype(hc))
- return(0);
+ 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);
+}
+
+void
+hpibattach(hc)
+ struct hp_ctlr *hc;
+{
+ struct hpib_softc *hs = &hpib_softc[hc->hp_unit];
+
+ /*
+ * Call the appropriate "attach" routine for this controller.
+ * The type is set in the "type" routine.
+ */
+ 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 */
+ }
+
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;
+
+ /* Establish the interrupt handler. */
hpib_isr[hc->hp_unit].isr_intr = hpibintr;
hpib_isr[hc->hp_unit].isr_ipl = hc->hp_ipl;
hpib_isr[hc->hp_unit].isr_arg = hc->hp_unit;
isrlink(&hpib_isr[hc->hp_unit]);
+
+ /* Reset the controller, display what we've seen, and we're done. */
hpibreset(hc->hp_unit);
- return(1);
+ printf(": %s\n", hs->sc_descrip);
}
+void
hpibreset(unit)
register int unit;
{
- if (hpib_softc[unit].sc_type == HPIBC)
- fhpibreset(unit);
- else
- nhpibreset(unit);
+
+ (hpib_softc[unit].sc_controller->hpib_reset)(unit);
}
+int
hpibreq(dq)
register struct devqueue *dq;
{
@@ -105,6 +165,7 @@ hpibreq(dq)
return(0);
}
+void
hpibfree(dq)
register struct devqueue *dq;
{
@@ -116,6 +177,7 @@ hpibfree(dq)
(dq->dq_driver->d_start)(dq->dq_unit);
}
+int
hpibid(unit, slave)
int unit, slave;
{
@@ -134,36 +196,37 @@ hpibid(unit, slave)
return(id);
}
+int
hpibsend(unit, slave, sec, addr, cnt)
- register int unit;
- int slave, sec, addr, cnt;
+ int unit, slave, sec, cnt;
+ void *addr;
{
- if (hpib_softc[unit].sc_type == HPIBC)
- return(fhpibsend(unit, slave, sec, addr, cnt));
- else
- return(nhpibsend(unit, slave, sec, addr, cnt));
+
+ return ((hpib_softc[unit].sc_controller->hpib_send)(unit, slave,
+ sec, addr, cnt));
}
+int
hpibrecv(unit, slave, sec, addr, cnt)
- register int unit;
- int slave, sec, addr, cnt;
+ int unit, slave, sec, cnt;
+ void *addr;
{
- if (hpib_softc[unit].sc_type == HPIBC)
- return(fhpibrecv(unit, slave, sec, addr, cnt));
- else
- return(nhpibrecv(unit, slave, sec, addr, cnt));
+
+ return ((hpib_softc[unit].sc_controller->hpib_recv)(unit, slave,
+ sec, addr, cnt));
}
+int
hpibpptest(unit, slave)
register int unit;
int slave;
{
- int (*ppoll)();
- ppoll = (hpib_softc[unit].sc_type == HPIBC) ? fhpibppoll : nhpibppoll;
- return((*ppoll)(unit) & (0x80 >> slave));
+ return ((hpib_softc[unit].sc_controller->hpib_ppoll)(unit) &
+ (0x80 >> slave));
}
+void
hpibppclear(unit)
int unit;
{
@@ -176,29 +239,29 @@ hpibawait(unit)
register struct hpib_softc *hs = &hpib_softc[unit];
hs->sc_flags |= HPIBF_PPOLL;
- if (hs->sc_type == HPIBC)
- fhpibppwatch((void *)unit);
- else
- nhpibppwatch((void *)unit);
+ (hs->sc_controller->hpib_ppwatch)((void *)unit);
}
+int
hpibswait(unit, slave)
register int unit;
int slave;
{
register int timo = hpibtimeout;
- register int mask, (*ppoll)();
+ register int mask, (*ppoll) __P((int));
- ppoll = (hpib_softc[unit].sc_type == HPIBC) ? fhpibppoll : nhpibppoll;
+ ppoll = hpib_softc[unit].sc_controller->hpib_ppoll;
mask = 0x80 >> slave;
while (((ppoll)(unit) & mask) == 0)
if (--timo == 0) {
- printf("hpib%d: swait timeout\n", unit);
+ printf("%s: swait timeout\n",
+ hpib_softc[unit].sc_hc->hp_xname);
return(-1);
}
return(0);
}
+int
hpibustart(unit)
int unit;
{
@@ -213,6 +276,7 @@ hpibustart(unit)
return(0);
}
+void
hpibstart(unit)
int unit;
{
@@ -222,34 +286,29 @@ hpibstart(unit)
(dq->dq_driver->d_go)(dq->dq_unit);
}
+void
hpibgo(unit, slave, sec, addr, count, rw, timo)
- register int unit;
- int slave, sec, addr, count, rw;
+ int unit, slave, sec, count, rw, timo;
+ void *addr;
{
- if (hpib_softc[unit].sc_type == HPIBC)
- fhpibgo(unit, slave, sec, addr, count, rw, timo);
- else
- nhpibgo(unit, slave, sec, addr, count, rw, timo);
+
+ (hpib_softc[unit].sc_controller->hpib_go)(unit, slave, sec,
+ addr, count, rw, timo);
}
+void
hpibdone(unit)
register int unit;
{
- if (hpib_softc[unit].sc_type == HPIBC)
- fhpibdone(unit);
- else
- nhpibdone(unit);
+
+ (hpib_softc[unit].sc_controller->hpib_done)(unit);
}
+int
hpibintr(unit)
register int unit;
{
- int found;
- if (hpib_softc[unit].sc_type == HPIBC)
- found = fhpibintr(unit);
- else
- found = nhpibintr(unit);
- return(found);
+ return ((hpib_softc[unit].sc_controller->hpib_intr)(unit));
}
-#endif
+#endif /* NHPIB > 0 */
diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h
index f50b4ff7c07..4a2a67d9718 100644
--- a/sys/arch/hp300/dev/hpibvar.h
+++ b/sys/arch/hp300/dev/hpibvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hpibvar.h,v 1.6 1995/03/28 18:16:09 jtc Exp $ */
+/* $NetBSD: hpibvar.h,v 1.7 1995/11/19 17:57:18 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -66,8 +66,25 @@
#define C_UNT_P 0xdf /* with odd parity */
#define C_SCG 0x60 /* Secondary group commands */
+/*
+ * 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_ppwatch) __P((void *));
+ void (*hpib_go) __P((int, int, int, void *, int, int, int));
+ void (*hpib_done) __P((int));
+ int (*hpib_intr) __P((int));
+};
+
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;
@@ -91,6 +108,8 @@ extern struct hpib_softc hpib_softc[];
extern caddr_t internalhpib;
extern int hpibtimeout;
extern int hpibdmathresh;
-void fhpibppwatch __P((void *arg));
-void nhpibppwatch __P((void *arg));
+
+void hpibreset __P((int));
+int hpibsend __P((int, int, int, void *, int));
+int hpibrecv __P((int, int, int, void *, int));
#endif
diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c
index e62fcfd5803..c0bb48780da 100644
--- a/sys/arch/hp300/dev/if_le.c
+++ b/sys/arch/hp300/dev/if_le.c
@@ -1,8 +1,12 @@
-/* $NetBSD: if_le.c,v 1.22 1995/08/04 08:08:41 thorpej Exp $ */
+/* $NetBSD: if_le.c,v 1.24 1995/12/10 00:49:33 mycroft Exp $ */
-/*
- * Copyright (c) 1982, 1990 The Regents of the University of California.
- * All rights reserved.
+/*-
+ * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell and Rick Macklem.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,51 +36,28 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)if_le.c 7.6 (Berkeley) 5/8/91
+ * @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
-#include "le.h"
-#if NLE > 0
-
#include "bpfilter.h"
-/*
- * AMD 7990 LANCE
- */
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/kernel.h>
#include <sys/mbuf.h>
-#include <sys/buf.h>
-#include <sys/socket.h>
#include <sys/syslog.h>
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#include <sys/errno.h>
+#include <sys/socket.h>
+#include <sys/device.h>
#include <net/if.h>
-#include <net/netisr.h>
-#include <net/route.h>
-#if NBPFILTER > 0
-#include <net/bpf.h>
-#include <net/bpfdesc.h>
-#endif
#ifdef INET
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
#include <netinet/if_ether.h>
#endif
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
#include <machine/cpu.h>
#include <machine/mtpr.h>
+
#include <hp300/hp300/isr.h>
#ifdef USELEDS
#include <hp300/hp300/led.h>
@@ -84,71 +65,33 @@
#include <hp300/dev/device.h>
#include <hp300/dev/if_lereg.h>
+#include <hp300/dev/if_levar.h>
+#include <dev/ic/am7990reg.h>
+#define LE_NEED_BUF_CONTIG
+#include <dev/ic/am7990var.h>
+#include "le.h"
+struct le_softc le_softc[NLE];
-#define ETHER_MIN_LEN 64
-#define ETHER_MAX_LEN 1518
-#define ETHER_ADDR_LEN 6
-
-
-/* offsets for: ID, REGS, MEM, NVRAM */
-int lestd[] = { 0, 0x4000, 0x8000, 0xC008 };
-
-struct isr le_isr[NLE];
-
-/*
- * Ethernet software status per interface.
- *
- * Each interface is referenced by a network interface structure,
- * arpcom.ac_if, which the routing code uses to locate the interface.
- * This structure contains the output queue for the interface, its address, ...
- */
-struct le_softc {
- struct arpcom sc_arpcom; /* common Ethernet structures */
- struct lereg0 *sc_r0; /* DIO registers */
- struct lereg1 *sc_r1; /* LANCE registers */
- void *sc_mem;
- struct init_block *sc_init;
- struct mds *sc_rd, *sc_td;
- u_char *sc_rbuf, *sc_tbuf;
- int sc_last_rd, sc_last_td;
- int sc_no_td;
-#ifdef LEDEBUG
- int sc_debug;
-#endif
-} le_softc[NLE];
-
-int leintr __P((int));
-int leioctl __P((struct ifnet *, u_long, caddr_t));
-void lestart __P((struct ifnet *));
-void lewatchdog __P((int));
-static inline void lewrcsr __P((/* struct le_softc *, u_short, u_short */));
-static inline u_short lerdcsr __P((/* struct le_softc *, u_short */));
-void leinit __P((struct le_softc *));
-void lememinit __P((struct le_softc *));
-void lereset __P((struct le_softc *));
-void lestop __P((struct le_softc *));
-void letint __P((int));
-void lerint __P((int));
-void leread __P((struct le_softc *, u_char *, int));
-struct mbuf *leget __P((u_char *, int, struct ifnet *));
-#ifdef LEDEBUG
-void recv_print __P((struct le_softc *, int));
-void xmit_print __P((struct le_softc *, int));
-#endif
-void lesetladrf __P((struct arpcom *, u_long *));
+#define LE_SOFTC(unit) &le_softc[unit]
+#define LE_DELAY(x) DELAY(x)
+#define LEINTR_UNIT
-int leattach __P((struct hp_device *));
+int lematch __P((struct hp_device *));
+void leattach __P((struct hp_device *));
+int leintr __P((int));
struct driver ledriver = {
- leattach, "le",
+ lematch, leattach, "le",
};
-static inline void
+/* offsets for: ID, REGS, MEM, NVRAM */
+int lestd[] = { 0, 0x4000, 0x8000, 0xC008 };
+
+integrate void
lewrcsr(sc, port, val)
struct le_softc *sc;
- register u_short port;
- register u_short val;
+ u_int16_t port, val;
{
register struct lereg0 *ler0 = sc->sc_r0;
register struct lereg1 *ler1 = sc->sc_r1;
@@ -161,14 +104,14 @@ lewrcsr(sc, port, val)
} while ((ler0->ler0_status & LE_ACK) == 0);
}
-static inline u_short
+integrate u_int16_t
lerdcsr(sc, port)
struct le_softc *sc;
- register u_short port;
+ u_int16_t port;
{
register struct lereg0 *ler0 = sc->sc_r0;
register struct lereg1 *ler1 = sc->sc_r1;
- register u_short val;
+ u_int16_t val;
do {
ler1->ler1_rap = port;
@@ -179,32 +122,51 @@ lerdcsr(sc, port)
return (val);
}
+int
+lematch(hd)
+ struct hp_device *hd;
+{
+ register struct lereg0 *ler0;
+ struct le_softc *sc = 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);
+ sc->sc_hd = hd;
+
+ return (1);
+}
+
/*
* Interface exists: make available by filling in network interface
* record. System will initialize the interface when it is ready
* to accept packets.
*/
-int
+void
leattach(hd)
struct hp_device *hd;
{
register struct lereg0 *ler0;
- struct le_softc *sc = &le_softc[hd->hp_unit];
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ struct le_softc *sc = LE_SOFTC(hd->hp_unit);
char *cp;
int i;
ler0 = sc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr);
- if (ler0->ler0_id != LEID)
- return(0);
- sc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr);
- sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr);
- le_isr[hd->hp_unit].isr_intr = leintr;
- hd->hp_ipl = le_isr[hd->hp_unit].isr_ipl = LE_IPL(ler0->ler0_status);
- le_isr[hd->hp_unit].isr_arg = hd->hp_unit;
ler0->ler0_id = 0xFF;
DELAY(100);
+ /* XXXX kluge for now */
+ sc->sc_dev.dv_unit = hd->hp_unit;
+ sprintf(sc->sc_dev.dv_xname, "%s%d", ledriver.d_name, hd->hp_unit);
+
+ sc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr);
+ sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr);
+ sc->sc_conf3 = LE_C3_BSWP;
+ sc->sc_addr = 0;
+ sc->sc_memsize = 16384;
+
/*
* Read the ethernet address off the board, one nibble at a time.
*/
@@ -215,843 +177,21 @@ leattach(hd)
sc->sc_arpcom.ac_enaddr[i] |= *++cp & 0xF;
cp++;
}
- printf("le%d: hardware address %s\n", hd->hp_unit,
- ether_sprintf(sc->sc_arpcom.ac_enaddr));
-
- isrlink(&le_isr[hd->hp_unit]);
- ler0->ler0_status = LE_IE;
-
- ifp->if_unit = hd->hp_unit;
- ifp->if_name = "le";
- ifp->if_output = ether_output;
- ifp->if_start = lestart;
- ifp->if_ioctl = leioctl;
- ifp->if_watchdog = lewatchdog;
- ifp->if_flags =
- IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
-
- if_attach(ifp);
- ether_ifattach(ifp);
-
-#if NBPFILTER > 0
- bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
-#endif
- return (1);
-}
-
-void
-lereset(sc)
- struct le_softc *sc;
-{
-
- leinit(sc);
-}
-
-void
-lewatchdog(unit)
- int unit;
-{
- struct le_softc *sc = &le_softc[unit];
-
- log(LOG_ERR, "le%d: device timeout\n", unit);
- ++sc->sc_arpcom.ac_if.if_oerrors;
-
- lereset(sc);
-}
-
-#define LANCE_ADDR(sc, a) \
- ((u_long)(a) - (u_long)sc->sc_mem)
-
-/* LANCE initialization block set up. */
-void
-lememinit(sc)
- register struct le_softc *sc;
-{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- int i;
- void *mem;
- u_long a;
-
- /*
- * At this point we assume that the memory allocated to the Lance is
- * quadword aligned. If it isn't then the initialisation is going
- * fail later on.
- */
- mem = sc->sc_mem;
-
- sc->sc_init = mem;
-#if NBPFILTER > 0
- if (ifp->if_flags & IFF_PROMISC)
- sc->sc_init->mode = LE_NORMAL | LE_PROM;
- else
-#endif
- sc->sc_init->mode = LE_NORMAL;
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->sc_init->padr[i] = sc->sc_arpcom.ac_enaddr[i^1];
- lesetladrf(&sc->sc_arpcom, sc->sc_init->ladrf);
- mem += sizeof(struct init_block);
-
- sc->sc_rd = mem;
- a = LANCE_ADDR(sc, mem);
- sc->sc_init->rdra = a;
- sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13);
- mem += NRBUF * sizeof(struct mds);
-
- sc->sc_td = mem;
- a = LANCE_ADDR(sc, mem);
- sc->sc_init->tdra = a;
- sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13);
- mem += NTBUF * sizeof(struct mds);
-
- /*
- * Set up receive ring descriptors.
- */
- sc->sc_rbuf = mem;
- for (i = 0; i < NRBUF; i++) {
- a = LANCE_ADDR(sc, mem);
- sc->sc_rd[i].addr = a;
- sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN;
- sc->sc_rd[i].bcnt = -BUFSIZE;
- sc->sc_rd[i].mcnt = 0;
- mem += BUFSIZE;
- }
-
- /*
- * Set up transmit ring descriptors.
- */
- sc->sc_tbuf = mem;
- for (i = 0; i < NTBUF; i++) {
- a = LANCE_ADDR(sc, mem);
- sc->sc_td[i].addr = a;
- sc->sc_td[i].flags= ((a >> 16) & 0xff);
- sc->sc_td[i].bcnt = 0xf000;
- sc->sc_td[i].mcnt = 0;
- mem += BUFSIZE;
- }
-}
-
-void
-lestop(sc)
- struct le_softc *sc;
-{
-
- lewrcsr(sc, 0, LE_STOP);
-}
-/*
- * Initialization of interface; set up initialization block
- * and transmit/receive descriptor rings.
- */
-void
-leinit(sc)
- register struct le_softc *sc;
-{
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- int s;
- register int timo;
- u_long a;
+ sc->sc_copytodesc = copytobuf_contig;
+ sc->sc_copyfromdesc = copyfrombuf_contig;
+ sc->sc_copytobuf = copytobuf_contig;
+ sc->sc_copyfrombuf = copyfrombuf_contig;
+ sc->sc_zerobuf = zerobuf_contig;
- s = splimp();
+ sc->sc_arpcom.ac_if.if_name = ledriver.d_name;
+ leconfig(sc);
- /* Don't want to get in a weird state. */
- lewrcsr(sc, 0, LE_STOP);
- DELAY(100);
-
- sc->sc_last_rd = sc->sc_last_td = sc->sc_no_td = 0;
-
- /* Set up LANCE init block. */
- lememinit(sc);
-
- /* Turn on byte swapping. */
- lewrcsr(sc, 3, LE_BSWP);
-
- /* Give LANCE the physical address of its init block. */
- a = LANCE_ADDR(sc, sc->sc_init);
- lewrcsr(sc, 1, a);
- lewrcsr(sc, 2, (a >> 16) & 0xff);
-
- /* Try to initialize the LANCE. */
- DELAY(100);
- lewrcsr(sc, 0, LE_INIT);
-
- /* Wait for initialization to finish. */
- for (timo = 100000; timo; timo--)
- if (lerdcsr(sc, 0) & LE_IDON)
- break;
-
- if (lerdcsr(sc, 0) & LE_IDON) {
- /* Start the LANCE. */
- lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON);
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
- lestart(ifp);
- } else
- printf("le%d: card failed to initialize\n", ifp->if_unit);
-
- (void) splx(s);
-}
-
-/*
- * Controller interrupt.
- */
-int
-leintr(unit)
- int unit;
-{
- register struct le_softc *sc = &le_softc[unit];
- register u_short isr;
-
- isr = lerdcsr(sc, 0);
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("le%d: leintr entering with isr=%04x\n",
- unit, isr);
-#endif
- if ((isr & LE_INTR) == 0)
- return 0;
-
- do {
- lewrcsr(sc, 0,
- isr & (LE_INEA | LE_BABL | LE_MISS | LE_MERR |
- LE_RINT | LE_TINT | LE_IDON));
- if (isr & (LE_BABL | LE_CERR | LE_MISS | LE_MERR)) {
- if (isr & LE_BABL) {
- printf("le%d: BABL\n", unit);
- sc->sc_arpcom.ac_if.if_oerrors++;
- }
-#if 0
- if (isr & LE_CERR) {
- printf("le%d: CERR\n", unit);
- sc->sc_arpcom.ac_if.if_collisions++;
- }
-#endif
- if (isr & LE_MISS) {
-#if 0
- printf("le%d: MISS\n", unit);
-#endif
- sc->sc_arpcom.ac_if.if_ierrors++;
- }
- if (isr & LE_MERR) {
- printf("le%d: MERR\n", unit);
- lereset(sc);
- goto out;
- }
- }
-
- if ((isr & LE_RXON) == 0) {
- printf("le%d: receiver disabled\n", unit);
- sc->sc_arpcom.ac_if.if_ierrors++;
- lereset(sc);
- goto out;
- }
- if ((isr & LE_TXON) == 0) {
- printf("le%d: transmitter disabled\n", unit);
- sc->sc_arpcom.ac_if.if_oerrors++;
- lereset(sc);
- goto out;
- }
-
- if (isr & LE_RINT) {
- /* Reset watchdog timer. */
- sc->sc_arpcom.ac_if.if_timer = 0;
- lerint(unit);
- }
- if (isr & LE_TINT) {
- /* Reset watchdog timer. */
- sc->sc_arpcom.ac_if.if_timer = 0;
- letint(unit);
- }
-
- isr = lerdcsr(sc, 0);
- } while ((isr & LE_INTR) != 0);
-
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("le%d: leintr returning with isr=%04x\n",
- unit, isr);
-#endif
-
-out:
- return 1;
-}
-
-#define NEXTTDS \
- if (++tmd == NTBUF) tmd=0, cdm=sc->sc_td; else ++cdm
-
-/*
- * Setup output on interface.
- * Get another datagram to send off of the interface queue, and map it to the
- * interface before starting the output.
- * Called only at splimp or interrupt level.
- */
-void
-lestart(ifp)
- struct ifnet *ifp;
-{
- register struct le_softc *sc = &le_softc[ifp->if_unit];
- register int tmd;
- struct mds *cdm;
- struct mbuf *m0, *m;
- u_char *buffer;
- int len;
-
- if ((sc->sc_arpcom.ac_if.if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
- IFF_RUNNING)
- return;
-
- tmd = sc->sc_last_td;
- cdm = &sc->sc_td[tmd];
-
- for (;;) {
- if (sc->sc_no_td >= NTBUF) {
- sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE;
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("no_td = %d, last_td = %d\n", sc->sc_no_td,
- sc->sc_last_td);
-#endif
- break;
- }
-
-#ifdef LEDEBUG
- if (cdm->flags & LE_OWN) {
- sc->sc_arpcom.ac_if.if_flags |= IFF_OACTIVE;
- printf("missing buffer, no_td = %d, last_td = %d\n",
- sc->sc_no_td, sc->sc_last_td);
- }
-#endif
-
- IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m);
- if (!m)
- break;
-
- ++sc->sc_no_td;
-
- /*
- * Copy the mbuf chain into the transmit buffer.
- */
- buffer = sc->sc_tbuf + (BUFSIZE * sc->sc_last_td);
- len = 0;
- for (m0 = m; m; m = m->m_next) {
- bcopy(mtod(m, caddr_t), buffer, m->m_len);
- buffer += m->m_len;
- len += m->m_len;
- }
-
-#ifdef LEDEBUG
- if (len > ETHER_MAX_LEN)
- printf("packet length %d\n", len);
-#endif
-
-#if NBPFILTER > 0
- if (sc->sc_arpcom.ac_if.if_bpf)
- bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0);
-#endif
-
- m_freem(m0);
- len = max(len, ETHER_MIN_LEN);
-
- /*
- * Init transmit registers, and set transmit start flag.
- */
- cdm->bcnt = -len;
- cdm->mcnt = 0;
- cdm->flags |= LE_OWN | LE_STP | LE_ENP;
-
-#ifdef LEDEBUG
- if (sc->sc_debug)
- xmit_print(sc, sc->sc_last_td);
-#endif
-
- lewrcsr(sc, 0, LE_INEA | LE_TDMD);
-
- NEXTTDS;
- }
-
- sc->sc_last_td = tmd;
-}
-
-void
-letint(unit)
- int unit;
-{
- register struct le_softc *sc = &le_softc[unit];
- register int tmd = (sc->sc_last_td - sc->sc_no_td + NTBUF) % NTBUF;
- struct mds *cdm = &sc->sc_td[tmd];
-
-#ifdef USELEDS
- if (inledcontrol == 0)
- ledcontrol(0, 0, LED_LANXMT);
-#endif
-
- if (cdm->flags & LE_OWN) {
- /* Race condition with loop below. */
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("le%d: extra tint\n", unit);
-#endif
- return;
- }
-
- sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
-
- do {
- if (sc->sc_no_td <= 0)
- break;
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("trans cdm = %x\n", cdm);
-#endif
- sc->sc_arpcom.ac_if.if_opackets++;
- --sc->sc_no_td;
- if (cdm->mcnt & (LE_TBUFF | LE_UFLO | LE_LCOL | LE_LCAR | LE_RTRY)) {
- if (cdm->mcnt & LE_TBUFF)
- printf("le%d: TBUFF\n", unit);
- if ((cdm->mcnt & (LE_TBUFF | LE_UFLO)) == LE_UFLO)
- printf("le%d: UFLO\n", unit);
- if (cdm->mcnt & LE_UFLO) {
- lereset(sc);
- return;
- }
-#if 0
- if (cdm->mcnt & LE_LCOL) {
- printf("le%d: late collision\n", unit);
- sc->sc_arpcom.ac_if.if_collisions++;
- }
- if (cdm->mcnt & LE_LCAR)
- printf("le%d: lost carrier\n", unit);
- if (cdm->mcnt & LE_RTRY) {
- printf("le%d: excessive collisions, tdr %d\n",
- unit, cdm->mcnt & 0x1ff);
- sc->sc_arpcom.ac_if.if_collisions += 16;
- }
-#endif
- } else if (cdm->flags & LE_ONE)
- sc->sc_arpcom.ac_if.if_collisions++;
- else if (cdm->flags & LE_MORE)
- /* Real number is unknown. */
- sc->sc_arpcom.ac_if.if_collisions += 2;
- NEXTTDS;
- } while ((cdm->flags & LE_OWN) == 0);
-
- lestart(&sc->sc_arpcom.ac_if);
-}
-
-#define NEXTRDS \
- if (++rmd == NRBUF) rmd=0, cdm=sc->sc_rd; else ++cdm
-
-/* only called from one place, so may as well integrate */
-void
-lerint(unit)
- int unit;
-{
- register struct le_softc *sc = &le_softc[unit];
- register int rmd = sc->sc_last_rd;
- struct mds *cdm = &sc->sc_rd[rmd];
-
-#ifdef USELEDS
- if (inledcontrol == 0)
- ledcontrol(0, 0, LED_LANRCV);
-#endif
-
- if (cdm->flags & LE_OWN) {
- /* Race condition with loop below. */
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("le%d: extra rint\n", unit);
-#endif
- return;
- }
-
- /* Process all buffers with valid data. */
- do {
- if (cdm->flags & (LE_FRAM | LE_OFLO | LE_CRC | LE_RBUFF)) {
- if ((cdm->flags & (LE_FRAM | LE_OFLO | LE_ENP)) == (LE_FRAM | LE_ENP))
- printf("le%d: FRAM\n", unit);
- if ((cdm->flags & (LE_OFLO | LE_ENP)) == LE_OFLO)
- printf("le%d: OFLO\n", unit);
- if ((cdm->flags & (LE_CRC | LE_OFLO | LE_ENP)) == (LE_CRC | LE_ENP))
- printf("le%d: CRC\n", unit);
- if (cdm->flags & LE_RBUFF)
- printf("le%d: RBUFF\n", unit);
- } else if (cdm->flags & (LE_STP | LE_ENP) != (LE_STP | LE_ENP)) {
- do {
- cdm->mcnt = 0;
- cdm->flags |= LE_OWN;
- NEXTRDS;
- } while ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) == 0);
- sc->sc_last_rd = rmd;
- printf("le%d: chained buffer\n", unit);
- if ((cdm->flags & (LE_OWN | LE_ERR | LE_STP | LE_ENP)) != LE_ENP) {
- lereset(sc);
- return;
- }
- } else {
-#ifdef LEDEBUG
- if (sc->sc_debug)
- recv_print(sc, sc->sc_last_rd);
-#endif
- leread(sc, sc->sc_rbuf + (BUFSIZE * rmd),
- (int)cdm->mcnt);
- sc->sc_arpcom.ac_if.if_ipackets++;
- }
-
- cdm->mcnt = 0;
- cdm->flags |= LE_OWN;
- NEXTRDS;
-#ifdef LEDEBUG
- if (sc->sc_debug)
- printf("sc->sc_last_rd = %x, cdm = %x\n",
- sc->sc_last_rd, cdm);
-#endif
- } while ((cdm->flags & LE_OWN) == 0);
-
- sc->sc_last_rd = rmd;
-}
-
-/*
- * Pass a packet to the higher levels.
- */
-void
-leread(sc, buf, len)
- register struct le_softc *sc;
- u_char *buf;
- int len;
-{
- struct ifnet *ifp;
- struct mbuf *m;
- struct ether_header *eh;
-
- len -= 4;
- if (len <= 0)
- return;
-
- /* Pull packet off interface. */
- ifp = &sc->sc_arpcom.ac_if;
- m = leget(buf, len, ifp);
- if (m == 0)
- return;
-
- /* We assume that the header fit entirely in one mbuf. */
- eh = mtod(m, struct ether_header *);
-
-#if NBPFILTER > 0
- /*
- * Check if there's a BPF listener on this interface.
- * If so, hand off the raw packet to BPF.
- */
- if (ifp->if_bpf) {
- bpf_mtap(ifp->if_bpf, m);
-
- /*
- * Note that the interface cannot be in promiscuous mode if
- * there are no BPF listeners. And if we are in promiscuous
- * mode, we have to check if this packet is really ours.
- */
- if ((ifp->if_flags & IFF_PROMISC) &&
- (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
- bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
- sizeof(eh->ether_dhost)) != 0) {
- m_freem(m);
- return;
- }
- }
-#endif
-
- /* We assume that the header fit entirely in one mbuf. */
- m->m_pkthdr.len -= sizeof(*eh);
- m->m_len -= sizeof(*eh);
- m->m_data += sizeof(*eh);
-
- ether_input(ifp, eh, m);
-}
-
-/*
- * Supporting routines
- */
-
-/*
- * Pull data off an interface.
- * Len is length of data, with local net header stripped.
- * We copy the data into mbufs. When full cluster sized units are present
- * we copy into clusters.
- */
-struct mbuf *
-leget(buf, totlen, ifp)
- u_char *buf;
- int totlen;
- struct ifnet *ifp;
-{
- struct mbuf *top, **mp, *m;
- int len;
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == 0)
- return 0;
- m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = totlen;
- len = MHLEN;
- top = 0;
- mp = &top;
-
- while (totlen > 0) {
- if (top) {
- MGET(m, M_DONTWAIT, MT_DATA);
- if (m == 0) {
- m_freem(top);
- return 0;
- }
- len = MLEN;
- }
- if (totlen >= MINCLSIZE) {
- MCLGET(m, M_DONTWAIT);
- if (m->m_flags & M_EXT)
- len = MCLBYTES;
- }
- m->m_len = len = min(totlen, len);
- bcopy((caddr_t)buf, mtod(m, caddr_t), len);
- buf += len;
- totlen -= len;
- *mp = m;
- mp = &m->m_next;
- }
-
- return top;
-}
-
-/*
- * Process an ioctl request.
- */
-int
-leioctl(ifp, cmd, data)
- register struct ifnet *ifp;
- u_long cmd;
- caddr_t data;
-{
- struct le_softc *sc = &le_softc[ifp->if_unit];
- struct ifaddr *ifa = (struct ifaddr *)data;
- struct ifreq *ifr = (struct ifreq *)data;
- int s, error = 0;
-
- s = splimp();
-
- switch (cmd) {
-
- case SIOCSIFADDR:
- ifp->if_flags |= IFF_UP;
-
- switch (ifa->ifa_addr->sa_family) {
-#ifdef INET
- case AF_INET:
- leinit(sc);
- arp_ifinit(&sc->sc_arpcom, ifa);
- break;
-#endif
-#ifdef NS
- /* XXX - This code is probably wrong. */
- case AF_NS:
- {
- register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
-
- if (ns_nullhost(*ina))
- ina->x_host =
- *(union ns_host *)(sc->sc_arpcom.ac_enaddr);
- else
- bcopy(ina->x_host.c_host,
- sc->sc_arpcom.ac_enaddr,
- sizeof(sc->sc_arpcom.ac_enaddr));
- /* Set new address. */
- leinit(sc);
- break;
- }
-#endif
- default:
- leinit(sc);
- break;
- }
- break;
-
- case SIOCSIFFLAGS:
- /*
- * If interface is marked down and it is running, then stop it
- */
- if ((ifp->if_flags & IFF_UP) == 0 &&
- (ifp->if_flags & IFF_RUNNING) != 0) {
- /*
- * If interface is marked down and it is running, then
- * stop it.
- */
- lestop(sc);
- ifp->if_flags &= ~IFF_RUNNING;
- } else if ((ifp->if_flags & IFF_UP) != 0 &&
- (ifp->if_flags & IFF_RUNNING) == 0) {
- /*
- * If interface is marked up and it is stopped, then
- * start it.
- */
- leinit(sc);
- } else {
- /*
- * Reset the interface to pick up changes in any other
- * flags that affect hardware registers.
- */
- /*lestop(sc);*/
- leinit(sc);
- }
-#ifdef LEDEBUG
- if (ifp->if_flags & IFF_DEBUG)
- sc->sc_debug = 1;
- else
- sc->sc_debug = 0;
-#endif
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- error = (cmd == SIOCADDMULTI) ?
- ether_addmulti(ifr, &sc->sc_arpcom):
- ether_delmulti(ifr, &sc->sc_arpcom);
-
- if (error == ENETRESET) {
- /*
- * Multicast list has changed; set the hardware filter
- * accordingly.
- */
- leinit(sc);
- error = 0;
- }
- break;
-
- default:
- error = EINVAL;
- }
- (void) splx(s);
- return error;
-}
-
-#ifdef LEDEBUG
-void
-recv_print(sc, no)
- struct le_softc *sc;
- int no;
-{
- struct mds *rmd;
- int i, printed = 0;
- u_short len;
-
- rmd = &sc->sc_rd[no];
- len = rmd->mcnt;
- printf("%s: receive buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
- len);
- printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0));
- for (i = 0; i < len; i++) {
- if (!printed) {
- printed = 1;
- printf("%s: data: ", sc->sc_dev.dv_xname);
- }
- printf("%x ", *(sc->sc_rbuf + (BUFSIZE*no) + i));
- }
- if (printed)
- printf("\n");
-}
-
-void
-xmit_print(sc, no)
- struct le_softc *sc;
- int no;
-{
- struct mds *rmd;
- int i, printed=0;
- u_short len;
-
- rmd = &sc->sc_td[no];
- len = -rmd->bcnt;
- printf("%s: transmit buffer %d, len = %d\n", sc->sc_dev.dv_xname, no,
- len);
- printf("%s: status %x\n", sc->sc_dev.dv_xname, lerdcsr(sc, 0));
- printf("%s: addr %x, flags %x, bcnt %x, mcnt %x\n",
- sc->sc_dev.dv_xname, rmd->addr, rmd->flags, rmd->bcnt, rmd->mcnt);
- for (i = 0; i < len; i++) {
- if (!printed) {
- printed = 1;
- printf("%s: data: ", sc->sc_dev.dv_xname);
- }
- printf("%x ", *(sc->sc_tbuf + (BUFSIZE*no) + i));
- }
- if (printed)
- printf("\n");
-}
-#endif /* LEDEBUG */
-
-/*
- * Set up the logical address filter.
- */
-void
-lesetladrf(ac, af)
- struct arpcom *ac;
- u_long *af;
-{
- struct ifnet *ifp = &ac->ac_if;
- struct ether_multi *enm;
- register u_char *cp, c;
- register u_long crc;
- register int i, len;
- struct ether_multistep step;
-
- /*
- * Set up multicast address filter by passing all multicast addresses
- * through a crc generator, and then using the high order 6 bits as an
- * index into the 64 bit logical address filter. The high order bit
- * selects the word, while the rest of the bits select the bit within
- * the word.
- */
-
- if (ifp->if_flags & IFF_PROMISC) {
- ifp->if_flags |= IFF_ALLMULTI;
- af[0] = af[1] = 0xffffffff;
- return;
- }
-
- af[0] = af[1] = 0;
- ETHER_FIRST_MULTI(step, ac, enm);
- while (enm != NULL) {
- if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
- sizeof(enm->enm_addrlo)) != 0) {
- /*
- * We must listen to a range of multicast addresses.
- * For now, just accept all multicasts, rather than
- * trying to set only those filter bits needed to match
- * the range. (At this time, the only use of address
- * ranges is for IP multicast routing, for which the
- * range is big enough to require all bits set.)
- */
- ifp->if_flags |= IFF_ALLMULTI;
- af[0] = af[1] = 0xffffffff;
- return;
- }
-
- cp = enm->enm_addrlo;
- crc = 0xffffffff;
- for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
- c = *cp++;
- for (i = 8; --i >= 0;) {
- if ((crc & 0x01) ^ (c & 0x01)) {
- crc >>= 1;
- crc ^= 0x6db88320 | 0x80000000;
- } else
- crc >>= 1;
- c >>= 1;
- }
- }
- /* Just want the 6 most significant bits. */
- crc >>= 26;
-
- /* Turn on the corresponding bit in the filter. */
- af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 16);
-
- ETHER_NEXT_MULTI(step, enm);
- }
- ifp->if_flags &= ~IFF_ALLMULTI;
+ sc->sc_isr.isr_intr = leintr;
+ sc->sc_isr.isr_arg = hd->hp_unit;
+ sc->sc_isr.isr_ipl = hd->hp_ipl;
+ isrlink(&sc->sc_isr);
+ ler0->ler0_status = LE_IE;
}
-#endif /* NLE > 0 */
+#include <dev/ic/am7990.c>
diff --git a/sys/arch/hp300/dev/if_lereg.h b/sys/arch/hp300/dev/if_lereg.h
index 6a21d24eb10..b745ad6ee06 100644
--- a/sys/arch/hp300/dev/if_lereg.h
+++ b/sys/arch/hp300/dev/if_lereg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: if_lereg.h,v 1.7 1994/10/26 07:24:23 cgd Exp $ */
+/* $NetBSD: if_lereg.h,v 1.8 1995/12/10 00:49:36 mycroft Exp $ */
/*
* Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -37,23 +37,14 @@
#define LEID 21
-#define NTBUF 2
-#define TLEN 1
-#define NRBUF 8
-#define RLEN 3
-#define BUFSIZE 1518
-
-#define vu_char volatile u_char
-#define vu_short volatile u_short
-
/*
- * LANCE registers.
+ * DIO registers.
*/
struct lereg0 {
- u_char ler0_pad0;
- vu_char ler0_id; /* ID */
- u_char ler0_pad1;
- vu_char ler0_status; /* interrupt enable/status */
+ u_int8_t ler0_pad0;
+ volatile u_int8_t ler0_id; /* ID */
+ u_int8_t ler0_pad1;
+ volatile u_int8_t ler0_status; /* interrupt enable/status */
};
/*
@@ -66,97 +57,10 @@ struct lereg0 {
#define LE_JAB 0x02 /* loss of tx clock (???) */
#define LE_IPL(x) ((((x) >> 4) & 0x3) + 3)
-struct lereg1 {
- vu_short ler1_rdp; /* data port */
- vu_short ler1_rap; /* register select port */
-};
-
-/*
- * Control and status bits -- lereg1
- */
-#define LE_SERR 0x8000
-#define LE_BABL 0x4000
-#define LE_CERR 0x2000
-#define LE_MISS 0x1000
-#define LE_MERR 0x0800
-#define LE_RINT 0x0400
-#define LE_TINT 0x0200
-#define LE_IDON 0x0100
-#define LE_INTR 0x0080
-#define LE_INEA 0x0040
-#define LE_RXON 0x0020
-#define LE_TXON 0x0010
-#define LE_TDMD 0x0008
-#define LE_STOP 0x0004
-#define LE_STRT 0x0002
-#define LE_INIT 0x0001
-
-#define LE_BSWP 0x0004
-#define LE_ACON 0x0002
-#define LE_BCON 0x0001
-
-/*
- * Overlayed on 16K dual-port RAM.
- * Current size is 15,284 bytes with 8 x 1518 receive buffers and
- * 2 x 1518 transmit buffers.
- */
-
/*
- * LANCE initialization block
- */
-struct init_block {
- u_short mode; /* mode register */
- u_char padr[6]; /* ethernet address */
- u_long ladrf[2]; /* logical address filter (multicast) */
- u_short rdra; /* low order pointer to receive ring */
- u_short rlen; /* high order pointer and no. rings */
- u_short tdra; /* low order pointer to transmit ring */
- u_short tlen; /* high order pointer and no rings */
-};
-
-/*
- * Mode bits -- init_block
- */
-#define LE_PROM 0x8000 /* promiscuous */
-#define LE_INTL 0x0040 /* internal loopback */
-#define LE_DRTY 0x0020 /* disable retry */
-#define LE_COLL 0x0010 /* force collision */
-#define LE_DTCR 0x0008 /* disable transmit crc */
-#define LE_LOOP 0x0004 /* loopback */
-#define LE_DTX 0x0002 /* disable transmitter */
-#define LE_DRX 0x0001 /* disable receiver */
-#define LE_NORMAL 0x0000
-
-/*
- * Message descriptor
+ * LANCE registers.
*/
-struct mds {
- u_short addr;
- u_short flags;
- u_short bcnt;
- u_short mcnt;
+struct lereg1 {
+ volatile u_int16_t ler1_rdp; /* data port */
+ volatile u_int16_t ler1_rap; /* register select port */
};
-
-/* Message descriptor flags */
-#define LE_OWN 0x8000 /* owner bit, 0=host, 1=LANCE */
-#define LE_ERR 0x4000 /* error */
-#define LE_STP 0x0200 /* start of packet */
-#define LE_ENP 0x0100 /* end of packet */
-
-/* Receive ring status flags */
-#define LE_FRAM 0x2000 /* framing error error */
-#define LE_OFLO 0x1000 /* silo overflow */
-#define LE_CRC 0x0800 /* CRC error */
-#define LE_RBUFF 0x0400 /* buffer error */
-
-/* Transmit ring status flags */
-#define LE_MORE 0x1000 /* more than 1 retry */
-#define LE_ONE 0x0800 /* one retry */
-#define LE_DEF 0x0400 /* deferred transmit */
-
-/* Transmit errors */
-#define LE_TBUFF 0x8000 /* buffer error */
-#define LE_UFLO 0x4000 /* silo underflow */
-#define LE_LCOL 0x1000 /* late collision */
-#define LE_LCAR 0x0800 /* loss of carrier */
-#define LE_RTRY 0x0400 /* tried 16 times */
diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h
new file mode 100644
index 00000000000..fd77b37ebc3
--- /dev/null
+++ b/sys/arch/hp300/dev/if_levar.h
@@ -0,0 +1,85 @@
+/* $NetBSD: if_levar.h,v 1.1 1995/12/10 00:49:37 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1995 Charles M. Hannum. All rights reserved.
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell and Rick Macklem.
+ *
+ * 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.
+ *
+ * @(#)if_le.c 8.2 (Berkeley) 11/16/93
+ */
+
+/*
+ * Ethernet software status per interface.
+ *
+ * Each interface is referenced by a network interface structure,
+ * arpcom.ac_if, which the routing code uses to locate the interface.
+ * This structure contains the output queue for the interface, its address, ...
+ */
+struct le_softc {
+ struct device sc_dev; /* base structure */
+ struct arpcom sc_arpcom; /* Ethernet common part */
+
+ void (*sc_copytodesc)(); /* Copy to descriptor */
+ void (*sc_copyfromdesc)(); /* Copy from descriptor */
+
+ void (*sc_copytobuf)(); /* Copy to buffer */
+ void (*sc_copyfrombuf)(); /* Copy from buffer */
+ void (*sc_zerobuf)(); /* and Zero bytes in buffer */
+
+ u_int16_t sc_conf3; /* CSR3 value */
+
+ void *sc_mem; /* base address of RAM -- CPU's view */
+ u_long sc_addr; /* base address of RAM -- LANCE's view */
+ u_long sc_memsize; /* size of RAM */
+
+ int sc_nrbuf; /* number of receive buffers */
+ int sc_ntbuf; /* number of transmit buffers */
+ int sc_last_rd;
+ int sc_first_td, sc_last_td, sc_no_td;
+
+ int sc_initaddr;
+ int sc_rmdaddr;
+ int sc_tmdaddr;
+ int sc_rbufaddr;
+ int sc_tbufaddr;
+
+#ifdef LEDEBUG
+ int sc_debug;
+#endif
+
+ struct hp_device *sc_hd;
+ struct isr sc_isr;
+ struct lereg0 *sc_r0; /* DIO registers */
+ struct lereg1 *sc_r1; /* LANCE registers */
+};
diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c
index 2d5f4d46b5a..bc1b738e7bb 100644
--- a/sys/arch/hp300/dev/ite.c
+++ b/sys/arch/hp300/dev/ite.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ite.c,v 1.27.2.1 1995/11/19 23:18:27 thorpej Exp $ */
+/* $NetBSD: ite.c,v 1.28 1995/11/19 23:14:22 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
diff --git a/sys/arch/hp300/dev/itevar.h b/sys/arch/hp300/dev/itevar.h
index 97fbaffa2ed..28b13d3064d 100644
--- a/sys/arch/hp300/dev/itevar.h
+++ b/sys/arch/hp300/dev/itevar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: itevar.h,v 1.7.2.1 1995/11/19 23:18:31 thorpej Exp $ */
+/* $NetBSD: itevar.h,v 1.8 1995/11/19 23:14:25 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
diff --git a/sys/arch/hp300/dev/kbdmap.h b/sys/arch/hp300/dev/kbdmap.h
index 424e59ff27d..38511760c51 100644
--- a/sys/arch/hp300/dev/kbdmap.h
+++ b/sys/arch/hp300/dev/kbdmap.h
@@ -1,4 +1,4 @@
-/* $NetBSD: kbdmap.h,v 1.5 1995/03/28 18:16:17 jtc Exp $ */
+/* $NetBSD: kbdmap.h,v 1.6 1995/12/06 22:13:26 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -52,6 +52,7 @@ struct kbdmap {
#define KBD_SPECIAL 0x00 /* user defined */
#define KBD_US 0x1F /* US ASCII */
#define KBD_UK 0x17 /* United Kingdom */
+#define KBD_SE 0x0e /* Swedish */
#define KBD_DEFAULT KBD_US /* default type */
diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c
index 2167809c99b..49defe6daf2 100644
--- a/sys/arch/hp300/dev/mt.c
+++ b/sys/arch/hp300/dev/mt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mt.c,v 1.1 1995/10/02 00:28:20 thorpej Exp $ */
+/* $NetBSD: mt.c,v 1.2 1995/12/02 18:22:04 thorpej Exp $ */
/*
* Copyright (c) 1992, The University of Utah and
@@ -62,6 +62,7 @@ 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) */
short sc_flags; /* see below */
@@ -90,35 +91,55 @@ 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 mtinit(), mtintr();
-void mtustart(), mtstart(), mtgo(), mtstrategy();
+int mtmatch(), mtintr();
+void mtattach(), mtustart(), mtstart(), mtgo(), mtstrategy();
struct driver mtdriver = {
- mtinit, "mt", (int (*)()) mtstart, (int (*)()) mtgo, mtintr,
+ mtmatch, mtattach, "mt", (int (*)()) mtstart, (int (*)()) mtgo, mtintr,
};
-mtinit(hd)
+int
+mtmatch(hd)
register struct hp_device *hd;
{
register int unit;
register int hpibno = hd->hp_ctlr;
register int slave = hd->hp_slave;
- register struct mt_softc *sc;
+ register struct mt_softc *sc = &mt_softc[hd->hp_unit];
register int id;
register struct buf *bp;
-
+
+ sc->sc_hd = hd;
+
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)
- goto gottype;
+ return (1);
return (0); /* not a known HP magtape */
+}
+
+void
+mtattach(hd)
+ register struct hp_device *hd;
+{
+ 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;
+
+ /* XXX Ick. */
+ unit = hpibid(hpibno, slave);
+ for (id = 0; id < nmtinfo; id++)
+ if (unit == mtinfo[id].hwid)
+ break;
- gottype:
unit = hd->hp_unit;
sc = &mt_softc[unit];
sc->sc_type = mtinfo[id].hwid;
- printf("mt%d: %s tape\n", unit, mtinfo[id].desc);
+ printf(": %s tape\n", mtinfo[id].desc);
sc->sc_hpibno = hpibno;
sc->sc_slave = slave;
@@ -127,7 +148,6 @@ mtinit(hd)
sc->sc_dq.dq_unit = unit;
sc->sc_dq.dq_slave = slave;
sc->sc_dq.dq_driver = &mtdriver;
- return (1);
}
/*
@@ -248,7 +268,7 @@ mtopen(dev, flag, mode, p)
goto errout;
}
if (!(sc->sc_stat1 & SR1_ONLINE)) {
- uprintf("mt%d: not online\n", unit);
+ uprintf("%s: not online\n", sc->sc_hd->hp_xname);
error = EIO;
goto errout;
}
@@ -285,7 +305,8 @@ mtopen(dev, flag, mode, p)
if (flag & FWRITE) {
if (!(sc->sc_stat1 & SR1_BOT)) {
if (sc->sc_density != req_den) {
- uprintf("mt%d: can't change density mid-tape\n", unit);
+ uprintf("%s: can't change density mid-tape\n",
+ sc->sc_hd->hp_xname);
error = EIO;
goto errout;
}
@@ -376,8 +397,8 @@ mtstrategy(bp)
#if 0
if (bp->b_bcount & ((1 << WRITE_BITS_IGNORED) - 1)) {
tprintf(sc->sc_ttyp,
- "mt%d: write record must be multiple of %d\n",
- unit, 1 << WRITE_BITS_IGNORED);
+ "%s: write record must be multiple of %d\n",
+ sc->sc_hd->hp_xname, 1 << WRITE_BITS_IGNORED);
goto error;
}
#endif
@@ -396,8 +417,8 @@ mtstrategy(bp)
}
if (bp->b_bcount > s) {
tprintf(sc->sc_ttyp,
- "mt%d: write record (%d) too big: limit (%d)\n",
- unit, bp->b_bcount, s);
+ "%s: write record (%d) too big: limit (%d)\n",
+ sc->sc_hd->hp_xname, bp->b_bcount, s);
error:
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
@@ -732,8 +753,8 @@ mtintr(unit)
}
if (sc->sc_stat1 & (SR1_ERR | SR1_REJECT)) {
i = sc->sc_stat4 & SR4_ERCLMASK;
- log(LOG_ERR, "mt%d: %s error, retry %d, SR2/3 %x/%x, code %d\n",
- unit, i == SR4_DEVICE ? "device" :
+ log(LOG_ERR, "%s: %s error, retry %d, SR2/3 %x/%x, code %d\n",
+ sc->sc_hd->hp_xname, i == SR4_DEVICE ? "device" :
(i == SR4_PROTOCOL ? "protocol" :
(i == SR4_SELFTEST ? "selftest" : "unknown")),
sc->sc_stat4 & SR4_RETRYMASK, sc->sc_stat2,
@@ -749,8 +770,8 @@ mtintr(unit)
* Report and clear any soft errors.
*/
if (sc->sc_stat1 & SR1_SOFTERR) {
- log(LOG_WARNING, "mt%d: soft error, retry %d\n",
- unit, sc->sc_stat4 & SR4_RETRYMASK);
+ log(LOG_WARNING, "%s: soft error, retry %d\n",
+ sc->sc_hd->hp_xname, sc->sc_stat4 & SR4_RETRYMASK);
sc->sc_stat1 &= ~SR1_SOFTERR;
}
/*
@@ -810,8 +831,8 @@ mtintr(unit)
unit, bp->b_bcount, bp->b_resid);
} else {
tprintf(sc->sc_ttyp,
- "mt%d: record (%d) larger than wanted (%d)\n",
- unit, i, bp->b_bcount);
+ "%s: record (%d) larger than wanted (%d)\n",
+ sc->sc_hd->hp_xname, i, bp->b_bcount);
error:
sc->sc_flags &= ~MTF_IO;
bp->b_error = EIO;
diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c
index 7d2342535a2..f7864d20ecb 100644
--- a/sys/arch/hp300/dev/nhpib.c
+++ b/sys/arch/hp300/dev/nhpib.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nhpib.c,v 1.6 1995/01/07 10:30:14 mycroft Exp $ */
+/* $NetBSD: nhpib.c,v 1.8 1995/12/02 18:22:06 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -74,6 +74,30 @@ 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 nhpibppwatch __P((void *));
+void nhpibgo __P((int, int, int, void *, int, int, int));
+void nhpibdone __P((int));
+int nhpibintr __P((int));
+
+/*
+ * Our controller ops structure.
+ */
+struct hpib_controller nhpib_controller = {
+ nhpibreset,
+ nhpibsend,
+ nhpibrecv,
+ nhpibppoll,
+ nhpibppwatch,
+ nhpibgo,
+ nhpibdone,
+ nhpibintr
+};
+
+int
nhpibtype(hc)
register struct hp_ctlr *hc;
{
@@ -82,19 +106,44 @@ nhpibtype(hc)
if (hc->hp_addr == internalhpib) {
hs->sc_type = HPIBA;
- hs->sc_ba = HPIBA_BA;
hc->hp_ipl = HPIBA_IPL;
- }
- else if (hd->hpib_cid == HPIBB) {
+ return (1);
+ } else if (hd->hpib_cid == HPIBB) {
hs->sc_type = HPIBB;
- hs->sc_ba = hd->hpib_csa & CSA_BA;
hc->hp_ipl = HPIB_IPL(hd->hpib_ids);
+ return (1);
}
- else
- return(0);
- return(1);
+
+ return(0);
+}
+
+void
+nhpibattach(hc)
+ register struct hp_ctlr *hc;
+{
+ 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 */
+ }
+
+ hs->sc_controller = &nhpib_controller;
}
+void
nhpibreset(unit)
int unit;
{
@@ -132,13 +181,15 @@ nhpibifc(hd)
hd->hpib_acr = AUX_SSRE;
}
-nhpibsend(unit, slave, sec, addr, origcnt)
+int
+nhpibsend(unit, slave, sec, ptr, origcnt)
int unit, slave, sec, origcnt;
- register char *addr;
+ void *ptr;
{
register struct hpib_softc *hs = &hpib_softc[unit];
register struct nhpibdevice *hd;
register int cnt = origcnt;
+ char *addr = ptr;
hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
hd->hpib_acr = AUX_TCA;
@@ -188,13 +239,15 @@ senderror:
return(origcnt - cnt - 1);
}
-nhpibrecv(unit, slave, sec, addr, origcnt)
+int
+nhpibrecv(unit, slave, sec, ptr, origcnt)
int unit, slave, sec, origcnt;
- register char *addr;
+ void *ptr;
{
register struct hpib_softc *hs = &hpib_softc[unit];
register struct nhpibdevice *hd;
register int cnt = origcnt;
+ char *addr = ptr;
hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
/*
@@ -239,13 +292,14 @@ recvbyteserror:
return(origcnt - cnt - 1);
}
-nhpibgo(unit, slave, sec, addr, count, rw, timo)
- register int unit, slave;
- int sec, count, rw;
- char *addr;
+void
+nhpibgo(unit, slave, sec, ptr, count, rw, timo)
+ int unit, slave, sec, count, rw, timo;
+ void *ptr;
{
register struct hpib_softc *hs = &hpib_softc[unit];
register struct nhpibdevice *hd;
+ char *addr = ptr;
hd = (struct nhpibdevice *)hs->sc_hc->hp_addr;
hs->sc_flags |= HPIBF_IO;
@@ -313,6 +367,7 @@ nhpibreadtimo(arg)
(void) splx(s);
}
+void
nhpibdone(unit)
register int unit;
{
@@ -344,6 +399,7 @@ nhpibdone(unit)
}
}
+int
nhpibintr(unit)
register int unit;
{
@@ -382,13 +438,14 @@ nhpibintr(unit)
}
#ifdef DEBUG
else
- printf("hpib%d: PPOLL intr bad status %x\n",
- unit, stat0);
+ printf("%s: PPOLL intr bad status %x\n",
+ hs->sc_hc->hp_xname, stat0);
#endif
}
return(1);
}
+int
nhpibppoll(unit)
int unit;
{
@@ -407,6 +464,7 @@ nhpibppoll(unit)
int nhpibreporttimo = 0;
#endif
+int
nhpibwait(hd, x)
register struct nhpibdevice *hd;
int x;
@@ -446,4 +504,4 @@ again:
else
timeout(nhpibppwatch, (void *)unit, 1);
}
-#endif
+#endif /* NHPIB > 0 */
diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c
index 62a41b89493..d34eb549453 100644
--- a/sys/arch/hp300/dev/ppi.c
+++ b/sys/arch/hp300/dev/ppi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ppi.c,v 1.6 1994/10/26 07:24:46 cgd Exp $ */
+/* $NetBSD: ppi.c,v 1.7 1995/12/02 18:22:08 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -51,10 +51,10 @@
#include <hp300/dev/device.h>
#include <hp300/dev/ppiioctl.h>
-int ppiattach(), ppistart();
-void ppitimo();
+int ppimatch(), ppistart();
+void ppiattach(), ppitimo();
struct driver ppidriver = {
- ppiattach, "ppi", ppistart,
+ ppimatch, ppiattach, "ppi", ppistart,
};
struct ppi_softc {
@@ -84,7 +84,8 @@ int ppidebug = 0x80;
#define PDB_NOCHECK 0x80
#endif
-ppiattach(hd)
+int
+ppimatch(hd)
register struct hp_device *hd;
{
register struct ppi_softc *sc = &ppi_softc[hd->hp_unit];
@@ -98,14 +99,25 @@ ppiattach(hd)
* a cs80 disk or tape for a ppi device.
*/
if (hpibid(hd->hp_ctlr, hd->hp_slave) & 0x200)
- return(0);
+ return (0);
+
+ sc->sc_hd = hd;
+ return (1);
+}
+
+void
+ppiattach(hd)
+ register struct hp_device *hd;
+{
+ struct ppi_softc *sc = &ppi_softc[hd->hp_unit];
+
+ printf("\n");
+
sc->sc_flags = PPIF_ALIVE;
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;
- sc->sc_hd = hd;
- return(1);
}
ppiopen(dev, flags)
diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c
index c5a3f3fc767..2b479345a3a 100644
--- a/sys/arch/hp300/dev/rd.c
+++ b/sys/arch/hp300/dev/rd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rd.c,v 1.13 1995/10/09 07:57:46 thorpej Exp $ */
+/* $NetBSD: rd.c,v 1.16 1995/12/09 07:31:07 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -69,10 +69,10 @@
#include <vm/vm_prot.h>
#include <vm/pmap.h>
-int rdinit(), rdstart(), rdgo(), rdintr();
-void rdstrategy();
+int rdmatch(), rdstart(), rdgo(), rdintr();
+void rdattach(), rdstrategy();
struct driver rddriver = {
- rdinit, "rd", rdstart, rdgo, rdintr,
+ rdmatch, rdattach, "rd", rdstart, rdgo, rdintr,
};
struct rd_softc rd_softc[NRD];
@@ -162,38 +162,88 @@ int rddebug = 0x80;
* Nothing really critical here, could do without it.
*/
struct rdidentinfo rdidentinfo[] = {
- { RD7946AID, 0, "7945A", 108416 },
- { RD9134DID, 1, "9134D", 29088 },
- { RD9134LID, 1, "9122S", 1232 },
- { RD7912PID, 0, "7912P", 128128 },
- { RD7914PID, 0, "7914P", 258048 },
- { RD7958AID, 0, "7958A", 255276 },
- { RD7957AID, 0, "7957A", 159544 },
- { RD7933HID, 0, "7933H", 789958 },
- { RD9134LID, 1, "9134L", 77840 },
- { RD7936HID, 0, "7936H", 600978 },
- { RD7937HID, 0, "7937H", 1116102 },
- { RD7914CTID, 0, "7914CT", 258048 },
- { RD7946AID, 0, "7946A", 108416 },
- { RD9134LID, 1, "9122D", 1232 },
- { RD7957BID, 0, "7957B", 159894 },
- { RD7958BID, 0, "7958B", 297108 },
- { RD7959BID, 0, "7959B", 594216 },
- { RD2200AID, 0, "2200A", 654948 },
- { RD2203AID, 0, "2203A", 1309896 }
+ { RD7946AID, 0, "7945A", NRD7945ABPT,
+ NRD7945ATRK, 968, 108416 },
+
+ { RD9134DID, 1, "9134D", NRD9134DBPT,
+ NRD9134DTRK, 303, 29088 },
+
+ { RD9134LID, 1, "9122S", NRD9122SBPT,
+ NRD9122STRK, 77, 1232 },
+
+ { RD7912PID, 0, "7912P", NRD7912PBPT,
+ NRD7912PTRK, 572, 128128 },
+
+ { RD7914PID, 0, "7914P", NRD7914PBPT,
+ NRD7914PTRK, 1152, 258048 },
+
+ { RD7958AID, 0, "7958A", NRD7958ABPT,
+ NRD7958ATRK, 1013, 255276 },
+
+ { RD7957AID, 0, "7957A", NRD7957ABPT,
+ NRD7957ATRK, 1036, 159544 },
+
+ { RD7933HID, 0, "7933H", NRD7933HBPT,
+ NRD7933HTRK, 1321, 789958 },
+
+ { RD9134LID, 1, "9134L", NRD9134LBPT,
+ NRD9134LTRK, 973, 77840 },
+
+ { RD7936HID, 0, "7936H", NRD7936HBPT,
+ NRD7936HTRK, 698, 600978 },
+
+ { RD7937HID, 0, "7937H", NRD7937HBPT,
+ NRD7937HTRK, 698, 1116102 },
+
+ { RD7914CTID, 0, "7914CT", NRD7914PBPT,
+ NRD7914PTRK, 1152, 258048 },
+
+ { RD7946AID, 0, "7946A", NRD7945ABPT,
+ NRD7945ATRK, 968, 108416 },
+
+ { RD9134LID, 1, "9122D", NRD9122SBPT,
+ NRD9122STRK, 77, 1232 },
+
+ { RD7957BID, 0, "7957B", NRD7957BBPT,
+ NRD7957BTRK, 1269, 159894 },
+
+ { RD7958BID, 0, "7958B", NRD7958BBPT,
+ NRD7958BTRK, 786, 297108 },
+
+ { RD7959BID, 0, "7959B", NRD7959BBPT,
+ NRD7959BTRK, 1572, 594216 },
+
+ { RD2200AID, 0, "2200A", NRD2200ABPT,
+ NRD2200ATRK, 1449, 654948 },
+
+ { RD2203AID, 0, "2203A", NRD2203ABPT,
+ NRD2203ATRK, 1449, 1309896 }
};
int numrdidentinfo = sizeof(rdidentinfo) / sizeof(rdidentinfo[0]);
-rdinit(hd)
+int
+rdmatch(hd)
register struct hp_device *hd;
{
register struct rd_softc *rs = &rd_softc[hd->hp_unit];
rs->sc_hd = hd;
rs->sc_punit = rdpunit(hd->hp_flags);
- rs->sc_type = rdident(rs, hd);
+ rs->sc_type = rdident(rs, hd, 0);
if (rs->sc_type < 0)
- return(0);
+ return (0);
+
+ return (1);
+}
+
+void
+rdattach(hd)
+ register struct hp_device *hd;
+{
+ register struct rd_softc *rs = &rd_softc[hd->hp_unit];
+
+ (void)rdident(rs, hd, 1); /* XXX Ick. */
+
rs->sc_dq.dq_ctlr = hd->hp_ctlr;
rs->sc_dq.dq_unit = hd->hp_unit;
rs->sc_dq.dq_slave = hd->hp_slave;
@@ -204,14 +254,15 @@ rdinit(hd)
if (rddebug & RDB_ERROR)
rderrthresh = 0;
#endif
- return(1);
}
-rdident(rs, hd)
+int
+rdident(rs, hd, verbose)
struct rd_softc *rs;
struct hp_device *hd;
+ int verbose;
{
- struct rd_describe desc;
+ struct rd_describe *desc = &rs->sc_rddesc;
u_char stat, cmd[3];
int unit, lunit;
char name[7];
@@ -252,33 +303,34 @@ rdident(rs, hd)
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_EXEC, desc, 37);
hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
bzero(name, sizeof(name));
if (!stat) {
- register int n = desc.d_name;
+ register int n = desc->d_name;
for (i = 5; i >= 0; i--) {
name[i] = (n & 0xf) + '0';
n >>= 4;
}
/* use drive characteristics to calculate xfer rate */
- rs->sc_wpms = 1000000 * (desc.d_sectsize/2) / desc.d_blocktime;
+ rs->sc_wpms = 1000000 * (desc->d_sectsize/2) /
+ desc->d_blocktime;
}
#ifdef DEBUG
if (rddebug & RDB_IDENT) {
printf("rd%d: name: %x ('%s')\n",
- lunit, desc.d_name, name);
+ lunit, 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);
}
#endif
/*
@@ -309,7 +361,18 @@ rdident(rs, hd)
id = RD9134D;
break;
}
- printf("rd%d: %s\n", lunit, rdidentinfo[id].ri_desc);
+ /*
+ * 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!
+ */
+ 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);
}
@@ -379,12 +442,12 @@ rdgetinfo(dev)
/*
* Now try to read the disklabel
*/
- msg = readdisklabel(rdlabdev(dev), rdstrategy, lp);
+ msg = readdisklabel(rdlabdev(dev), rdstrategy, lp, NULL);
if (msg == NULL)
return(0);
pi = lp->d_partitions;
- printf("rd%d: WARNING: %s, ", unit, msg);
+ printf("%s: WARNING: %s, ", rs->sc_hd->hp_xname, msg);
#ifdef COMPAT_NOLABEL
printf("using old default partitioning\n");
rdmakedisklabel(unit, lp);
@@ -643,8 +706,8 @@ again:
*/
#ifdef DEBUG
if (rddebug & RDB_ERROR)
- printf("rd%d: rdstart: cmd %x adr %d blk %d len %d ecnt %d\n",
- unit, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
+ 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++;
#endif
@@ -652,8 +715,8 @@ again:
rdreset(rs, hp);
if (rdtab[unit].b_errcnt++ < RDRETRY)
goto again;
- printf("rd%d: rdstart err: cmd 0x%x sect %d blk %d len %d\n",
- unit, rs->sc_ioc.c_cmd, rs->sc_ioc.c_addr,
+ 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,
bp->b_blkno, rs->sc_resid);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
@@ -703,7 +766,7 @@ rdintr(unit)
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("rd%d: bp == NULL\n", unit);
+ printf("%s: bp == NULL\n", rs->sc_hd->hp_xname);
return;
}
#endif
@@ -812,7 +875,7 @@ rderror(unit)
if (rdstatus(rs)) {
#ifdef DEBUG
- printf("rd%d: couldn't get status\n", unit);
+ printf("%s: couldn't get status\n", rs->sc_hd->hp_xname);
#endif
rdreset(rs, rs->sc_hd);
return(1);
@@ -835,8 +898,8 @@ rderror(unit)
extern int hz;
int rdtimo = RDWAITC << rdtab[unit].b_errcnt;
#ifdef DEBUG
- printf("rd%d: internal maintenance, %d second timeout\n",
- unit, rdtimo);
+ printf("%s: internal maintenance, %d second timeout\n",
+ rs->sc_hd->hp_xname, rdtimo);
rdstats[unit].rdtimeouts++;
#endif
hpibfree(&rs->sc_dq);
diff --git a/sys/arch/hp300/dev/rd_compat.c b/sys/arch/hp300/dev/rd_compat.c
index cf7f001b81a..239dd4bc0e6 100644
--- a/sys/arch/hp300/dev/rd_compat.c
+++ b/sys/arch/hp300/dev/rd_compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rd_compat.c,v 1.3 1994/10/26 07:24:52 cgd Exp $ */
+/* $NetBSD: rd_compat.c,v 1.4 1995/11/19 19:07:20 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -228,49 +228,45 @@ struct size {
* Indexed the same as rdidentinfo array.
*/
struct rdcompatinfo {
- int nbpt; /* DEV_BSIZE blocks per track */
- int ntpc; /* tracks per cylinder */
- int ncyl; /* cylinders per unit */
struct size *sizes; /* partition info */
} rdcompatinfo[] = {
- NRD7945ABPT, NRD7945ATRK, 968, rd7945A_sizes,
- NRD9134DBPT, NRD9134DTRK, 303, rd9134D_sizes,
- NRD9122SBPT, NRD9122STRK, 77, rd9122S_sizes,
- NRD7912PBPT, NRD7912PTRK, 572, rd7912P_sizes,
- NRD7914PBPT, NRD7914PTRK, 1152, rd7914P_sizes,
- NRD7958ABPT, NRD7958ATRK, 1013, rd7958A_sizes,
- NRD7957ABPT, NRD7957ATRK, 1036, rd7957A_sizes,
- NRD7933HBPT, NRD7933HTRK, 1321, rd7933H_sizes,
- NRD9134LBPT, NRD9134LTRK, 973, rd9134L_sizes,
- NRD7936HBPT, NRD7936HTRK, 698, rd7936H_sizes,
- NRD7937HBPT, NRD7937HTRK, 698, rd7937H_sizes,
- NRD7914PBPT, NRD7914PTRK, 1152, rd7914P_sizes,
- NRD7945ABPT, NRD7945ATRK, 968, rd7945A_sizes,
- NRD9122SBPT, NRD9122STRK, 77, rd9122S_sizes,
- NRD7957BBPT, NRD7957BTRK, 1269, rd7957B_sizes,
- NRD7958BBPT, NRD7958BTRK, 786, rd7958B_sizes,
- NRD7959BBPT, NRD7959BTRK, 1572, rd7959B_sizes,
- NRD2200ABPT, NRD2200ATRK, 1449, rd2200A_sizes,
- NRD2203ABPT, NRD2203ATRK, 1449, rd2203A_sizes,
+ rd7945A_sizes,
+ rd9134D_sizes,
+ rd9122S_sizes,
+ rd7912P_sizes,
+ rd7914P_sizes,
+ rd7958A_sizes,
+ rd7957A_sizes,
+ rd7933H_sizes,
+ rd9134L_sizes,
+ rd7936H_sizes,
+ rd7937H_sizes,
+ rd7914P_sizes,
+ rd7945A_sizes,
+ rd9122S_sizes,
+ rd7957B_sizes,
+ rd7958B_sizes,
+ rd7959B_sizes,
+ rd2200A_sizes,
+ rd2203A_sizes,
};
int nrdcompatinfo = sizeof(rdcompatinfo) / sizeof(rdcompatinfo[0]);
-extern struct rd_softc rd_softc[];
-
rdmakedisklabel(unit, lp)
int unit;
struct disklabel *lp;
{
register struct rd_softc *rs = &rd_softc[unit];
register struct rdcompatinfo *ci = &rdcompatinfo[rs->sc_type];
+ struct rdidentinfo *ri = &rdidentinfo[rs->sc_type];
register struct partition *pi;
register int dcount;
- lp->d_nsectors = ci->nbpt;
- lp->d_ntracks = ci->ntpc;
- lp->d_ncylinders = ci->ncyl;
- lp->d_secpercyl = ci->nbpt * ci->ntpc;
- lp->d_secperunit = lp->d_secpercyl * ci->ncyl;
+ lp->d_nsectors = ri->ri_nbpt;
+ lp->d_ntracks = ri->ri_ntpc;
+ lp->d_ncylinders = ri->ri_ncyl;
+ lp->d_secpercyl = ri->ri_nbpt * ri->ri_ntpc;
+ lp->d_secperunit = lp->d_secpercyl * ri->ri_ncyl;
lp->d_rpm = 3600;
lp->d_interleave = 1;
lp->d_npartitions = 8;
diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h
index 2bd93d2715f..6d1214d46a7 100644
--- a/sys/arch/hp300/dev/rdvar.h
+++ b/sys/arch/hp300/dev/rdvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rdvar.h,v 1.2 1994/10/26 07:24:56 cgd Exp $ */
+/* $NetBSD: rdvar.h,v 1.3 1995/11/19 19:07:21 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -46,6 +46,9 @@ struct rdidentinfo {
short ri_hwid; /* 2 byte HW id */
short ri_maxunum; /* maximum allowed unit number */
char *ri_desc; /* drive type description */
+ int ri_nbpt; /* DEV_BSIZE blocks per track */
+ int ri_ntpc; /* tracks per cylinder */
+ int ri_ncyl; /* cylinders per unit */
int ri_nblocks; /* DEV_BSIZE blocks on disk */
};
@@ -65,6 +68,7 @@ struct rd_softc {
int sc_resid;
u_int sc_wpms;
struct rdinfo sc_info;
+ struct rd_describe sc_rddesc;
struct devqueue sc_dq;
struct rd_iocmd sc_ioc;
struct rd_rscmd sc_rsc;
@@ -100,3 +104,8 @@ struct rdstats {
#define RDRETRY 5
#define RDWAITC 1 /* min time for timeout in seconds */
+
+#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 04e69fdf8a2..b61f563dd8d 100644
--- a/sys/arch/hp300/dev/scsi.c
+++ b/sys/arch/hp300/dev/scsi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi.c,v 1.5.2.1 1995/10/16 09:01:39 thorpej Exp $ */
+/* $NetBSD: scsi.c,v 1.7 1995/12/02 18:22:12 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -72,10 +72,10 @@ extern void isrlink();
extern void _insque();
extern void _remque();
-int scsiinit(), scsigo(), scsiintr(), scsixfer();
-void scsistart(), scsidone(), scsifree(), scsireset();
+int scsimatch(), scsigo(), scsiintr(), scsixfer();
+void scsiattach(), scsistart(), scsidone(), scsifree(), scsireset();
struct driver scsidriver = {
- scsiinit, "scsi", (int (*)())scsistart, scsigo, scsiintr,
+ scsimatch, scsiattach, "scsi", (int (*)())scsistart, scsigo, scsiintr,
(int (*)())scsidone,
};
@@ -122,8 +122,8 @@ scsiabort(hs, hd, where)
int startlen; /* XXX - kludge till I understand whats *supposed* to happen */
u_char junk;
- printf("scsi%d: abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n",
- hs->sc_hc->hp_unit, where, hd->scsi_psns, hd->scsi_ssts,
+ printf("%s: abort from %s: phase=0x%x, ssts=0x%x, ints=0x%x\n",
+ hs->sc_hc->hp_xname, where, hd->scsi_psns, hd->scsi_ssts,
hd->scsi_ints);
hd->scsi_ints = hd->scsi_ints;
@@ -178,8 +178,8 @@ out:
* Either way, reset the card & the SPC.
*/
if (len < 0 && hs)
- printf("scsi%d: abort failed. phase=0x%x, ssts=0x%x\n",
- hs->sc_hc->hp_unit, hd->scsi_psns, hd->scsi_ssts);
+ printf("%s: abort failed. phase=0x%x, ssts=0x%x\n",
+ hs->sc_hc->hp_xname, hd->scsi_psns, hd->scsi_ssts);
if (! ((junk = hd->scsi_ints) & INTS_RESEL)) {
hd->scsi_sctl |= SCTL_CTRLRST;
@@ -220,15 +220,39 @@ scsi_delay(delay)
}
int
-scsiinit(hc)
+scsimatch(hc)
register struct hp_ctlr *hc;
{
register struct scsi_softc *hs = &scsi_softc[hc->hp_unit];
register struct scsidevice *hd = (struct scsidevice *)hc->hp_addr;
-
- if ((hd->scsi_id & ID_MASK) != SCSI_ID)
- return(0);
- hc->hp_ipl = SCSI_IPL(hd->scsi_csr);
+ 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);
+
+ hc->hp_ipl = SCSI_IPL(hd->scsi_csr);
+ return (1);
+ /* NOTREACHED */
+ }
+
+ return (0);
+}
+
+void
+scsiattach(hc)
+ struct hp_ctlr *hc;
+{
+ register struct scsi_softc *hs = &scsi_softc[hc->hp_unit];
+ register struct scsidevice *hd = (struct scsidevice *)hc->hp_addr;
+
hs->sc_hc = hc;
hs->sc_dq.dq_unit = hc->hp_unit;
hs->sc_dq.dq_driver = &scsidriver;
@@ -238,12 +262,45 @@ scsiinit(hc)
scsi_isr[hc->hp_unit].isr_arg = hc->hp_unit;
isrlink(&scsi_isr[hc->hp_unit]);
scsireset(hc->hp_unit);
+
+ /*
+ * Print information about what we've found.
+ */
+ printf(":");
+ if (hs->sc_flags & SCSI_DMA32)
+ printf(" 32 bit dma, ");
+
+ switch (hs->sc_sync) {
+ case 0:
+ printf("async");
+ break;
+
+ case (TMOD_SYNC | 0x3e):
+ printf("250ns sync");
+ break;
+
+ case (TMOD_SYNC | 0x5e):
+ printf("375ns sync");
+ break;
+
+ case (TMOD_SYNC | 0x7d):
+ printf("500ns sync");
+ break;
+
+ default:
+ panic("scsiattach: unknown sync param 0x%x", hs->sc_sync);
+ }
+
+ if ((hd->scsi_hconf & HCONF_PARITY) == 0)
+ printf(", no parity");
+
+ printf(", scsi id %d\n", hs->sc_scsiid);
+
/*
* XXX scale initialization wait according to CPU speed.
* Should we do this for all wait? Should we do this at all?
*/
scsi_init_wait *= cpuspeed;
- return(1);
}
void
@@ -258,8 +315,6 @@ scsireset(unit)
if (hs->sc_flags & SCSI_ALIVE)
scsiabort(hs, hd, "reset");
- printf("scsi%d: ", unit);
-
hd->scsi_id = 0xFF;
DELAY(100);
/*
@@ -276,10 +331,8 @@ scsireset(unit)
hd->scsi_tcl = 0;
hd->scsi_ints = 0;
- if ((hd->scsi_id & ID_WORD_DMA) == 0) {
+ if ((hd->scsi_id & ID_WORD_DMA) == 0)
hs->sc_flags |= SCSI_DMA32;
- printf("32 bit dma, ");
- }
/* Determine Max Synchronous Transfer Rate */
if (scsi_nosync)
@@ -289,19 +342,15 @@ scsireset(unit)
switch (i) {
case 0:
hs->sc_sync = TMOD_SYNC | 0x3e; /* 250 nsecs */
- printf("250ns sync");
break;
case 1:
hs->sc_sync = TMOD_SYNC | 0x5e; /* 375 nsecs */
- printf("375ns sync");
break;
case 2:
hs->sc_sync = TMOD_SYNC | 0x7d; /* 500 nsecs */
- printf("500ns sync");
break;
case 3:
hs->sc_sync = 0;
- printf("async");
break;
}
@@ -312,19 +361,17 @@ scsireset(unit)
i = (~hd->scsi_hconf) & 0x7;
hs->sc_scsi_addr = 1 << i;
hd->scsi_bdid = i;
+ hs->sc_scsiid = i;
if (hd->scsi_hconf & HCONF_PARITY)
hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
SCTL_SEL_ENAB | SCTL_RESEL_ENAB |
SCTL_INTR_ENAB | SCTL_PARITY_ENAB;
- else {
+ else
hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
SCTL_SEL_ENAB | SCTL_RESEL_ENAB |
SCTL_INTR_ENAB;
- printf(", no parity");
- }
- hd->scsi_sctl &=~ SCTL_DISABLE;
- printf(", scsi id %d\n", i);
+ hd->scsi_sctl &=~ SCTL_DISABLE;
hs->sc_flags |= SCSI_ALIVE;
}
@@ -337,7 +384,7 @@ scsierror(hs, hd, ints)
int unit = hs->sc_hc->hp_unit;
char *sep = "";
- printf("scsi%d: ", unit);
+ printf("%s: ", hs->sc_hc->hp_xname);
if (ints & INTS_RST) {
DELAY(100);
if (hd->scsi_hconf & HCONF_SD)
@@ -668,8 +715,8 @@ scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
goto out;
default:
- printf("scsi%d: unexpected phase %d in icmd from %d\n",
- hs->sc_hc->hp_unit, phase, target);
+ printf("%s: unexpected phase %d in icmd from %d\n",
+ hs->sc_hc->hp_xname, phase, target);
goto abort;
}
/* wait for last command to complete */
@@ -773,8 +820,8 @@ finishxfer(hs, hd, target)
return;
default:
- printf("scsi%d: unexpected phase %d in finishxfer from %d\n",
- hs->sc_hc->hp_unit, phase, target);
+ printf("%s: unexpected phase %d in finishxfer from %d\n",
+ hs->sc_hc->hp_xname, phase, target);
goto abort;
}
if (ints = hd->scsi_ints) {
@@ -996,8 +1043,8 @@ scsigo(ctlr, slave, unit, bp, cdb, pad)
goto out;
default:
- printf("scsi%d: unexpected phase %d in go from %d\n",
- hs->sc_hc->hp_unit, phase, slave);
+ printf("%s: unexpected phase %d in go from %d\n",
+ hs->sc_hc->hp_xname, phase, slave);
goto abort;
}
while ((ints = hd->scsi_ints) == 0) {
@@ -1073,8 +1120,8 @@ out:
#ifdef DEBUG
hs->sc_flags |= SCSI_PAD;
if (i & 1)
- printf("scsi%d: odd byte count: %d bytes @ %d\n",
- ctlr, i, bp->b_cylin);
+ printf("%s: odd byte count: %d bytes @ %d\n",
+ hs->sc_hc->hp_xname, i, bp->b_cylin);
#endif
} else
i += 4;
@@ -1102,7 +1149,7 @@ scsidone(unit)
#ifdef DEBUG
if (scsi_debug)
- printf("scsi%d: done called!\n", unit);
+ printf("%s: done called!\n", scsi_softc[unit].sc_hc->hp_xname);
#endif
/* dma operation is done -- turn off card dma */
hd->scsi_csr &=~ (CSR_DE1|CSR_DE0);
diff --git a/sys/arch/hp300/dev/scsivar.h b/sys/arch/hp300/dev/scsivar.h
index 8e8941f73aa..6f7db737286 100644
--- a/sys/arch/hp300/dev/scsivar.h
+++ b/sys/arch/hp300/dev/scsivar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: scsivar.h,v 1.4 1994/10/26 07:25:01 cgd Exp $ */
+/* $NetBSD: scsivar.h,v 1.5 1995/12/02 18:22:14 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -45,6 +45,7 @@ struct scsi_softc {
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];
};
diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c
index 3f3bf119f19..c6c26a42bbb 100644
--- a/sys/arch/hp300/dev/sd.c
+++ b/sys/arch/hp300/dev/sd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.16.2.2 1995/10/16 09:01:36 thorpej Exp $ */
+/* $NetBSD: sd.c,v 1.20 1995/12/09 07:31:03 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -85,11 +85,12 @@ extern void biodone();
extern int physio();
extern void TBIS();
-int sdinit();
-void sdstrategy(), sdstart(), sdustart(), sdgo(), sdintr();
+int sdmatch();
+void sdattach(), sdstrategy(), sdstart(), sdustart(), sdgo(), sdintr();
struct driver sddriver = {
- sdinit, "sd", (int (*)())sdstart, (int (*)())sdgo, (int (*)())sdintr,
+ sdmatch, sdattach, "sd", (int (*)())sdstart,
+ (int (*)())sdgo, (int (*)())sdintr,
};
#ifdef DEBUG
@@ -170,9 +171,10 @@ sdgetgeom(sc, hd)
}
static int
-sdident(sc, hd)
+sdident(sc, hd, verbose)
struct sd_softc *sc;
struct hp_device *hd;
+ int verbose;
{
int unit;
register int ctlr, slave;
@@ -265,45 +267,50 @@ sdident(sc, hd)
switch (inqbuf.version) {
case 1:
case 2:
- printf("sd%d: %s %s", hd->hp_unit, vendor, product);
- if (revision[0] != '\0')
- printf(" rev %s", revision);
- if (inqbuf.version == 2)
- printf(" (SCSI-2)");
+ if (verbose) {
+ printf(": <%s, %s, %s>", vendor, product, revision);
+ if (inqbuf.version == 2)
+ printf(" (SCSI-2)");
+ }
break;
default:
- printf("sd%d: type 0x%x, qual 0x%x, ver %d", hd->hp_unit,
- inqbuf.type, inqbuf.qual, inqbuf.version);
+ if (verbose)
+ printf(": type 0x%x, qual 0x%x, ver %d",
+ inqbuf.type, inqbuf.qual, inqbuf.version);
break;
}
- printf("\n");
+ if (verbose)
+ printf("\n");
- /*
- * Print out some additional information.
- */
- printf("sd%d: ", hd->hp_unit);
- switch (inqbuf.type) {
- case 4:
- printf("WORM, ");
- break;
+ 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;
+ case 5:
+ printf("CD-ROM, ");
+ break;
- case 7:
- printf("Magneto-optical, ");
- break;
+ case 7:
+ printf("Magneto-optical, ");
+ break;
- default:
- printf("%d cylinders, %d heads, ", sc->sc_cyls, sc->sc_heads);
- }
+ 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");
+ 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_wpms = 32 * (60 * DEV_BSIZE / 2); /* XXX */
scsi_delay(0);
@@ -314,7 +321,7 @@ failed:
}
int
-sdinit(hd)
+sdmatch(hd)
register struct hp_device *hd;
{
register struct sd_softc *sc = &sd_softc[hd->hp_unit];
@@ -327,16 +334,27 @@ sdinit(hd)
*/
sc->sc_format_pid = -1;
sc->sc_punit = sdpunit(hd->hp_flags);
- sc->sc_type = sdident(sc, hd);
+ sc->sc_type = sdident(sc, hd, 0);
if (sc->sc_type < 0)
- return(0);
+ return (0);
+
+ return (1);
+}
+
+void
+sdattach(hd)
+ register struct hp_device *hd;
+{
+ struct sd_softc *sc = &sd_softc[hd->hp_unit];
+
+ (void)sdident(sc, hd, 1); /* XXX Ick. */
+
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;
sc->sc_flags |= SDF_ALIVE;
- return(1);
}
void
@@ -400,8 +418,8 @@ sdgetcapacity(sc, hd, dev)
if (i != STS_CHECKCOND || (sc->sc_flags & SDF_RMEDIA) == 0) {
#ifdef DEBUG
if (sddebug & SDB_CAPACITY)
- printf("sd%d: read_capacity returns %d\n",
- hd->hp_unit, i);
+ printf("%s: read_capacity returns %d\n",
+ hd->hp_xname, i);
#endif
free(capbuf, M_DEVBUF);
return (-1);
@@ -414,8 +432,8 @@ sdgetcapacity(sc, hd, dev)
sc->sc_bshift = 0;
#ifdef DEBUG
if (sddebug & SDB_CAPACITY)
- printf("sd%d: removable media not present\n",
- hd->hp_unit);
+ printf("%s: removable media not present\n",
+ hd->hp_xname);
#endif
free(capbuf, M_DEVBUF);
return (1);
@@ -430,8 +448,8 @@ sdgetcapacity(sc, hd, dev)
if (sc->sc_blksize != DEV_BSIZE) {
if (sc->sc_blksize < DEV_BSIZE) {
- printf("sd%d: need at least %d byte blocks - %s\n",
- hd->hp_unit, DEV_BSIZE, "drive ignored");
+ printf("%s: need at least %d byte blocks - %s\n",
+ hd->hp_xname, DEV_BSIZE, "drive ignored");
return (-1);
}
for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1)
@@ -440,7 +458,7 @@ sdgetcapacity(sc, hd, dev)
}
#ifdef DEBUG
if (sddebug & SDB_CAPACITY)
- printf("sd%d: blks=%d, blksize=%d, bshift=%d\n", hd->hp_unit,
+ printf("%s: blks=%d, blksize=%d, bshift=%d\n", hd->hp_xname,
sc->sc_blks, sc->sc_blksize, sc->sc_bshift);
#endif
sdgetgeom(sc, hd);
@@ -520,13 +538,13 @@ sdgetinfo(dev)
/* XXX ensure size is at least one device block */
lp->d_partitions[2].p_size =
roundup(LABELSECTOR+1, btodb(sc->sc_blksize));
- msg = readdisklabel(sdlabdev(dev), sdstrategy, lp);
+ msg = readdisklabel(sdlabdev(dev), sdstrategy, lp, NULL);
if (msg == NULL)
return (0);
}
pi = lp->d_partitions;
- printf("sd%d: WARNING: %s, ", unit, msg);
+ printf("%s: WARNING: %s, ", sc->sc_hd->hp_xname, msg);
#ifdef COMPAT_NOLABEL
if (usedefault) {
printf("using old default partitioning\n");
@@ -825,7 +843,7 @@ sderror(unit, sc, hp, stat)
sc->sc_punit, sdsense[unit].sense,
sizeof(sdsense[unit].sense));
sp = (struct scsi_xsense *)sdsense[unit].sense;
- printf("sd%d: scsi sense class %d, code %d", unit,
+ printf("%s: scsi sense class %d, code %d", hp->hp_xname,
sp->class, sp->code);
if (sp->class == 7) {
printf(", key %d", sp->key);
@@ -955,8 +973,8 @@ sdgo(unit)
pad = (bp->b_bcount & (sc->sc_blksize - 1)) != 0;
#ifdef DEBUG
if (pad)
- printf("sd%d: partial block xfer -- %x bytes\n",
- unit, bp->b_bcount);
+ printf("%s: partial block xfer -- %x bytes\n",
+ sc->sc_hd->hp_xname, bp->b_bcount);
#endif
sdstats[unit].sdtransfers++;
}
@@ -975,8 +993,9 @@ sdgo(unit)
}
#ifdef DEBUG
if (sddebug & SDB_ERROR)
- printf("sd%d: sdstart: %s adr %d blk %d len %d ecnt %d\n",
- unit, bp->b_flags & B_READ? "read" : "write",
+ printf("%s: sdstart: %s adr %d blk %d len %d ecnt %d\n",
+ sc->sc_hd->hp_xname,
+ bp->b_flags & B_READ? "read" : "write",
bp->b_un.b_addr, bp->b_cylin, bp->b_bcount,
sdtab[unit].b_errcnt);
#endif
@@ -996,7 +1015,7 @@ sdintr(unit, stat)
int cond;
if (bp == NULL) {
- printf("sd%d: bp == NULL\n", unit);
+ printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
return;
}
if (hp->hp_dk >= 0)
@@ -1004,16 +1023,17 @@ sdintr(unit, stat)
if (stat) {
#ifdef DEBUG
if (sddebug & SDB_ERROR)
- printf("sd%d: sdintr: bad scsi status 0x%x\n",
- unit, stat);
+ printf("%s: sdintr: bad scsi status 0x%x\n",
+ sc->sc_hd->hp_xname, stat);
#endif
cond = sderror(unit, sc, hp, stat);
if (cond) {
if (cond < 0 && sdtab[unit].b_errcnt++ < SDRETRY) {
#ifdef DEBUG
if (sddebug & SDB_ERROR)
- printf("sd%d: retry #%d\n",
- unit, sdtab[unit].b_errcnt);
+ printf("%s: retry #%d\n",
+ sc->sc_hd->hp_xname,
+ sdtab[unit].b_errcnt);
#endif
sdstart(unit);
return;
diff --git a/sys/arch/hp300/dev/sdvar.h b/sys/arch/hp300/dev/sdvar.h
index 906227f927f..13a74c6398a 100644
--- a/sys/arch/hp300/dev/sdvar.h
+++ b/sys/arch/hp300/dev/sdvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sdvar.h,v 1.2.2.1 1995/10/15 10:11:06 thorpej Exp $ */
+/* $NetBSD: sdvar.h,v 1.3 1995/10/15 10:03:20 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
diff --git a/sys/arch/hp300/dev/st.c b/sys/arch/hp300/dev/st.c
index b7bcf6265c4..69841b2f550 100644
--- a/sys/arch/hp300/dev/st.c
+++ b/sys/arch/hp300/dev/st.c
@@ -1,4 +1,4 @@
-/* $NetBSD: st.c,v 1.11.2.1 1995/10/16 09:01:38 thorpej Exp $ */
+/* $NetBSD: st.c,v 1.13 1995/12/02 18:22:18 thorpej Exp $ */
/*
* Copyright (c) 1990 University of Utah.
@@ -104,9 +104,10 @@ extern void scsi_str __P((char *, char *, size_t));
extern int scsi_immed_command();
-int stinit(), ststart(), stgo(), stintr();
+int stmatch(), ststart(), stgo(), stintr();
+void stattach();
struct driver stdriver = {
- stinit, "st", ststart, stgo, stintr,
+ stmatch, stattach, "st", ststart, stgo, stintr,
};
struct st_softc {
@@ -223,7 +224,8 @@ int st_extti = 0x01; /* bitmask of unit numbers, do extra */
/* sensing so TTi display gets updated */
#endif
-stinit(hd)
+int
+stmatch(hd)
register struct hp_device *hd;
{
register struct st_softc *sc = &st_softc[hd->hp_unit];
@@ -233,21 +235,34 @@ stinit(hd)
bp->b_actb = &bp->b_actf;
sc->sc_hd = hd;
sc->sc_punit = stpunit(hd->hp_flags);
- sc->sc_type = stident(sc, hd);
+ sc->sc_type = stident(sc, hd, 0);
if (sc->sc_type < 0)
- return(0);
+ 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_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;
- return(1);
}
-stident(sc, hd)
+int
+stident(sc, hd, verbose)
register struct st_softc *sc;
register struct hp_device *hd;
+ int verbose;
{
int unit;
int ctlr, slave;
@@ -315,12 +330,12 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version);
sizeof(st_inqbuf.inqbuf.product_id));
scsi_str(st_inqbuf.inqbuf.rev, revision,
sizeof(st_inqbuf.inqbuf.rev));
- printf("st%d: %s, %s rev %s\n", hd->hp_unit, vendor, product,
- revision);
+ if (verbose)
+ printf(": <%s, %s, %s>\n", vendor, product, revision);
}
if (stat == 0xff) {
- printf("st%d: Cant handle this tape drive\n", hd->hp_unit);
+ printf("st%d: Can't handle this tape drive\n", hd->hp_unit);
goto failed;
}
@@ -359,8 +374,9 @@ st_inqbuf.inqbuf.qual, st_inqbuf.inqbuf.version);
sc->sc_datalen[CMD_MODE_SELECT] = 12;
sc->sc_datalen[CMD_MODE_SENSE] = 12;
} else {
- printf("st%d: Unsupported tape device, faking it\n",
- hd->hp_unit);
+ if (verbose)
+ printf("%s: Unsupported tape device, faking it\n",
+ sc->sc_hd->hp_xname);
sc->sc_tapeid = MT_ISAR;
sc->sc_datalen[CMD_REQUEST_SENSE] = 8;
sc->sc_datalen[CMD_INQUIRY] = 5;
@@ -618,7 +634,7 @@ retryselect:
}
break;
default:
- uprintf("st%d: not ready\n", UNIT(dev));
+ uprintf("%s: not ready\n", sc->sc_hd->hp_xname);
prtkey(UNIT(dev), sc);
break;
}
@@ -660,7 +676,8 @@ retryselect:
sc->sc_filepos = 0;
#ifdef DEBUG
if (st_debug & ST_FMKS)
- printf("st%d: open filepos = %d\n", UNIT(dev), sc->sc_filepos);
+ printf("%s: open filepos = %d\n", sc->sc_hd->hp_xname,
+ sc->sc_filepos);
#endif
sc->sc_flags |= (STF_OPEN);
@@ -780,8 +797,9 @@ stgo(unit)
nblks = bp->b_bcount / sc->sc_blklen;
if (bp->b_bcount % sc->sc_blklen) {
tprintf(sc->sc_ctty,
- "st%d: I/O not block aligned %d/%ld\n",
- unit, sc->sc_blklen, bp->b_bcount);
+ "%s: I/O not block aligned %d/%ld\n",
+ sc->sc_hd->hp_xname, sc->sc_blklen,
+ bp->b_bcount);
cmd->cdb[1] &= 0xfe; /* force error */
}
} else /* variable len */
@@ -810,8 +828,8 @@ stgo(unit)
if (bp->b_bcount & 1) {
#ifdef DEBUG
if (st_debug & ST_ODDIO)
- printf("stgo%d: odd count %d using manual transfer\n",
- unit, bp->b_bcount);
+ printf("%s: stgo: odd count %d using manual transfer\n",
+ sc->sc_hd->hp_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,
@@ -980,7 +998,7 @@ stintr(unit, stat)
#ifdef DEBUG
if (bp == NULL) {
- printf("st%d: bp == NULL\n", unit);
+ printf("%s: bp == NULL\n", sc->sc_hd->hp_xname);
return;
}
#endif
@@ -1021,8 +1039,9 @@ stintr(unit, stat)
*/
if (sc->sc_blklen) {
tprintf(sc->sc_ctty,
- "st%d: Incorrect Length Indicator, blkcnt diff %d\n",
- unit, sc->sc_blklen - bp->b_resid);
+ "%s: Incorrect Length Indicator, blkcnt diff %d\n",
+ sc->sc_hd->hp_xname,
+ sc->sc_blklen - bp->b_resid);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
@@ -1047,8 +1066,8 @@ stintr(unit, stat)
*/
if (!st_dmaoddretry) {
tprintf(sc->sc_ctty,
- "st%d: Odd length read %d\n",
- UNIT(bp->b_dev),
+ "%s: Odd length read %d\n",
+ sc->sc_hd->hp_xname,
bp->b_bcount - bp->b_resid);
bp->b_error = EIO;
bp->b_flags |= B_ERROR;
@@ -1059,8 +1078,8 @@ stintr(unit, stat)
*/
#ifdef DEBUG
if (st_debug & ST_ODDIO)
- printf("st%d: stintr odd count %d, do BSR then oddio\n",
- UNIT(bp->b_dev),
+ printf("%s: stintr odd count %d, do BSR then oddio\n",
+ sc->sc_hd->hp_xname,
bp->b_bcount - bp->b_resid);
#endif
stat = scsi_tt_oddio(hp->hp_ctlr, hp->hp_slave,
@@ -1087,13 +1106,15 @@ stintr(unit, stat)
bp->b_error = ENOSPC;
break;
}
- tprintf(sc->sc_ctty, "st%d: unknown scsi error\n", unit);
+ tprintf(sc->sc_ctty, "%s: unknown scsi error\n",
+ sc->sc_hd->hp_xname);
bp->b_flags |= B_ERROR;
bp->b_error = EIO;
break;
default:
- printf("st%d: stintr unknown stat 0x%x\n", unit, stat);
+ printf("%s: stintr unknown stat 0x%x\n", sc->sc_hd->hp_xname,
+ stat);
break;
}
#ifdef DEBUG
@@ -1205,8 +1226,8 @@ stcommand(dev, command, cnt)
sc->sc_filepos = 0;
break;
default:
- printf("st%d: stcommand bad command 0x%x\n",
- UNIT(dev), command);
+ printf("%s: stcommand bad command 0x%x\n",
+ sc->sc_hd->hp_xname, command);
}
sc->sc_flags |= STF_CMD;
@@ -1216,8 +1237,8 @@ stcommand(dev, command, cnt)
again:
#ifdef DEBUG
if (st_debug & ST_FMKS)
- printf("st%d: stcommand filepos %d cmdcnt %d cnt %d\n",
- UNIT(dev), sc->sc_filepos, cmdcnt, cnt);
+ printf("%s: stcommand filepos %d cmdcnt %d cnt %d\n",
+ sc->sc_hd->hp_xname, sc->sc_filepos, cmdcnt, cnt);
#endif
s = splbio();
while (bp->b_flags & B_BUSY) {
@@ -1258,7 +1279,8 @@ sterror(unit, sc, stat)
prtkey(unit, sc);
else if (stat)
tprintf(sc->sc_ctty,
- "st%d: bad scsi status 0x%x\n", unit, stat);
+ "%s: bad scsi status 0x%x\n", sc->sc_hd->hp_xname,
+ stat);
if ((sc->sc_flags & STF_CMD) && sc->sc_cmd == CMD_SPACE) /* fsf */
sc->sc_filepos--;
@@ -1290,32 +1312,36 @@ prtkey(unit, sc)
case XSK_NOTUSEDE:
break;
case XSK_REVERVED:
- tprintf(sc->sc_ctty, "st%d: Reserved sense key 0x%x\n",
- unit, xp->sc_xsense.key);
+ tprintf(sc->sc_ctty, "%s: Reserved sense key 0x%x\n",
+ sc->sc_hd->hp_xname, xp->sc_xsense.key);
break;
case XSK_NOTRDY:
- tprintf(sc->sc_ctty, "st%d: NOT READY\n", unit);
+ tprintf(sc->sc_ctty, "%s: NOT READY\n", sc->sc_hd->hp_xname);
break;
case XSK_MEDERR:
- tprintf(sc->sc_ctty, "st%d: MEDIUM ERROR\n", unit);
+ tprintf(sc->sc_ctty, "%s: MEDIUM ERROR\n", sc->sc_hd->hp_xname);
break;
case XSK_HRDWERR:
- tprintf(sc->sc_ctty, "st%d: HARDWARE ERROR\n", unit);
+ tprintf(sc->sc_ctty, "%s: HARDWARE ERROR\n",
+ sc->sc_hd->hp_xname);
break;
case XSK_ILLREQ:
- tprintf(sc->sc_ctty, "st%d: ILLEGAL REQUEST\n", unit);
+ tprintf(sc->sc_ctty, "%s: ILLEGAL REQUEST\n",
+ sc->sc_hd->hp_xname);
break;
case XSK_UNTATTEN:
- tprintf(sc->sc_ctty, "st%d: UNIT ATTENTION\n", unit);
+ tprintf(sc->sc_ctty, "%s: UNIT ATTENTION\n",
+ sc->sc_hd->hp_xname);
break;
case XSK_DATAPROT:
- tprintf(sc->sc_ctty, "st%d: DATA PROTECT\n", unit);
+ tprintf(sc->sc_ctty, "%s: DATA PROTECT\n", sc->sc_hd->hp_xname);
break;
case XSK_BLNKCHK:
- tprintf(sc->sc_ctty, "st%d: BLANK CHECK\n", unit);
+ tprintf(sc->sc_ctty, "%s: BLANK CHECK\n", sc->sc_hd->hp_xname);
break;
case XSK_VENDOR:
- tprintf(sc->sc_ctty, "st%d: VENDER UNIQUE SENSE KEY ", unit);
+ tprintf(sc->sc_ctty, "%s: VENDER UNIQUE SENSE KEY ",
+ sc->sc_hd->hp_xname);
switch (sc->sc_tapeid) {
case MT_ISEXABYTE:
tprintf(sc->sc_ctty, "Exabyte: ");
@@ -1331,48 +1357,58 @@ prtkey(unit, sc)
}
break;
case XSK_CPYABORT:
- tprintf(sc->sc_ctty, "st%d: COPY ABORTED\n", unit);
+ tprintf(sc->sc_ctty, "%s: COPY ABORTED\n", sc->sc_hd->hp_xname);
break;
case XSK_ABORTCMD:
- tprintf(sc->sc_ctty, "st%d: ABORTED COMMAND\n", unit);
+ tprintf(sc->sc_ctty, "%s: ABORTED COMMAND\n",
+ sc->sc_hd->hp_xname);
break;
case XSK_VOLOVER:
- tprintf(sc->sc_ctty, "st%d: VOLUME OVERFLOW\n", unit);
+ tprintf(sc->sc_ctty, "%s: VOLUME OVERFLOW\n",
+ sc->sc_hd->hp_xname);
break;
default:
- tprintf(sc->sc_ctty, "st%d: unknown sense key 0x%x\n",
- unit, xp->sc_xsense.key);
+ tprintf(sc->sc_ctty, "%s: unknown sense key 0x%x\n",
+ sc->sc_hd->hp_xname, xp->sc_xsense.key);
}
if (sc->sc_tapeid == MT_ISEXABYTE) {
if (xp->exb_xsense.bpe)
- tprintf(sc->sc_ctty, "st%d: Bus Parity Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: Bus Parity Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.fpe)
tprintf(sc->sc_ctty,
- "st%d: Formatted Buffer Parity Errorn", unit);
+ "%s: Formatted Buffer Parity Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.eco)
- tprintf(sc->sc_ctty, "st%d: Error Counter Overflown",
- unit);
+ tprintf(sc->sc_ctty, "%s: Error Counter Overflow",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.tme)
- tprintf(sc->sc_ctty, "st%d: Tape Motion Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: Tape Motion Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.xfr)
- tprintf(sc->sc_ctty, "st%d: Transfer About Errorn",
- unit);
+ tprintf(sc->sc_ctty, "%s: Transfer About Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.tmd)
- tprintf(sc->sc_ctty, "st%d: Tape Mark Detect Errorn",
- unit);
+ tprintf(sc->sc_ctty, "%s: Tape Mark Detect Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.fmke)
- tprintf(sc->sc_ctty, "st%d: Filemark Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: Filemark Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.ure)
- tprintf(sc->sc_ctty, "st%d: Under Run Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: Under Run Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.sse)
- tprintf(sc->sc_ctty, "st%d: Servo System Errorn",
- unit);
+ tprintf(sc->sc_ctty, "%s: Servo System Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.fe)
- tprintf(sc->sc_ctty, "st%d: Formatter Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: Formatter Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.wseb)
- tprintf(sc->sc_ctty, "st%d: WSEB Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: WSEB Error",
+ sc->sc_hd->hp_xname);
if (xp->exb_xsense.wseo)
- tprintf(sc->sc_ctty, "st%d: WSEO Errorn", unit);
+ tprintf(sc->sc_ctty, "%s: WSEO Error",
+ sc->sc_hd->hp_xname);
}
}