summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/dev
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-01-12 15:13:47 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-01-12 15:13:47 +0000
commite661b0e07a7f4c778ac8e9b5eb341a7ad9795c2b (patch)
tree6158c02b8e503faa614ccff77b3cca01e9b912e4 /sys/arch/hp300/dev
parentd470dc6647ff9a7e3f6d00b205d12ab7428cc092 (diff)
Mostly sync to NetBSD-current of 011196. Compiles, links, boots to single
user. KNOWN NOT WORKING: * DIO-II devices * Dynamic executables NOT EVEN TRIED: * New config support
Diffstat (limited to 'sys/arch/hp300/dev')
-rw-r--r--sys/arch/hp300/dev/Makefile8
-rw-r--r--sys/arch/hp300/dev/ac.c3
-rw-r--r--sys/arch/hp300/dev/acioctl.h1
-rw-r--r--sys/arch/hp300/dev/acvar.h1
-rw-r--r--sys/arch/hp300/dev/ct.c6
-rw-r--r--sys/arch/hp300/dev/ctreg.h1
-rw-r--r--sys/arch/hp300/dev/dca.c182
-rw-r--r--sys/arch/hp300/dev/dcareg.h1
-rw-r--r--sys/arch/hp300/dev/dcm.c296
-rw-r--r--sys/arch/hp300/dev/dcmreg.h1
-rw-r--r--sys/arch/hp300/dev/device.h13
-rw-r--r--sys/arch/hp300/dev/devlist2h.awk167
-rw-r--r--sys/arch/hp300/dev/dio.c307
-rw-r--r--sys/arch/hp300/dev/diodevs104
-rw-r--r--sys/arch/hp300/dev/diodevs.h192
-rw-r--r--sys/arch/hp300/dev/diodevs_data.h142
-rw-r--r--sys/arch/hp300/dev/dioreg.h141
-rw-r--r--sys/arch/hp300/dev/diovar.h80
-rw-r--r--sys/arch/hp300/dev/dma.c39
-rw-r--r--sys/arch/hp300/dev/dmareg.h6
-rw-r--r--sys/arch/hp300/dev/dmavar.h4
-rw-r--r--sys/arch/hp300/dev/fhpib.c3
-rw-r--r--sys/arch/hp300/dev/fhpibreg.h1
-rw-r--r--sys/arch/hp300/dev/grf.c170
-rw-r--r--sys/arch/hp300/dev/grf_conf.c8
-rw-r--r--sys/arch/hp300/dev/grf_dv.c126
-rw-r--r--sys/arch/hp300/dev/grf_dvreg.h1
-rw-r--r--sys/arch/hp300/dev/grf_gb.c124
-rw-r--r--sys/arch/hp300/dev/grf_gbreg.h1
-rw-r--r--sys/arch/hp300/dev/grf_hy.c81
-rw-r--r--sys/arch/hp300/dev/grf_hyreg.h1
-rw-r--r--sys/arch/hp300/dev/grf_machdep.c9
-rw-r--r--sys/arch/hp300/dev/grf_rb.c124
-rw-r--r--sys/arch/hp300/dev/grf_rbreg.h1
-rw-r--r--sys/arch/hp300/dev/grf_subr.c123
-rw-r--r--sys/arch/hp300/dev/grf_tc.c181
-rw-r--r--sys/arch/hp300/dev/grf_tcreg.h1
-rw-r--r--sys/arch/hp300/dev/grfioctl.h1
-rw-r--r--sys/arch/hp300/dev/grfreg.h1
-rw-r--r--sys/arch/hp300/dev/grfvar.h31
-rw-r--r--sys/arch/hp300/dev/hil.c129
-rw-r--r--sys/arch/hp300/dev/hil_keymaps.c1
-rw-r--r--sys/arch/hp300/dev/hilioctl.h1
-rw-r--r--sys/arch/hp300/dev/hilreg.h1
-rw-r--r--sys/arch/hp300/dev/hilvar.h1
-rw-r--r--sys/arch/hp300/dev/hpib.c6
-rw-r--r--sys/arch/hp300/dev/hpibvar.h1
-rw-r--r--sys/arch/hp300/dev/if_le.c81
-rw-r--r--sys/arch/hp300/dev/if_lereg.h1
-rw-r--r--sys/arch/hp300/dev/if_levar.h5
-rw-r--r--sys/arch/hp300/dev/intio.c115
-rw-r--r--sys/arch/hp300/dev/intiovar.h50
-rw-r--r--sys/arch/hp300/dev/iotypes.h1
-rw-r--r--sys/arch/hp300/dev/ite.c155
-rw-r--r--sys/arch/hp300/dev/ite_dv.c0
-rw-r--r--sys/arch/hp300/dev/ite_gb.c0
-rw-r--r--sys/arch/hp300/dev/ite_hy.c0
-rw-r--r--sys/arch/hp300/dev/ite_rb.c0
-rw-r--r--sys/arch/hp300/dev/ite_subr.c8
-rw-r--r--sys/arch/hp300/dev/ite_tc.c0
-rw-r--r--sys/arch/hp300/dev/itereg.h1
-rw-r--r--sys/arch/hp300/dev/itevar.h8
-rw-r--r--sys/arch/hp300/dev/kbdmap.h18
-rw-r--r--sys/arch/hp300/dev/maskbits.h1
-rw-r--r--sys/arch/hp300/dev/mt.c6
-rw-r--r--sys/arch/hp300/dev/mtreg.h1
-rw-r--r--sys/arch/hp300/dev/nhpib.c3
-rw-r--r--sys/arch/hp300/dev/nhpibreg.h1
-rw-r--r--sys/arch/hp300/dev/ppi.c3
-rw-r--r--sys/arch/hp300/dev/ppiioctl.h1
-rw-r--r--sys/arch/hp300/dev/rd.c202
-rw-r--r--sys/arch/hp300/dev/rd_compat.c1
-rw-r--r--sys/arch/hp300/dev/rdreg.h1
-rw-r--r--sys/arch/hp300/dev/rdvar.h3
-rw-r--r--sys/arch/hp300/dev/scsi.c7
-rw-r--r--sys/arch/hp300/dev/scsireg.h1
-rw-r--r--sys/arch/hp300/dev/scsivar.h1
-rw-r--r--sys/arch/hp300/dev/sd.c199
-rw-r--r--sys/arch/hp300/dev/sd_compat.c1
-rw-r--r--sys/arch/hp300/dev/sdvar.h3
-rw-r--r--sys/arch/hp300/dev/st.c6
-rw-r--r--sys/arch/hp300/dev/stvar.h1
82 files changed, 3256 insertions, 452 deletions
diff --git a/sys/arch/hp300/dev/Makefile b/sys/arch/hp300/dev/Makefile
new file mode 100644
index 00000000000..9d0c418ba17
--- /dev/null
+++ b/sys/arch/hp300/dev/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1 1997/01/12 15:12:17 downsj Exp $
+# $NetBSD: Makefile,v 1.1 1996/12/17 08:40:59 thorpej Exp $
+
+AWK= awk
+
+diodevs.h diodevs_data.h: diodevs devlist2h.awk
+ /bin/rm -f diodevs.h diodevs_data.h
+ ${AWK} -f devlist2h.awk diodevs
diff --git a/sys/arch/hp300/dev/ac.c b/sys/arch/hp300/dev/ac.c
index c90eb0875ae..1e6c54544cc 100644
--- a/sys/arch/hp300/dev/ac.c
+++ b/sys/arch/hp300/dev/ac.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ac.c,v 1.4 1996/02/14 02:43:54 thorpej Exp $ */
+/* $OpenBSD: ac.c,v 1.4 1997/01/12 15:12:17 downsj Exp $
+/* $NetBSD: ac.c,v 1.6 1996/10/13 03:14:05 christos Exp $ */
/*
* Copyright (c) 1991 University of Utah.
diff --git a/sys/arch/hp300/dev/acioctl.h b/sys/arch/hp300/dev/acioctl.h
index 1d9544e595c..1c09209f210 100644
--- a/sys/arch/hp300/dev/acioctl.h
+++ b/sys/arch/hp300/dev/acioctl.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: acioctl.h,v 1.2 1997/01/12 15:12:18 downsj Exp $ */
/* $NetBSD: acioctl.h,v 1.2 1994/10/26 07:23:25 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/acvar.h b/sys/arch/hp300/dev/acvar.h
index 8ed78882806..e3dac326867 100644
--- a/sys/arch/hp300/dev/acvar.h
+++ b/sys/arch/hp300/dev/acvar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: acvar.h,v 1.2 1997/01/12 15:12:19 downsj Exp $ */
/* $NetBSD: acvar.h,v 1.2 1994/10/26 07:23:27 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c
index 374a66222af..596375523f8 100644
--- a/sys/arch/hp300/dev/ct.c
+++ b/sys/arch/hp300/dev/ct.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ct.c,v 1.15 1996/02/14 02:44:02 thorpej Exp $ */
+/* $OpenBSD: ct.c,v 1.5 1997/01/12 15:12:19 downsj Exp $ */
+/* $NetBSD: ct.c,v 1.18 1996/10/14 07:14:11 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -167,6 +168,9 @@ ctattach(hd)
sc->sc_dq.dq_slave = hd->hp_slave;
sc->sc_dq.dq_driver = &ctdriver;
sc->sc_flags |= CTF_ALIVE;
+
+ /* XXX Set device class. */
+ hd->hp_dev.dv_class = DV_TAPE;
}
int
diff --git a/sys/arch/hp300/dev/ctreg.h b/sys/arch/hp300/dev/ctreg.h
index 42b93735620..2ba97fb73b6 100644
--- a/sys/arch/hp300/dev/ctreg.h
+++ b/sys/arch/hp300/dev/ctreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: ctreg.h,v 1.4 1997/01/12 15:12:20 downsj Exp $ */
/* $NetBSD: ctreg.h,v 1.6 1996/02/09 18:00:35 scottr Exp $ */
/*
diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c
index f81f6a60d58..6d13a06bef3 100644
--- a/sys/arch/hp300/dev/dca.c
+++ b/sys/arch/hp300/dev/dca.c
@@ -1,4 +1,5 @@
-/* $NetBSD: dca.c,v 1.23.4.1 1996/06/06 15:39:09 thorpej Exp $ */
+/* $OpenBSD: dca.c,v 1.6 1997/01/12 15:12:21 downsj Exp $ */
+/* $NetBSD: dca.c,v 1.31 1996/12/17 08:41:00 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
@@ -36,9 +37,6 @@
* @(#)dca.c 8.2 (Berkeley) 1/12/94
*/
-#include "dca.h"
-#if NDCA > 0
-
/*
* Driver for the 98626/98644/internal serial interface on hp300/hp400,
* based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs.
@@ -61,24 +59,28 @@
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#ifndef NEWCONFIG
#include <hp300/dev/device.h>
+#endif
+
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
#include <hp300/dev/dcareg.h>
#include <hp300/hp300/isr.h>
-int dcamatch();
-void dcaattach();
-struct driver dcadriver = {
- dcamatch, dcaattach, "dca",
-};
-
struct dca_softc {
+ struct device sc_dev; /* generic device glue */
+#ifndef NEWCONFIG
struct hp_device *sc_hd; /* device info */
+#endif
struct dcadevice *sc_dca; /* pointer to hardware */
struct tty *sc_tty; /* our tty instance */
int sc_oflows; /* overflow counter */
@@ -92,12 +94,33 @@ struct dca_softc {
#define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */
#define DCA_ISCONSOLE 0x0008 /* indicates unit is console */
-} dca_softc[NDCA];
+};
+
+#ifdef NEWCONFIG
+int dcamatch __P((struct device *, struct cfdata *, void *));
+void dcaattach __P((struct device *, struct device *, void *));
+
+struct cfattach dca_ca = {
+ sizeof(struct dca_softc), dcamatch, dcaattach
+};
+
+struct cfdriver dca_cd = {
+ NULL, "dca", DV_TTY
+};
+#else /* ! NEWCONFIG */
+int dcamatch();
+void dcaattach();
+struct driver dcadriver = {
+ dcamatch, dcaattach, "dca",
+};
+
+#include "dca.h"
+struct dca_softc dca_softc[NDCA];
+#endif /* NEWCONFIG */
void dcastart();
int dcaparam();
int dcaintr __P((void *));
-int ndca = NDCA;
int dcadefaultrate = TTYDEF_SPEED;
int dcamajor;
@@ -146,6 +169,26 @@ long dcamintcount[16];
void dcainit __P((struct dcadevice *, int));
+#ifdef NEWCONFIG
+int
+dcamatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ switch (da->da_id) {
+ case DIO_DEVICE_ID_DCA0:
+ case DIO_DEVICE_ID_DCA0REM:
+ case DIO_DEVICE_ID_DCA1:
+ case DIO_DEVICE_ID_DCA1REM:
+ return (1);
+ }
+
+ return (0);
+}
+#else /* ! NEWCONFIG */
int
dcamatch(hd)
register struct hp_device *hd;
@@ -164,7 +207,21 @@ dcamatch(hd)
return (1);
}
+#endif /* NEWCONFIG */
+#ifdef NEWCONFIG
+void
+dcaattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct dca_softc *sc = (struct dca_softc *)self;
+ struct dio_attach_args *da = aux;
+ struct dcadevice *dca;
+ int unit = self->dv_unit;
+ int scode = da->da_scode;
+ int ipl;
+#else /* ! NEWCONFIG */
void
dcaattach(hd)
register struct hp_device *hd;
@@ -172,8 +229,12 @@ dcaattach(hd)
int unit = hd->hp_unit;
struct dcadevice *dca = (struct dcadevice *)hd->hp_addr;
struct dca_softc *sc = &dca_softc[unit];
+ int scode = hd->hp_args->hw_sc;
+ int ipl = hd->hp_ipl;
+#endif /* NEWCONFIG */
- if (hd->hp_args->hw_sc == conscode) {
+ if (scode == conscode) {
+ dca = (struct dcadevice *)conaddr;
sc->sc_flags |= DCA_ISCONSOLE;
DELAY(100000);
@@ -182,8 +243,29 @@ dcaattach(hd)
* the console probe, so we have to fixup cn_dev here.
*/
cn_tab->cn_dev = makedev(dcamajor, unit);
+ } else {
+#ifdef NEWCONFIG
+ dca = (struct dcadevice *)iomap(dio_scodetopa(da->da_scode),
+ da->da_size);
+ if (dca == NULL) {
+ printf("\n%s: can't map registers\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+#endif /* NEWCONFIG */
}
+ sc->sc_dca = dca;
+
+#ifdef NEWCONFIG
+ ipl = DIO_IPL(dca);
+ printf(" ipl %d", ipl);
+#else /* ! NEWCONFIG */
+ /* XXX Set the device class. */
+ hd->hp_dev.dv_class = DV_TTY;
+ bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device));
+#endif /* NEWCONFIG */
+
dca->dca_reset = 0xFF;
DELAY(100);
@@ -193,14 +275,16 @@ dcaattach(hd)
if ((dca->dca_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK)
sc->sc_flags |= DCA_HASFIFO;
- sc->sc_dca = dca;
-
/* Establish interrupt handler. */
- isrlink(dcaintr, sc, hd->hp_ipl,
+ (void) isrlink(dcaintr, sc, ipl,
(sc->sc_flags & DCA_HASFIFO) ? ISRPRI_TTY : ISRPRI_TTYNOBUF);
sc->sc_flags |= DCA_ACTIVE;
+#ifdef NEWCONFIG
+ if (self->dv_cfdata->cf_flags)
+#else
if (hd->hp_flags)
+#endif
sc->sc_flags |= DCA_SOFTCAR;
/* Enable interrupts. */
@@ -234,11 +318,11 @@ dcaattach(hd)
* Print prefix of device name,
* let kgdb_connect print the rest.
*/
- printf("%s: ", sc->sc_hd->hp_xname);
+ printf("%s: ", sc->sc_dev.dv_xname);
kgdb_connect(1);
} else
printf("%s: kgdb enabled\n",
- sc->sc_hd->hp_xname);
+ sc->sc_dev.dv_xname);
}
}
#endif
@@ -258,10 +342,16 @@ dcaopen(dev, flag, mode, p)
u_char code;
int s, error = 0;
+#ifdef NEWCONFIG
+ if (unit >= dca_cd.cd_ndevs ||
+ (sc = dca_cd.cd_devs[unit]) == NULL)
+ return (ENXIO);
+#else
if (unit >= NDCA)
return (ENXIO);
-
sc = &dca_softc[unit];
+#endif /* NEWCONFIG */
+
if ((sc->sc_flags & DCA_ACTIVE) == 0)
return (ENXIO);
@@ -355,7 +445,12 @@ dcaclose(dev, flag, mode, p)
unit = DCAUNIT(dev);
+#ifdef NEWCONFIG
+ sc = dca_cd.cd_devs[unit];
+#else
sc = &dca_softc[unit];
+#endif
+
dca = sc->sc_dca;
tp = sc->sc_tty;
(*linesw[tp->t_line].l_close)(tp, flag);
@@ -390,10 +485,17 @@ dcaread(dev, uio, flag)
int flag;
{
int unit = DCAUNIT(dev);
- struct dca_softc *sc = &dca_softc[unit];
- struct tty *tp = sc->sc_tty;
+ struct dca_softc *sc;
+ struct tty *tp;
int error, of;
+
+#ifdef NEWCONFIG
+ sc = dca_cd.cd_devs[unit];
+#else
+ sc = &dca_softc[unit];
+#endif
+ tp = sc->sc_tty;
of = sc->sc_oflows;
error = (*linesw[tp->t_line].l_read)(tp, uio, flag);
/*
@@ -401,7 +503,7 @@ dcaread(dev, uio, flag)
* at interrupt time just exacerbates the problem.
*/
if (sc->sc_oflows != of)
- log(LOG_WARNING, "%s: silo overflow\n", sc->sc_hd->hp_xname);
+ log(LOG_WARNING, "%s: silo overflow\n", sc->sc_dev.dv_xname);
return (error);
}
@@ -411,7 +513,12 @@ dcawrite(dev, uio, flag)
struct uio *uio;
int flag;
{
+#ifdef NEWCONFIG
+ struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)];
+ struct tty *tp = sc->sc_tty;
+#else
struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty;
+#endif
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
}
@@ -420,8 +527,13 @@ struct tty *
dcatty(dev)
dev_t dev;
{
+#ifdef NEWCONFIG
+ struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)];
+#else
+ struct dca_softc *sc = &dca_softc[DCAUNIT(dev)];
+#endif
- return (dca_softc[DCAUNIT(dev)].sc_tty);
+ return (sc->sc_tty);
}
int
@@ -429,7 +541,7 @@ dcaintr(arg)
void *arg;
{
struct dca_softc *sc = arg;
- int unit = sc->sc_hd->hp_unit;
+ int unit = sc->sc_dev.dv_unit;
register struct dcadevice *dca = sc->sc_dca;
register struct tty *tp = sc->sc_tty;
register u_char code;
@@ -512,7 +624,7 @@ dcaintr(arg)
if (code & IIR_NOPEND)
return (1);
log(LOG_WARNING, "%s: weird interrupt: 0x%x\n",
- sc->sc_hd->hp_xname, code);
+ sc->sc_dev.dv_xname, code);
/* fall through */
case IIR_MLSC:
dcamint(sc);
@@ -591,7 +703,11 @@ dcaioctl(dev, cmd, data, flag, p)
struct proc *p;
{
int unit = DCAUNIT(dev);
+#ifdef NEWCONFIG
+ struct dca_softc *sc = dca_cd.cd_devs[unit];
+#else
struct dca_softc *sc = &dca_softc[unit];
+#endif
struct tty *tp = sc->sc_tty;
struct dcadevice *dca = sc->sc_dca;
int error;
@@ -680,7 +796,11 @@ dcaparam(tp, t)
register struct termios *t;
{
int unit = DCAUNIT(tp->t_dev);
+#ifdef NEWCONFIG
+ struct dca_softc *sc = dca_cd.cd_devs[unit];
+#else
struct dca_softc *sc = &dca_softc[unit];
+#endif
struct dcadevice *dca = sc->sc_dca;
int cfcr, cflag = t->c_cflag;
int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab);
@@ -756,7 +876,11 @@ dcastart(tp)
register struct tty *tp;
{
int s, c, unit = DCAUNIT(tp->t_dev);
+#ifdef NEWCONFIG
+ struct dca_softc *sc = dca_cd.cd_devs[unit];
+#else
struct dca_softc *sc = &dca_softc[unit];
+#endif
struct dcadevice *dca = sc->sc_dca;
s = spltty();
@@ -795,7 +919,7 @@ out:
* Stop output on a line.
*/
/*ARGSUSED*/
-int
+void
dcastop(tp, flag)
register struct tty *tp;
int flag;
@@ -871,8 +995,9 @@ dcainit(dca, rate)
dca->dca_ier = rate >> 8;
dca->dca_cfcr = CFCR_8BITS;
dca->dca_ier = IER_ERXRDY | IER_ETXRDY;
- dca->dca_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14;
- dca->dca_mcr |= MCR_IEN;
+ dca->dca_fifo =
+ FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1;
+ dca->dca_mcr = MCR_DTR | MCR_RTS;
DELAY(100);
stat = dca->dca_iir;
splx(s);
@@ -1030,4 +1155,3 @@ dcacnputc(dev, c)
stat = dca_cn->dca_iir;
splx(s);
}
-#endif /* NDCA > 0 */
diff --git a/sys/arch/hp300/dev/dcareg.h b/sys/arch/hp300/dev/dcareg.h
index b2ee8e5cef6..4cf68db4002 100644
--- a/sys/arch/hp300/dev/dcareg.h
+++ b/sys/arch/hp300/dev/dcareg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: dcareg.h,v 1.4 1997/01/12 15:12:21 downsj Exp $ */
/* $NetBSD: dcareg.h,v 1.6 1996/02/24 00:55:02 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c
index a124effeb8f..5f211ba768b 100644
--- a/sys/arch/hp300/dev/dcm.c
+++ b/sys/arch/hp300/dev/dcm.c
@@ -1,4 +1,5 @@
-/* $NetBSD: dcm.c,v 1.27.4.1 1996/06/06 15:39:11 thorpej Exp $ */
+/* $OpenBSD: dcm.c,v 1.6 1997/01/12 15:12:22 downsj Exp $ */
+/* $NetBSD: dcm.c,v 1.34 1996/12/17 08:41:01 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
@@ -49,8 +50,6 @@
* Test console support.
*/
-#include "dcm.h"
-#if NDCM > 0
/*
* 98642/MUX
*/
@@ -65,13 +64,20 @@
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/time.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#ifndef NEWCONFIG
#include <hp300/dev/device.h>
+#endif
+
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
#include <hp300/dev/dcmreg.h>
#include <hp300/hp300/isr.h>
@@ -79,12 +85,6 @@
#define DEFAULT_BAUD_RATE 9600
#endif
-int dcmmatch(), dcmparam();
-void dcmattach(), dcmstart();
-struct driver dcmdriver = {
- dcmmatch, dcmattach, "dcm",
-};
-
struct speedtab dcmspeedtab[] = {
0, BR_0,
50, BR_50,
@@ -223,7 +223,10 @@ static char iconv[16] = {
#define NDCMPORT 4
struct dcm_softc {
+ struct device sc_dev; /* generic device glue */
+#ifndef NEWCONFIG
struct hp_device *sc_hd; /* device info */
+#endif
struct dcmdevice *sc_dcm; /* pointer to hardware */
struct tty *sc_tty[NDCMPORT]; /* our tty instances */
struct modemreg *sc_modem[NDCMPORT]; /* modem control */
@@ -249,71 +252,98 @@ struct dcm_softc {
#ifdef DCMSTATS
struct dcmstats sc_stats; /* metrics gathering */
#endif
-} dcm_softc[NDCM];
+};
+
+#ifdef NEWCONFIG
+int dcmmatch __P((struct device *, struct cfdata *, void *));
+void dcmattach __P((struct device *, struct device *, void *));
+
+struct cfattach dcm_ca = {
+ sizeof(struct dcm_softc), dcmmatch, dcmattach
+};
+
+struct cfdriver dcm_cd = {
+ NULL, "dcm", DV_TTY
+};
+#else /* ! NEWCONFIG */
+int dcmmatch();
+void dcmattach();
+
+struct driver dcmdriver = {
+ dcmmatch, dcmattach, "dcm",
+};
+
+#include "dcm.h"
+struct dcm_softc dcm_softc[NDCM];
+#endif /* NEWCONFIG */
+
+int dcmparam();
+void dcmstart();
void dcminit __P((struct dcmdevice *, int, int));
int dcmintr __P((void *));
+int dcmselftest __P((struct dcm_softc *));
+
+#ifdef NEWCONFIG
+int
+dcmmatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ switch (da->da_id) {
+ case DIO_DEVICE_ID_DCM:
+ case DIO_DEVICE_ID_DCMREM:
+ return (1);
+ }
+
+ return (0);
+}
+#else /* ! NEWCONFIG */
int
dcmmatch(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, mbits;
+ struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr;
- dcm = (struct dcmdevice *)hd->hp_addr;
if ((dcm->dcm_rsid & 0x1f) != DCMID)
return (0);
- brd = hd->hp_unit;
-
sc->sc_hd = hd;
hd->hp_ipl = DCMIPL(dcm->dcm_ic);
-
- /*
- * Empirically derived self-test magic
- */
- s = spltty();
- dcm->dcm_rsid = DCMRS;
- DELAY(50000); /* 5000 is not long enough */
- dcm->dcm_rsid = 0;
- dcm->dcm_ic = IC_IE;
- dcm->dcm_cr = CR_SELFT;
- while ((dcm->dcm_ic & IC_IR) == 0)
- if (++timo == 20000)
- return (0);
- DELAY(50000); /* XXX why is this needed ???? */
- while ((dcm->dcm_iir & IIR_SELFT) == 0)
- if (++timo == 400000)
- return (0);
- DELAY(50000); /* XXX why is this needed ???? */
- if (dcm->dcm_stcon != ST_OK) {
- if (hd->hp_args->hw_sc != conscode)
- printf("dcm%d: self test failed: %x\n",
- brd, dcm->dcm_stcon);
- return (0);
- }
- dcm->dcm_ic = IC_ID;
- splx(s);
-
- return (1);
}
+#endif /* NEWCONFIG */
+#ifdef NEWCONFIG
+void
+dcmattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct dcm_softc *sc = (struct dcm_softc *)self;
+ struct dio_attach_args *da = aux;
+ struct dcmdevice *dcm;
+ int brd = self->dv_unit;
+ int scode = da->da_scode;
+ int i, mbits, ipl;
+#else /* ! NEWCONFIG */
void
dcmattach(hd)
register struct hp_device *hd;
{
struct dcm_softc *sc = &dcm_softc[hd->hp_unit];
- struct dcmdevice *dcm;
- int i, timo = 0;
- int s, brd, mbits;
-
- dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr;
-
- brd = hd->hp_unit;
- if (hd->hp_args->hw_sc == conscode) {
+ struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr;
+ int brd = hd->hp_unit;
+ int scode = hd->hp_args->hw_sc;
+ int i, mbits, ipl = hd->hp_ipl;
+#endif /* NEWCONFIG */
+
+ if (scode == conscode) {
+ dcm = (struct dcmdevice *)conaddr;
sc->sc_flags |= DCM_ISCONSOLE;
/*
@@ -322,17 +352,48 @@ dcmattach(hd)
* Note that we always assume port 1 on the board.
*/
cn_tab->cn_dev = makedev(dcmmajor, (brd << 2) | DCMCONSPORT);
+ } else {
+#ifdef NEWCONFIG
+ dcm = (struct dcmdevice *)iomap(dio_scodetopa(da->da_scode),
+ da->da_size);
+ if (dcm == NULL) {
+ printf("\n%s: can't map registers\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+#endif
+ }
+
+ sc->sc_dcm = dcm;
+
+#ifdef NEWCONFIG
+ ipl = DIO_IPL(dcm);
+ printf(" ipl %d", ipl);
+#else /* ! NEWCONFIG */
+ /* XXX Set the device class. */
+ hd->hp_dev.dv_class = DV_TTY;
+ bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device));
+#endif /* NEWCONFIG */
+
+ if (dcmselftest(sc)) {
+ printf("\n%s: self-test failed\n", sc->sc_dev.dv_xname);
+ return;
}
/* Extract configuration info from flags. */
+#ifdef NEWCONFIG
+ sc->sc_softCAR = self->dv_cfdata->cf_flags & DCM_SOFTCAR;
+ sc->sc_flags = self->dv_cfdata->cf_flags & DCM_FLAGMASK;
+#else
sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR);
sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK);
+#endif /* NEWCONFIG */
/* Mark our unit as configured. */
sc->sc_flags |= DCM_ACTIVE;
/* Establish the interrupt handler. */
- isrlink(dcmintr, sc, hd->hp_ipl, ISRPRI_TTY);
+ (void) isrlink(dcmintr, sc, ipl, ISRPRI_TTY);
if (dcmistype == DIS_TIMER)
dcmsetischeme(brd, DIS_RESET|DIS_TIMER);
@@ -381,18 +442,18 @@ dcmattach(hd)
dcminit(dcm, DCMPORT(DCMUNIT(kgdb_dev)),
kgdb_rate);
if (kgdb_debug_init) {
- printf("%s port %d: ", sc->sc_hd->hp_xname,
+ printf("%s port %d: ", sc->sc_dev.dv_xname,
DCMPORT(DCMUNIT(kgdb_dev)));
kgdb_connect(1);
} else
printf("%s port %d: kgdb enabled\n",
- sc->sc_hd->hp_xname,
+ sc->sc_dev.dv_xname,
DCMPORT(DCMUNIT(kgdb_dev)));
}
/* end could be replaced */
-#endif
+#endif /* KGDB_CHEAT */
}
-#endif
+#endif /* KGDB */
}
/* ARGSUSED */
@@ -411,10 +472,16 @@ dcmopen(dev, flag, mode, p)
brd = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ if (brd >= dcm_cd.cd_ndevs || port >= NDCMPORT ||
+ (sc = dcm_cd.cd_devs[brd]) == NULL)
+ return (ENXIO);
+#else /* ! NEWCONFIG */
if ((brd >= NDCM) || (port >= NDCMPORT))
return (ENXIO);
-
sc = &dcm_softc[brd];
+#endif /* NEWCONFIG */
+
if ((sc->sc_flags & DCM_ACTIVE) == 0)
return (ENXIO);
@@ -468,7 +535,7 @@ dcmopen(dev, flag, mode, p)
#ifdef DEBUG
if (dcmdebug & DDB_MODEM)
printf("%s: dcmopen port %d softcarr %c\n",
- sc->sc_hd->hp_xname, port,
+ sc->sc_dev.dv_xname, port,
(tp->t_state & TS_CARR_ON) ? '1' : '0');
#endif
@@ -490,7 +557,7 @@ dcmopen(dev, flag, mode, p)
#ifdef DEBUG
if (dcmdebug & DDB_OPENCLOSE)
printf("%s port %d: dcmopen: st %x fl %x\n",
- sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags);
+ sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags);
#endif
if (error == 0)
error = (*linesw[tp->t_line].l_open)(dev, tp);
@@ -513,7 +580,11 @@ dcmclose(dev, flag, mode, p)
board = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
tp = sc->sc_tty[port];
(*linesw[tp->t_line].l_close)(tp, flag);
@@ -526,7 +597,7 @@ dcmclose(dev, flag, mode, p)
#ifdef DEBUG
if (dcmdebug & DDB_OPENCLOSE)
printf("%s port %d: dcmclose: st %x fl %x\n",
- sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags);
+ sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags);
#endif
splx(s);
ttyclose(tp);
@@ -552,7 +623,11 @@ dcmread(dev, uio, flag)
board = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
tp = sc->sc_tty[port];
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
@@ -572,7 +647,11 @@ dcmwrite(dev, uio, flag)
board = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
tp = sc->sc_tty[port];
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
@@ -589,7 +668,11 @@ dcmtty(dev)
board = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
return (sc->sc_tty[port]);
}
@@ -601,7 +684,7 @@ dcmintr(arg)
struct dcm_softc *sc = arg;
struct dcmdevice *dcm = sc->sc_dcm;
struct dcmischeme *dis = &sc->sc_scheme;
- int brd = sc->sc_hd->hp_unit;
+ int brd = sc->sc_dev.dv_unit;
int code, i;
int pcnd[4], mcode, mcnd[4];
@@ -631,7 +714,7 @@ dcmintr(arg)
#ifdef DEBUG
if (dcmdebug & DDB_INTR) {
printf("%s: dcmintr: iir %x pc %x/%x/%x/%x ",
- sc->sc_hd->hp_xname, code, pcnd[0], pcnd[1],
+ sc->sc_dev.dv_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]);
@@ -773,7 +856,7 @@ dcmreadbuf(sc, port)
#ifdef DEBUG
if (dcmdebug & DDB_INPUT)
printf("%s port %d: dcmreadbuf: c%x('%c') s%x f%x h%x t%x\n",
- sc->sc_hd->hp_xname, port,
+ sc->sc_dev.dv_xname, port,
c&0xFF, c, stat&0xFF,
tp->t_flags, head, pp->r_tail);
#endif
@@ -784,7 +867,7 @@ dcmreadbuf(sc, port)
#ifdef DEBUG
if (dcmdebug & (DDB_INPUT|DDB_SIOERR))
printf("%s port %d: dcmreadbuf: err: c%x('%c') s%x\n",
- sc->sc_hd->hp_xname, port,
+ sc->sc_dev.dv_xname, port,
stat, c&0xFF, c);
#endif
if (stat & (RD_BD | RD_FE))
@@ -794,11 +877,11 @@ dcmreadbuf(sc, port)
else if (stat & RD_OVF)
log(LOG_WARNING,
"%s port %d: silo overflow\n",
- sc->sc_hd->hp_xname, port);
+ sc->sc_dev.dv_xname, port);
else if (stat & RD_OE)
log(LOG_WARNING,
"%s port %d: uart overflow\n",
- sc->sc_hd->hp_xname, port);
+ sc->sc_dev.dv_xname, port);
}
(*linesw[tp->t_line].l_rint)(c, tp);
}
@@ -838,7 +921,7 @@ dcmmint(sc, port, mcnd)
#ifdef DEBUG
if (dcmdebug & DDB_MODEM)
printf("%s port %d: dcmmint: mcnd %x mcndlast %x\n",
- sc->sc_hd->hp_xname, port, mcnd, sc->sc_mcndlast[port]);
+ sc->sc_dev.dv_xname, port, mcnd, sc->sc_mcndlast[port]);
#endif
delta = mcnd ^ sc->sc_mcndlast[port];
sc->sc_mcndlast[port] = mcnd;
@@ -882,14 +965,18 @@ dcmioctl(dev, cmd, data, flag, p)
port = DCMPORT(unit);
board = DCMBOARD(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
dcm = sc->sc_dcm;
tp = sc->sc_tty[port];
#ifdef DEBUG
if (dcmdebug & DDB_IOCTL)
printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n",
- sc->sc_hd->hp_xname, port, cmd, *data, flag);
+ sc->sc_dev.dv_xname, port, cmd, *data, flag);
#endif
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error >= 0)
@@ -997,7 +1084,11 @@ dcmparam(tp, t)
board = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
dcm = sc->sc_dcm;
/* check requested parameters */
@@ -1036,7 +1127,7 @@ dcmparam(tp, t)
#ifdef DEBUG
if (dcmdebug & DDB_PARAM)
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,
+ sc->sc_dev.dv_xname, port, cflag, mode, tp->t_ospeed,
DCM_USPERCH(tp->t_ospeed));
#endif
@@ -1084,7 +1175,11 @@ dcmstart(tp)
board = DCMBOARD(unit);
port = DCMPORT(unit);
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[board];
+#else
sc = &dcm_softc[board];
+#endif
dcm = sc->sc_dcm;
s = spltty();
@@ -1094,7 +1189,7 @@ dcmstart(tp)
#ifdef DEBUG
if (dcmdebug & DDB_OUTPUT)
printf("%s port %d: dcmstart: state %x flags %x outcc %d\n",
- sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags,
+ sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags,
tp->t_outq.c_cc);
#endif
if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
@@ -1176,7 +1271,7 @@ again:
#ifdef DEBUG
if (dcmdebug & DDB_INTR)
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);
+ sc->sc_dev.dv_xname, port, head, tail, tp->t_outq.c_cc);
#endif
out:
#ifdef DCMSTATS
@@ -1192,7 +1287,7 @@ out:
/*
* Stop output on a line.
*/
-int
+void
dcmstop(tp, flag)
register struct tty *tp;
int flag;
@@ -1222,13 +1317,18 @@ dcmmctl(dev, bits, how)
unit = DCMUNIT(dev);
brd = DCMBOARD(unit);
port = DCMPORT(unit);
+
+#ifdef NEWCONFIG
+ sc = dcm_cd.cd_devs[brd];
+#else
sc = &dcm_softc[brd];
+#endif
dcm = sc->sc_dcm;
#ifdef DEBUG
if (dcmdebug & DDB_MODEM)
printf("%s port %d: dcmmctl: bits 0x%x how %x\n",
- sc->sc_hd->hp_xname, port, bits, how);
+ sc->sc_dev.dv_xname, port, bits, how);
#endif
s = spltty();
@@ -1272,7 +1372,11 @@ dcmmctl(dev, bits, how)
dcmsetischeme(brd, flags)
int brd, flags;
{
+#ifdef NEWCONFIG
+ struct dcm_softc *sc = dcm_cd.cd_devs[brd];
+#else
struct dcm_softc *sc = &dcm_softc[brd];
+#endif
struct dcmdevice *dcm = sc->sc_dcm;
struct dcmischeme *dis = &sc->sc_scheme;
int i;
@@ -1282,11 +1386,11 @@ dcmsetischeme(brd, flags)
#ifdef DEBUG
if (dcmdebug & DDB_INTSCHM)
printf("%s: dcmsetischeme(%d): cur %d, ints %d, chars %d\n",
- sc->sc_hd->hp_xname, perchar, dis->dis_perchar,
+ sc->sc_dev.dv_xname, perchar, dis->dis_perchar,
dis->dis_intr, dis->dis_char);
if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) {
printf("%s: dcmsetischeme: redundent request %d\n",
- sc->sc_hd->hp_xname, perchar);
+ sc->sc_dev.dv_xname, perchar);
return;
}
#endif
@@ -1369,6 +1473,45 @@ dcminit(dcm, port, rate)
}
/*
+ * Empirically derived self-test magic
+ */
+int
+dcmselftest(sc)
+ struct dcm_softc *sc;
+{
+ struct dcmdevice *dcm = sc->sc_dcm;
+ int i, timo = 0;
+ int s, brd, mbits;
+
+ s = spltty();
+ dcm->dcm_rsid = DCMRS;
+ DELAY(50000); /* 5000 is not long enough */
+ dcm->dcm_rsid = 0;
+ dcm->dcm_ic = IC_IE;
+ dcm->dcm_cr = CR_SELFT;
+ while ((dcm->dcm_ic & IC_IR) == 0)
+ if (++timo == 20000)
+ return (1);
+ DELAY(50000); /* XXX why is this needed ???? */
+ while ((dcm->dcm_iir & IIR_SELFT) == 0)
+ if (++timo == 400000)
+ return (1);
+ DELAY(50000); /* XXX why is this needed ???? */
+ if (dcm->dcm_stcon != ST_OK) {
+#if 0
+ if (hd->hp_args->hw_sc != conscode)
+ printf("dcm%d: self test failed: %x\n",
+ brd, dcm->dcm_stcon);
+#endif
+ return (1);
+ }
+ dcm->dcm_ic = IC_ID;
+ splx(s);
+
+ return (0);
+}
+
+/*
* Following are all routines needed for DCM to act as console
*/
@@ -1558,4 +1701,3 @@ dcmcnputc(dev, c)
}
splx(s);
}
-#endif /* NDCM > 0 */
diff --git a/sys/arch/hp300/dev/dcmreg.h b/sys/arch/hp300/dev/dcmreg.h
index d27cfbcf264..4c7fe75e63d 100644
--- a/sys/arch/hp300/dev/dcmreg.h
+++ b/sys/arch/hp300/dev/dcmreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: dcmreg.h,v 1.3 1997/01/12 15:12:23 downsj Exp $ */
/* $NetBSD: dcmreg.h,v 1.5 1996/02/24 00:55:05 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/device.h b/sys/arch/hp300/dev/device.h
index ca2861e45df..32dee0bf48b 100644
--- a/sys/arch/hp300/dev/device.h
+++ b/sys/arch/hp300/dev/device.h
@@ -1,4 +1,5 @@
-/* $NetBSD: device.h,v 1.7 1996/02/14 02:44:14 thorpej Exp $ */
+/* $OpenBSD: device.h,v 1.4 1997/01/12 15:12:24 downsj Exp $ */
+/* $NetBSD: device.h,v 1.9 1996/10/20 23:47:40 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -35,6 +36,8 @@
* @(#)device.h 8.1 (Berkeley) 6/10/93
*/
+#include <sys/device.h>
+
struct driver {
int (*d_match)();
void (*d_attach)();
@@ -64,6 +67,7 @@ struct hp_ctlr {
int hp_ipl;
struct hp_hw *hp_args;
char hp_xname[8];
+ struct device hp_dev;
};
struct hp_device {
@@ -78,9 +82,12 @@ struct hp_device {
int hp_alive;
int hp_ipl;
struct hp_hw *hp_args;
- char hp_xname[8];
+ struct device hp_dev;
};
+/* XXX until the code is cleaed up */
+#define hp_xname hp_dev.dv_xname
+
/* XXX This needs to die. */
struct devqueue {
struct devqueue *dq_forw;
@@ -129,6 +136,6 @@ struct devqueue {
extern struct hp_hw sc_table[];
extern struct hp_ctlr hp_cinit[];
extern struct hp_device hp_dinit[];
-extern caddr_t sctova(), sctopa(), iomap();
+extern caddr_t sctopa(), iomap();
#endif
#endif
diff --git a/sys/arch/hp300/dev/devlist2h.awk b/sys/arch/hp300/dev/devlist2h.awk
new file mode 100644
index 00000000000..db29dec28b9
--- /dev/null
+++ b/sys/arch/hp300/dev/devlist2h.awk
@@ -0,0 +1,167 @@
+#! /usr/bin/awk -f
+#
+# $OpenBSD: devlist2h.awk,v 1.1 1997/01/12 15:12:24 downsj Exp $
+# $NetBSD: devlist2h.awk,v 1.1 1996/12/17 08:41:02 thorpej Exp $
+#
+# Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
+# Copyright (c) 1995, 1996 Christopher G. Demetriou
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Christopher G. Demetriou.
+# 4. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+#
+BEGIN {
+ ndevices = 0
+ fbid = 0
+ dfile="diodevs_data.h"
+ hfile="diodevs.h"
+}
+NR == 1 {
+ VERSION = $0
+ gsub("\\$", "", VERSION)
+
+ printf("/*\n") > dfile
+ printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > dfile
+ printf(" *\n") > dfile
+ printf(" * generated from:\n") > dfile
+ printf(" *\t%s\n", VERSION) > dfile
+ printf(" */\n") > dfile
+
+ printf("/*\n") > hfile
+ printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
+ > hfile
+ printf(" *\n") > hfile
+ printf(" * generated from:\n") > hfile
+ printf(" *\t%s\n", VERSION) > hfile
+ printf(" */\n") > hfile
+
+ next
+}
+$1 == "device" {
+ ndevices++
+
+ devices[ndevices, 1] = $2 # nickname
+ devices[ndevices, 2] = $3 # dio primary id
+ devices[ndevices, 3] = "0" # dio secondary id
+ devices[ndevices, 4] = $4 # number of select codes
+ # used by device
+
+ # if this is the framebuffer entry, save the primary id
+ if ($2 == "FRAMEBUFFER") {
+ fbid = $3;
+ }
+
+ # emit device primary id
+ printf("\n#define\tDIO_DEVICE_ID_%s\t%s\n", devices[ndevices, 1], \
+ devices[ndevices, 2]) > hfile
+
+ # emit description
+ printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \
+ > hfile
+
+ f = 5;
+
+ while (f <= NF) {
+ printf("%s", $f) > hfile
+ if (f < NF)
+ printf(" ") > hfile
+ f++;
+ }
+ printf("\"\n") > hfile
+
+ next
+}
+$1 == "framebuffer" {
+ ndevices++
+
+ devices[ndevices, 1] = $2 # nickname
+ devices[ndevices, 2] = fbid # dio primary id
+ devices[ndevices, 3] = $3 # dio secondary id
+ devices[ndevices, 4] = $4 # number of select codes
+ # used by device
+
+ # emit device secondary id
+ printf("\n#define\tDIO_DEVICE_SECID_%s\t%s\n", devices[ndevices, 1], \
+ devices[ndevices, 3]) > hfile
+
+ # emit description
+ printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \
+ > hfile
+
+ f = 5;
+
+ while (f <= NF) {
+ printf("%s", $f) > hfile
+ if (f < NF)
+ printf(" ") > hfile
+ f++;
+ }
+ printf("\"\n") > hfile
+
+ next
+}
+{
+ if ($0 == "")
+ blanklines++
+ if (blanklines != 2 && blanklines != 3)
+ print $0 > hfile
+ if (blanklines < 2)
+ print $0 > dfile
+}
+END {
+ # emit device count
+
+ printf("\n") > dfile
+ printf("#define DIO_NDEVICES\t%d\n", ndevices) > dfile
+
+ # emit select code size table
+
+ printf("\n") > dfile
+
+ printf("struct dio_devdata dio_devdatas[] = {\n") > dfile
+ for (i = 1; i <= ndevices; i++) {
+ printf("\t{ %s,\t%s,\t%s },\n", devices[i, 2],
+ devices[i, 3], devices[i, 4]) > dfile
+ }
+
+ printf("};\n") > dfile
+
+ # emit description table
+
+ printf("\n") > dfile
+ printf("#ifdef DIOVERBOSE\n") > dfile
+
+ printf("struct dio_devdesc dio_devdescs[] = {\n") > dfile
+
+ for (i = 1; i <= ndevices; i++) {
+ printf("\t{ %s,\t%s,\tDIO_DEVICE_DESC_%s },\n",
+ devices[i, 2], devices[i, 3], devices[i, 1]) > dfile
+ }
+
+ printf("};\n") > dfile
+
+ printf("#endif /* DIOVERBOSE */\n") > dfile
+}
diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c
new file mode 100644
index 00000000000..ee64e36c33f
--- /dev/null
+++ b/sys/arch/hp300/dev/dio.c
@@ -0,0 +1,307 @@
+/* $OpenBSD: dio.c,v 1.1 1997/01/12 15:12:25 downsj Exp $ */
+/* $NetBSD: dio.c,v 1.1 1996/12/17 08:41:02 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * Autoconfiguration and mapping support for the DIO bus.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+
+#include <hp300/dev/diodevs.h>
+#include <hp300/dev/diodevs_data.h>
+
+extern caddr_t internalhpib;
+
+int dio_scodesize __P((struct dio_attach_args *));
+char *dio_devinfo __P((struct dio_attach_args *, char *, size_t));
+
+#ifdef NEWCONFIG
+int diomatch __P((struct device *, struct cfdata *, void *));
+void dioattach __P((struct device *, struct device *, void *));
+int dioprint __P((void *, const char *));
+int diosubmatch __P((struct device *, struct cfdata *, void *));
+
+struct cfattach dio_ca = {
+ sizeof(struct device), diomatch, dioattach
+};
+
+struct cfdriver dio_cd = {
+ NULL, "dio", DV_DULL
+};
+
+int
+diomatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ static int dio_matched = 0;
+
+ /* Allow only one instance. */
+ if (dio_matched)
+ return (0);
+
+ dio_matched = 1;
+ return (1);
+}
+
+void
+dioattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct dio_attach_args da;
+ caddr_t pa, va;
+ int scode, scmax, didmap, scodesize;
+
+ scmax = DIO_SCMAX(machineid);
+ printf("\n");
+
+ for (scode = 0; scode < scmax; ) {
+ if (DIO_INHOLE(scode)) {
+ scode++;
+ continue;
+ }
+
+ didmap = 0;
+
+ /*
+ * Temporarily map the space corresponding to
+ * the current select code unless:
+ * - this is the internal hpib select code,
+ * - this is the console select code.
+ */
+ pa = dio_scodetopa(scode);
+ if (scode == conscode)
+ va = conaddr;
+ else if ((scode == 7) && internalhpib)
+ va = internalhpib = (caddr_t)IIOV(pa);
+ else {
+ va = iomap(pa, NBPG);
+ if (va == NULL) {
+ printf("%s: can't map scode %d\n", scode);
+ scode++;
+ continue;
+ }
+ didmap = 1;
+ }
+
+ /* Check for hardware. */
+ if (badaddr(va)) {
+ if (didmap)
+ iounmap(va, NBPG);
+ scode++;
+ continue;
+ }
+
+ /* Fill out attach args. */
+ bzero(&da, sizeof(da));
+ da.da_scode = scode;
+ da.da_id = DIO_ID(va);
+
+ if (DIO_ISFRAMEBUFFER(da.da_id))
+ da.da_secid = DIO_SECID(va);
+
+ da.da_size = DIO_SIZE(scode, va);
+ scodesize = dio_scodesize(&da);
+ if (DIO_ISDIO(scode))
+ da.da_size *= scodesize;
+
+ /* No longer need the device to be mapped. */
+ if (didmap)
+ iounmap(va, NBPG);
+
+ /* Attach matching device. */
+ config_found_sm(self, &da, dioprint, diosubmatch);
+ scode += scodesize;
+ }
+}
+
+int
+diosubmatch(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (cf->diocf_scode != DIO_UNKNOWN_SCODE &&
+ cf->diocf_scode != da->da_scode)
+ return (0);
+
+ return ((*cf->cf_attach->ca_match)(parent, cf, aux));
+}
+
+int
+dioprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct dio_attach_args *da = aux;
+ char buf[128];
+
+ if (pnp)
+ printf("%s at %s", dio_devinfo(da, buf, sizeof(buf)), pnp);
+ printf(" scode %d", da->da_scode);
+ return (UNCONF);
+}
+#endif /* NEWCONFIG */
+
+/*
+ * Convert a select code to a system physical address.
+ */
+void *
+dio_scodetopa(scode)
+ int scode;
+{
+ u_long rval;
+
+ if (scode == 7 && internalhpib)
+ rval = DIO_IHPIBADDR;
+ else if (DIO_ISDIO(scode))
+ rval = DIO_BASE + (scode * DIO_DEVSIZE);
+ else if (DIO_ISDIOII(scode))
+ rval = DIOII_BASE + (scode * DIOII_DEVSIZE);
+ else
+ rval = 0;
+
+ return ((void *)rval);
+}
+
+/*
+ * Return the select code size for this device, defaulting to 1
+ * if we don't know what kind of device we have.
+ */
+int
+dio_scodesize(da)
+ struct dio_attach_args *da;
+{
+ int i;
+
+ /*
+ * Deal with lame internal HP-IB controllers which don't have
+ * consistent/reliable device ids.
+ */
+ if (da->da_scode == 7 && internalhpib)
+ return (1);
+
+ /*
+ * Find the dio_devdata matchind the primary id.
+ * If we're a framebuffer, we also check the secondary id.
+ */
+ for (i = 0; i < DIO_NDEVICES; i++) {
+ if (da->da_id == dio_devdatas[i].dd_id) {
+ if (DIO_ISFRAMEBUFFER(da->da_id)) {
+ if (da->da_secid == dio_devdatas[i].dd_secid) {
+ goto foundit;
+ }
+ } else {
+ foundit:
+ return (dio_devdatas[i].dd_nscode);
+ }
+ }
+ }
+
+ /*
+ * Device is unknown. Print a warning and assume a default.
+ */
+ printf("WARNING: select code size unknown for id = 0x%x secid = 0x%x\n",
+ da->da_id, da->da_secid);
+ return (1);
+}
+
+/*
+ * Return a reasonable description of a DIO device.
+ */
+char *
+dio_devinfo(da, buf, buflen)
+ struct dio_attach_args *da;
+ char *buf;
+ size_t buflen;
+{
+ int i;
+
+ bzero(buf, buflen);
+
+ /*
+ * Deal with lame internal HP-IB controllers which don't have
+ * consistent/reliable device ids.
+ */
+ if (da->da_scode == 7 && internalhpib) {
+ sprintf(buf, DIO_DEVICE_DESC_IHPIB);
+ return (buf);
+ }
+
+#ifdef DIOVERBOSE
+ /*
+ * Find the description matching our primary id.
+ * If we're a framebuffer, we also check the secondary id.
+ */
+ for (i = 0; i < DIO_NDEVICES; i++) {
+ if (da->da_id == dio_devdescs[i].dd_id) {
+ if (DIO_ISFRAMEBUFFER(da->da_id)) {
+ if (da->da_secid == dio_devdescs[i].dd_secid) {
+ goto foundit;
+ }
+ } else {
+ foundit:
+ sprintf(buf, "%s", dio_devdescs[i].dd_desc);
+ return (buf);
+ }
+ }
+ }
+#endif /* DIOVERBOSE */
+
+ /*
+ * Device is unknown. Construct something reasonable.
+ */
+ sprintf(buf, "device id = 0x%x secid = 0x%x",
+ da->da_id, da->da_secid);
+ return (buf);
+}
diff --git a/sys/arch/hp300/dev/diodevs b/sys/arch/hp300/dev/diodevs
new file mode 100644
index 00000000000..5df0b035ddd
--- /dev/null
+++ b/sys/arch/hp300/dev/diodevs
@@ -0,0 +1,104 @@
+$OpenBSD: diodevs,v 1.1 1997/01/12 15:12:25 downsj Exp $
+$NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp $
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * List of known DIO devices
+ */
+
+/* Devices we have drivers for. */
+
+device DCA0 0x02 1 98644A serial
+device DCA0REM 0x82 1 98644A serial
+device DCA1 0x42 1 98644A serial
+device DCA1REM 0xc2 1 98644A serial
+
+device DCM 0x05 1 98642A serial MUX
+device DCMREM 0x85 1 98642A serial MUX
+
+device LAN 0x15 1 98643A LAN
+
+device FHPIB 0x08 1 98625A/98625B HP-IB
+device NHPIB 0x80 1 98624A HP-IB
+device IHPIB 0x00 1 internal HP-IB
+
+device SCSI0 0x07 1 98625A SCSI
+device SCSI1 0x27 1 98625A SCSI
+device SCSI2 0x47 1 98625A SCSI
+device SCSI3 0x67 1 98625A SCSI
+
+/* Framebuffer devices; same primary ID, different secondary IDs. */
+
+device FRAMEBUFFER 0x39 1 bitmapped display
+
+framebuffer GATORBOX 0x01 1 98700/98710 (\"gatorbox\") display
+framebuffer TOPCAT 0x02 1 98544/98545/98547 (\"topcat\") display
+framebuffer RENASSIANCE 0x04 2 98720/98721 (\"renassiance\") display
+framebuffer LRCATSEYE 0x05 1 low-res catseye display
+framebuffer HRCCATSEYE 0x06 1 high-res color catseye display
+framebuffer HRMCATSEYE 0x07 1 high-res mono catseye display
+framebuffer DAVINCI 0x08 2 98730/98731 (\"davinci\") display
+framebuffer XXXCATSEYE 0x09 1 catseye display
+framebuffer HYPERION 0x0e 1 A1096A (\"hyperion\") display
+
+/* Unsupported framebuffers. */
+
+framebuffer XGENESIS 0x0b 1 x-genesis display
+framebuffer TIGER 0x0c 1 tiger display
+framebuffer YGENESIS 0x0d 1 y-genesis display
+
+/* Devices not yet supported. Descriptions are lacking. */
+
+device MISC0 0x03 1 98622A
+device MISC1 0x04 1 98623A
+device PARALLEL 0x06 1 internal parallel
+device MISC2 0x09 1 98287A keyboard
+device MISC3 0x0a 1 HP98635A floating point accelerator
+device MISC4 0x0b 1 timer
+device MISC5 0x12 1 98640A
+device MISC6 0x16 1 98659A
+device MISC7 0x19 1 237 display
+device MISC8 0x1a 4 quad-wide card
+device MISC9 0x1b 1 98253A
+device MISC10 0x1c 1 98627A
+device MISC11 0x1d 1 98633A
+device MISC12 0x1e 1 98259A
+device MISC13 0x1f 1 8741
+device VME 0x31 2 98577A VME adapter
+device DCL 0x34 1 98628A serial
+device DCLREM 0xb4 1 98628A serial
diff --git a/sys/arch/hp300/dev/diodevs.h b/sys/arch/hp300/dev/diodevs.h
new file mode 100644
index 00000000000..297f4dda8aa
--- /dev/null
+++ b/sys/arch/hp300/dev/diodevs.h
@@ -0,0 +1,192 @@
+/*
+ * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
+ *
+ * generated from:
+ * NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp
+ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+
+#define DIO_DEVICE_ID_DCA0 0x02
+#define DIO_DEVICE_DESC_DCA0 "98644A serial"
+
+#define DIO_DEVICE_ID_DCA0REM 0x82
+#define DIO_DEVICE_DESC_DCA0REM "98644A serial"
+
+#define DIO_DEVICE_ID_DCA1 0x42
+#define DIO_DEVICE_DESC_DCA1 "98644A serial"
+
+#define DIO_DEVICE_ID_DCA1REM 0xc2
+#define DIO_DEVICE_DESC_DCA1REM "98644A serial"
+
+
+#define DIO_DEVICE_ID_DCM 0x05
+#define DIO_DEVICE_DESC_DCM "98642A serial MUX"
+
+#define DIO_DEVICE_ID_DCMREM 0x85
+#define DIO_DEVICE_DESC_DCMREM "98642A serial MUX"
+
+
+#define DIO_DEVICE_ID_LAN 0x15
+#define DIO_DEVICE_DESC_LAN "98643A LAN"
+
+
+#define DIO_DEVICE_ID_FHPIB 0x08
+#define DIO_DEVICE_DESC_FHPIB "98625A/98625B HP-IB"
+
+#define DIO_DEVICE_ID_NHPIB 0x80
+#define DIO_DEVICE_DESC_NHPIB "98624A HP-IB"
+
+#define DIO_DEVICE_ID_IHPIB 0x00
+#define DIO_DEVICE_DESC_IHPIB "internal HP-IB"
+
+
+#define DIO_DEVICE_ID_SCSI0 0x07
+#define DIO_DEVICE_DESC_SCSI0 "98625A SCSI"
+
+#define DIO_DEVICE_ID_SCSI1 0x27
+#define DIO_DEVICE_DESC_SCSI1 "98625A SCSI"
+
+#define DIO_DEVICE_ID_SCSI2 0x47
+#define DIO_DEVICE_DESC_SCSI2 "98625A SCSI"
+
+#define DIO_DEVICE_ID_SCSI3 0x67
+#define DIO_DEVICE_DESC_SCSI3 "98625A SCSI"
+
+/* Framebuffer devices; same primary ID, different secondary IDs. */
+
+
+#define DIO_DEVICE_ID_FRAMEBUFFER 0x39
+#define DIO_DEVICE_DESC_FRAMEBUFFER "bitmapped display"
+
+
+#define DIO_DEVICE_SECID_GATORBOX 0x01
+#define DIO_DEVICE_DESC_GATORBOX "98700/98710 (\"gatorbox\") display"
+
+#define DIO_DEVICE_SECID_TOPCAT 0x02
+#define DIO_DEVICE_DESC_TOPCAT "98544/98545/98547 (\"topcat\") display"
+
+#define DIO_DEVICE_SECID_RENASSIANCE 0x04
+#define DIO_DEVICE_DESC_RENASSIANCE "98720/98721 (\"renassiance\") display"
+
+#define DIO_DEVICE_SECID_LRCATSEYE 0x05
+#define DIO_DEVICE_DESC_LRCATSEYE "low-res catseye display"
+
+#define DIO_DEVICE_SECID_HRCCATSEYE 0x06
+#define DIO_DEVICE_DESC_HRCCATSEYE "high-res color catseye display"
+
+#define DIO_DEVICE_SECID_HRMCATSEYE 0x07
+#define DIO_DEVICE_DESC_HRMCATSEYE "high-res mono catseye display"
+
+#define DIO_DEVICE_SECID_DAVINCI 0x08
+#define DIO_DEVICE_DESC_DAVINCI "98730/98731 (\"davinci\") display"
+
+#define DIO_DEVICE_SECID_XXXCATSEYE 0x09
+#define DIO_DEVICE_DESC_XXXCATSEYE "catseye display"
+
+#define DIO_DEVICE_SECID_HYPERION 0x0e
+#define DIO_DEVICE_DESC_HYPERION "A1096A (\"hyperion\") display"
+
+/* Unsupported framebuffers. */
+
+
+#define DIO_DEVICE_SECID_XGENESIS 0x0b
+#define DIO_DEVICE_DESC_XGENESIS "x-genesis display"
+
+#define DIO_DEVICE_SECID_TIGER 0x0c
+#define DIO_DEVICE_DESC_TIGER "tiger display"
+
+#define DIO_DEVICE_SECID_YGENESIS 0x0d
+#define DIO_DEVICE_DESC_YGENESIS "y-genesis display"
+
+/* Devices not yet supported. Descriptions are lacking. */
+
+
+#define DIO_DEVICE_ID_MISC0 0x03
+#define DIO_DEVICE_DESC_MISC0 "98622A"
+
+#define DIO_DEVICE_ID_MISC1 0x04
+#define DIO_DEVICE_DESC_MISC1 "98623A"
+
+#define DIO_DEVICE_ID_PARALLEL 0x06
+#define DIO_DEVICE_DESC_PARALLEL "internal parallel"
+
+#define DIO_DEVICE_ID_MISC2 0x09
+#define DIO_DEVICE_DESC_MISC2 "98287A keyboard"
+
+#define DIO_DEVICE_ID_MISC3 0x0a
+#define DIO_DEVICE_DESC_MISC3 "HP98635A floating point accelerator"
+
+#define DIO_DEVICE_ID_MISC4 0x0b
+#define DIO_DEVICE_DESC_MISC4 "timer"
+
+#define DIO_DEVICE_ID_MISC5 0x12
+#define DIO_DEVICE_DESC_MISC5 "98640A"
+
+#define DIO_DEVICE_ID_MISC6 0x16
+#define DIO_DEVICE_DESC_MISC6 "98659A"
+
+#define DIO_DEVICE_ID_MISC7 0x19
+#define DIO_DEVICE_DESC_MISC7 "237 display"
+
+#define DIO_DEVICE_ID_MISC8 0x1a
+#define DIO_DEVICE_DESC_MISC8 "quad-wide card"
+
+#define DIO_DEVICE_ID_MISC9 0x1b
+#define DIO_DEVICE_DESC_MISC9 "98253A"
+
+#define DIO_DEVICE_ID_MISC10 0x1c
+#define DIO_DEVICE_DESC_MISC10 "98627A"
+
+#define DIO_DEVICE_ID_MISC11 0x1d
+#define DIO_DEVICE_DESC_MISC11 "98633A"
+
+#define DIO_DEVICE_ID_MISC12 0x1e
+#define DIO_DEVICE_DESC_MISC12 "98259A"
+
+#define DIO_DEVICE_ID_MISC13 0x1f
+#define DIO_DEVICE_DESC_MISC13 "8741"
+
+#define DIO_DEVICE_ID_VME 0x31
+#define DIO_DEVICE_DESC_VME "98577A VME adapter"
+
+#define DIO_DEVICE_ID_DCL 0x34
+#define DIO_DEVICE_DESC_DCL "98628A serial"
+
+#define DIO_DEVICE_ID_DCLREM 0xb4
+#define DIO_DEVICE_DESC_DCLREM "98628A serial"
diff --git a/sys/arch/hp300/dev/diodevs_data.h b/sys/arch/hp300/dev/diodevs_data.h
new file mode 100644
index 00000000000..9ada75170fe
--- /dev/null
+++ b/sys/arch/hp300/dev/diodevs_data.h
@@ -0,0 +1,142 @@
+/*
+ * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
+ *
+ * generated from:
+ * NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp
+ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+#define DIO_NDEVICES 45
+
+struct dio_devdata dio_devdatas[] = {
+ { 0x02, 0, 1 },
+ { 0x82, 0, 1 },
+ { 0x42, 0, 1 },
+ { 0xc2, 0, 1 },
+ { 0x05, 0, 1 },
+ { 0x85, 0, 1 },
+ { 0x15, 0, 1 },
+ { 0x08, 0, 1 },
+ { 0x80, 0, 1 },
+ { 0x00, 0, 1 },
+ { 0x07, 0, 1 },
+ { 0x27, 0, 1 },
+ { 0x47, 0, 1 },
+ { 0x67, 0, 1 },
+ { 0x39, 0, 1 },
+ { 0x39, 0x01, 1 },
+ { 0x39, 0x02, 1 },
+ { 0x39, 0x04, 2 },
+ { 0x39, 0x05, 1 },
+ { 0x39, 0x06, 1 },
+ { 0x39, 0x07, 1 },
+ { 0x39, 0x08, 2 },
+ { 0x39, 0x09, 1 },
+ { 0x39, 0x0e, 1 },
+ { 0x39, 0x0b, 1 },
+ { 0x39, 0x0c, 1 },
+ { 0x39, 0x0d, 1 },
+ { 0x03, 0, 1 },
+ { 0x04, 0, 1 },
+ { 0x06, 0, 1 },
+ { 0x09, 0, 1 },
+ { 0x0a, 0, 1 },
+ { 0x0b, 0, 1 },
+ { 0x12, 0, 1 },
+ { 0x16, 0, 1 },
+ { 0x19, 0, 1 },
+ { 0x1a, 0, 4 },
+ { 0x1b, 0, 1 },
+ { 0x1c, 0, 1 },
+ { 0x1d, 0, 1 },
+ { 0x1e, 0, 1 },
+ { 0x1f, 0, 1 },
+ { 0x31, 0, 2 },
+ { 0x34, 0, 1 },
+ { 0xb4, 0, 1 },
+};
+
+#ifdef DIOVERBOSE
+struct dio_devdesc dio_devdescs[] = {
+ { 0x02, 0, DIO_DEVICE_DESC_DCA0 },
+ { 0x82, 0, DIO_DEVICE_DESC_DCA0REM },
+ { 0x42, 0, DIO_DEVICE_DESC_DCA1 },
+ { 0xc2, 0, DIO_DEVICE_DESC_DCA1REM },
+ { 0x05, 0, DIO_DEVICE_DESC_DCM },
+ { 0x85, 0, DIO_DEVICE_DESC_DCMREM },
+ { 0x15, 0, DIO_DEVICE_DESC_LAN },
+ { 0x08, 0, DIO_DEVICE_DESC_FHPIB },
+ { 0x80, 0, DIO_DEVICE_DESC_NHPIB },
+ { 0x00, 0, DIO_DEVICE_DESC_IHPIB },
+ { 0x07, 0, DIO_DEVICE_DESC_SCSI0 },
+ { 0x27, 0, DIO_DEVICE_DESC_SCSI1 },
+ { 0x47, 0, DIO_DEVICE_DESC_SCSI2 },
+ { 0x67, 0, DIO_DEVICE_DESC_SCSI3 },
+ { 0x39, 0, DIO_DEVICE_DESC_FRAMEBUFFER },
+ { 0x39, 0x01, DIO_DEVICE_DESC_GATORBOX },
+ { 0x39, 0x02, DIO_DEVICE_DESC_TOPCAT },
+ { 0x39, 0x04, DIO_DEVICE_DESC_RENASSIANCE },
+ { 0x39, 0x05, DIO_DEVICE_DESC_LRCATSEYE },
+ { 0x39, 0x06, DIO_DEVICE_DESC_HRCCATSEYE },
+ { 0x39, 0x07, DIO_DEVICE_DESC_HRMCATSEYE },
+ { 0x39, 0x08, DIO_DEVICE_DESC_DAVINCI },
+ { 0x39, 0x09, DIO_DEVICE_DESC_XXXCATSEYE },
+ { 0x39, 0x0e, DIO_DEVICE_DESC_HYPERION },
+ { 0x39, 0x0b, DIO_DEVICE_DESC_XGENESIS },
+ { 0x39, 0x0c, DIO_DEVICE_DESC_TIGER },
+ { 0x39, 0x0d, DIO_DEVICE_DESC_YGENESIS },
+ { 0x03, 0, DIO_DEVICE_DESC_MISC0 },
+ { 0x04, 0, DIO_DEVICE_DESC_MISC1 },
+ { 0x06, 0, DIO_DEVICE_DESC_PARALLEL },
+ { 0x09, 0, DIO_DEVICE_DESC_MISC2 },
+ { 0x0a, 0, DIO_DEVICE_DESC_MISC3 },
+ { 0x0b, 0, DIO_DEVICE_DESC_MISC4 },
+ { 0x12, 0, DIO_DEVICE_DESC_MISC5 },
+ { 0x16, 0, DIO_DEVICE_DESC_MISC6 },
+ { 0x19, 0, DIO_DEVICE_DESC_MISC7 },
+ { 0x1a, 0, DIO_DEVICE_DESC_MISC8 },
+ { 0x1b, 0, DIO_DEVICE_DESC_MISC9 },
+ { 0x1c, 0, DIO_DEVICE_DESC_MISC10 },
+ { 0x1d, 0, DIO_DEVICE_DESC_MISC11 },
+ { 0x1e, 0, DIO_DEVICE_DESC_MISC12 },
+ { 0x1f, 0, DIO_DEVICE_DESC_MISC13 },
+ { 0x31, 0, DIO_DEVICE_DESC_VME },
+ { 0x34, 0, DIO_DEVICE_DESC_DCL },
+ { 0xb4, 0, DIO_DEVICE_DESC_DCLREM },
+};
+#endif /* DIOVERBOSE */
diff --git a/sys/arch/hp300/dev/dioreg.h b/sys/arch/hp300/dev/dioreg.h
new file mode 100644
index 00000000000..a5d096dbd5b
--- /dev/null
+++ b/sys/arch/hp300/dev/dioreg.h
@@ -0,0 +1,141 @@
+/* $OpenBSD: dioreg.h,v 1.1 1997/01/12 15:12:26 downsj Exp $ */
+/* $NetBSD: dioreg.h,v 1.1 1996/12/17 08:41:04 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Portions of this file are derived from software contributed to Berkeley
+ * by the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * Register definitions for the DIO and DIO-II bus.
+ */
+
+/*
+ * DIO/DIO-II device registers, offsets from base of device. All
+ * registers are 8-bit.
+ */
+#define DIO_IDOFF 0x01 /* primary device id */
+#define DIO_IPLOFF 0x03 /* interrupt level */
+#define DIO_SECIDOFF 0x15 /* secondary device id */
+#define DIOII_SIZEOFF 0x101 /* device size */
+
+/*
+ * System physical addresses of some `special' DIO devices.
+ */
+#define DIO_IHPIBADDR 0x478000 /* internal HP-IB; select code 7 */
+
+/*
+ * DIO ranges from select codes 0-63 at physical addresses given by:
+ * 0x600000 + (sc - 32) * 0x10000
+ * DIO cards are addressed in the range 0-31 [0x600000-0x800000) for
+ * their control space and the remaining areas, [0x200000-0x400000) and
+ * [0x800000-0x1000000), are for additional space required by a card;
+ * e.g. a display framebuffer.
+ *
+ * DIO-II ranges from select codes 132-255 at physical addresses given by:
+ * 0x1000000 + (sc - 132) * 0x400000
+ * The address range of DIO-II space is thus [0x1000000-0x20000000).
+ *
+ * DIO/DIO-II space is too large to map in its entirety, instead devices
+ * are mapped into kernel virtual address space allocated from a range
+ * of EIOMAPSIZE pages (vmparam.h) starting at ``extiobase''.
+ */
+#define DIO_BASE 0x600000 /* start of DIO space */
+#define DIO_END 0x1000000 /* end of DIO space */
+#define DIO_DEVSIZE 0x10000 /* size of a DIO device */
+
+#define DIOII_BASE 0x01000000 /* start of DIO-II space */
+#define DIOII_END 0x20000000 /* end of DIO-II space */
+#define DIOII_DEVSIZE 0x00400000 /* size of a DIO-II device */
+
+/*
+ * Find the highest select code for a given machine; HP320 doesn't
+ * have DIO-II.
+ */
+#define DIO_SCMAX(machineid) ((machineid) == HP_320 ? 32 : 256)
+
+/*
+ * Macro that returns true if a select code lies within
+ * the select code `hole'.
+ */
+#define DIO_INHOLE(scode) ((scode) >= 32 && (scode) < 132)
+
+/*
+ * Macros to determine if device is DIO or DIO-II.
+ */
+#define DIO_ISDIO(scode) ((scode) >= 0 && (scode) < 32)
+#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
+
+/*
+ * Macro to determine if device is a framebuffer, given the
+ * primary id of the device. We key off this to determine if
+ * we should look at secondary id and ignore interrupt level.
+ */
+#define DIO_ISFRAMEBUFFER(id) \
+ ((id) == DIO_DEVICE_ID_FRAMEBUFFER)
+
+/*
+ * Macro to extract primary and decondary device ids, given
+ * the base address of the device.
+ */
+#define DIO_ID(base) \
+ (*((u_int8_t *)((u_long)(base) + DIO_IDOFF)))
+#define DIO_SECID(base) \
+ (*((u_int8_t *)((u_long)(base) + DIO_SECIDOFF)))
+
+/*
+ * Macro to extract the interrupt level, given the
+ * base address of the device.
+ */
+#define DIO_IPL(base) \
+ ((((*((u_int8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3)
+
+/*
+ * Macro to compute the size of a DIO-II device's address
+ * space, given the base address of the device.
+ */
+#define DIOII_SIZE(base) \
+ ((int)((*((u_int8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1) \
+ * 0x100000))
+
+/*
+ * Given a select code and device base address, compute
+ * the size of the DIO/DIO-II device.
+ */
+#define DIO_SIZE(scode, base) \
+ (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
diff --git a/sys/arch/hp300/dev/diovar.h b/sys/arch/hp300/dev/diovar.h
new file mode 100644
index 00000000000..d2c22432c17
--- /dev/null
+++ b/sys/arch/hp300/dev/diovar.h
@@ -0,0 +1,80 @@
+/* $OpenBSD: diovar.h,v 1.1 1997/01/12 15:12:27 downsj Exp $ */
+/* $NetBSD: diovar.h,v 1.1 1996/12/17 08:41:05 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * Autoconfiguration definitions and prototypes for the DIO bus.
+ */
+
+/*
+ * Arguments used to attach a device to the DIO bus.
+ */
+struct dio_attach_args {
+ int da_scode; /* select code */
+ int da_size; /* size of address space */
+ u_int8_t da_id; /* primary device id */
+ u_int8_t da_secid; /* secondary device id */
+};
+
+/*
+ * This structure is used by the autoconfiguration code to lookup
+ * the size of a DIO device (not all use one select code).
+ */
+struct dio_devdata {
+ u_int8_t dd_id; /* primary device id */
+ u_int8_t dd_secid; /* secondary device id */
+ int dd_nscode; /* number of select codes */
+};
+
+/*
+ * This structure is used by the autoconfiguration code to print
+ * a textual description of a device.
+ */
+struct dio_devdesc {
+ u_int8_t dd_id; /* primary device id */
+ u_int8_t dd_secid; /* secondary device id */
+ const char *dd_desc; /* description */
+};
+
+#define diocf_scode cf_loc[0]
+
+#define DIO_UNKNOWN_SCODE -1
+
+#ifdef _KERNEL
+void *dio_scodetopa __P((int));
+#endif /* _KERNEL */
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c
index 17820334441..ebfa5901534 100644
--- a/sys/arch/hp300/dev/dma.c
+++ b/sys/arch/hp300/dev/dma.c
@@ -1,7 +1,8 @@
-/* $NetBSD: dma.c,v 1.7 1996/02/14 02:44:17 thorpej Exp $ */
+/* $OpenBSD: dma.c,v 1.4 1997/01/12 15:12:28 downsj Exp $ */
+/* $NetBSD: dma.c,v 1.10 1996/12/09 03:09:51 thorpej Exp $ */
/*
- * Copyright (c) 1995 Jason R. Thorpe.
+ * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved.
* Copyright (c) 1982, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -54,7 +55,6 @@
#include <hp300/hp300/isr.h>
-extern void isrlink();
extern void _insque();
extern void _remque();
extern u_int kvtop();
@@ -89,6 +89,8 @@ struct dma_softc {
struct dmareg *sc_dmareg; /* pointer to our hardware */
struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */
char sc_type; /* A, B, or C */
+ int sc_ipl; /* our interrupt level */
+ void *sc_ih; /* interrupt cookie */
} Dma_softc;
/* types */
@@ -140,7 +142,7 @@ dmainit()
*
* 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).
+ * splbio works out to ipl 3).
*/
if (badbaddr((char *)&dma->dma_id[2])) {
rev = 'B';
@@ -181,8 +183,31 @@ dmainit()
printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname,
rev, (rev == 'B') ? 16 : 32);
- /* Establish the interrupt handler */
- isrlink(dmaintr, sc, DMAINTLVL, ISRPRI_BIO);
+ /*
+ * Defer hooking up our interrupt until the first
+ * DMA-using controller has hooked up theirs.
+ */
+ sc->sc_ih = NULL;
+}
+
+/*
+ * Compute the ipl and (re)establish the interrupt handler
+ * for the DMA controller.
+ */
+void
+dmacomputeipl()
+{
+ struct dma_softc *sc = &Dma_softc;
+
+ if (sc->sc_ih != NULL)
+ isrunlink(sc->sc_ih);
+
+ /*
+ * Our interrupt level must be as high as the highest
+ * device using DMA (i.e. splbio).
+ */
+ sc->sc_ipl = PSLTOIPL(hp300_bioipl);
+ sc->sc_ih = isrlink(dmaintr, sc, sc->sc_ipl, ISRPRI_BIO);
}
int
@@ -342,7 +367,7 @@ dmago(unit, addr, count, flags)
/*
* Set up the command word based on flags
*/
- dc->dm_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START;
+ dc->dm_cmd = DMA_ENAB | DMA_IPL(sc->sc_ipl) | DMA_START;
if ((flags & DMAGO_READ) == 0)
dc->dm_cmd |= DMA_WRT;
if (flags & DMAGO_LWORD)
diff --git a/sys/arch/hp300/dev/dmareg.h b/sys/arch/hp300/dev/dmareg.h
index 3a6ae6538f9..1e94ae6c069 100644
--- a/sys/arch/hp300/dev/dmareg.h
+++ b/sys/arch/hp300/dev/dmareg.h
@@ -1,4 +1,5 @@
-/* $NetBSD: dmareg.h,v 1.6 1995/12/02 02:46:49 thorpej Exp $ */
+/* $OpenBSD: dmareg.h,v 1.3 1997/01/12 15:12:28 downsj Exp $ */
+/* $NetBSD: dmareg.h,v 1.7 1996/12/09 06:18:13 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -73,9 +74,6 @@ struct dmareg {
/* 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
-
/* addresses */
#define DMA_BASE IIOV(0x500000)
diff --git a/sys/arch/hp300/dev/dmavar.h b/sys/arch/hp300/dev/dmavar.h
index 412db731c55..cd814185f6e 100644
--- a/sys/arch/hp300/dev/dmavar.h
+++ b/sys/arch/hp300/dev/dmavar.h
@@ -1,4 +1,5 @@
-/* $NetBSD: dmavar.h,v 1.5 1995/03/28 18:16:03 jtc Exp $ */
+/* $OpenBSD: dmavar.h,v 1.2 1997/01/12 15:12:29 downsj Exp $ */
+/* $NetBSD: dmavar.h,v 1.6 1996/12/09 03:09:51 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -50,4 +51,5 @@
#ifdef _KERNEL
extern void dmago(), dmafree();
extern int dmareq();
+extern void dmacomputeipl __P((void));
#endif
diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c
index 1a73c0462a5..af421d6f542 100644
--- a/sys/arch/hp300/dev/fhpib.c
+++ b/sys/arch/hp300/dev/fhpib.c
@@ -1,4 +1,5 @@
-/* $NetBSD: fhpib.c,v 1.11 1996/05/18 23:56:59 thorpej Exp $ */
+/* $OpenBSD: fhpib.c,v 1.5 1997/01/12 15:12:29 downsj Exp $ */
+/* $NetBSD: fhpib.c,v 1.13 1996/10/13 03:14:10 christos Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
diff --git a/sys/arch/hp300/dev/fhpibreg.h b/sys/arch/hp300/dev/fhpibreg.h
index d9e5add5a9f..1aa1d45a781 100644
--- a/sys/arch/hp300/dev/fhpibreg.h
+++ b/sys/arch/hp300/dev/fhpibreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: fhpibreg.h,v 1.2 1997/01/12 15:12:30 downsj Exp $ */
/* $NetBSD: fhpibreg.h,v 1.4 1994/10/26 07:23:45 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c
index bc4c09a799c..8f3abe5bbcb 100644
--- a/sys/arch/hp300/dev/grf.c
+++ b/sys/arch/hp300/dev/grf.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf.c,v 1.17 1996/02/24 00:55:07 thorpej Exp $ */
+/* $OpenBSD: grf.c,v 1.4 1997/01/12 15:12:31 downsj Exp $ */
+/* $NetBSD: grf.c,v 1.22 1997/01/10 00:07:27 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -48,9 +49,6 @@
* Hardware access is through the machine dependent grf switch routines.
*/
-#include "grf.h"
-#if NGRF > 0
-
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
@@ -58,6 +56,8 @@
#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/mman.h>
+#include <sys/conf.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
@@ -82,11 +82,30 @@ extern struct emul emul_hpux;
#if NITE > 0
#include <hp300/dev/itevar.h>
#else
-#define iteon(u,f)
+#define iteon(u,f) 0 /* normally returns int */
#define iteoff(u,f)
#endif /* NITE > 0 */
+/* prototypes for the devsw entry points */
+cdev_decl(grf);
+
+#ifdef NEWCONFIG
+int grfmatch __P((struct device *, struct cfdata *, void *));
+void grfattach __P((struct device *, struct device *, void *));
+
+struct cfattach grf_ca = {
+ sizeof(struct grf_softc), grfmatch, grfattach
+};
+
+struct cfdriver grf_cd = {
+ NULL, "grf", DV_DULL
+};
+
+int grfprint __P((void *, const char *));
+#else /* ! NEWCONFIG */
+#include "grf.h"
struct grf_softc grf_softc[NGRF];
+#endif /* NEWCONFIG */
/*
* Frambuffer state information, statically allocated for benefit
@@ -102,7 +121,50 @@ int grfdebug = 0;
#define GDB_LOCK 0x08
#endif
+#ifdef NEWCONFIG
+int
+grfmatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+
+ return (1);
+}
+
+void
+grfattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grf_softc *sc = (struct grf_softc *)self;
+ struct grfdev_attach_args *ga = aux;
+
+ printf("\n");
+
+ sc->sc_data = ga->ga_data;
+ sc->sc_scode = ga->ga_scode; /* XXX */
+
+ /* Attach an ITE. */
+ (void)config_found(self, aux, grfprint);
+}
+
+int
+grfprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+
+ /* Only ITEs can attach to GRFs, easy... */
+ if (pnp)
+ printf("ite at %s", pnp);
+
+ return (UNCONF);
+}
+#endif /* NEWCONFIG */
+
/*ARGSUSED*/
+int
grfopen(dev, flags, mode, p)
dev_t dev;
int flags, mode;
@@ -113,10 +175,16 @@ grfopen(dev, flags, mode, p)
struct grf_data *gp;
int error = 0;
+#ifdef NEWCONFIG
+ if (unit >= grf_cd.cd_ndevs ||
+ (sc = grf_cd.cd_devs[unit]) == NULL)
+ return (ENXIO);
+#else
if (unit >= NGRF)
return(ENXIO);
-
sc = &grf_softc[unit];
+#endif
+
gp = sc->sc_data;
if ((gp->g_flags & GF_ALIVE) == 0)
@@ -152,6 +220,7 @@ grfopen(dev, flags, mode, p)
}
/*ARGSUSED*/
+int
grfclose(dev, flags, mode, p)
dev_t dev;
int flags, mode;
@@ -161,10 +230,12 @@ grfclose(dev, flags, mode, p)
struct grf_softc *sc;
struct grf_data *gp;
- if (unit >= NGRF)
- return(ENXIO);
-
+#ifdef NEWCONFIG
+ sc = grf_cd.cd_devs[unit];
+#else
sc = &grf_softc[unit];
+#endif
+
gp = sc->sc_data;
if ((gp->g_flags & GF_ALIVE) == 0)
@@ -179,9 +250,11 @@ grfclose(dev, flags, mode, p)
}
/*ARGSUSED*/
+int
grfioctl(dev, cmd, data, flag, p)
dev_t dev;
- int cmd, flag;
+ u_long cmd;
+ int flag;
caddr_t data;
struct proc *p;
{
@@ -189,10 +262,12 @@ grfioctl(dev, cmd, data, flag, p)
struct grf_data *gp;
int error, unit = GRFUNIT(dev);
- if (unit >= NGRF)
- return(ENXIO);
-
+#ifdef NEWCONFIG
+ sc = grf_cd.cd_devs[unit];
+#else
sc = &grf_softc[unit];
+#endif
+
gp = sc->sc_data;
if ((gp->g_flags & GF_ALIVE) == 0)
@@ -234,9 +309,11 @@ grfioctl(dev, cmd, data, flag, p)
}
/*ARGSUSED*/
-grfselect(dev, rw)
+int
+grfselect(dev, rw, p)
dev_t dev;
int rw;
+ struct proc *p;
{
if (rw == FREAD)
return(0);
@@ -244,11 +321,18 @@ grfselect(dev, rw)
}
/*ARGSUSED*/
+int
grfmmap(dev, off, prot)
dev_t dev;
int off, prot;
{
- return(grfaddr(&grf_softc[GRFUNIT(dev)], off));
+#ifdef NEWCONFIG
+ struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
+#else
+ struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
+#endif
+
+ return (grfaddr(sc, off));
}
int
@@ -259,7 +343,11 @@ grfon(dev)
struct grf_softc *sc;
struct grf_data *gp;
+#ifdef NEWCONFIG
+ sc = grf_cd.cd_devs[unit];
+#else
sc = &grf_softc[unit];
+#endif
gp = sc->sc_data;
/*
@@ -282,7 +370,11 @@ grfoff(dev)
struct grf_data *gp;
int error;
+#ifdef NEWCONFIG
+ sc = grf_cd.cd_devs[unit];
+#else
sc = &grf_softc[unit];
+#endif
gp = sc->sc_data;
(void) grfunmap(dev, (caddr_t)0, curproc);
@@ -290,7 +382,7 @@ grfoff(dev)
(dev&GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF,
(caddr_t)0);
/* XXX: see comment for iteoff above */
- (void) iteon(sc->sc_ite->sc_data, 2);
+ iteon(sc->sc_ite->sc_data, 2);
return(error);
}
@@ -321,13 +413,18 @@ grfaddr(sc, off)
#ifdef COMPAT_HPUX
/*ARGSUSED*/
+int
hpuxgrfioctl(dev, cmd, data, flag, p)
dev_t dev;
int cmd, flag;
caddr_t data;
struct proc *p;
{
+#ifdef NEWCONFIG
+ struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
+#else
struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
+#endif
struct grf_data *gp = sc->sc_data;
int error;
@@ -479,6 +576,7 @@ grflock(gp, block)
return(0);
}
+int
grfunlock(gp)
struct grf_data *gp;
{
@@ -515,23 +613,34 @@ grfunlock(gp)
* XXX: This may give the wrong result for remote stats of other
* machines where device 10 exists.
*/
+int
grfdevno(dev)
dev_t dev;
{
int unit = GRFUNIT(dev);
- struct grf_softc *sc = &grf_softc[unit];
- struct grf_data *gp = sc->sc_data;
+ struct grf_softc *sc;
+ struct grf_data *gp;
int newdev;
- if (unit >= NGRF || (gp->g_flags&GF_ALIVE) == 0)
- return(bsdtohpuxdev(dev));
+#ifdef NEWCONFIG
+ if (unit >= grf_cd.cd_ndevs ||
+ (sc = grf_cd.cd_devs[unit]) == NULL)
+ return (bsdtohpuxdev(dev));
+#else
+ if (unit >= NGRF)
+ return (bsdtohpuxdev(dev));
+ sc = &grf_softc[unit];
+#endif
+
+ gp = sc->sc_data;
+ if ((gp->g_flags & GF_ALIVE) == 0)
+ return (bsdtohpuxdev(dev));
+
/* magic major number */
newdev = 12 << 24;
/* now construct minor number */
- if (gp->g_display.gd_regaddr != (caddr_t)GRFIADDR) {
- int sc = patosc(gp->g_display.gd_regaddr);
- newdev |= (sc << 16) | 0x200;
- }
+ if (gp->g_display.gd_regaddr != (caddr_t)GRFIADDR)
+ newdev |= (sc->sc_scode << 16) | 0x200;
if (dev & GRFIMDEV)
newdev |= 0x02;
else if (dev & GRFOVDEV)
@@ -545,12 +654,17 @@ grfdevno(dev)
#endif /* COMPAT_HPUX */
+int
grfmap(dev, addrp, p)
dev_t dev;
caddr_t *addrp;
struct proc *p;
{
+#ifdef NEWCONFIG
+ struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
+#else
struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
+#endif
struct grf_data *gp = sc->sc_data;
int len, error;
struct vnode vn;
@@ -583,7 +697,11 @@ grfunmap(dev, addr, p)
caddr_t addr;
struct proc *p;
{
+#ifdef NEWCONFIG
+ struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)];
+#else
struct grf_softc *sc = &grf_softc[GRFUNIT(dev)];
+#endif
struct grf_data *gp = sc->sc_data;
vm_size_t size;
int rv;
@@ -601,6 +719,7 @@ grfunmap(dev, addr, p)
}
#ifdef COMPAT_HPUX
+int
iommap(dev, addrp)
dev_t dev;
caddr_t *addrp;
@@ -613,6 +732,7 @@ iommap(dev, addrp)
return(EINVAL);
}
+int
iounmmap(dev, addr)
dev_t dev;
caddr_t addr;
@@ -728,5 +848,3 @@ grflckunmmap(dev, addr)
return(EINVAL);
}
#endif /* COMPAT_HPUX */
-
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_conf.c b/sys/arch/hp300/dev/grf_conf.c
index 3bbafb6cc19..3d0dae6bb12 100644
--- a/sys/arch/hp300/dev/grf_conf.c
+++ b/sys/arch/hp300/dev/grf_conf.c
@@ -1,4 +1,9 @@
-/* $NetBSD: grf_conf.c,v 1.3 1996/02/24 00:55:08 thorpej Exp $ */
+/* $OpenBSD: grf_conf.c,v 1.3 1997/01/12 15:12:31 downsj Exp $ */
+/* $NetBSD: grf_conf.c,v 1.4 1996/12/17 08:41:06 thorpej Exp $ */
+
+/*
+ * XXX This file is old config only!
+ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -50,6 +55,7 @@
#if NGRF > 0
#include <sys/types.h>
+#include <sys/device.h>
#include <hp300/dev/grfioctl.h> /* XXX */
#include <hp300/dev/grfvar.h>
diff --git a/sys/arch/hp300/dev/grf_dv.c b/sys/arch/hp300/dev/grf_dv.c
index ef1946fa244..eab98b4e939 100644
--- a/sys/arch/hp300/dev/grf_dv.c
+++ b/sys/arch/hp300/dev/grf_dv.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf_dv.c,v 1.7 1996/03/03 16:48:56 thorpej Exp $ */
+/* $OpenBSD: grf_dv.c,v 1.3 1997/01/12 15:12:32 downsj Exp $ */
+/* $NetBSD: grf_dv.c,v 1.9 1996/12/17 08:41:07 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -43,9 +44,6 @@
* @(#)grf_dv.c 8.4 (Berkeley) 1/12/94
*/
-#include "grf.h"
-#if NGRF > 0
-
/*
* Graphics routines for the DaVinci, HP98730/98731 Graphics system.
*/
@@ -56,12 +54,17 @@
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+#include <hp300/dev/intiovar.h>
+
#include <hp300/dev/grfioctl.h>
#include <hp300/dev/grfvar.h>
#include <hp300/dev/grfreg.h>
@@ -76,9 +79,29 @@ int dv_init __P((struct grf_data *, int, caddr_t));
int dv_mode __P((struct grf_data *, int, caddr_t));
void dv_reset __P((struct dvboxfb *));
+#ifdef NEWCONFIG
+int dvbox_intio_match __P((struct device *, struct cfdata *, void *));
+void dvbox_intio_attach __P((struct device *, struct device *, void *));
+
+int dvbox_dio_match __P((struct device *, struct cfdata *, void *));
+void dvbox_dio_attach __P((struct device *, struct device *, void *));
+
+struct cfattach dvbox_intio_ca = {
+ sizeof(struct grfdev_softc), dvbox_intio_match, dvbox_intio_attach
+};
+
+struct cfattach dvbox_dio_ca = {
+ sizeof(struct grfdev_softc), dvbox_dio_match, dvbox_dio_attach
+};
+
+struct cfdriver dvbox_cd = {
+ NULL, "dvbox", DV_DULL
+};
+#endif /* NEWCONFIG */
+
/* DaVinci grf switch */
struct grfsw dvbox_grfsw = {
- GID_DAVINCI, GRFDAVINCI, "davinci", dv_init, dv_mode
+ GID_DAVINCI, GRFDAVINCI, "dvbox", dv_init, dv_mode
};
#if NITE > 0
@@ -98,6 +121,83 @@ struct itesw dvbox_itesw = {
};
#endif /* NITE > 0 */
+#ifdef NEWCONFIG
+int
+dvbox_intio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct intio_attach_args *ia = aux;
+ struct grfreg *grf;
+
+ grf = (struct grfreg *)IIOV(GRFIADDR);
+ if (badaddr((caddr_t)grf))
+ return (0);
+
+ if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ grf->gr_id2 == DIO_DEVICE_SECID_DAVINCI) {
+ ia->ia_addr = (caddr_t)GRFIADDR;
+ return (1);
+ }
+
+ return (0);
+}
+
+void
+dvbox_intio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ caddr_t grf;
+
+ grf = (caddr_t)IIOV(GRFIADDR);
+ sc->sc_scode = -1; /* XXX internal i/o */
+
+ grfdev_attach(sc, dv_init, grf, &dvbox_grfsw);
+}
+
+int
+dvbox_dio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ da->da_secid == DIO_DEVICE_SECID_DAVINCI)
+ return (1);
+
+ return (0);
+}
+
+void
+dvbox_dio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ struct dio_attach_args *da = aux;
+ caddr_t grf;
+
+ sc->sc_scode = da->da_scode;
+ if (sc->sc_scode == conscode)
+ grf = conaddr;
+ else {
+ grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size);
+ if (grf == 0) {
+ printf("%s: can't map framebuffer\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ }
+
+ grfdev_attach(sc, dv_init, grf, &dvbox_grfsw);
+}
+#endif /* NEWCONFIG */
+
/*
* Initialize hardware.
* Must point g_display at a grfinfo structure describing the hardware.
@@ -112,7 +212,7 @@ dv_init(gp, scode, addr)
register struct dvboxfb *dbp;
struct grfinfo *gi = &gp->g_display;
int fboff;
- extern caddr_t sctopa(), iomap();
+ extern caddr_t iomap();
/*
* If the console has been initialized, and it was us, there's
@@ -123,7 +223,7 @@ dv_init(gp, scode, addr)
if (ISIIOVA(addr))
gi->gd_regaddr = (caddr_t) IIOP(addr);
else
- gi->gd_regaddr = sctopa(scode);
+ gi->gd_regaddr = dio_scodetopa(scode);
gi->gd_regsize = 0x20000;
gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb;
gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb;
@@ -618,7 +718,6 @@ void
dvboxcninit(cp)
struct consdev *cp;
{
- struct ite_data *ip = &ite_cn;
struct grf_data *gp = &grf_cn;
/*
@@ -634,16 +733,9 @@ dvboxcninit(cp)
gp->g_flags = GF_ALIVE;
/*
- * Set up required ite data and initialize ite.
+ * Initialize the terminal emulator.
*/
- ip->isw = &dvbox_itesw;
- ip->grf = gp;
- ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS;
- ip->attrbuf = console_attributes;
- iteinit(ip);
-
- kbd_ite = ip; /* XXX */
+ itecninit(gp, &dvbox_itesw);
}
#endif /* NITE > 0 */
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_dvreg.h b/sys/arch/hp300/dev/grf_dvreg.h
index 29cd2854849..d156424416b 100644
--- a/sys/arch/hp300/dev/grf_dvreg.h
+++ b/sys/arch/hp300/dev/grf_dvreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grf_dvreg.h,v 1.2 1997/01/12 15:12:33 downsj Exp $ */
/* $NetBSD: grf_dvreg.h,v 1.5 1994/10/26 07:23:50 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grf_gb.c b/sys/arch/hp300/dev/grf_gb.c
index a443c74693a..f7aac480613 100644
--- a/sys/arch/hp300/dev/grf_gb.c
+++ b/sys/arch/hp300/dev/grf_gb.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf_gb.c,v 1.7 1996/03/03 16:48:58 thorpej Exp $ */
+/* $OpenBSD: grf_gb.c,v 1.3 1997/01/12 15:12:33 downsj Exp $ */
+/* $NetBSD: grf_gb.c,v 1.9 1996/12/17 08:41:08 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -43,9 +44,6 @@
* @(#)grf_gb.c 8.4 (Berkeley) 1/12/94
*/
-#include "grf.h"
-#if NGRF > 0
-
/*
* Graphics routines for the Gatorbox.
*
@@ -60,12 +58,17 @@
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+#include <hp300/dev/intiovar.h>
+
#include <hp300/dev/grfioctl.h>
#include <hp300/dev/grfvar.h>
#include <hp300/dev/grfreg.h>
@@ -86,6 +89,26 @@ int gb_init __P((struct grf_data *gp, int, caddr_t));
int gb_mode __P((struct grf_data *gp, int, caddr_t));
void gb_microcode __P((struct gboxfb *));
+#ifdef NEWCONFIG
+int gbox_intio_match __P((struct device *, struct cfdata *, void *));
+void gbox_intio_attach __P((struct device *, struct device *, void *));
+
+int gbox_dio_match __P((struct device *, struct cfdata *, void *));
+void gbox_dio_attach __P((struct device *, struct device *, void *));
+
+struct cfattach gbox_intio_ca = {
+ sizeof(struct grfdev_softc), gbox_intio_match, gbox_intio_attach
+};
+
+struct cfattach gbox_dio_ca = {
+ sizeof(struct grfdev_softc), gbox_dio_match, gbox_dio_attach
+};
+
+struct cfdriver gbox_cd = {
+ NULL, "gbox", DV_DULL
+};
+#endif /* NEWCONFIG */
+
/* Gatorbox grf switch */
struct grfsw gbox_grfsw = {
GID_GATORBOX, GRFGATOR, "gatorbox", gb_init, gb_mode
@@ -108,6 +131,83 @@ struct itesw gbox_itesw = {
};
#endif /* NITE > 0 */
+#ifdef NEWCONFIG
+int
+gbox_intio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct intio_attach_args *ia = aux;
+ struct grfreg *grf;
+
+ grf = (struct grfreg *)IIOV(GRFIADDR);
+ if (badaddr((caddr_t)grf))
+ return (0);
+
+ if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ grf->gr_id2 == DIO_DEVICE_SECID_GATORBOX) {
+ ia->ia_addr = (caddr_t)GRFIADDR;
+ return (1);
+ }
+
+ return (0);
+}
+
+void
+gbox_intio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ caddr_t grf;
+
+ grf = (caddr_t)IIOV(GRFIADDR);
+ sc->sc_scode = -1; /* XXX internal i/o */
+
+ grfdev_attach(sc, gb_init, grf, &gbox_grfsw);
+}
+
+int
+gbox_dio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ da->da_secid == DIO_DEVICE_SECID_GATORBOX)
+ return (1);
+
+ return (0);
+}
+
+void
+gbox_dio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ struct dio_attach_args *da = aux;
+ caddr_t grf;
+
+ sc->sc_scode = da->da_scode;
+ if (sc->sc_scode == conscode)
+ grf = conaddr;
+ else {
+ grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size);
+ if (grf == 0) {
+ printf("%s: can't map framebuffer\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ }
+
+ grfdev_attach(sc, gb_init, grf, &gbox_grfsw);
+}
+#endif /* NEWCONFIG */
+
/*
* Initialize hardware.
* Must point g_display at a grfinfo structure describing the hardware.
@@ -123,7 +223,7 @@ gb_init(gp, scode, addr)
struct grfinfo *gi = &gp->g_display;
u_char *fbp, save;
int fboff;
- extern caddr_t sctopa(), iomap();
+ extern caddr_t iomap();
/*
* If the console has been initialized, and it was us, there's
@@ -134,7 +234,7 @@ gb_init(gp, scode, addr)
if (ISIIOVA(addr))
gi->gd_regaddr = (caddr_t) IIOP(addr);
else
- gi->gd_regaddr = sctopa(scode);
+ gi->gd_regaddr = dio_scodetopa(scode);
gi->gd_regsize = 0x10000;
gi->gd_fbwidth = 1024; /* XXX */
gi->gd_fbheight = 1024; /* XXX */
@@ -568,7 +668,6 @@ void
gboxcninit(cp)
struct consdev *cp;
{
- struct ite_data *ip = &ite_cn;
struct grf_data *gp = &grf_cn;
/*
@@ -584,16 +683,9 @@ gboxcninit(cp)
gp->g_flags = GF_ALIVE;
/*
- * Set up required ite data and initialize ite.
+ * Initialize the terminal emulator.
*/
- ip->isw = &gbox_itesw;
- ip->grf = gp;
- ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS;
- ip->attrbuf = console_attributes;
- iteinit(ip);
-
- kbd_ite = ip; /* XXX */
+ itecninit(gp, &gbox_itesw);
}
#endif /* NITE > 0 */
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_gbreg.h b/sys/arch/hp300/dev/grf_gbreg.h
index e93a16d216a..187aeb2a9f4 100644
--- a/sys/arch/hp300/dev/grf_gbreg.h
+++ b/sys/arch/hp300/dev/grf_gbreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grf_gbreg.h,v 1.2 1997/01/12 15:12:34 downsj Exp $ */
/* $NetBSD: grf_gbreg.h,v 1.4 1994/10/26 07:23:53 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grf_hy.c b/sys/arch/hp300/dev/grf_hy.c
index 9598a9d4da5..4a4155c5e42 100644
--- a/sys/arch/hp300/dev/grf_hy.c
+++ b/sys/arch/hp300/dev/grf_hy.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf_hy.c,v 1.5 1996/03/03 16:49:00 thorpej Exp $ */
+/* $OpenBSD: grf_hy.c,v 1.3 1997/01/12 15:12:35 downsj Exp $ */
+/* $NetBSD: grf_hy.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -44,9 +45,6 @@
* @(#)grf_hy.c 8.4 (Berkeley) 1/12/94
*/
-#include "grf.h"
-#if NGRF > 0
-
/*
* Graphics routines for HYPERION frame buffer
*/
@@ -58,12 +56,17 @@
#include <sys/tty.h>
#include <sys/systm.h>
#include <sys/uio.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+#include <hp300/dev/intiovar.h>
+
#include <hp300/dev/grfioctl.h>
#include <hp300/dev/grfvar.h>
#include <hp300/dev/grfreg.h>
@@ -80,6 +83,19 @@ int hy_init __P((struct grf_data *gp, int, caddr_t));
int hy_mode __P((struct grf_data *gp, int, caddr_t));
void hyper_ite_fontinit __P((struct ite_data *));
+#ifdef NEWCONFIG
+int hyper_dio_match __P((struct device *, struct cfdata *, void *));
+void hyper_dio_attach __P((struct device *, struct device *, void *));
+
+struct cfattach hyper_dio_ca = {
+ sizeof(struct grfdev_softc), hyper_dio_match, hyper_dio_attach
+};
+
+struct cfdriver hyper_cd = {
+ NULL, "hyper", DV_DULL
+};
+#endif /* NEWCONFIG */
+
/* Hyperion grf switch */
struct grfsw hyper_grfsw = {
GID_HYPERION, GRFHYPERION, "hyperion", hy_init, hy_mode
@@ -103,6 +119,47 @@ struct itesw hyper_itesw = {
};
#endif /* NITE > 0 */
+#ifdef NEWCONFIG
+int
+hyper_dio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ da->da_secid == DIO_DEVICE_SECID_HYPERION)
+ return (1);
+
+ return (0);
+}
+
+void
+hyper_dio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ struct dio_attach_args *da = aux;
+ caddr_t grf;
+
+ sc->sc_scode = da->da_scode;
+ if (sc->sc_scode == conscode)
+ grf = conaddr;
+ else {
+ grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size);
+ if (grf == 0) {
+ printf("%s: can't map framebuffer\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ }
+
+ grfdev_attach(sc, hy_init, grf, &hyper_grfsw);
+}
+#endif /* NEWCONFIG */
+
/*
* Initialize hardware.
* Must fill in the grfinfo structure in g_softc.
@@ -117,7 +174,7 @@ hy_init(gp, scode, addr)
register struct hyboxfb *hy = (struct hyboxfb *) addr;
struct grfinfo *gi = &gp->g_display;
int fboff;
- extern caddr_t sctopa(), iomap();
+ extern caddr_t iomap();
/*
* If the console has been initialized, and it was us, there's
@@ -127,7 +184,7 @@ hy_init(gp, scode, addr)
if (ISIIOVA(addr))
gi->gd_regaddr = (caddr_t) IIOP(addr);
else
- gi->gd_regaddr = sctopa(scode);
+ gi->gd_regaddr = dio_scodetopa(scode);
gi->gd_regsize = 0x20000;
gi->gd_fbwidth = (hy->fbwmsb << 8) | hy->fbwlsb;
gi->gd_fbheight = (hy->fbhmsb << 8) | hy->fbhlsb;
@@ -764,7 +821,6 @@ void
hypercninit(cp)
struct consdev *cp;
{
- struct ite_data *ip = &ite_cn;
struct grf_data *gp = &grf_cn;
/*
@@ -780,16 +836,9 @@ hypercninit(cp)
gp->g_flags = GF_ALIVE;
/*
- * Set up required ite data and initialize ite.
+ * Initialize the terminal emulator.
*/
- ip->isw = &hyper_itesw;
- ip->grf = gp;
- ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS;
- ip->attrbuf = console_attributes;
- iteinit(ip);
-
- kbd_ite = ip; /* XXX */
+ itecninit(gp, &hyper_itesw);
}
#endif /* NITE > 0 */
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_hyreg.h b/sys/arch/hp300/dev/grf_hyreg.h
index 556399e31c0..9e23836fc8a 100644
--- a/sys/arch/hp300/dev/grf_hyreg.h
+++ b/sys/arch/hp300/dev/grf_hyreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grf_hyreg.h,v 1.2 1997/01/12 15:12:35 downsj Exp $ */
/* $NetBSD: grf_hyreg.h,v 1.2 1994/10/26 07:23:57 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grf_machdep.c b/sys/arch/hp300/dev/grf_machdep.c
index 5792f6cc14d..aed8e6c91dc 100644
--- a/sys/arch/hp300/dev/grf_machdep.c
+++ b/sys/arch/hp300/dev/grf_machdep.c
@@ -1,4 +1,9 @@
-/* $NetBSD: grf_machdep.c,v 1.4 1996/02/24 00:55:13 thorpej Exp $ */
+/* $OpenBSD: grf_machdep.c,v 1.4 1997/01/12 15:12:36 downsj Exp $ */
+/* $NetBSD: grf_machdep.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */
+
+/*
+ * XXX This file is old config only!
+ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -125,6 +130,8 @@ grfattach(hd)
else
isconsole = 0;
+ sc->sc_scode = scode;
+
printf(": %d x %d ", gp->g_display.gd_dwidth,
gp->g_display.gd_dheight);
if (gp->g_display.gd_colors == 2)
diff --git a/sys/arch/hp300/dev/grf_rb.c b/sys/arch/hp300/dev/grf_rb.c
index d06d7d72f79..ba5e98f0313 100644
--- a/sys/arch/hp300/dev/grf_rb.c
+++ b/sys/arch/hp300/dev/grf_rb.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf_rb.c,v 1.7 1996/03/03 16:49:02 thorpej Exp $ */
+/* $OpenBSD: grf_rb.c,v 1.3 1997/01/12 15:12:36 downsj Exp $ */
+/* $NetBSD: grf_rb.c,v 1.9 1996/12/17 08:41:10 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -43,9 +44,6 @@
* @(#)grf_rb.c 8.4 (Berkeley) 1/12/94
*/
-#include "grf.h"
-#if NGRF > 0
-
/*
* Graphics routines for the Renaissance, HP98720 Graphics system.
*/
@@ -56,12 +54,17 @@
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+#include <hp300/dev/intiovar.h>
+
#include <hp300/dev/grfioctl.h>
#include <hp300/dev/grfvar.h>
#include <hp300/dev/grfreg.h>
@@ -75,6 +78,26 @@
int rb_init __P((struct grf_data *gp, int, caddr_t));
int rb_mode __P((struct grf_data *gp, int, caddr_t));
+#ifdef NEWCONFIG
+int rbox_intio_match __P((struct device *, struct cfdata *, void *));
+void rbox_intio_attach __P((struct device *, struct device *, void *));
+
+int rbox_dio_match __P((struct device *, struct cfdata *, void *));
+void rbox_dio_attach __P((struct device *, struct device *, void *));
+
+struct cfattach rbox_intio_ca = {
+ sizeof(struct grfdev_softc), rbox_intio_match, rbox_intio_attach
+};
+
+struct cfattach rbox_dio_ca = {
+ sizeof(struct grfdev_softc), rbox_dio_match, rbox_dio_attach
+};
+
+struct cfdriver rbox_cd = {
+ NULL, "rbox", DV_DULL
+};
+#endif /* NEWCONFIG */
+
/* Renaissance grf switch */
struct grfsw rbox_grfsw = {
GID_RENAISSANCE, GRFRBOX, "renaissance", rb_init, rb_mode
@@ -97,6 +120,83 @@ struct itesw rbox_itesw = {
};
#endif /* NITE > 0 */
+#ifdef NEWCONFIG
+int
+rbox_intio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct intio_attach_args *ia = aux;
+ struct grfreg *grf;
+
+ grf = (struct grfreg *)IIOV(GRFIADDR);
+ if (badaddr((caddr_t)grf))
+ return (0);
+
+ if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ grf->gr_id2 == DIO_DEVICE_SECID_RENASSIANCE) {
+ ia->ia_addr = (caddr_t)GRFIADDR;
+ return (1);
+ }
+
+ return (0);
+}
+
+void
+rbox_intio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ caddr_t grf;
+
+ grf = (caddr_t)IIOV(GRFIADDR);
+ sc->sc_scode = -1; /* XXX internal i/o */
+
+ grfdev_attach(sc, rb_init, grf, &rbox_grfsw);
+}
+
+int
+rbox_dio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER &&
+ da->da_secid == DIO_DEVICE_SECID_RENASSIANCE)
+ return (1);
+
+ return (0);
+}
+
+void
+rbox_dio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ struct dio_attach_args *da = aux;
+ caddr_t grf;
+
+ sc->sc_scode = da->da_scode;
+ if (sc->sc_scode == conscode)
+ grf = conaddr;
+ else {
+ grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size);
+ if (grf == 0) {
+ printf("%s: can't map framebuffer\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ }
+
+ grfdev_attach(sc, rb_init, grf, &rbox_grfsw);
+}
+#endif /* NEWCONFIG */
+
/*
* Initialize hardware.
* Must point g_display at a grfinfo structure describing the hardware.
@@ -111,7 +211,7 @@ rb_init(gp, scode, addr)
register struct rboxfb *rbp;
struct grfinfo *gi = &gp->g_display;
int fboff;
- extern caddr_t sctopa(), iomap();
+ extern caddr_t iomap();
/*
* If the console has been initialized, and it was us, there's
@@ -122,7 +222,7 @@ rb_init(gp, scode, addr)
if (ISIIOVA(addr))
gi->gd_regaddr = (caddr_t) IIOP(addr);
else
- gi->gd_regaddr = sctopa(scode);
+ gi->gd_regaddr = dio_scodetopa(scode);
gi->gd_regsize = 0x20000;
gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb;
gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb;
@@ -565,7 +665,6 @@ void
rboxcninit(cp)
struct consdev *cp;
{
- struct ite_data *ip = &ite_cn;
struct grf_data *gp = &grf_cn;
/*
@@ -581,16 +680,9 @@ rboxcninit(cp)
gp->g_flags = GF_ALIVE;
/*
- * Set up required ite data and initialize ite.
+ * Initialize the terminal emulator.
*/
- ip->isw = &rbox_itesw;
- ip->grf = gp;
- ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS;
- ip->attrbuf = console_attributes;
- iteinit(ip);
-
- kbd_ite = ip; /* XXX */
+ itecninit(gp, &rbox_itesw);
}
#endif /* NITE > 0 */
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_rbreg.h b/sys/arch/hp300/dev/grf_rbreg.h
index 890302713a9..98686b9eb5c 100644
--- a/sys/arch/hp300/dev/grf_rbreg.h
+++ b/sys/arch/hp300/dev/grf_rbreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grf_rbreg.h,v 1.2 1997/01/12 15:12:37 downsj Exp $ */
/* $NetBSD: grf_rbreg.h,v 1.4 1994/10/26 07:24:03 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grf_subr.c b/sys/arch/hp300/dev/grf_subr.c
new file mode 100644
index 00000000000..3f2b845daf0
--- /dev/null
+++ b/sys/arch/hp300/dev/grf_subr.c
@@ -0,0 +1,123 @@
+/* $OpenBSD: grf_subr.c,v 1.1 1997/01/12 15:12:38 downsj Exp $ */
+/* $NetBSD: grf_subr.c,v 1.1 1996/12/17 08:41:11 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * Subroutines common to all framebuffer devices.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+
+#include <hp300/dev/grfioctl.h>
+#include <hp300/dev/grfvar.h>
+
+int grfdevprint __P((void *, const char *));
+
+void
+grfdev_attach(sc, init, regs, sw)
+ struct grfdev_softc *sc;
+ int (*init) __P((struct grf_data *, int, caddr_t));
+ caddr_t regs;
+ struct grfsw *sw;
+{
+ struct grfdev_attach_args ga;
+ struct grf_data *gp;
+ int isconsole;
+
+ isconsole = (sc->sc_scode == conscode);
+
+ if (isconsole)
+ sc->sc_data = gp = &grf_cn;
+ else {
+ sc->sc_data = gp =
+ (struct grf_data *)malloc(sizeof(struct grf_data),
+ M_DEVBUF, M_NOWAIT);
+ if (sc->sc_data == NULL) {
+ printf("\n%s: can't allocate grf data\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ bzero(sc->sc_data, sizeof(struct grf_data));
+
+ /* Initialize the framebuffer hardware. */
+ if ((*init)(sc->sc_data, sc->sc_scode, regs) == 0) {
+ printf("\n%s: init failed\n",
+ sc->sc_dev.dv_xname);
+ free(sc->sc_data, M_DEVBUF);
+ return;
+ }
+
+ gp->g_sw = sw;
+ gp->g_display.gd_id = gp->g_sw->gd_swid;
+ }
+
+ /* Announce ourselves. */
+ 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);
+
+ /* Attach a grf. */
+ ga.ga_scode = sc->sc_scode; /* XXX */
+ ga.ga_isconsole = isconsole;
+ ga.ga_data = (void *)sc->sc_data;
+ (void)config_found(&sc->sc_dev, &ga, grfdevprint);
+}
+
+int
+grfdevprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct grfdev_attach_args *ga = aux;
+
+ /* Only grf's can attach to grfdev's... easy. */
+ if (pnp)
+ printf("grf at %s", pnp);
+
+ return (UNCONF);
+}
diff --git a/sys/arch/hp300/dev/grf_tc.c b/sys/arch/hp300/dev/grf_tc.c
index fdde9bbaea4..65eae4683d5 100644
--- a/sys/arch/hp300/dev/grf_tc.c
+++ b/sys/arch/hp300/dev/grf_tc.c
@@ -1,4 +1,5 @@
-/* $NetBSD: grf_tc.c,v 1.7 1996/03/03 16:49:04 thorpej Exp $ */
+/* $OpenBSD: grf_tc.c,v 1.3 1997/01/12 15:12:38 downsj Exp $ */
+/* $NetBSD: grf_tc.c,v 1.9 1996/12/17 08:41:12 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -43,9 +44,6 @@
* @(#)grf_tc.c 8.4 (Berkeley) 1/12/94
*/
-#include "grf.h"
-#if NGRF > 0
-
/*
* Graphics routines for TOPCAT and CATSEYE frame buffers
*/
@@ -56,12 +54,17 @@
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/cons.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+#include <hp300/dev/intiovar.h>
+
#include <hp300/dev/grfioctl.h>
#include <hp300/dev/grfvar.h>
#include <hp300/dev/grfreg.h>
@@ -75,6 +78,28 @@
int tc_init __P((struct grf_data *, int, caddr_t));
int tc_mode __P((struct grf_data *, int, caddr_t));
+#ifdef NEWCONFIG
+void topcat_common_attach __P((struct grfdev_softc *, caddr_t, u_int8_t));
+
+int topcat_intio_match __P((struct device *, struct cfdata *, void *));
+void topcat_intio_attach __P((struct device *, struct device *, void *));
+
+int topcat_dio_match __P((struct device *, struct cfdata *, void *));
+void topcat_dio_attach __P((struct device *, struct device *, void *));
+
+struct cfattach topcat_intio_ca = {
+ sizeof(struct grfdev_softc), topcat_intio_match, topcat_intio_attach
+};
+
+struct cfattach topcat_dio_ca = {
+ sizeof(struct grfdev_softc), topcat_dio_match, topcat_dio_attach
+};
+
+struct cfdriver topcat_cd = {
+ NULL, "topcat", DV_DULL
+};
+#endif /* NEWCONFIG */
+
/* Topcat (bobcat) grf switch */
struct grfsw topcat_grfsw = {
GID_TOPCAT, GRFBOBCAT, "topcat", tc_init, tc_mode
@@ -112,6 +137,139 @@ struct itesw topcat_itesw = {
};
#endif /* NITE > 0 */
+#ifdef NEWCONFIG
+int
+topcat_intio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct intio_attach_args *ia = aux;
+ struct grfreg *grf;
+
+ grf = (struct grfreg *)IIOV(GRFIADDR);
+
+ if (badaddr((caddr_t)grf))
+ return (0);
+
+ if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER) {
+ switch (grf->gr_id2) {
+ case DIO_DEVICE_SECID_TOPCAT:
+ case DIO_DEVICE_SECID_LRCATSEYE:
+ case DIO_DEVICE_SECID_HRCCATSEYE:
+ case DIO_DEVICE_SECID_HRMCATSEYE:
+#if 0
+ case DIO_DEVICE_SECID_XXXCATSEYE:
+#endif
+ ia->ia_addr = (caddr_t)GRFIADDR;
+ return (1);
+ }
+ }
+
+ return (0);
+}
+
+void
+topcat_intio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ struct grfreg *grf;
+
+ grf = (struct grfreg *)IIOV(GRFIADDR);
+ sc->sc_scode = -1; /* XXX internal i/o */
+
+ topcat_common_attach(sc, (caddr_t)grf, grf->gr_id2);
+}
+
+int
+topcat_dio_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER) {
+ switch (da->da_secid) {
+ case DIO_DEVICE_SECID_TOPCAT:
+ case DIO_DEVICE_SECID_LRCATSEYE:
+ case DIO_DEVICE_SECID_HRCCATSEYE:
+ case DIO_DEVICE_SECID_HRMCATSEYE:
+#if 0
+ case DIO_DEVICE_SECID_XXXCATSEYE:
+#endif
+ return (1);
+ }
+ }
+
+ return (0);
+}
+
+void
+topcat_dio_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct grfdev_softc *sc = (struct grfdev_softc *)self;
+ struct dio_attach_args *da = aux;
+ caddr_t grf;
+
+ sc->sc_scode = da->da_scode;
+ if (sc->sc_scode == conscode)
+ grf = conaddr;
+ else {
+ grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size);
+ if (grf == 0) {
+ printf("%s: can't map framebuffer\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+ }
+
+ topcat_common_attach(sc, grf, da->da_secid);
+}
+
+void
+topcat_common_attach(sc, grf, secid)
+ struct grfdev_softc *sc;
+ caddr_t grf;
+ u_int8_t secid;
+{
+ struct grfsw *sw;
+
+ switch (secid) {
+ case DIO_DEVICE_SECID_TOPCAT:
+ sw = &topcat_grfsw;
+ break;
+
+ case DIO_DEVICE_SECID_LRCATSEYE:
+ sw = &lrcatseye_grfsw;
+ break;
+
+ case DIO_DEVICE_SECID_HRCCATSEYE:
+ sw = &hrcatseye_grfsw;
+ break;
+
+ case DIO_DEVICE_SECID_HRMCATSEYE:
+ sw = &hrmcatseye_grfsw;
+ break;
+#if 0
+ case DIO_DEVICE_SECID_XXXCATSEYE:
+ sw = XXX?
+ break;
+#endif
+ default:
+ printf("%s: unkown device 0x%x\n",
+ sc->sc_dev.dv_xname, secid);
+ panic("topcat_common_attach");
+ }
+
+ grfdev_attach(sc, tc_init, grf, sw);
+}
+#endif /* NEWCONFIG */
+
/*
* Initialize hardware.
* Must fill in the grfinfo structure in g_softc.
@@ -128,7 +286,6 @@ tc_init(gp, scode, addr)
volatile u_char *fbp;
u_char save;
int fboff;
- extern caddr_t sctopa();
/*
* If the console has been initialized, and it was us, there's
@@ -138,7 +295,7 @@ tc_init(gp, scode, addr)
if (ISIIOVA(addr))
gi->gd_regaddr = (caddr_t) IIOP(addr);
else
- gi->gd_regaddr = sctopa(scode);
+ gi->gd_regaddr = dio_scodetopa(scode);
gi->gd_regsize = 0x10000;
gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb;
gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb;
@@ -626,7 +783,6 @@ void
topcatcninit(cp)
struct consdev *cp;
{
- struct ite_data *ip = &ite_cn;
struct grf_data *gp = &grf_cn;
struct grfreg *grf = (struct grfreg *)conaddr;
@@ -663,16 +819,9 @@ topcatcninit(cp)
gp->g_flags = GF_ALIVE;
/*
- * Set up required ite data and initialize ite.
+ * Initialize the terminal emulator.
*/
- ip->isw = &topcat_itesw;
- ip->grf = gp;
- ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS;
- ip->attrbuf = console_attributes;
- iteinit(ip);
-
- kbd_ite = ip; /* XXX */
+ itecninit(gp, &topcat_itesw);
}
#endif /* NITE > 0 */
-#endif /* NGRF > 0 */
diff --git a/sys/arch/hp300/dev/grf_tcreg.h b/sys/arch/hp300/dev/grf_tcreg.h
index 38c7dd825ce..b3146f0100c 100644
--- a/sys/arch/hp300/dev/grf_tcreg.h
+++ b/sys/arch/hp300/dev/grf_tcreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grf_tcreg.h,v 1.2 1997/01/12 15:12:39 downsj Exp $ */
/* $NetBSD: grf_tcreg.h,v 1.6 1994/10/26 07:24:06 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grfioctl.h b/sys/arch/hp300/dev/grfioctl.h
index 1d186584cc8..4467860af9b 100644
--- a/sys/arch/hp300/dev/grfioctl.h
+++ b/sys/arch/hp300/dev/grfioctl.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grfioctl.h,v 1.2 1997/01/12 15:12:40 downsj Exp $ */
/* $NetBSD: grfioctl.h,v 1.5 1994/10/26 07:24:08 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grfreg.h b/sys/arch/hp300/dev/grfreg.h
index d80205fffd6..e69b02df4bc 100644
--- a/sys/arch/hp300/dev/grfreg.h
+++ b/sys/arch/hp300/dev/grfreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: grfreg.h,v 1.2 1997/01/12 15:12:40 downsj Exp $ */
/* $NetBSD: grfreg.h,v 1.2 1994/10/26 07:24:09 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/grfvar.h b/sys/arch/hp300/dev/grfvar.h
index f6f02a0158f..ac6a5d51db9 100644
--- a/sys/arch/hp300/dev/grfvar.h
+++ b/sys/arch/hp300/dev/grfvar.h
@@ -1,4 +1,5 @@
-/* $NetBSD: grfvar.h,v 1.7 1996/02/24 00:55:18 thorpej Exp $ */
+/* $OpenBSD: grfvar.h,v 1.3 1997/01/12 15:12:41 downsj Exp $ */
+/* $NetBSD: grfvar.h,v 1.8 1996/12/17 08:41:12 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -77,10 +78,28 @@ struct grfsw {
};
struct grf_softc {
+ struct device sc_dev; /* generic device info */
+ int sc_scode; /* select code; for grfdevno() */
struct grf_data *sc_data; /* display state information */
struct ite_softc *sc_ite; /* pointer to ite; may be NULL */
};
+struct grfdev_softc {
+ struct device sc_dev; /* generic device info */
+ struct grf_data *sc_data; /* generic grf data */
+ int sc_scode; /* select code, -1 for intio */
+};
+
+/*
+ * Set up by the hardware driver, and passed all the way down to
+ * the ITE, if appropriate.
+ */
+struct grfdev_attach_args {
+ int ga_scode; /* XXX select code, -1 for intio */
+ int ga_isconsole; /* from hardware; is console? */
+ void *ga_data; /* hardware-dependent data */
+};
+
/* flags */
#define GF_ALIVE 0x01
#define GF_OPEN 0x02
@@ -105,7 +124,15 @@ struct grf_softc {
#ifdef _KERNEL
extern struct grf_data grf_cn; /* grf_data for console device */
+#ifndef NEWCONFIG
extern struct grf_softc grf_softc[];
extern struct grfsw *grfsw[];
extern int ngrfsw;
-#endif
+#endif /* ! NEWCONFIG */
+
+#ifdef NEWCONFIG
+void grfdev_attach __P((struct grfdev_softc *,
+ int (*init)(struct grf_data *, int, caddr_t),
+ caddr_t, struct grfsw *));
+#endif /* NEWCONFIG */
+#endif /* _KERNEL */
diff --git a/sys/arch/hp300/dev/hil.c b/sys/arch/hp300/dev/hil.c
index bf93d1eec0a..fc159f1fe9d 100644
--- a/sys/arch/hp300/dev/hil.c
+++ b/sys/arch/hp300/dev/hil.c
@@ -1,4 +1,5 @@
-/* $NetBSD: hil.c,v 1.22 1996/02/14 02:44:24 thorpej Exp $ */
+/* $OpenBSD: hil.c,v 1.8 1997/01/12 15:12:41 downsj Exp $ */
+/* $NetBSD: hil.c,v 1.29 1996/10/14 07:09:41 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -93,6 +94,13 @@ int hildebug = 0;
extern struct emul emul_hpux;
#endif
+/* XXX ITE interface */
+char *kbd_keymap;
+char *kbd_shiftmap;
+char *kbd_ctrlmap;
+char *kbd_ctrlshiftmap;
+char **kbd_stringmap;
+
/* symbolic sleep message strings */
char hilin[] = "hilin";
@@ -103,6 +111,10 @@ hilsoftinit(unit, hilbase)
register struct hil_softc *hilp = &hil_softc[unit];
register int i;
+ /* XXX ITE interface */
+ extern char *us_keymap, *us_shiftmap, *us_ctrlmap,
+ *us_ctrlshiftmap, **us_stringmap;
+
#ifdef DEBUG
if (hildebug & HDB_FOLLOW)
printf("hilsoftinit(%d, %x)\n", unit, hilbase);
@@ -117,7 +129,6 @@ hilsoftinit(unit, hilbase)
hilp->hl_cmdbp = hilp->hl_cmdbuf;
hilp->hl_pollbp = hilp->hl_pollbuf;
hilp->hl_kbddev = 0;
- hilp->hl_kbdlang = KBD_DEFAULT;
hilp->hl_kbdflags = 0;
/*
* Clear all queues and device associations with queues
@@ -130,6 +141,18 @@ hilsoftinit(unit, hilbase)
for (i = 0; i < NHILD; i++)
hilp->hl_device[i].hd_qmask = 0;
hilp->hl_device[HILLOOPDEV].hd_flags = (HIL_ALIVE|HIL_PSEUDO);
+
+ /*
+ * Set up default keyboard language. We always default
+ * to US ASCII - it seems to work OK for non-recognized
+ * keyboards.
+ */
+ hilp->hl_kbdlang = KBD_DEFAULT;
+ kbd_keymap = us_keymap; /* XXX */
+ kbd_shiftmap = us_shiftmap; /* XXX */
+ kbd_ctrlmap = us_ctrlmap; /* XXX */
+ kbd_ctrlshiftmap = us_ctrlshiftmap; /* XXX */
+ kbd_stringmap = us_stringmap; /* XXX */
}
hilinit(unit, hilbase)
@@ -681,6 +704,7 @@ hilmmap(dev, off, prot)
}
/*ARGSUSED*/
+int
hilselect(dev, rw, p)
dev_t dev;
int rw;
@@ -691,7 +715,7 @@ hilselect(dev, rw, p)
register struct hiliqueue *qp;
register int mask;
int s, device;
-
+
if (rw == FWRITE)
return (1);
device = HILUNIT(dev);
@@ -831,10 +855,6 @@ hil_process_int(hilp, stat, c)
}
}
-#if (defined(DDB) || defined(DEBUG)) && !defined(PANICBUTTON)
-#define PANICBUTTON
-#endif
-
/*
* Optimized macro to compute:
* eq->head == (eq->tail + 1) % eq->size
@@ -857,20 +877,6 @@ hilevent(hilp)
int s, len0;
long tenths;
-#ifdef PANICBUTTON
- static int first;
- extern int panicbutton;
-
- cp = hilp->hl_pollbuf;
- if (panicbutton && (*cp & HIL_KBDDATA)) {
- if (*++cp == 0x4E)
- first = 1;
- else if (first && *cp == 0x46 && !panicstr)
- panic("are we having fun yet?");
- else
- first = 0;
- }
-#endif
#ifdef DEBUG
if (hildebug & HDB_EVENTS) {
printf("hilevent: dev %d pollbuf: ", hilp->hl_actdev);
@@ -1128,28 +1134,86 @@ kbddisable(unit)
}
/*
+ * The following chunk of code implements HIL console keyboard
+ * support.
+ */
+
+struct hil_dev *hilkbd_cn_device;
+char *kbd_cn_keymap;
+char *kbd_cn_shiftmap;
+char *kbd_cn_ctrlmap;
+
+/*
* XXX: read keyboard directly and return code.
* Used by console getchar routine. Could really screw up anybody
* reading from the keyboard in the normal, interrupt driven fashion.
*/
-kbdgetc(unit, statp)
- int unit, *statp;
+int
+kbdgetc(statp)
+ int *statp;
{
- struct hil_softc *hilp = &hil_softc[unit];
- register struct hil_dev *hildevice = hilp->hl_addr;
register int c, stat;
int s;
+ if (hilkbd_cn_device == NULL)
+ return (0);
+
+ /*
+ * XXX needs to be splraise because we could be called
+ * XXX at splhigh, e.g. in DDB.
+ */
s = splhil();
- while (((stat = READHILSTAT(hildevice)) & HIL_DATA_RDY) == 0)
+ while (((stat = READHILSTAT(hilkbd_cn_device)) & HIL_DATA_RDY) == 0)
;
- c = READHILDATA(hildevice);
+ c = READHILDATA(hilkbd_cn_device);
splx(s);
*statp = stat;
- return(c);
+ return (c);
}
/*
+ * Perform basic initialization of the HIL keyboard, suitable
+ * for early console use.
+ */
+void
+kbdcninit()
+{
+ struct hil_dev *h = HILADDR; /* == VA (see hilreg.h) */
+ struct kbdmap *km;
+ u_char lang;
+
+ /* XXX from hil_keymaps.c */
+ extern char *us_keymap, *us_shiftmap, *us_ctrlmap;
+
+ hilkbd_cn_device = h;
+
+ /* Default to US-ASCII keyboard. */
+ kbd_cn_keymap = us_keymap;
+ kbd_cn_shiftmap = us_shiftmap;
+ kbd_cn_ctrlmap = us_ctrlmap;
+
+ HILWAIT(h);
+ WRITEHILCMD(h, HIL_SETARR);
+ HILWAIT(h);
+ WRITEHILDATA(h, ar_format(KBD_ARR));
+ HILWAIT(h);
+ WRITEHILCMD(h, HIL_READKBDLANG);
+ HILDATAWAIT(h);
+ lang = READHILDATA(h);
+ for (km = kbd_map; km->kbd_code; km++) {
+ if (km->kbd_code == lang) {
+ kbd_cn_keymap = km->kbd_keymap;
+ kbd_cn_shiftmap = km->kbd_shiftmap;
+ kbd_cn_ctrlmap = km->kbd_ctrlmap;
+ }
+ }
+ HILWAIT(h);
+ WRITEHILCMD(h, HIL_INTON);
+}
+
+/* End of HIL console keyboard code. */
+
+/*
* Recoginize and clear keyboard generated NMIs.
* Returns 1 if it was ours, 0 otherwise. Note that we cannot use
* send_hil_cmd() to issue the clear NMI command as that would actually
@@ -1335,7 +1399,7 @@ hilconfig(hilp)
if (hilp->hl_kbdlang != KBD_SPECIAL) {
struct kbdmap *km;
- for (km = kbd_map; km->kbd_code; km++)
+ for (km = kbd_map; km->kbd_code; km++) {
if (km->kbd_code == db) {
hilp->hl_kbdlang = db;
/* XXX */
@@ -1344,7 +1408,14 @@ hilconfig(hilp)
kbd_ctrlmap = km->kbd_ctrlmap;
kbd_ctrlshiftmap = km->kbd_ctrlshiftmap;
kbd_stringmap = km->kbd_stringmap;
+ break;
}
+ }
+ if (km->kbd_code == 0) {
+ printf(
+ "hilconfig: unknown keyboard type 0x%x, using default\n",
+ db);
+ }
}
splx(s);
}
diff --git a/sys/arch/hp300/dev/hil_keymaps.c b/sys/arch/hp300/dev/hil_keymaps.c
index 03f8174dc95..a9b65e5b91f 100644
--- a/sys/arch/hp300/dev/hil_keymaps.c
+++ b/sys/arch/hp300/dev/hil_keymaps.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: hil_keymaps.c,v 1.3 1997/01/12 15:12:42 downsj Exp $ */
/* $NetBSD: hil_keymaps.c,v 1.6 1995/12/06 22:13:23 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/hilioctl.h b/sys/arch/hp300/dev/hilioctl.h
index c01b97855fc..54c7ba453c4 100644
--- a/sys/arch/hp300/dev/hilioctl.h
+++ b/sys/arch/hp300/dev/hilioctl.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: hilioctl.h,v 1.2 1997/01/12 15:12:43 downsj Exp $ */
/* $NetBSD: hilioctl.h,v 1.6 1994/10/26 07:24:14 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/hilreg.h b/sys/arch/hp300/dev/hilreg.h
index dd793af3cc7..0b09598d0b9 100644
--- a/sys/arch/hp300/dev/hilreg.h
+++ b/sys/arch/hp300/dev/hilreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: hilreg.h,v 1.2 1997/01/12 15:12:44 downsj Exp $ */
/* $NetBSD: hilreg.h,v 1.5 1994/10/26 07:24:15 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/hilvar.h b/sys/arch/hp300/dev/hilvar.h
index 078268a514a..6db06e20042 100644
--- a/sys/arch/hp300/dev/hilvar.h
+++ b/sys/arch/hp300/dev/hilvar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: hilvar.h,v 1.3 1997/01/12 15:12:44 downsj Exp $ */
/* $NetBSD: hilvar.h,v 1.11 1995/12/11 19:41:47 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c
index 4d39539f24f..fd8f0b969c8 100644
--- a/sys/arch/hp300/dev/hpib.c
+++ b/sys/arch/hp300/dev/hpib.c
@@ -1,4 +1,5 @@
-/* $NetBSD: hpib.c,v 1.9 1996/05/17 15:09:39 thorpej Exp $ */
+/* $OpenBSD: hpib.c,v 1.5 1997/01/12 15:12:45 downsj Exp $ */
+/* $NetBSD: hpib.c,v 1.12 1996/12/09 03:16:27 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -135,7 +136,8 @@ hpibattach(hc)
hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq;
/* Establish the interrupt handler. */
- isrlink(hpibintr, hs, hc->hp_ipl, ISRPRI_BIO);
+ (void) isrlink(hpibintr, hs, hc->hp_ipl, ISRPRI_BIO);
+ dmacomputeipl();
/* Reset the controller, display what we've seen, and we're done. */
hpibreset(hc->hp_unit);
diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h
index 3e1f6a3abed..81bf17c5579 100644
--- a/sys/arch/hp300/dev/hpibvar.h
+++ b/sys/arch/hp300/dev/hpibvar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: hpibvar.h,v 1.4 1997/01/12 15:12:45 downsj Exp $ */
/* $NetBSD: hpibvar.h,v 1.8 1996/02/14 02:44:31 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c
index 7c17d759f20..14e6a47e5c5 100644
--- a/sys/arch/hp300/dev/if_le.c
+++ b/sys/arch/hp300/dev/if_le.c
@@ -1,4 +1,5 @@
-/* $NetBSD: if_le.c,v 1.31 1996/05/09 21:11:47 thorpej Exp $ */
+/* $OpenBSD: if_le.c,v 1.6 1997/01/12 15:12:46 downsj Exp $ */
+/* $NetBSD: if_le.c,v 1.36 1996/12/17 08:41:13 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -55,6 +56,7 @@
#include <netinet/if_ether.h>
#endif
+#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/mtpr.h>
@@ -64,24 +66,39 @@
#include <hp300/hp300/led.h>
#endif
+#ifndef NEWCONFIG
#include <hp300/dev/device.h>
+#endif
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
#include <hp300/dev/if_lereg.h>
#include <hp300/dev/if_levar.h>
+#ifdef NEWCONFIG
+int lematch __P((struct device *, struct cfdata *, void *));
+void leattach __P((struct device *, struct device *, void *));
+
+struct cfattach le_ca = {
+ sizeof(struct le_softc), lematch, leattach
+};
+#else /* ! NEWCONFIG */
#include "le.h"
struct le_softc le_softc[NLE];
int lematch __P((struct hp_device *));
void leattach __P((struct hp_device *));
-int leintr __P((void *));
struct driver ledriver = {
lematch, leattach, "le",
};
+#endif /* NEWCONFIG */
+
+int leintr __P((void *));
/* offsets for: ID, REGS, MEM, NVRAM */
int lestd[] = { 0, 0x4000, 0x8000, 0xC008 };
@@ -123,6 +140,20 @@ lerdcsr(sc, port)
return (val);
}
+#ifdef NEWCONFIG
+int
+lematch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct dio_attach_args *da = aux;
+
+ if (da->da_id == DIO_DEVICE_ID_LAN)
+ return (1);
+ return (0);
+}
+#else /* ! NEWCONFIG */
int
lematch(hd)
struct hp_device *hd;
@@ -139,32 +170,62 @@ lematch(hd)
return (1);
}
+#endif /* NEWCONFIG */
/*
* Interface exists: make available by filling in network interface
* record. System will initialize the interface when it is ready
* to accept packets.
*/
+#ifdef NEWCONFIG
+void
+leattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+#else /* ! NEWCONFIG */
void
leattach(hd)
struct hp_device *hd;
+#endif /* NEWCONFIG */
{
register struct lereg0 *ler0;
+#ifdef NEWCONFIG
+ struct dio_attach_args *da = aux;
+ struct le_softc *lesc = (struct le_softc *)self;
+ caddr_t addr;
+#else
struct le_softc *lesc = &le_softc[hd->hp_unit];
+ caddr_t addr = hd->hp_addr;
+#endif /* NEWCONFIG */
struct am7990_softc *sc = &lesc->sc_am7990;
char *cp;
- int i;
+ int i, ipl;
+
+#ifdef NEWCONFIG
+ addr = iomap(dio_scodetopa(da->da_scode), da->da_size);
+ if (addr == 0) {
+ printf("\n%s: can't map LANCE registers\n",
+ sc->sc_dev.dv_xname);
+ return;
+ }
+#endif /* NEWCONFIG */
- ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr);
+ ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)addr);
ler0->ler0_id = 0xFF;
DELAY(100);
+#ifdef NEWCONFIG
+ ipl = DIO_IPL(addr);
+ printf(" ipl %d", ipl);
+#else /* ! NEWCONFIG */
/* XXXX kluge for now */
- sc->sc_dev.dv_unit = hd->hp_unit;
- sprintf(sc->sc_dev.dv_xname, "%s%d", le_cd.cd_name, hd->hp_unit);
+ hd->hp_dev.dv_class = DV_IFNET;
+ bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device));
+ ipl = hd->hp_ipl;
+#endif /* NEWCONFIG */
- lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr);
- sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr);
+ lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)addr);
+ sc->sc_mem = (void *)(lestd[2] + (int)addr);
sc->sc_conf3 = LE_C3_BSWP;
sc->sc_addr = 0;
sc->sc_memsize = 16384;
@@ -172,7 +233,7 @@ leattach(hd)
/*
* Read the ethernet address off the board, one nibble at a time.
*/
- cp = (char *)(lestd[3] + (int)hd->hp_addr);
+ cp = (char *)(lestd[3] + (int)addr);
for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++) {
sc->sc_arpcom.ac_enaddr[i] = (*++cp & 0xF) << 4;
cp++;
@@ -193,7 +254,7 @@ leattach(hd)
am7990_config(sc);
/* Establish the interrupt handler. */
- isrlink(leintr, sc, hd->hp_ipl, ISRPRI_NET);
+ (void) isrlink(leintr, sc, ipl, ISRPRI_NET);
ler0->ler0_status = LE_IE;
}
diff --git a/sys/arch/hp300/dev/if_lereg.h b/sys/arch/hp300/dev/if_lereg.h
index b745ad6ee06..7bb7fcc24c9 100644
--- a/sys/arch/hp300/dev/if_lereg.h
+++ b/sys/arch/hp300/dev/if_lereg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: if_lereg.h,v 1.3 1997/01/12 15:12:46 downsj Exp $ */
/* $NetBSD: if_lereg.h,v 1.8 1995/12/10 00:49:36 mycroft Exp $ */
/*
diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h
index 40d64ab8e1f..7e1f2f7523f 100644
--- a/sys/arch/hp300/dev/if_levar.h
+++ b/sys/arch/hp300/dev/if_levar.h
@@ -1,4 +1,5 @@
-/* $NetBSD: if_levar.h,v 1.4 1996/05/07 00:58:00 thorpej Exp $ */
+/* $OpenBSD: if_levar.h,v 1.3 1997/01/12 15:12:47 downsj Exp $ */
+/* $NetBSD: if_levar.h,v 1.5 1996/12/17 08:41:14 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -49,7 +50,9 @@
struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
+#ifndef NEWCONFIG
struct hp_device *sc_hd;
+#endif
struct isr sc_isr;
struct lereg0 *sc_r0; /* DIO registers */
struct lereg1 *sc_r1; /* LANCE registers */
diff --git a/sys/arch/hp300/dev/intio.c b/sys/arch/hp300/dev/intio.c
new file mode 100644
index 00000000000..af6a5a1bb02
--- /dev/null
+++ b/sys/arch/hp300/dev/intio.c
@@ -0,0 +1,115 @@
+/* $OpenBSD: intio.c,v 1.1 1997/01/12 15:12:47 downsj Exp $ */
+/* $NetBSD: intio.c,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * Autoconfiguration support for hp300 internal i/o space.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <hp300/dev/intiovar.h>
+
+int intiomatch __P((struct device *, struct cfdata *, void *));
+void intioattach __P((struct device *, struct device *, void *));
+int intioprint __P((void *, const char *));
+int intiosearch __P((struct device *, struct cfdata *, void *));
+
+struct cfattach intio_ca = {
+ sizeof(struct device), intiomatch, intioattach
+};
+
+struct cfdriver intio_cd = {
+ NULL, "intio", DV_DULL
+};
+
+int
+intiomatch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ static int intio_matched = 0;
+
+ /* Allow only one instance. */
+ if (intio_matched)
+ return (0);
+
+ intio_matched = 1;
+ return (1);
+}
+
+void
+intioattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+
+ printf("\n");
+
+ /* Search for and attach children. */
+ config_search(intiosearch, self, NULL);
+}
+
+int
+intioprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct intio_attach_args *ia = aux;
+
+ if (ia->ia_addr != 0)
+ printf(" addr %p", ia->ia_addr);
+ return (UNCONF);
+}
+
+int
+intiosearch(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct intio_attach_args ia;
+
+ bzero(&ia, sizeof(ia));
+ if ((*cf->cf_attach->ca_match)(parent, cf, &ia) > 0)
+ config_attach(parent, cf, &ia, intioprint);
+ return (0);
+}
diff --git a/sys/arch/hp300/dev/intiovar.h b/sys/arch/hp300/dev/intiovar.h
new file mode 100644
index 00000000000..e6dc6dbc0e2
--- /dev/null
+++ b/sys/arch/hp300/dev/intiovar.h
@@ -0,0 +1,50 @@
+/* $OpenBSD: intiovar.h,v 1.1 1997/01/12 15:12:48 downsj Exp $ */
+/* $NetBSD: intiovar.h,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 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.
+ */
+
+/*
+ * Autoconfiguration definitions and prototypes for the hp300
+ * internal i/o space.
+ */
+
+/*
+ * Arguments used to attach a device to the internal i/o space.
+ */
+struct intio_attach_args {
+ caddr_t ia_addr; /* physical address */
+};
diff --git a/sys/arch/hp300/dev/iotypes.h b/sys/arch/hp300/dev/iotypes.h
index e088f61ef94..c21e717af95 100644
--- a/sys/arch/hp300/dev/iotypes.h
+++ b/sys/arch/hp300/dev/iotypes.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: iotypes.h,v 1.2 1997/01/12 15:12:48 downsj Exp $ */
/* $NetBSD: iotypes.h,v 1.2 1994/10/26 07:24:24 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c
index a2416c6d8ca..4217dce8d07 100644
--- a/sys/arch/hp300/dev/ite.c
+++ b/sys/arch/hp300/dev/ite.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ite.c,v 1.29.4.1 1996/06/06 15:39:12 thorpej Exp $ */
+/* $OpenBSD: ite.c,v 1.6 1997/01/12 15:12:49 downsj Exp $ */
+/* $NetBSD: ite.c,v 1.34 1996/12/17 08:41:16 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -48,12 +49,6 @@
* This is a very rudimentary. Much more can be abstracted out of
* the hardware dependent routines.
*/
-#include "ite.h"
-#if NITE > 0
-
-#include "grf.h"
-#undef NITE
-#define NITE NGRF
#include <sys/param.h>
#include <sys/conf.h>
@@ -62,6 +57,7 @@
#include <sys/tty.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/device.h>
#include <machine/autoconf.h>
@@ -90,9 +86,23 @@
*/
int iteburst = 64;
-int nite = NITE;
struct ite_data *kbd_ite = NULL;
-struct ite_softc ite_softc[NITE];
+
+#ifdef NEWCONFIG
+int itematch __P((struct device *, struct cfdata *, void *));
+void iteattach __P((struct device *, struct device *, void *));
+
+struct cfattach ite_ca = {
+ sizeof(struct ite_softc), itematch, iteattach
+};
+
+struct cfdriver ite_cd = {
+ NULL, "ite", DV_TTY
+};
+#else /* ! NEWCONFIG */
+#include "grf.h"
+struct ite_softc ite_softc[NGRF];
+#endif /* NEWCONFIG */
/*
* Terminal emulator state information, statically allocated
@@ -116,7 +126,7 @@ void itestart __P((struct tty *));
* found. Secondary displays alloc the attribute buffer as needed.
* Size is based on a 68x128 display, which is currently our largest.
*/
-u_char console_attributes[0x2200];
+u_char ite_console_attributes[0x2200];
#define ite_erasecursor(ip, sp) { \
if ((ip)->flags & ITE_CURSORON) \
@@ -131,6 +141,57 @@ u_char console_attributes[0x2200];
(*(sp)->ite_cursor)((ip), MOVE_CURSOR); \
}
+#ifdef NEWCONFIG
+int
+itematch(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+
+ return (1);
+}
+
+void
+iteattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct ite_softc *ite = (struct ite_softc *)self;
+ struct grf_softc *grf = (struct grf_softc *)parent;
+ struct grfdev_attach_args *ga = aux;
+
+ /* Allocate the ite_data. */
+ if (ga->ga_isconsole) {
+ ite->sc_data = &ite_cn;
+ printf(": console");
+
+ /*
+ * We didn't know which unit this would be during
+ * the console probe, so we have to fixup cn_dev here.
+ */
+ cn_tab->cn_dev = makedev(ite_major(), self->dv_unit);
+ } else {
+ ite->sc_data =
+ (struct ite_data *)malloc(sizeof(struct ite_data),
+ M_DEVBUF, M_NOWAIT);
+ if (ite->sc_data == NULL) {
+ printf("\n%s: malloc for ite_data failed\n",
+ ite->sc_dev.dv_xname);
+ return;
+ }
+ bzero(ite->sc_data, sizeof(struct ite_data));
+ }
+
+ /*
+ * Cross-reference the ite and the grf.
+ */
+ ite->sc_grf = grf;
+ grf->sc_ite = ite;
+
+ printf("\n");
+}
+#else /* ! NEWCONFIG */
/*
* Dummy for pseudo-device config.
*/
@@ -182,6 +243,7 @@ ite_attach_grf(unit, isconsole)
printf("ite%d at grf%d: attached\n", unit, unit);
}
+#endif /* NEWCONFIG */
/*
* Perform functions necessary to setup device as a terminal emulator.
@@ -290,11 +352,22 @@ iteopen(dev, mode, devtype, p)
{
int unit = ITEUNIT(dev);
struct tty *tp;
- struct ite_softc *sc = &ite_softc[unit];
- struct ite_data *ip = sc->sc_data;
+ struct ite_softc *sc;
+ struct ite_data *ip;
int error;
int first = 0;
+#ifdef NEWCONFIG
+ if (unit >= ite_cd.cd_ndevs ||
+ (sc = ite_cd.cd_devs[unit]) == NULL)
+ return (ENXIO);
+#else
+ if (unit >= NGRF)
+ return (ENXIO);
+ sc = &ite_softc[unit];
+#endif
+ ip = sc->sc_data;
+
if (ip->tty == NULL) {
tp = ip->tty = ttymalloc();
tty_attach(tp);
@@ -338,7 +411,11 @@ iteclose(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
+#ifdef NEWCONFIG
+ struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
+#else
struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
+#endif
struct ite_data *ip = sc->sc_data;
struct tty *tp = ip->tty;
@@ -359,7 +436,11 @@ iteread(dev, uio, flag)
struct uio *uio;
int flag;
{
+#ifdef NEWCONFIG
+ struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
+#else
struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
+#endif
struct tty *tp = sc->sc_data->tty;
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
@@ -371,7 +452,11 @@ itewrite(dev, uio, flag)
struct uio *uio;
int flag;
{
+#ifdef NEWCONFIG
+ struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
+#else
struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
+#endif
struct tty *tp = sc->sc_data->tty;
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
@@ -381,7 +466,11 @@ struct tty *
itetty(dev)
dev_t dev;
{
+#ifdef NEWCONFIG
+ struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
+#else
struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
+#endif
return (sc->sc_data->tty);
}
@@ -394,7 +483,11 @@ iteioctl(dev, cmd, addr, flag, p)
int flag;
struct proc *p;
{
+#ifdef NEWCONFIG
+ struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)];
+#else
struct ite_softc *sc = &ite_softc[ITEUNIT(dev)];
+#endif
struct ite_data *ip = sc->sc_data;
struct tty *tp = ip->tty;
int error;
@@ -417,7 +510,11 @@ itestart(tp)
struct ite_softc *sc;
struct ite_data *ip;
+#ifdef NEWCONFIG
+ sc = ite_cd.cd_devs[ITEUNIT(tp->t_dev)];
+#else
sc = &ite_softc[ITEUNIT(tp->t_dev)];
+#endif
ip = sc->sc_data;
/*
@@ -937,6 +1034,31 @@ ite_major()
* framebuffer drivers.
*/
+void
+itecninit(gp, isw)
+ struct grf_data *gp;
+ struct itesw *isw;
+{
+ extern void kbdcninit __P((void)); /* XXX */
+ struct ite_data *ip = &ite_cn;
+
+ /*
+ * Set up required ite data and initialize ite.
+ */
+ ip->isw = isw;
+ ip->grf = gp;
+ ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS;
+ ip->attrbuf = ite_console_attributes;
+ iteinit(ip);
+
+ /*
+ * Initialize the console keyboard.
+ */
+ kbdcninit();
+
+ kbd_ite = ip; /* XXX */
+}
+
/*ARGSUSED*/
int
itecngetc(dev)
@@ -945,16 +1067,16 @@ itecngetc(dev)
register int c;
int stat;
- c = kbdgetc(0, &stat); /* XXX always read from keyboard 0 for now */
+ c = kbdgetc(&stat);
switch ((stat >> KBD_SSHIFT) & KBD_SMASK) {
case KBD_SHIFT:
- c = kbd_shiftmap[c & KBD_CHARMASK];
+ c = kbd_cn_shiftmap[c & KBD_CHARMASK];
break;
case KBD_CTRL:
- c = kbd_ctrlmap[c & KBD_CHARMASK];
+ c = kbd_cn_ctrlmap[c & KBD_CHARMASK];
break;
case KBD_KEY:
- c = kbd_keymap[c & KBD_CHARMASK];
+ c = kbd_cn_keymap[c & KBD_CHARMASK];
break;
default:
c = 0;
@@ -979,4 +1101,3 @@ itecnputc(dev, c)
}
iteputchar(c, ip);
}
-#endif
diff --git a/sys/arch/hp300/dev/ite_dv.c b/sys/arch/hp300/dev/ite_dv.c
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/arch/hp300/dev/ite_dv.c
+++ /dev/null
diff --git a/sys/arch/hp300/dev/ite_gb.c b/sys/arch/hp300/dev/ite_gb.c
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/arch/hp300/dev/ite_gb.c
+++ /dev/null
diff --git a/sys/arch/hp300/dev/ite_hy.c b/sys/arch/hp300/dev/ite_hy.c
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/arch/hp300/dev/ite_hy.c
+++ /dev/null
diff --git a/sys/arch/hp300/dev/ite_rb.c b/sys/arch/hp300/dev/ite_rb.c
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/arch/hp300/dev/ite_rb.c
+++ /dev/null
diff --git a/sys/arch/hp300/dev/ite_subr.c b/sys/arch/hp300/dev/ite_subr.c
index dcf26adae6d..fdfba6aa83c 100644
--- a/sys/arch/hp300/dev/ite_subr.c
+++ b/sys/arch/hp300/dev/ite_subr.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ite_subr.c,v 1.6 1996/02/24 00:55:29 thorpej Exp $ */
+/* $OpenBSD: ite_subr.c,v 1.3 1997/01/12 15:12:51 downsj Exp $ */
+/* $NetBSD: ite_subr.c,v 1.7 1996/12/17 08:41:17 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -42,15 +43,13 @@
* @(#)ite_subr.c 8.2 (Berkeley) 1/12/94
*/
-#include "ite.h"
-#if NITE > 0
-
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/systm.h>
+#include <sys/device.h>
#include <hp300/dev/itevar.h>
#include <hp300/dev/itereg.h>
@@ -152,4 +151,3 @@ ite_writeglyph(ip, fbmem, glyphp)
fbmem += ip->fbwidth;
}
}
-#endif
diff --git a/sys/arch/hp300/dev/ite_tc.c b/sys/arch/hp300/dev/ite_tc.c
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/arch/hp300/dev/ite_tc.c
+++ /dev/null
diff --git a/sys/arch/hp300/dev/itereg.h b/sys/arch/hp300/dev/itereg.h
index f3e7a767ef2..3ccb0c0f88e 100644
--- a/sys/arch/hp300/dev/itereg.h
+++ b/sys/arch/hp300/dev/itereg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: itereg.h,v 1.2 1997/01/12 15:12:52 downsj Exp $ */
/* $NetBSD: itereg.h,v 1.5 1994/10/26 07:24:39 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/itevar.h b/sys/arch/hp300/dev/itevar.h
index 53e43760f17..2bff7f73c50 100644
--- a/sys/arch/hp300/dev/itevar.h
+++ b/sys/arch/hp300/dev/itevar.h
@@ -1,4 +1,5 @@
-/* $NetBSD: itevar.h,v 1.9 1996/02/24 00:55:31 thorpej Exp $ */
+/* $OpenBSD: itevar.h,v 1.5 1997/01/12 15:12:52 downsj Exp $ */
+/* $NetBSD: itevar.h,v 1.12 1997/01/09 01:07:59 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -42,6 +43,7 @@
* @(#)itevar.h 8.1 (Berkeley) 6/10/93
*/
+#ifdef _KERNEL
#define ITEUNIT(dev) minor(dev)
#define getbyte(ip, offset) \
@@ -88,9 +90,11 @@ struct itesw {
};
struct ite_softc {
+ struct device sc_dev; /* generic device info */
struct ite_data *sc_data; /* terminal state info */
struct grf_softc *sc_grf; /* pointer to framebuffer */
};
+#endif
/* Flags */
#define ITE_ALIVE 0x01 /* hardware exists */
@@ -192,7 +196,6 @@ extern struct ite_data ite_cn; /* ite_data for console device */
extern struct ite_data *kbd_ite; /* XXX */
extern struct ite_softc ite_softc[];
extern struct itesw itesw[];
-extern u_char console_attributes[];
extern int nitesw;
/* ite.c prototypes */
@@ -200,6 +203,7 @@ void ite_attach_grf __P((int, int));
int iteon __P((struct ite_data *, int));
void iteoff __P((struct ite_data *, int));
void itefilter __P((char, char));
+void itecninit __P((struct grf_data *, struct itesw *));
int ite_major __P((void));
/* ite_subr.c prototypes */
diff --git a/sys/arch/hp300/dev/kbdmap.h b/sys/arch/hp300/dev/kbdmap.h
index 38511760c51..c48ce3adcea 100644
--- a/sys/arch/hp300/dev/kbdmap.h
+++ b/sys/arch/hp300/dev/kbdmap.h
@@ -1,4 +1,5 @@
-/* $NetBSD: kbdmap.h,v 1.6 1995/12/06 22:13:26 thorpej Exp $ */
+/* $OpenBSD: kbdmap.h,v 1.3 1997/01/12 15:12:53 downsj Exp $ */
+/* $NetBSD: kbdmap.h,v 1.7 1996/10/05 05:22:11 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -58,11 +59,16 @@ struct kbdmap {
#ifdef _KERNEL
/* XXX: ITE interface */
-char *kbd_keymap;
-char *kbd_shiftmap;
-char *kbd_ctrlmap;
-char *kbd_ctrlshiftmap;
-char **kbd_stringmap;
+extern char *kbd_keymap;
+extern char *kbd_shiftmap;
+extern char *kbd_ctrlmap;
+extern char *kbd_ctrlshiftmap;
+extern char **kbd_stringmap;
+
+/* XXX: itecngetc() interface */
+extern char *kbd_cn_keymap;
+extern char *kbd_cn_shiftmap;
+extern char *kbd_cn_ctrlmap;
extern struct kbdmap kbd_map[];
#endif
diff --git a/sys/arch/hp300/dev/maskbits.h b/sys/arch/hp300/dev/maskbits.h
index 4c943283027..948197c36e1 100644
--- a/sys/arch/hp300/dev/maskbits.h
+++ b/sys/arch/hp300/dev/maskbits.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: maskbits.h,v 1.2 1997/01/12 15:12:53 downsj Exp $ */
/* $NetBSD: maskbits.h,v 1.2 1994/10/26 07:24:43 cgd Exp $ */
/*-
diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c
index 7f4574b8eee..a1bd5d77b1c 100644
--- a/sys/arch/hp300/dev/mt.c
+++ b/sys/arch/hp300/dev/mt.c
@@ -1,4 +1,5 @@
-/* $NetBSD: mt.c,v 1.3 1996/02/14 02:44:40 thorpej Exp $ */
+/* $OpenBSD: mt.c,v 1.4 1997/01/12 15:12:54 downsj Exp $ */
+/* $NetBSD: mt.c,v 1.6 1996/10/14 07:14:18 thorpej Exp $ */
/*
* Copyright (c) 1992, The University of Utah and
@@ -149,6 +150,9 @@ mtattach(hd)
sc->sc_dq.dq_unit = unit;
sc->sc_dq.dq_slave = slave;
sc->sc_dq.dq_driver = &mtdriver;
+
+ /* XXX Set device class. */
+ hd->hp_dev.dv_class = DV_TAPE;
}
/*
diff --git a/sys/arch/hp300/dev/mtreg.h b/sys/arch/hp300/dev/mtreg.h
index 1a14952fff2..84fb799ae81 100644
--- a/sys/arch/hp300/dev/mtreg.h
+++ b/sys/arch/hp300/dev/mtreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: mtreg.h,v 1.2 1997/01/12 15:12:55 downsj Exp $ */
/* $NetBSD: mtreg.h,v 1.1 1995/10/02 00:28:22 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c
index e1e7f7c9c70..edf606177d7 100644
--- a/sys/arch/hp300/dev/nhpib.c
+++ b/sys/arch/hp300/dev/nhpib.c
@@ -1,4 +1,5 @@
-/* $NetBSD: nhpib.c,v 1.11 1996/05/18 23:57:01 thorpej Exp $ */
+/* $OpenBSD: nhpib.c,v 1.5 1997/01/12 15:12:56 downsj Exp $ */
+/* $NetBSD: nhpib.c,v 1.13 1996/10/13 03:14:19 christos Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
diff --git a/sys/arch/hp300/dev/nhpibreg.h b/sys/arch/hp300/dev/nhpibreg.h
index 495546a84e8..e80cdabfaa8 100644
--- a/sys/arch/hp300/dev/nhpibreg.h
+++ b/sys/arch/hp300/dev/nhpibreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: nhpibreg.h,v 1.2 1997/01/12 15:12:56 downsj Exp $ */
/* $NetBSD: nhpibreg.h,v 1.5 1995/01/07 10:30:15 mycroft Exp $ */
/*
diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c
index 9560cd4d93a..8a3a5cddc57 100644
--- a/sys/arch/hp300/dev/ppi.c
+++ b/sys/arch/hp300/dev/ppi.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ppi.c,v 1.8 1996/02/14 02:44:49 thorpej Exp $ */
+/* $OpenBSD: ppi.c,v 1.4 1997/01/12 15:12:57 downsj Exp $ */
+/* $NetBSD: ppi.c,v 1.10 1996/10/13 03:14:20 christos Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
diff --git a/sys/arch/hp300/dev/ppiioctl.h b/sys/arch/hp300/dev/ppiioctl.h
index c5d6ea01f9e..52d0dcf3cff 100644
--- a/sys/arch/hp300/dev/ppiioctl.h
+++ b/sys/arch/hp300/dev/ppiioctl.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: ppiioctl.h,v 1.2 1997/01/12 15:12:58 downsj Exp $ */
/* $NetBSD: ppiioctl.h,v 1.4 1994/10/26 07:24:48 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c
index 8e42519d2f5..e34026ff1b3 100644
--- a/sys/arch/hp300/dev/rd.c
+++ b/sys/arch/hp300/dev/rd.c
@@ -1,4 +1,5 @@
-/* $NetBSD: rd.c,v 1.20.4.1 1996/06/06 16:22:01 thorpej Exp $ */
+/* $OpenBSD: rd.c,v 1.7 1997/01/12 15:12:58 downsj Exp $ */
+/* $NetBSD: rd.c,v 1.26 1997/01/07 09:29:32 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -274,6 +275,9 @@ rdattach(hd)
if (rddebug & RDB_ERROR)
rderrthresh = 0;
#endif
+
+ /* XXX Set device class. */
+ hd->hp_dev.dv_class = DV_DISK;
}
int
@@ -486,7 +490,7 @@ rdopen(dev, flags, mode, p)
{
register int unit = rdunit(dev);
register struct rd_softc *rs = &rd_softc[unit];
- int error, mask;
+ int error, mask, part;
if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
return(ENXIO);
@@ -511,12 +515,27 @@ rdopen(dev, flags, mode, p)
return(error);
}
- mask = 1 << rdpart(dev);
- if (mode == S_IFCHR)
+ part = rdpart(dev);
+ mask = 1 << part;
+
+ /* Check that the partition exists. */
+ if (part != RAW_PART &&
+ (part > rs->sc_dkdev.dk_label->d_npartitions ||
+ rs->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED))
+ return (ENXIO);
+
+ /* Ensure only one open at a time. */
+ switch (mode) {
+ case S_IFCHR:
rs->sc_dkdev.dk_copenmask |= mask;
- else
+ break;
+ case S_IFBLK:
rs->sc_dkdev.dk_bopenmask |= mask;
- rs->sc_dkdev.dk_openmask |= mask;
+ break;
+ }
+ rs->sc_dkdev.dk_openmask =
+ rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask;
+
return(0);
}
@@ -568,6 +587,7 @@ rdstrategy(bp)
register struct partition *pinfo;
register daddr_t bn;
register int sz, s;
+ int offset;
#ifdef DEBUG
if (rddebug & RDB_FOLLOW)
@@ -578,30 +598,41 @@ rdstrategy(bp)
bn = bp->b_blkno;
sz = howmany(bp->b_bcount, DEV_BSIZE);
pinfo = &rs->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)];
- if (bn < 0 || bn + sz > pinfo->p_size) {
- sz = pinfo->p_size - bn;
- if (sz == 0) {
- bp->b_resid = bp->b_bcount;
- goto done;
- }
- if (sz < 0) {
- bp->b_error = EINVAL;
- goto bad;
+
+ /* Don't perform partition translation on RAW_PART. */
+ offset = (rdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset;
+
+ if (rdpart(bp->b_dev) != RAW_PART) {
+ /*
+ * XXX This block of code belongs in
+ * XXX bounds_check_with_label()
+ */
+
+ if (bn < 0 || bn + sz > pinfo->p_size) {
+ sz = pinfo->p_size - bn;
+ if (sz == 0) {
+ bp->b_resid = bp->b_bcount;
+ goto done;
+ }
+ if (sz < 0) {
+ bp->b_error = EINVAL;
+ goto bad;
+ }
+ bp->b_bcount = dbtob(sz);
}
- bp->b_bcount = dbtob(sz);
- }
- /*
- * Check for write to write protected label
- */
- if (bn + pinfo->p_offset <= LABELSECTOR &&
+ /*
+ * Check for write to write protected label
+ */
+ if (bn + offset <= LABELSECTOR &&
#if LABELSECTOR != 0
- bn + pinfo->p_offset + sz > LABELSECTOR &&
+ bn + offset + sz > LABELSECTOR &&
#endif
- !(bp->b_flags & B_READ) && !(rs->sc_flags & RDF_WLABEL)) {
- bp->b_error = EROFS;
- goto bad;
+ !(bp->b_flags & B_READ) && !(rs->sc_flags & RDF_WLABEL)) {
+ bp->b_error = EROFS;
+ goto bad;
+ }
}
- bp->b_cylin = bn + pinfo->p_offset;
+ bp->b_cylin = bn + offset;
s = splbio();
disksort(dp, bp);
if (dp->b_active == 0) {
@@ -1115,75 +1146,108 @@ rdprinterr(str, err, tab)
}
#endif
+static int rddoingadump; /* simple mutex */
+
/*
* Non-interrupt driven, non-dma dump routine.
*/
int
-rddump(dev)
+rddump(dev, blkno, va, size)
dev_t dev;
+ daddr_t blkno;
+ caddr_t va;
+ size_t size;
{
- int part = rdpart(dev);
- int unit = rdunit(dev);
- register struct rd_softc *rs = &rd_softc[unit];
- register struct hp_device *hp = rs->sc_hd;
- register struct partition *pinfo;
- register daddr_t baddr;
- register int maddr, pages, i;
+ int sectorsize; /* size of a disk sector */
+ int nsects; /* number of sectors in partition */
+ int sectoff; /* sector offset of partition */
+ int totwrt; /* total number of sectors left to write */
+ int nwrt; /* current number of sectors to write */
+ int unit, part;
+ struct rd_softc *rs;
+ struct hp_device *hp;
+ struct disklabel *lp;
char stat;
- extern int lowram, dumpsize;
-#ifdef DEBUG
- extern int pmapdebug;
- pmapdebug = 0;
-#endif
- /* is drive ok? */
- if (unit >= NRD || (rs->sc_flags & RDF_ALIVE) == 0)
+ /* Check for recursive dump; if so, punt. */
+ if (rddoingadump)
+ return (EFAULT);
+ rddoingadump = 1;
+
+ /* Decompose unit and partition. */
+ unit = rdunit(dev);
+ part = rdpart(dev);
+
+ /* Make sure dump device is ok. */
+ if (unit >= NRD)
+ return (ENXIO);
+ rs = &rd_softc[unit];
+ if ((rs->sc_flags & RDF_ALIVE) == 0)
return (ENXIO);
- pinfo = &rs->sc_dkdev.dk_label->d_partitions[part];
- /* dump parameters in range? */
- if (dumplo < 0 || dumplo >= pinfo->p_size ||
- pinfo->p_fstype != FS_SWAP)
+ hp = rs->sc_hd;
+
+ /*
+ * Convert to disk sectors. Request must be a multiple of size.
+ */
+ lp = rs->sc_dkdev.dk_label;
+ sectorsize = lp->d_secsize;
+ if ((size % sectorsize) != 0)
+ return (EFAULT);
+ totwrt = size / sectorsize;
+ blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */
+
+ nsects = lp->d_partitions[part].p_size;
+ sectoff = lp->d_partitions[part].p_offset;
+
+ /* Check transfer bounds against partition size. */
+ if ((blkno < 0) || (blkno + totwrt) > nsects)
return (EINVAL);
- pages = dumpsize;
- if (dumplo + ctod(pages) > pinfo->p_size)
- pages = dtoc(pinfo->p_size - dumplo);
- maddr = lowram;
- baddr = dumplo + pinfo->p_offset;
- /* HPIB idle? */
- if (!hpibreq(&rs->sc_dq)) {
- hpibreset(hp->hp_ctlr);
- rdreset(rs, rs->sc_hd);
- printf("[ drive %d reset ] ", unit);
- }
- for (i = 0; i < pages; i++) {
-#define NPGMB (1024*1024/NBPG)
- /* print out how many Mbs we have dumped */
- if (i && (i % NPGMB) == 0)
- printf("%d ", i / NPGMB);
-#undef NPBMG
+
+ /* Offset block number to start of partition. */
+ blkno += sectoff;
+
+ while (totwrt > 0) {
+ nwrt = totwrt; /* XXX */
+#ifndef RD_DUMP_NOT_TRUSTED
+ /*
+ * Fill out and send HPIB command.
+ */
rs->sc_ioc.c_unit = C_SUNIT(rs->sc_punit);
rs->sc_ioc.c_volume = C_SVOL(0);
rs->sc_ioc.c_saddr = C_SADDR;
rs->sc_ioc.c_hiaddr = 0;
- rs->sc_ioc.c_addr = RDBTOS(baddr);
+ rs->sc_ioc.c_addr = RDBTOS(blkno);
rs->sc_ioc.c_nop2 = C_NOP;
rs->sc_ioc.c_slen = C_SLEN;
- rs->sc_ioc.c_len = NBPG;
+ rs->sc_ioc.c_len = nwrt * sectorsize;
rs->sc_ioc.c_cmd = C_WRITE;
hpibsend(hp->hp_ctlr, hp->hp_slave, C_CMD,
&rs->sc_ioc.c_unit, sizeof(rs->sc_ioc)-2);
if (hpibswait(hp->hp_ctlr, hp->hp_slave))
return (EIO);
- pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, maddr,
- VM_PROT_READ, TRUE);
- hpibsend(hp->hp_ctlr, hp->hp_slave, C_EXEC, vmmap, NBPG);
+
+ /*
+ * Send the data.
+ */
+ hpibsend(hp->hp_ctlr, hp->hp_slave, C_EXEC, va,
+ nwrt * sectorsize);
(void) hpibswait(hp->hp_ctlr, hp->hp_slave);
hpibrecv(hp->hp_ctlr, hp->hp_slave, C_QSTAT, &stat, 1);
if (stat)
return (EIO);
- maddr += NBPG;
- baddr += ctod(1);
+#else /* RD_DUMP_NOT_TRUSTED */
+ /* Let's just talk about this first... */
+ printf("%s: dump addr %p, blk %d\n", hp->hp_xname,
+ va, blkno);
+ delay(500 * 1000); /* half a second */
+#endif /* RD_DUMP_NOT_TRUSTED */
+
+ /* update block count */
+ totwrt -= nwrt;
+ blkno += nwrt;
+ va += sectorsize * nwrt;
}
+ rddoingadump = 0;
return (0);
}
#endif
diff --git a/sys/arch/hp300/dev/rd_compat.c b/sys/arch/hp300/dev/rd_compat.c
index 4adea53bcbd..ed607f2dbbc 100644
--- a/sys/arch/hp300/dev/rd_compat.c
+++ b/sys/arch/hp300/dev/rd_compat.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: rd_compat.c,v 1.4 1997/01/12 15:12:59 downsj Exp $ */
/* $NetBSD: rd_compat.c,v 1.5 1996/01/07 22:02:14 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/rdreg.h b/sys/arch/hp300/dev/rdreg.h
index 65cf20a4569..ad1c9ccf478 100644
--- a/sys/arch/hp300/dev/rdreg.h
+++ b/sys/arch/hp300/dev/rdreg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: rdreg.h,v 1.4 1997/01/12 15:13:00 downsj Exp $ */
/* $NetBSD: rdreg.h,v 1.7 1996/02/09 18:00:37 scottr Exp $ */
/*
diff --git a/sys/arch/hp300/dev/rdvar.h b/sys/arch/hp300/dev/rdvar.h
index d7bd8637184..064a544503d 100644
--- a/sys/arch/hp300/dev/rdvar.h
+++ b/sys/arch/hp300/dev/rdvar.h
@@ -1,4 +1,5 @@
-/* $NetBSD: rdvar.h,v 1.4.4.1 1996/06/06 16:22:03 thorpej Exp $ */
+/* $OpenBSD: rdvar.h,v 1.5 1997/01/12 15:13:00 downsj Exp $ */
+/* $NetBSD: rdvar.h,v 1.5 1996/06/06 16:17:42 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
diff --git a/sys/arch/hp300/dev/scsi.c b/sys/arch/hp300/dev/scsi.c
index 942e4a51fe6..ba9d7c0f1a8 100644
--- a/sys/arch/hp300/dev/scsi.c
+++ b/sys/arch/hp300/dev/scsi.c
@@ -1,4 +1,5 @@
-/* $NetBSD: scsi.c,v 1.10 1996/05/18 23:57:03 thorpej Exp $ */
+/* $OpenBSD: scsi.c,v 1.5 1997/01/12 15:13:01 downsj Exp $ */
+/* $NetBSD: scsi.c,v 1.13 1996/12/09 03:16:26 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -68,7 +69,6 @@
#define SCSI_DATA_WAIT 10000 /* wait per data in/out step */
#define SCSI_INIT_WAIT 50000 /* wait per step (both) during init */
-extern void isrlink();
extern void _insque();
extern void _remque();
@@ -262,7 +262,8 @@ scsiattach(hc)
hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq;
/* Establish the interrupt handler. */
- isrlink(scsiintr, hs, hc->hp_ipl, ISRPRI_BIO);
+ (void) isrlink(scsiintr, hs, hc->hp_ipl, ISRPRI_BIO);
+ dmacomputeipl();
/* Reset the controller. */
scsireset(hc->hp_unit);
diff --git a/sys/arch/hp300/dev/scsireg.h b/sys/arch/hp300/dev/scsireg.h
index 571861ebcab..2ddbc961f4f 100644
--- a/sys/arch/hp300/dev/scsireg.h
+++ b/sys/arch/hp300/dev/scsireg.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: scsireg.h,v 1.2 1997/01/12 15:13:02 downsj Exp $ */
/* $NetBSD: scsireg.h,v 1.4 1994/10/26 07:24:59 cgd Exp $ */
/*
diff --git a/sys/arch/hp300/dev/scsivar.h b/sys/arch/hp300/dev/scsivar.h
index 6f7db737286..a9226295744 100644
--- a/sys/arch/hp300/dev/scsivar.h
+++ b/sys/arch/hp300/dev/scsivar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: scsivar.h,v 1.3 1997/01/12 15:13:02 downsj Exp $ */
/* $NetBSD: scsivar.h,v 1.5 1995/12/02 18:22:14 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c
index 75121b1b6dc..713833396f3 100644
--- a/sys/arch/hp300/dev/sd.c
+++ b/sys/arch/hp300/dev/sd.c
@@ -1,4 +1,5 @@
-/* $NetBSD: sd.c,v 1.22.4.1 1996/06/06 16:22:04 thorpej Exp $ */
+/* $OpenBSD: sd.c,v 1.6 1997/01/12 15:13:03 downsj Exp $ */
+/* $NetBSD: sd.c,v 1.28 1997/01/07 09:29:30 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -366,6 +367,9 @@ sdattach(hd)
disk_attach(&sc->sc_dkdev);
sc->sc_flags |= SDF_ALIVE;
+
+ /* XXX Set device class. */
+ hd->hp_dev.dv_class = DV_DISK;
}
void
@@ -579,7 +583,7 @@ sdopen(dev, flags, mode, p)
{
register int unit = sdunit(dev);
register struct sd_softc *sc = &sd_softc[unit];
- int error, mask;
+ int error, mask, part;
if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0)
return(ENXIO);
@@ -604,12 +608,27 @@ sdopen(dev, flags, mode, p)
return(error);
}
- mask = 1 << sdpart(dev);
- if (mode == S_IFCHR)
+ part = sdpart(dev);
+ mask = 1 << part;
+
+ /* Check that the partition exists. */
+ if (part != RAW_PART &&
+ (part >= sc->sc_dkdev.dk_label->d_npartitions ||
+ sc->sc_dkdev.dk_label->d_partitions[part].p_fstype == FS_UNUSED))
+ return (ENXIO);
+
+ /* Ensure only one open at a time. */
+ switch (mode) {
+ case S_IFCHR:
sc->sc_dkdev.dk_copenmask |= mask;
- else
+ break;
+ case S_IFBLK:
sc->sc_dkdev.dk_bopenmask |= mask;
- sc->sc_dkdev.dk_openmask |= mask;
+ break;
+ }
+ sc->sc_dkdev.dk_openmask =
+ sc->sc_dkdev.dk_copenmask | sc->sc_dkdev.dk_bopenmask;
+
return(0);
}
@@ -760,6 +779,7 @@ sdstrategy(bp)
register struct partition *pinfo;
register daddr_t bn;
register int sz, s;
+ int offset;
if (sc->sc_format_pid >= 0) {
if (sc->sc_format_pid != curproc->p_pid) { /* XXX */
@@ -775,28 +795,40 @@ sdstrategy(bp)
bn = bp->b_blkno;
sz = howmany(bp->b_bcount, DEV_BSIZE);
pinfo = &sc->sc_dkdev.dk_label->d_partitions[sdpart(bp->b_dev)];
- if (bn < 0 || bn + sz > pinfo->p_size) {
- sz = pinfo->p_size - bn;
- if (sz == 0) {
- bp->b_resid = bp->b_bcount;
- goto done;
- }
- if (sz < 0) {
- bp->b_error = EINVAL;
- goto bad;
+
+ /* Don't perform partition translation on RAW_PART. */
+ offset = (sdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset;
+
+ if (sdpart(bp->b_dev) != RAW_PART) {
+ /*
+ * XXX This block of code belongs in
+ * XXX bounds_check_with_label()
+ */
+
+ if (bn < 0 || bn + sz > pinfo->p_size) {
+ sz = pinfo->p_size - bn;
+ if (sz == 0) {
+ bp->b_resid = bp->b_bcount;
+ goto done;
+ }
+ if (sz < 0) {
+ bp->b_error = EINVAL;
+ goto bad;
+ }
+ bp->b_bcount = dbtob(sz);
}
- bp->b_bcount = dbtob(sz);
- }
- /*
- * Check for write to write protected label
- */
- if (bn + pinfo->p_offset <= LABELSECTOR &&
+ /*
+ * Check for write to write protected label
+ */
+ if (bn + offset <= LABELSECTOR &&
#if LABELSECTOR != 0
- bn + pinfo->p_offset + sz > LABELSECTOR &&
+ bn + offset + sz > LABELSECTOR &&
#endif
- !(bp->b_flags & B_READ) && !(sc->sc_flags & SDF_WLABEL)) {
- bp->b_error = EROFS;
- goto bad;
+ !(bp->b_flags & B_READ) &&
+ !(sc->sc_flags & SDF_WLABEL)) {
+ bp->b_error = EROFS;
+ goto bad;
+ }
}
/*
* Non-aligned or partial-block transfers handled specially.
@@ -806,7 +838,7 @@ sdstrategy(bp)
sdlblkstrat(bp, sc->sc_blksize);
goto done;
}
- bp->b_cylin = (bn + pinfo->p_offset) >> sc->sc_bshift;
+ bp->b_cylin = (bn + offset) >> sc->sc_bshift;
}
s = splbio();
disksort(dp, bp);
@@ -1216,60 +1248,93 @@ sdsize(dev)
return (psize);
}
+static int sddoingadump; /* simple mutex */
+
/*
* Non-interrupt driven, non-dma dump routine.
*/
int
-sddump(dev)
+sddump(dev, blkno, va, size)
dev_t dev;
+ daddr_t blkno;
+ caddr_t va;
+ size_t size;
{
- int part = sdpart(dev);
- int unit = sdunit(dev);
- register struct sd_softc *sc = &sd_softc[unit];
- register struct hp_device *hp = sc->sc_hd;
- register struct partition *pinfo;
- register daddr_t baddr;
- register int maddr;
- register int pages, i;
- int stat;
- extern int lowram, dumpsize;
-
- /* is drive ok? */
- if (unit >= NSD || (sc->sc_flags & SDF_ALIVE) == 0)
+ int sectorsize; /* size of a disk sector */
+ int nsects; /* number of sectors in partition */
+ int sectoff; /* sector offset of partition */
+ int totwrt; /* total number of sectors left to write */
+ int nwrt; /* current number of sectors to write */
+ int unit, part;
+ struct sd_softc *sc;
+ struct hp_device *hp;
+ struct disklabel *lp;
+ daddr_t baddr;
+ char stat;
+
+ /* Check for recursive dump; if so, punt. */
+ if (sddoingadump)
+ return (EFAULT);
+ sddoingadump = 1;
+
+ /* Decompose unit and partition. */
+ unit = sdunit(dev);
+ part = sdpart(dev);
+
+ /* Make sure device is ok. */
+ if (unit >= NSD)
+ return (ENXIO);
+ sc = &sd_softc[unit];
+ if ((sc->sc_flags & SDF_ALIVE) == 0)
return (ENXIO);
- pinfo = &sc->sc_dkdev.dk_label->d_partitions[part];
- /* dump parameters in range? */
- if (dumplo < 0 || dumplo >= pinfo->p_size ||
- pinfo->p_fstype != FS_SWAP)
+ hp = sc->sc_hd;
+
+ /*
+ * Convert to disk sectors. Request must be a multiple of size.
+ */
+ lp = sc->sc_dkdev.dk_label;
+ sectorsize = lp->d_secsize;
+ if ((size % sectorsize) != 0)
+ return (EFAULT);
+ totwrt = size / sectorsize;
+ blkno = dbtob(blkno) / sectorsize; /* blkno in DEV_BSIZE units */
+
+ nsects = lp->d_partitions[part].p_size;
+ sectoff = lp->d_partitions[part].p_offset;
+
+ /* Check transfer bounds against partition size. */
+ if ((blkno < 0) || (blkno + totwrt) > nsects)
return (EINVAL);
- pages = dumpsize;
- if (dumplo + ctod(pages) > pinfo->p_size)
- pages = dtoc(pinfo->p_size - dumplo);
- maddr = lowram;
- baddr = dumplo + pinfo->p_offset;
- /* scsi bus idle? */
- if (!scsireq(&sc->sc_dq)) {
- scsireset(hp->hp_ctlr);
- sdreset(sc, sc->sc_hd);
- printf("[ drive %d reset ] ", unit);
- }
- for (i = 0; i < pages; i++) {
-#define NPGMB (1024*1024/NBPG)
- /* print out how many Mbs we have dumped */
- if (i && (i % NPGMB) == 0)
- printf("%d ", i / NPGMB);
-#undef NPBMG
- pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, maddr,
- VM_PROT_READ, TRUE);
+
+ /* Offset block number to start of partition. */
+ blkno += sectoff;
+
+ while (totwrt > 0) {
+ nwrt = totwrt; /* XXX */
+#ifndef SD_DUMP_NOT_TRUSTED
+ /*
+ * Send the data. Note the `0' argument for bshift;
+ * we've done the necessary conversion above.
+ */
stat = scsi_tt_write(hp->hp_ctlr, hp->hp_slave, sc->sc_punit,
- vmmap, NBPG, baddr, sc->sc_bshift);
+ va, nwrt * sectorsize, blkno, 0);
if (stat) {
- printf("sddump: scsi write error 0x%x\n", stat);
+ printf("\nsddump: scsi write error 0x%x\n", stat);
return (EIO);
}
- maddr += NBPG;
- baddr += ctod(1);
+#else /* SD_DUMP_NOT_TRUSTED */
+ /* Lets just talk about it first. */
+ printf("%s: dump addr %p, blk %d\n", hp->hp_xname,
+ va, blkno);
+ delay(500 * 1000); /* half a second */
+#endif /* SD_DUMP_NOT_TRUSTED */
+
+ /* update block count */
+ totwrt -= nwrt;
+ blkno += nwrt;
+ va += sectorsize * nwrt;
}
+ sddoingadump = 0;
return (0);
}
#endif
diff --git a/sys/arch/hp300/dev/sd_compat.c b/sys/arch/hp300/dev/sd_compat.c
index 60e25a63b81..a05e9e5f663 100644
--- a/sys/arch/hp300/dev/sd_compat.c
+++ b/sys/arch/hp300/dev/sd_compat.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: sd_compat.c,v 1.3 1997/01/12 15:13:04 downsj Exp $ */
/* $NetBSD: sd_compat.c,v 1.4 1996/01/07 22:02:20 thorpej Exp $ */
/*
diff --git a/sys/arch/hp300/dev/sdvar.h b/sys/arch/hp300/dev/sdvar.h
index fbdf0025bb7..a91895cf127 100644
--- a/sys/arch/hp300/dev/sdvar.h
+++ b/sys/arch/hp300/dev/sdvar.h
@@ -1,4 +1,5 @@
-/* $NetBSD: sdvar.h,v 1.4.4.1 1996/06/06 16:22:06 thorpej Exp $ */
+/* $OpenBSD: sdvar.h,v 1.5 1997/01/12 15:13:04 downsj Exp $ */
+/* $NetBSD: sdvar.h,v 1.5 1996/06/06 16:17:45 thorpej Exp $ */
/*
* Copyright (c) 1990, 1993
diff --git a/sys/arch/hp300/dev/st.c b/sys/arch/hp300/dev/st.c
index f73e4c886dc..2a9f5d19ec2 100644
--- a/sys/arch/hp300/dev/st.c
+++ b/sys/arch/hp300/dev/st.c
@@ -1,4 +1,5 @@
-/* $NetBSD: st.c,v 1.14.4.1 1996/06/10 06:45:33 thorpej Exp $ */
+/* $OpenBSD: st.c,v 1.5 1997/01/12 15:13:05 downsj Exp $ */
+/* $NetBSD: st.c,v 1.18 1996/10/14 07:14:21 thorpej Exp $ */
/*
* Copyright (c) 1990 University of Utah.
@@ -257,6 +258,9 @@ stattach(hd)
sc->sc_dq.dq_driver = &stdriver;
sc->sc_blkno = 0;
sc->sc_flags = STF_ALIVE;
+
+ /* XXX Set device class. */
+ hd->hp_dev.dv_class = DV_TAPE;
}
int
diff --git a/sys/arch/hp300/dev/stvar.h b/sys/arch/hp300/dev/stvar.h
index 3f432610dd7..5c32757078d 100644
--- a/sys/arch/hp300/dev/stvar.h
+++ b/sys/arch/hp300/dev/stvar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: stvar.h,v 1.2 1997/01/12 15:13:06 downsj Exp $ */
/* $NetBSD: stvar.h,v 1.4 1994/10/26 07:25:14 cgd Exp $ */
/*