summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/hp300/dev')
-rw-r--r--sys/arch/hp300/dev/apci.c998
-rw-r--r--sys/arch/hp300/dev/apcireg.h7
-rw-r--r--sys/arch/hp300/dev/dca.c6
-rw-r--r--sys/arch/hp300/dev/dcm.c8
-rw-r--r--sys/arch/hp300/dev/dio.c50
-rw-r--r--sys/arch/hp300/dev/diovar.h8
-rw-r--r--sys/arch/hp300/dev/dma.c76
-rw-r--r--sys/arch/hp300/dev/dmareg.h11
-rw-r--r--sys/arch/hp300/dev/fhpib.c7
-rw-r--r--sys/arch/hp300/dev/frodo.c329
-rw-r--r--sys/arch/hp300/dev/frodoreg.h123
-rw-r--r--sys/arch/hp300/dev/frodovar.h49
-rw-r--r--sys/arch/hp300/dev/hd.c20
-rw-r--r--sys/arch/hp300/dev/hpib.c5
-rw-r--r--sys/arch/hp300/dev/if_le.c23
-rw-r--r--sys/arch/hp300/dev/nhpib.c7
-rw-r--r--sys/arch/hp300/dev/scsi.c8
-rw-r--r--sys/arch/hp300/dev/sd.c19
18 files changed, 1655 insertions, 99 deletions
diff --git a/sys/arch/hp300/dev/apci.c b/sys/arch/hp300/dev/apci.c
new file mode 100644
index 00000000000..d1c7da73a20
--- /dev/null
+++ b/sys/arch/hp300/dev/apci.c
@@ -0,0 +1,998 @@
+/* $OpenBSD: apci.c,v 1.1 1997/07/06 08:01:44 downsj Exp $ */
+/* $NetBSD: apci.c,v 1.1 1997/05/12 08:12:36 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1997 Michael Smith. All rights reserved.
+ * Copyright (c) 1995, 1996, 1997 Jason R. Thorpe. All rights reserved.
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)dca.c 8.2 (Berkeley) 1/12/94
+ */
+
+/*
+ * Device driver for the APCI 8250-like UARTs found on the Apollo
+ * Utility Chip on HP 9000/400-series workstations.
+ *
+ * There are 4 APCI UARTs on the Frodo ASIC. The first one
+ * is used to communicate with the Domain keyboard. The second
+ * one is the serial console port when the firmware is in Domain/OS
+ * mode, and is mapped to select code 9 by the HP-UX firmware (except
+ * on 425e models).
+ *
+ * We don't bother attaching a tty to the first UART; it lacks modem/flow
+ * control, and is directly connected to the keyboard connector anyhow.
+ */
+
+/*
+ * XXX This driver is very similar to the dca driver, and much
+ * XXX more code could be shared. (Currently, no code is shared.)
+ * XXX FIXME!
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/tty.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#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 <machine/hp300spu.h>
+
+#include <dev/cons.h>
+
+#include <hp300/dev/dioreg.h> /* to check for dca at 9 */
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+
+#include <hp300/dev/frodoreg.h>
+#include <hp300/dev/frodovar.h>
+#include <hp300/dev/apcireg.h>
+#include <hp300/dev/dcareg.h> /* register bit definitions */
+
+struct apci_softc {
+ struct device sc_dev; /* generic device glue */
+ struct apciregs *sc_apci; /* device registers */
+ struct tty *sc_tty; /* tty glue */
+ int sc_ferr,
+ sc_perr,
+ sc_oflow,
+ sc_toterr; /* stats */
+ int sc_flags;
+};
+
+/* sc_flags */
+#define APCI_HASFIFO 0x01 /* unit has a fifo */
+#define APCI_ISCONSOLE 0x02 /* unit is console */
+#define APCI_SOFTCAR 0x04 /* soft carrier */
+
+int apcimatch __P((struct device *, void *, void *));
+void apciattach __P((struct device *, struct device *, void *));
+
+struct cfattach apci_ca = {
+ sizeof(struct apci_softc), apcimatch, apciattach
+};
+
+struct cfdriver apci_cd = {
+ NULL, "apci", DV_TTY
+};
+
+int apciintr __P((void *));
+void apcieint __P((struct apci_softc *, int));
+void apcimint __P((struct apci_softc *, u_char));
+int apciparam __P((struct tty *, struct termios *));
+void apcistart __P((struct tty *));
+int apcimctl __P((struct apci_softc *, int, int));
+void apciinit __P((struct apciregs *, int));
+void apcitimeout __P((void *));
+
+int apcicheckdca __P((void));
+
+cdev_decl(apci);
+
+#define APCIUNIT(x) minor(x)
+
+int apcidefaultrate = TTYDEF_SPEED;
+
+struct speedtab apcispeedtab[] = {
+ { 0, 0 },
+ { 50, APCIBRD(50) },
+ { 75, APCIBRD(75) },
+ { 110, APCIBRD(110) },
+ { 134, APCIBRD(134) },
+ { 150, APCIBRD(150) },
+ { 200, APCIBRD(200) },
+ { 300, APCIBRD(300) },
+ { 600, APCIBRD(600) },
+ { 1200, APCIBRD(1200) },
+ { 1800, APCIBRD(1800) },
+ { 2400, APCIBRD(2400) },
+ { 4800, APCIBRD(4800) },
+ { 9600, APCIBRD(9600) },
+ { 19200, APCIBRD(19200) },
+ { 38400, APCIBRD(38400) },
+ { -1, -1 },
+};
+
+/*
+ * Console support.
+ */
+struct apciregs *apci_cn = NULL; /* console hardware */
+int apciconsinit; /* has been initialized */
+int apcimajor; /* our major number */
+
+void apcicnprobe __P((struct consdev *));
+void apcicninit __P((struct consdev *));
+int apcicngetc __P((dev_t));
+void apcicnputc __P((dev_t, int));
+
+
+int
+apcimatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct frodo_attach_args *fa = aux;
+
+ /* Looking for an apci? */
+ if (strcmp(fa->fa_name, apci_cd.cd_name) != 0)
+ return (0);
+
+ /* Are we checking a valid APCI offset? */
+ switch (fa->fa_offset) {
+ case FRODO_APCI_OFFSET(1):
+ case FRODO_APCI_OFFSET(2):
+ case FRODO_APCI_OFFSET(3):
+ break;
+ default:
+ return (0);
+ }
+
+ /* Make sure there's not a DCA in the way. */
+ if (fa->fa_offset == FRODO_APCI_OFFSET(1) && apcicheckdca())
+ return (0);
+
+ return (1);
+}
+
+void
+apciattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct apci_softc *sc = (struct apci_softc *)self;
+ struct apciregs *apci;
+ struct frodo_attach_args *fa = aux;
+
+ sc->sc_apci = apci =
+ (struct apciregs *)IIOV(FRODO_BASE + fa->fa_offset);
+ sc->sc_flags = 0;
+
+ /* Are we the console? */
+ if (apci == apci_cn) {
+ sc->sc_flags |= APCI_ISCONSOLE;
+ delay(100000);
+
+ /*
+ * 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(apcimajor, self->dv_unit);
+ }
+
+ /* Look for a FIFO. */
+ apci->ap_fifo = FIFO_ENABLE|FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_14;
+ delay(100);
+ if ((apci->ap_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK)
+ sc->sc_flags |= APCI_HASFIFO;
+
+ /* Establish out interrupt handler. */
+ frodo_intr_establish(parent, apciintr, sc, fa->fa_line,
+ (sc->sc_flags & APCI_HASFIFO) ? IPL_TTY : IPL_TTYNOBUF);
+
+ /* Set soft carrier if requested by operator. */
+ if (self->dv_cfdata->cf_flags)
+ sc->sc_flags |= APCI_SOFTCAR;
+
+ /*
+ * Need to reset baud rate, etc. of next print, so reset apciconsinit.
+ * Also make sure console is always "hardwired".
+ */
+ if (sc->sc_flags & APCI_ISCONSOLE) {
+ apciconsinit = 0;
+ sc->sc_flags |= APCI_SOFTCAR;
+ printf(": console, ");
+ } else
+ printf(": ");
+
+ if (sc->sc_flags & APCI_HASFIFO)
+ printf("working fifo\n");
+ else
+ printf("no fifo\n");
+}
+
+/* ARGSUSED */
+int
+apciopen(dev, flag, mode, p)
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
+{
+ int unit = APCIUNIT(dev);
+ struct apci_softc *sc;
+ struct tty *tp;
+ struct apciregs *apci;
+ u_char code;
+ int s, error = 0;
+
+ if (unit >= apci_cd.cd_ndevs ||
+ (sc = apci_cd.cd_devs[unit]) == NULL)
+ return (ENXIO);
+
+ apci = sc->sc_apci;
+
+ if (sc->sc_tty == NULL) {
+ tp = sc->sc_tty = ttymalloc();
+ tty_attach(tp);
+ } else
+ tp = sc->sc_tty;
+ tp->t_oproc = apcistart;
+ tp->t_param = apciparam;
+ tp->t_dev = dev;
+
+ if ((tp->t_state & TS_ISOPEN) == 0) {
+ /*
+ * Sanity clause: reset the chip on first open.
+ * The chip might be left in an inconsistent state
+ * if it is read inadventently.
+ */
+ apciinit(apci, apcidefaultrate);
+
+ tp->t_state |= TS_WOPEN;
+ ttychars(tp);
+ tp->t_iflag = TTYDEF_IFLAG;
+ tp->t_oflag = TTYDEF_OFLAG;
+ tp->t_cflag = TTYDEF_CFLAG;
+ tp->t_lflag = TTYDEF_LFLAG;
+ tp->t_ispeed = tp->t_ospeed = apcidefaultrate;
+
+ s = spltty();
+
+ apciparam(tp, &tp->t_termios);
+ ttsetwater(tp);
+
+ /* Set the FIFO threshold based on the receive speed. */
+ if (sc->sc_flags & APCI_HASFIFO)
+ apci->ap_fifo = FIFO_ENABLE | FIFO_RCV_RST |
+ FIFO_XMT_RST |
+ (tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 :
+ FIFO_TRIGGER_14);
+
+ /* Flush any pending I/O. */
+ while ((apci->ap_iir & IIR_IMASK) == IIR_RXRDY)
+ code = apci->ap_data;
+ } else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
+ return (EBUSY);
+ else
+ s = spltty();
+
+ /* Set the modem control state. */
+ (void) apcimctl(sc, MCR_DTR | MCR_RTS, DMSET);
+
+ /* Set soft-carrier if so configured. */
+ if ((sc->sc_flags & APCI_SOFTCAR) ||
+ (apcimctl(sc, 0, DMGET) & MSR_DCD))
+ tp->t_state |= TS_CARR_ON;
+
+ /* Wait for carrier if necessary. */
+ if ((flag & O_NONBLOCK) == 0) {
+ while ((tp->t_cflag & CLOCAL) == 0 &&
+ (tp->t_state & TS_CARR_ON) == 0) {
+ tp->t_state |= TS_WOPEN;
+ error = ttysleep(tp, (caddr_t)&tp->t_rawq,
+ TTIPRI | PCATCH, ttopen, 0);
+ if (error) {
+ splx(s);
+ return (error);
+ }
+ }
+ }
+
+ splx(s);
+
+ if (error == 0)
+ error = (*linesw[tp->t_line].l_open)(dev, tp);
+
+ if (error == 0) {
+ /* clear errors, start timeout */
+ sc->sc_ferr = sc->sc_perr = sc->sc_oflow = sc->sc_toterr = 0;
+ timeout(apcitimeout, sc, hz);
+ }
+
+ return (error);
+}
+
+/* ARGSUSED */
+int
+apciclose(dev, flag, mode, p)
+ dev_t dev;
+ int flag, mode;
+ struct proc *p;
+{
+ struct apci_softc *sc;
+ struct tty *tp;
+ struct apciregs *apci;
+ int unit = APCIUNIT(dev);
+ int s;
+
+ sc = apci_cd.cd_devs[unit];
+ apci = sc->sc_apci;
+ tp = sc->sc_tty;
+
+ (*linesw[tp->t_line].l_close)(tp, flag);
+
+ s = spltty();
+
+ apci->ap_cfcr &= ~CFCR_SBREAK;
+ apci->ap_ier = 0;
+ if (tp->t_cflag & HUPCL && (sc->sc_flags & APCI_SOFTCAR) == 0) {
+ /* XXX perhaps only clear DTR */
+ (void) apcimctl(sc, 0, DMSET);
+ }
+ tp->t_state &= ~(TS_BUSY | TS_FLUSH);
+ splx(s);
+ ttyclose(tp);
+#if 0
+ tty_detach(tp);
+ ttyfree(tp);
+ sc->sc_tty = NULL;
+#endif
+ return (0);
+}
+
+int
+apciread(dev, uio, flag)
+ dev_t dev;
+ struct uio *uio;
+ int flag;
+{
+ struct apci_softc *sc = apci_cd.cd_devs[APCIUNIT(dev)];
+ struct tty *tp = sc->sc_tty;
+
+ return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
+}
+
+int
+apciwrite(dev, uio, flag)
+ dev_t dev;
+ struct uio *uio;
+ int flag;
+{
+ struct apci_softc *sc = apci_cd.cd_devs[APCIUNIT(dev)];
+ struct tty *tp = sc->sc_tty;
+
+ return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
+}
+
+struct tty *
+apcitty(dev)
+ dev_t dev;
+{
+ struct apci_softc *sc = apci_cd.cd_devs[APCIUNIT(dev)];
+
+ return (sc->sc_tty);
+}
+
+int
+apciintr(arg)
+ void *arg;
+{
+ struct apci_softc *sc = arg;
+ struct apciregs *apci = sc->sc_apci;
+ struct tty *tp = sc->sc_tty;
+ u_char iir, lsr, c;
+ int iflowdone = 0, claimed = 0;
+
+#define RCVBYTE() \
+ c = apci->ap_data; \
+ if ((tp->t_state & TS_ISOPEN) != 0) \
+ (*linesw[tp->t_line].l_rint)(c, tp)
+
+ for (;;) {
+ iir = apci->ap_iir; /* get UART status */
+
+ switch (iir & IIR_IMASK) {
+ case IIR_RLS:
+ apcieint(sc, apci->ap_lsr);
+ break;
+
+ case IIR_RXRDY:
+ case IIR_RXTOUT:
+ RCVBYTE();
+ if (sc->sc_flags & APCI_HASFIFO) {
+ while ((lsr = apci->ap_lsr) & LSR_RCV_MASK) {
+ if (lsr == LSR_RXRDY) {
+ RCVBYTE();
+ } else
+ apcieint(sc, lsr);
+ }
+ }
+ if (iflowdone == 0 && (tp->t_cflag & CRTS_IFLOW) &&
+ tp->t_rawq.c_cc > (TTYHOG / 2)) {
+ apci->ap_mcr &= ~MCR_RTS;
+ iflowdone = 1;
+ }
+ break;
+
+ case IIR_TXRDY:
+ tp->t_state &=~ (TS_BUSY|TS_FLUSH);
+ if (tp->t_line)
+ (*linesw[tp->t_line].l_start)(tp);
+ else
+ apcistart(tp);
+ break;
+
+ default:
+ if (iir & IIR_NOPEND)
+ return (claimed);
+ log(LOG_WARNING, "%s: weird interrupt: 0x%x\n",
+ sc->sc_dev.dv_xname, iir);
+ /* fall through */
+
+ case IIR_MLSC:
+ apcimint(sc, apci->ap_msr);
+ break;
+ }
+
+ claimed = 1;
+ }
+}
+
+void
+apcieint(sc, stat)
+ struct apci_softc *sc;
+ int stat;
+{
+ struct tty *tp = sc->sc_tty;
+ struct apciregs *apci = sc->sc_apci;
+ int c;
+
+ c = apci->ap_data;
+ if ((tp->t_state & TS_ISOPEN) == 0)
+ return;
+
+ if (stat & (LSR_BI | LSR_FE)) {
+ c |= TTY_FE;
+ sc->sc_ferr++;
+ } else if (stat & LSR_PE) {
+ c |= TTY_PE;
+ sc->sc_perr++;
+ } else if (stat & LSR_OE)
+ sc->sc_oflow++;
+ (*linesw[tp->t_line].l_rint)(c, tp);
+}
+
+void
+apcimint(sc, stat)
+ struct apci_softc *sc;
+ u_char stat;
+{
+ struct tty *tp = sc->sc_tty;
+ struct apciregs *apci = sc->sc_apci;
+
+ if ((stat & MSR_DDCD) &&
+ (sc->sc_flags & APCI_SOFTCAR) == 0) {
+ if (stat & MSR_DCD)
+ (void)(*linesw[tp->t_line].l_modem)(tp, 1);
+ else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0)
+ apci->ap_mcr &= ~(MCR_DTR | MCR_RTS);
+ }
+
+ /*
+ * CTS change.
+ * If doing HW output flow control, start/stop output as appropriate.
+ */
+ if ((stat & MSR_DCTS) &&
+ (tp->t_state & TS_ISOPEN) && (tp->t_cflag & CCTS_OFLOW)) {
+ if (stat & MSR_CTS) {
+ tp->t_state &=~ TS_TTSTOP;
+ apcistart(tp);
+ } else
+ tp->t_state |= TS_TTSTOP;
+ }
+}
+
+int
+apciioctl(dev, cmd, data, flag, p)
+ dev_t dev;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+ struct apci_softc *sc = apci_cd.cd_devs[APCIUNIT(dev)];
+ struct tty *tp = sc->sc_tty;
+ struct apciregs *apci = sc->sc_apci;
+ int error;
+
+ error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
+ if (error >= 0)
+ return (error);
+ error = ttioctl(tp, cmd, data, flag, p);
+ if (error >= 0)
+ return (error);
+
+ switch (cmd) {
+ case TIOCSBRK:
+ apci->ap_cfcr |= CFCR_SBREAK;
+ break;
+
+ case TIOCCBRK:
+ apci->ap_cfcr &= ~CFCR_SBREAK;
+ break;
+
+ case TIOCSDTR:
+ (void) apcimctl(sc, MCR_DTR | MCR_RTS, DMBIS);
+ break;
+
+ case TIOCCDTR:
+ (void) apcimctl(sc, MCR_DTR | MCR_RTS, DMBIC);
+ break;
+
+ case TIOCMSET:
+ (void) apcimctl(sc, *(int *)data, DMSET);
+ break;
+
+ case TIOCMBIS:
+ (void) apcimctl(sc, *(int *)data, DMBIS);
+ break;
+
+ case TIOCMBIC:
+ (void) apcimctl(sc, *(int *)data, DMBIC);
+ break;
+
+ case TIOCMGET:
+ *(int *)data = apcimctl(sc, 0, DMGET);
+ break;
+
+ case TIOCGFLAGS: {
+ int bits = 0;
+
+ if (sc->sc_flags & APCI_SOFTCAR)
+ bits |= TIOCFLAG_SOFTCAR;
+
+ if (tp->t_cflag & CLOCAL)
+ bits |= TIOCFLAG_CLOCAL;
+
+ *(int *)data = bits;
+ break;
+ }
+
+ case TIOCSFLAGS: {
+ int userbits;
+
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
+ return (EPERM);
+
+ userbits = *(int *)data;
+
+ if ((userbits & TIOCFLAG_SOFTCAR) ||
+ (sc->sc_flags & APCI_ISCONSOLE))
+ sc->sc_flags |= APCI_SOFTCAR;
+
+ if (userbits & TIOCFLAG_CLOCAL)
+ tp->t_cflag |= CLOCAL;
+
+ break;
+ }
+
+ default:
+ return (ENOTTY);
+ }
+ return (0);
+}
+
+int
+apciparam(tp, t)
+ struct tty *tp;
+ struct termios *t;
+{
+ struct apci_softc *sc = apci_cd.cd_devs[APCIUNIT(tp->t_dev)];
+ struct apciregs *apci = sc->sc_apci;
+ int cfcr, cflag = t->c_cflag;
+ int ospeed = ttspeedtab(t->c_ospeed, apcispeedtab);
+ int s;
+
+ /* check requested parameters */
+ if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
+ return (EINVAL);
+
+ switch (cflag & CSIZE) {
+ case CS5:
+ cfcr = CFCR_5BITS;
+ break;
+
+ case CS6:
+ cfcr = CFCR_6BITS;
+ break;
+
+ case CS7:
+ cfcr = CFCR_7BITS;
+ break;
+
+ case CS8:
+ default: /* XXX gcc whines about cfcr being uninitialized... */
+ cfcr = CFCR_8BITS;
+ break;
+ }
+ if (cflag & PARENB) {
+ cfcr |= CFCR_PENAB;
+ if ((cflag & PARODD) == 0)
+ cfcr |= CFCR_PEVEN;
+ }
+ if (cflag & CSTOPB)
+ cfcr |= CFCR_STOPB;
+
+ s = spltty();
+
+ if (ospeed == 0)
+ (void) apcimctl(sc, 0, DMSET); /* hang up line */
+
+ /*
+ * Set the FIFO threshold based on the recieve speed, if we
+ * are changing it.
+ */
+ if (tp->t_ispeed != t->c_ispeed) {
+ if (sc->sc_flags & APCI_HASFIFO)
+ apci->ap_fifo = FIFO_ENABLE |
+ (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 :
+ FIFO_TRIGGER_14);
+ }
+
+ if (ospeed != 0) {
+ apci->ap_cfcr |= CFCR_DLAB;
+ apci->ap_data = ospeed & 0xff;
+ apci->ap_ier = (ospeed >> 8) & 0xff;
+ apci->ap_cfcr = cfcr;
+ } else
+ apci->ap_cfcr;
+
+ /* and copy to tty */
+ tp->t_ispeed = t->c_ispeed;
+ tp->t_ospeed = t->c_ospeed;
+ tp->t_cflag = cflag;
+
+ apci->ap_ier = IER_ERXRDY | IER_ETXRDY | IER_ERLS | IER_EMSC;
+ apci->ap_mcr |= MCR_IEN;
+
+ splx(s);
+ return (0);
+}
+
+void
+apcistart(tp)
+ struct tty *tp;
+{
+ struct apci_softc *sc = apci_cd.cd_devs[APCIUNIT(tp->t_dev)];
+ struct apciregs *apci = sc->sc_apci;
+ int s, c;
+
+ s = spltty();
+
+ if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
+ goto out;
+ if (tp->t_outq.c_cc <= tp->t_lowat) {
+ if (tp->t_state & TS_ASLEEP) {
+ tp->t_state &= ~TS_ASLEEP;
+ wakeup((caddr_t)&tp->t_outq);
+ }
+ if (tp->t_outq.c_cc == 0)
+ goto out;
+ selwakeup(&tp->t_wsel);
+ }
+ if (apci->ap_lsr & LSR_TXRDY) {
+ tp->t_state |= TS_BUSY;
+ if (sc->sc_flags & APCI_HASFIFO) {
+ for (c = 0; c < 16 && tp->t_outq.c_cc; ++c)
+ apci->ap_data = getc(&tp->t_outq);
+ } else
+ apci->ap_data = getc(&tp->t_outq);
+ }
+
+ out:
+ splx(s);
+}
+
+/*
+ * Stop output on a line.
+ */
+/* ARGSUSED */
+int
+apcistop(tp, flag)
+ struct tty *tp;
+ int flag;
+{
+ int s;
+
+ s = spltty();
+ if (tp->t_state & TS_BUSY)
+ if ((tp->t_state & TS_TTSTOP) == 0)
+ tp->t_state |= TS_FLUSH;
+ splx(s);
+ return (0);
+}
+
+int
+apcimctl(sc, bits, how)
+ struct apci_softc *sc;
+ int bits, how;
+{
+ struct apciregs *apci = sc->sc_apci;
+ int s;
+
+ /*
+ * Always make sure MCR_IEN is set (unless setting to 0)
+ */
+ if (how == DMBIS || (how == DMSET && bits))
+ bits |= MCR_IEN;
+ else if (how == DMBIC)
+ bits &= ~MCR_IEN;
+
+ s = spltty();
+
+ switch (how) {
+ case DMSET:
+ apci->ap_mcr = bits;
+ break;
+
+ case DMBIS:
+ apci->ap_mcr |= bits;
+ break;
+
+ case DMBIC:
+ apci->ap_mcr &= ~bits;
+ break;
+
+ case DMGET:
+ bits = apci->ap_msr;
+ break;
+ }
+
+ splx(s);
+ return (bits);
+}
+
+void
+apciinit(apci, rate)
+ struct apciregs *apci;
+ int rate;
+{
+ int s;
+ short stat;
+
+ s = splhigh();
+
+ rate = ttspeedtab(rate, apcispeedtab);
+
+ apci->ap_cfcr = CFCR_DLAB;
+ apci->ap_data = rate & 0xff;
+ apci->ap_ier = (rate >> 8) & 0xff;
+ apci->ap_cfcr = CFCR_8BITS;
+ apci->ap_ier = IER_ERXRDY | IER_ETXRDY;
+ apci->ap_fifo =
+ FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1;
+ apci->ap_mcr = MCR_DTR | MCR_RTS;
+ delay(100);
+ stat = apci->ap_iir;
+ splx(s);
+}
+
+void
+apcitimeout(arg)
+ void *arg;
+{
+ struct apci_softc *sc = arg;
+ int ferr, perr, oflow, s;
+
+ if (sc->sc_tty == NULL ||
+ (sc->sc_tty->t_state & TS_ISOPEN) == 0)
+ return;
+
+ /* Log any errors. */
+ if (sc->sc_ferr || sc->sc_perr || sc->sc_oflow) {
+ s = spltty(); /* XXX necessary? */
+ ferr = sc->sc_ferr;
+ perr = sc->sc_perr;
+ oflow = sc->sc_oflow;
+ sc->sc_ferr = sc->sc_perr = sc->sc_oflow = 0;
+ splx(s);
+ sc->sc_toterr += ferr + perr + oflow;
+ log(LOG_WARNING,
+ "%s: %d frame, %d parity, %d overflow, %d total errors\n",
+ sc->sc_dev.dv_xname, ferr, perr, oflow, sc->sc_toterr);
+ }
+
+ timeout(apcitimeout, sc, hz);
+}
+
+int
+apcicheckdca()
+{
+ caddr_t va;
+ int rv = 0;
+
+ /*
+ * On systems that also have a dca at select code 9, we
+ * cannot use the second UART, as it is mapped to select
+ * code 9 by the firmware. We check for this by mapping
+ * select code 9 and checking for a dca. Yuck.
+ */
+ va = iomap(dio_scodetopa(9), NBPG);
+ if (va == NULL) {
+ printf("apcicheckdca: can't map scode 9!\n");
+ return (1); /* Safety. */
+ }
+
+ /* Check for hardware. */
+ if (badaddr(va)) {
+ /* Nothing there, assume APCI. */
+ goto unmap;
+ }
+
+ /* Check DIO ID against DCA IDs. */
+ switch (DIO_ID(va)) {
+ case DIO_DEVICE_ID_DCA0:
+ case DIO_DEVICE_ID_DCA0REM:
+ case DIO_DEVICE_ID_DCA1:
+ case DIO_DEVICE_ID_DCA1REM:
+ rv = 1;
+ }
+ unmap:
+ iounmap(va, NBPG);
+
+ return (rv);
+}
+
+
+/*
+ * The following routines are required for the APCI to act as the console.
+ */
+
+void
+apcicnprobe(cp)
+ struct consdev *cp;
+{
+
+ /* locate the major number */
+ for (apcimajor = 0; apcimajor < nchrdev; apcimajor++)
+ if (cdevsw[apcimajor].d_open == apciopen)
+ break;
+
+ /* initialize the required fields */
+ cp->cn_dev = makedev(apcimajor, 0); /* XXX */
+ cp->cn_pri = CN_DEAD;
+
+ /* Abort early if console is already forced. */
+ if (conforced)
+ return;
+
+ /* These can only exist on 400-series machines. */
+ switch (machineid) {
+ case HP_400:
+ case HP_425:
+ case HP_433:
+ break;
+
+ default:
+ return;
+ }
+
+ /* Make sure a DCA isn't in the way. */
+ if (apcicheckdca() == 0) {
+#ifdef APCI_FORCE_CONSOLE
+ cp->cn_pri = CN_REMOTE;
+ conforced = 1;
+ conscode = -2; /* XXX */
+#else
+ cp->cn_pri = CN_NORMAL;
+#endif
+ }
+}
+
+/* ARGSUSED */
+void
+apcicninit(cp)
+ struct consdev *cp;
+{
+
+ apci_cn = (struct apciregs *)IIOV(FRODO_BASE + FRODO_APCI_OFFSET(1));
+ apciinit(apci_cn, apcidefaultrate);
+ apciconsinit = 1;
+}
+
+/* ARGSUSED */
+int
+apcicngetc(dev)
+ dev_t dev;
+{
+ u_char stat;
+ int c, s;
+
+ s = splhigh();
+ while (((stat = apci_cn->ap_lsr) & LSR_RXRDY) == 0)
+ ;
+ c = apci_cn->ap_data;
+ stat = apci_cn->ap_iir;
+ splx(s);
+ return (c);
+}
+
+/* ARGSUSED */
+void
+apcicnputc(dev, c)
+ dev_t dev;
+ int c;
+{
+ int timo;
+ u_char stat;
+ int s;
+
+ s = splhigh();
+
+ if (apciconsinit == 0) {
+ apciinit(apci_cn, apcidefaultrate);
+ apciconsinit = 1;
+ }
+
+ /* wait for any pending transmission to finish */
+ timo = 50000;
+ while (((stat = apci_cn->ap_lsr) & LSR_TXRDY) == 0 && --timo)
+ ;
+
+ apci_cn->ap_data = c & 0xff;
+
+ /* wait for this transmission to complete */
+ timo = 1500000;
+ while (((stat = apci_cn->ap_lsr) & LSR_TXRDY) == 0 && --timo)
+ ;
+
+ /* clear any interrupts generated by this transmission */
+ stat = apci_cn->ap_iir;
+ splx(s);
+}
diff --git a/sys/arch/hp300/dev/apcireg.h b/sys/arch/hp300/dev/apcireg.h
index 577033f53f5..aab1b8e22ca 100644
--- a/sys/arch/hp300/dev/apcireg.h
+++ b/sys/arch/hp300/dev/apcireg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: apcireg.h,v 1.1 1997/04/16 11:55:57 downsj Exp $ */
-/* $NetBSD: apcireg.h,v 1.1 1997/04/14 20:36:11 thorpej Exp $ */
+/* $OpenBSD: apcireg.h,v 1.2 1997/07/06 08:01:45 downsj Exp $ */
+/* $NetBSD: apcireg.h,v 1.2 1997/05/12 08:14:01 thorpej Exp $ */
/*
* Copyright (c) 1997 Michael Smith. All rights reserved.
@@ -50,9 +50,6 @@ struct apciregs {
/* max number of apci ports */
#define APCI_MAXPORT 4
-/* Frodo interrupt number of lowest apci port */
-#define APCI_INTR0 12
-
/*
* baudrate divisor calculations.
*
diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c
index 69df5b9a3ae..675d1c23206 100644
--- a/sys/arch/hp300/dev/dca.c
+++ b/sys/arch/hp300/dev/dca.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dca.c,v 1.8 1997/04/16 11:55:58 downsj Exp $ */
-/* $NetBSD: dca.c,v 1.34 1997/04/14 02:33:16 thorpej Exp $ */
+/* $OpenBSD: dca.c,v 1.9 1997/07/06 08:01:46 downsj Exp $ */
+/* $NetBSD: dca.c,v 1.35 1997/05/05 20:58:18 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -231,7 +231,7 @@ dcaattach(parent, self, aux)
sc->sc_flags |= DCA_HASFIFO;
/* Establish interrupt handler. */
- (void) intr_establish(dcaintr, sc, ipl,
+ (void) dio_intr_establish(dcaintr, sc, ipl,
(sc->sc_flags & DCA_HASFIFO) ? IPL_TTY : IPL_TTYNOBUF);
sc->sc_flags |= DCA_ACTIVE;
diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c
index 62a4541ec14..2fbb9f50691 100644
--- a/sys/arch/hp300/dev/dcm.c
+++ b/sys/arch/hp300/dev/dcm.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dcm.c,v 1.8 1997/04/16 11:55:59 downsj Exp $ */
-/* $NetBSD: dcm.c,v 1.39 1997/04/14 02:33:17 thorpej Exp $ */
+/* $OpenBSD: dcm.c,v 1.9 1997/07/06 08:01:47 downsj Exp $ */
+/* $NetBSD: dcm.c,v 1.41 1997/05/05 20:59:16 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -354,7 +354,7 @@ dcmattach(parent, self, aux)
sc->sc_flags |= DCM_ACTIVE;
/* Establish the interrupt handler. */
- (void) intr_establish(dcmintr, sc, ipl, IPL_TTY);
+ (void) dio_intr_establish(dcmintr, sc, ipl, IPL_TTY);
if (dcmistype == DIS_TIMER)
dcmsetischeme(brd, DIS_RESET|DIS_TIMER);
@@ -776,7 +776,7 @@ dcmreadbuf(sc, port)
dsp->rints++;
#endif
tp = sc->sc_tty[port];
- if (tp == NULL || (tp->t_state & TS_ISOPEN) == 0)
+ if (tp == NULL)
return;
if ((tp->t_state & TS_ISOPEN) == 0) {
diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c
index deb17145f54..6560bf9b53e 100644
--- a/sys/arch/hp300/dev/dio.c
+++ b/sys/arch/hp300/dev/dio.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: dio.c,v 1.4 1997/04/16 11:55:59 downsj Exp $ */
-/* $NetBSD: dio.c,v 1.5 1997/04/04 09:53:43 thorpej Exp $ */
+/* $OpenBSD: dio.c,v 1.5 1997/07/06 08:01:48 downsj Exp $ */
+/* $NetBSD: dio.c,v 1.7 1997/05/05 21:00:32 thorpej Exp $ */
/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -41,6 +41,8 @@
* Autoconfiguration and mapping support for the DIO bus.
*/
+#define _HP300_INTR_H_PRIVATE
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
@@ -49,6 +51,9 @@
#include <machine/autoconf.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
+
+#include <hp300/dev/dmavar.h>
#include <hp300/dev/dioreg.h>
#include <hp300/dev/diovar.h>
@@ -99,7 +104,8 @@ dioattach(parent, self, aux)
int scode, scmax, didmap, scodesize;
scmax = DIO_SCMAX(machineid);
- printf("\n");
+ printf(": ");
+ dmainit();
for (scode = 0; scode < scmax; ) {
if (DIO_INHOLE(scode)) {
@@ -305,3 +311,39 @@ dio_devinfo(da, buf, buflen)
da->da_id, da->da_secid);
return (buf);
}
+
+/*
+ * Establish an interrupt handler for a DIO device.
+ */
+void *
+dio_intr_establish(func, arg, ipl, priority)
+ int (*func) __P((void *));
+ void *arg;
+ int ipl;
+ int priority;
+{
+ void *ih;
+
+ ih = intr_establish(func, arg, ipl, priority);
+
+ if (priority == IPL_BIO)
+ dmacomputeipl();
+
+ return (ih);
+}
+
+/*
+ * Remove an interrupt handler for a DIO device.
+ */
+void
+dio_intr_disestablish(arg)
+ void *arg;
+{
+ struct isr *isr = arg;
+ int priority = isr->isr_priority;
+
+ intr_disestablish(arg);
+
+ if (priority == IPL_BIO)
+ dmacomputeipl();
+}
diff --git a/sys/arch/hp300/dev/diovar.h b/sys/arch/hp300/dev/diovar.h
index 555cb0b4924..735334aa099 100644
--- a/sys/arch/hp300/dev/diovar.h
+++ b/sys/arch/hp300/dev/diovar.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: diovar.h,v 1.2 1997/02/03 04:47:21 downsj Exp $ */
-/* $NetBSD: diovar.h,v 1.2 1997/01/30 09:18:41 thorpej Exp $ */
+/* $OpenBSD: diovar.h,v 1.3 1997/07/06 08:01:48 downsj Exp $ */
+/* $NetBSD: diovar.h,v 1.3 1997/05/05 21:01:33 thorpej Exp $ */
/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -77,4 +77,6 @@ struct dio_devdesc {
#ifdef _KERNEL
void *dio_scodetopa __P((int));
+void *dio_intr_establish __P((int (*)(void *), void *, int, int));
+void dio_intr_disestablish __P((void *));
#endif /* _KERNEL */
diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c
index 84583358f0a..78c0420c7d7 100644
--- a/sys/arch/hp300/dev/dma.c
+++ b/sys/arch/hp300/dev/dma.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: dma.c,v 1.7 1997/04/16 11:56:00 downsj Exp $ */
-/* $NetBSD: dma.c,v 1.17 1997/04/14 02:33:18 thorpej Exp $ */
+/* $OpenBSD: dma.c,v 1.8 1997/07/06 08:01:49 downsj Exp $ */
+/* $NetBSD: dma.c,v 1.19 1997/05/05 21:02:39 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997
@@ -42,6 +42,8 @@
* DMA driver
*/
+#include <machine/hp300spu.h> /* XXX param.h includes cpu.h */
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/time.h>
@@ -64,14 +66,13 @@
*/
#define DMAMAXIO (MAXPHYS/NBPG+1)
-struct dma_chain {
+struct dma_chain {
int dc_count;
char *dc_addr;
};
-struct dma_channel {
+struct dma_channel {
struct dmaqueue *dm_job; /* current job */
- struct dma_softc *dm_softc; /* pointer back to softc */
struct dmadevice *dm_hwaddr; /* registers if DMA_C */
struct dmaBdevice *dm_Bhwaddr; /* registers if not DMA_C */
char dm_flags; /* misc. flags */
@@ -81,15 +82,14 @@ struct dma_channel {
struct dma_chain dm_chain[DMAMAXIO]; /* all segments */
};
-struct dma_softc {
- char *sc_xname; /* XXX external name */
+struct dma_softc {
struct dmareg *sc_dmareg; /* pointer to our hardware */
struct dma_channel sc_chan[NDMACHAN]; /* 2 channels */
TAILQ_HEAD(, dmaqueue) sc_queue; /* job queue */
char sc_type; /* A, B, or C */
int sc_ipl; /* our interrupt level */
void *sc_ih; /* interrupt cookie */
-} Dma_softc;
+} dma_softc;
/* types */
#define DMA_B 0
@@ -119,10 +119,13 @@ long dmaword[NDMACHAN];
long dmalword[NDMACHAN];
#endif
+/*
+ * Initialize the DMA engine, called by dioattach()
+ */
void
dmainit()
{
- struct dma_softc *sc = &Dma_softc;
+ struct dma_softc *sc = &dma_softc;
struct dmareg *dma;
struct dma_channel *dc;
int i;
@@ -131,7 +134,6 @@ dmainit()
/* There's just one. */
sc->sc_dmareg = (struct dmareg *)DMA_BASE;
dma = sc->sc_dmareg;
- sc->sc_xname = "dma0";
/*
* Determine the DMA type. A DMA_A or DMA_B will fail the
@@ -155,7 +157,6 @@ dmainit()
for (i = 0; i < NDMACHAN; i++) {
dc = &sc->sc_chan[i];
- dc->dm_softc = sc;
dc->dm_job = NULL;
switch (i) {
case 0:
@@ -179,8 +180,8 @@ dmainit()
timeout(dmatimeout, sc, 30 * hz);
#endif
- printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname,
- rev, (rev == 'B') ? 16 : 32);
+ printf("98620%c, 2 channels, %d bit DMA\n",
+ rev, (rev == 'B') ? 16 : 32);
/*
* Defer hooking up our interrupt until the first
@@ -196,7 +197,7 @@ dmainit()
void
dmacomputeipl()
{
- struct dma_softc *sc = &Dma_softc;
+ struct dma_softc *sc = &dma_softc;
if (sc->sc_ih != NULL)
intr_disestablish(sc->sc_ih);
@@ -213,7 +214,7 @@ int
dmareq(dq)
struct dmaqueue *dq;
{
- struct dma_softc *sc = &Dma_softc;
+ struct dma_softc *sc = &dma_softc;
int i, chan, s;
#if 1
@@ -258,7 +259,7 @@ dmafree(dq)
struct dmaqueue *dq;
{
int unit = dq->dq_chan;
- struct dma_softc *sc = &Dma_softc;
+ struct dma_softc *sc = &dma_softc;
struct dma_channel *dc = &sc->sc_chan[unit];
struct dmaqueue *dn;
int chan, s;
@@ -274,7 +275,8 @@ dmafree(dq)
#endif
DMA_CLEAR(dc);
-#if defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375) || defined(HP380)
+
+#if defined(CACHE_HAVE_PAC) || defined(M68040)
/*
* XXX we may not always go thru the flush code in dmastop()
*/
@@ -283,7 +285,8 @@ dmafree(dq)
dc->dm_flags &= ~DMAF_PCFLUSH;
}
#endif
-#if defined(HP320) || defined(HP350)
+
+#if defined(CACHE_HAVE_VAC)
if (dc->dm_flags & DMAF_VCFLUSH) {
/*
* 320/350s have VACs that may also need flushing.
@@ -298,6 +301,7 @@ dmafree(dq)
dc->dm_flags &= ~DMAF_VCFLUSH;
}
#endif
+
/*
* Channel is now free. Look for another job to run on this
* channel.
@@ -328,17 +332,19 @@ dmago(unit, addr, count, flags)
int count;
int flags;
{
- struct dma_softc *sc = &Dma_softc;
+ struct dma_softc *sc = &dma_softc;
struct dma_channel *dc = &sc->sc_chan[unit];
char *dmaend = NULL;
int seg, tcount;
if (count > MAXPHYS)
panic("dmago: count > MAXPHYS");
+
#if defined(HP320)
if (sc->sc_type == DMA_B && (flags & DMAGO_LWORD))
panic("dmago: no can do 32-bit DMA");
#endif
+
#ifdef DEBUG
if (dmadebug & DDB_FOLLOW)
printf("dmago(%d, %p, %x, %x)\n",
@@ -355,7 +361,7 @@ dmago(unit, addr, count, flags)
*/
for (seg = 0; count > 0; seg++) {
dc->dm_chain[seg].dc_addr = (char *) kvtop(addr);
-#if defined(HP380)
+#if defined(M68040)
/*
* Push back dirty cache lines
*/
@@ -412,7 +418,8 @@ dmago(unit, addr, count, flags)
dc->dm_cmd |= DMA_WORD;
if (flags & DMAGO_PRI)
dc->dm_cmd |= DMA_PRI;
-#if defined(HP380)
+
+#if defined(M68040)
/*
* On the 68040 we need to flush (push) the data cache before a
* DMA (already done above) and flush again after DMA completes.
@@ -423,7 +430,8 @@ dmago(unit, addr, count, flags)
if (mmutype == MMU_68040 && (flags & DMAGO_READ))
dc->dm_flags |= DMAF_PCFLUSH;
#endif
-#if defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375)
+
+#if defined(CACHE_HAVE_PAC)
/*
* Remember if we need to flush external physical cache when
* DMA is done. We only do this if we are reading (writing memory).
@@ -431,10 +439,12 @@ dmago(unit, addr, count, flags)
if (ectype == EC_PHYS && (flags & DMAGO_READ))
dc->dm_flags |= DMAF_PCFLUSH;
#endif
-#if defined(HP320) || defined(HP350)
+
+#if defined(CACHE_HAVE_VAC)
if (ectype == EC_VIRT && (flags & DMAGO_READ))
dc->dm_flags |= DMAF_VCFLUSH;
#endif
+
/*
* Remember if we can skip the dma completion interrupt on
* the last segment in the chain.
@@ -459,14 +469,14 @@ dmago(unit, addr, count, flags)
}
dmatimo[unit] = 1;
#endif
- DMA_ARM(dc);
+ DMA_ARM(sc, dc);
}
void
dmastop(unit)
int unit;
{
- struct dma_softc *sc = &Dma_softc;
+ struct dma_softc *sc = &dma_softc;
struct dma_channel *dc = &sc->sc_chan[unit];
#ifdef DEBUG
@@ -475,13 +485,15 @@ dmastop(unit)
dmatimo[unit] = 0;
#endif
DMA_CLEAR(dc);
-#if defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375) || defined(HP380)
+
+#if defined(CACHE_HAVE_PAC) || defined(M68040)
if (dc->dm_flags & DMAF_PCFLUSH) {
PCIA();
dc->dm_flags &= ~DMAF_PCFLUSH;
}
#endif
-#if defined(HP320) || defined(HP350)
+
+#if defined(CACHE_HAVE_VAC)
if (dc->dm_flags & DMAF_VCFLUSH) {
/*
* 320/350s have VACs that may also need flushing.
@@ -496,6 +508,7 @@ dmastop(unit)
dc->dm_flags &= ~DMAF_VCFLUSH;
}
#endif
+
/*
* We may get this interrupt after a device service routine
* has freed the dma channel. So, ignore the intr if there's
@@ -532,8 +545,7 @@ dmaintr(arg)
dc->dm_flags, i, stat, dc->dm_cur + 1);
}
if (stat & DMA_ARMED)
- printf("%s, chan %d: intr when armed\n",
- sc->sc_xname, i);
+ printf("dma channel %d: intr when armed\n", i);
#endif
/*
* Load the next segemnt, or finish up if we're done.
@@ -551,7 +563,7 @@ dmaintr(arg)
(dc->dm_flags & DMAF_NOINTR))
dc->dm_cmd &= ~DMA_ENAB;
DMA_CLEAR(dc);
- DMA_ARM(dc);
+ DMA_ARM(sc, dc);
} else
dmastop(i);
}
@@ -570,8 +582,8 @@ dmatimeout(arg)
s = splbio();
if (dmatimo[i]) {
if (dmatimo[i] > 1)
- printf("%s: chan %d timeout #%d\n",
- sc->sc_xname, i, dmatimo[i]-1);
+ printf("dma channel %d timeout #%d\n",
+ i, dmatimo[i]-1);
dmatimo[i]++;
}
splx(s);
diff --git a/sys/arch/hp300/dev/dmareg.h b/sys/arch/hp300/dev/dmareg.h
index 231b6510353..7698edc7e0e 100644
--- a/sys/arch/hp300/dev/dmareg.h
+++ b/sys/arch/hp300/dev/dmareg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: dmareg.h,v 1.5 1997/04/16 11:56:00 downsj Exp $ */
-/* $NetBSD: dmareg.h,v 1.10 1997/04/01 03:10:58 scottr Exp $ */
+/* $OpenBSD: dmareg.h,v 1.6 1997/07/06 08:01:49 downsj Exp $ */
+/* $NetBSD: dmareg.h,v 1.12 1997/05/05 21:02:40 thorpej Exp $ */
/*
* Copyright (c) 1982, 1990, 1993
@@ -37,6 +37,7 @@
*/
#include <hp300/dev/iotypes.h> /* XXX */
+#include <machine/hp300spu.h>
/*
* Hardware layout for the 98620[ABC]:
@@ -116,8 +117,8 @@ struct dmareg {
#define DMA_STAT(dc) dc->dm_Bhwaddr->dmaB_stat
#if defined(HP320)
-#define DMA_ARM(dc) \
- if (dc->dm_softc->sc_type == DMA_B) { \
+#define DMA_ARM(sc, dc) \
+ if (sc->sc_type == DMA_B) { \
struct dmaBdevice *dma = dc->dm_Bhwaddr; \
dma->dmaB_addr = dc->dm_chain[dc->dm_cur].dc_addr; \
dma->dmaB_count = dc->dm_chain[dc->dm_cur].dc_count - 1; \
@@ -129,7 +130,7 @@ struct dmareg {
dma->dma_cmd = dc->dm_cmd; \
}
#else
-#define DMA_ARM(dc) \
+#define DMA_ARM(sc, dc) \
{ \
struct dmadevice *dma = dc->dm_hwaddr; \
dma->dma_addr = dc->dm_chain[dc->dm_cur].dc_addr; \
diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c
index 4626ffadfba..c2dbe3ff313 100644
--- a/sys/arch/hp300/dev/fhpib.c
+++ b/sys/arch/hp300/dev/fhpib.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: fhpib.c,v 1.7 1997/04/16 11:56:01 downsj Exp $ */
-/* $NetBSD: fhpib.c,v 1.17 1997/04/14 02:33:19 thorpej Exp $ */
+/* $OpenBSD: fhpib.c,v 1.8 1997/07/06 08:01:50 downsj Exp $ */
+/* $NetBSD: fhpib.c,v 1.18 1997/05/05 21:04:16 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -158,8 +158,7 @@ fhpibattach(parent, self, aux)
printf(" ipl %d: %s\n", ipl, DIO_DEVICE_DESC_FHPIB);
/* Establish the interrupt handler. */
- (void) intr_establish(fhpibintr, sc, ipl, IPL_BIO);
- dmacomputeipl();
+ (void) dio_intr_establish(fhpibintr, sc, ipl, IPL_BIO);
ha.ha_ops = &fhpib_controller;
ha.ha_type = HPIBC; /* XXX */
diff --git a/sys/arch/hp300/dev/frodo.c b/sys/arch/hp300/dev/frodo.c
new file mode 100644
index 00000000000..d9065c466df
--- /dev/null
+++ b/sys/arch/hp300/dev/frodo.c
@@ -0,0 +1,329 @@
+/* $OpenBSD: frodo.c,v 1.1 1997/07/06 08:01:50 downsj Exp $ */
+/* $NetBSD: frodo.c,v 1.1 1997/05/12 08:03:48 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
+ * Copyright (c) 1997 Michael Smith. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/*
+ * Support for the "Frodo" (a.k.a. "Apollo Utility") chip found
+ * in HP Apollo 9000/4xx workstations.
+ */
+
+#define _HP300_INTR_H_PRIVATE
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/device.h>
+
+#include <machine/cpu.h>
+#include <machine/intr.h>
+#include <machine/hp300spu.h>
+
+#include <hp300/dev/intiovar.h>
+
+#include <hp300/dev/frodoreg.h>
+#include <hp300/dev/frodovar.h>
+
+/*
+ * Description of a Frodo interrupt handler.
+ */
+struct frodo_isr {
+ int (*isr_func) __P((void *));
+ void *isr_arg;
+ int isr_priority;
+};
+
+struct frodo_softc {
+ struct device sc_dev; /* generic device glue */
+ volatile u_int8_t *sc_regs; /* register base */
+ struct frodo_isr sc_intr[FRODO_NINTR]; /* interrupt handlers */
+ void *sc_ih; /* out interrupt cookie */
+ int sc_refcnt; /* number of interrupt refs */
+};
+
+int frodomatch __P((struct device *, void *, void *));
+void frodoattach __P((struct device *, struct device *, void *));
+
+int frodoprint __P((void *, const char *));
+int frodosubmatch __P((struct device *, void *, void *));
+
+int frodointr __P((void *));
+
+void frodo_imask __P((struct frodo_softc *, u_int16_t, u_int16_t));
+
+struct cfattach frodo_ca = {
+ sizeof(struct frodo_softc), frodomatch, frodoattach
+};
+
+struct cfdriver frodo_cd = {
+ NULL, "frodo", DV_DULL
+};
+
+struct frodo_attach_args frodo_subdevs[] = {
+ { "dnkbd", FRODO_APCI_OFFSET(0), FRODO_INTR_APCI0 },
+ { "apci", FRODO_APCI_OFFSET(1), FRODO_INTR_APCI1 },
+ { "apci", FRODO_APCI_OFFSET(2), FRODO_INTR_APCI2 },
+ { "apci", FRODO_APCI_OFFSET(3), FRODO_INTR_APCI3 },
+ { NULL, 0, 0 },
+};
+
+int
+frodomatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct intio_attach_args *ia = aux;
+ caddr_t va;
+ static int frodo_matched = 0;
+
+ /* only allow one instance */
+ if (frodo_matched)
+ return (0);
+
+ /* only 4xx workstations can have this */
+ switch (machineid) {
+ case HP_400:
+ case HP_425:
+ case HP_433:
+ break;
+
+ default:
+ return (0);
+ }
+
+ /* make sure the hardware is there in any case */
+ va = (caddr_t)IIOV(FRODO_BASE);
+ if (badaddr(va))
+ return (0);
+
+ frodo_matched = 1;
+ ia->ia_addr = va;
+ return (1);
+}
+
+void
+frodoattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct frodo_softc *sc = (struct frodo_softc *)self;
+ struct intio_attach_args *ia = aux;
+ int i;
+
+ sc->sc_regs = (volatile u_int8_t *)ia->ia_addr;
+
+ if ((FRODO_READ(sc, FRODO_IISR) & FRODO_IISR_SERVICE) == 0)
+ printf(": service mode enabled");
+ printf("\n");
+
+ /* Clear all of the interrupt handlers. */
+ bzero(sc->sc_intr, sizeof(sc->sc_intr));
+ sc->sc_refcnt = 0;
+
+ /*
+ * Disable all of the interrupt lines; we reenable them
+ * as subdevices attach.
+ */
+ frodo_imask(sc, 0, 0xffff);
+
+ /* Clear any pending interrupts. */
+ FRODO_WRITE(sc, FRODO_PIC_PU, 0xff);
+ FRODO_WRITE(sc, FRODO_PIC_PL, 0xff);
+
+ /* Set interrupt polarities. */
+ FRODO_WRITE(sc, FRODO_PIO_IPR, 0x10);
+
+ /* ...and configure for edge triggering. */
+ FRODO_WRITE(sc, FRODO_PIO_IELR, 0xcf);
+
+ /*
+ * We defer hooking up our interrupt handler until
+ * a subdevice hooks up theirs.
+ */
+ sc->sc_ih = NULL;
+
+ /* ... and attach subdevices. */
+ for (i = 0; frodo_subdevs[i].fa_name != NULL; i++)
+ config_found_sm(self, &frodo_subdevs[i],
+ frodoprint, frodosubmatch);
+}
+
+int
+frodosubmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct cfdata *cf = match;
+ struct frodo_attach_args *fa = aux;
+
+ if (cf->frodocf_offset != FRODO_UNKNOWN_OFFSET &&
+ cf->frodocf_offset != fa->fa_offset)
+ return (0);
+
+ return ((*cf->cf_attach->ca_match)(parent, cf, aux));
+}
+
+int
+frodoprint(aux, pnp)
+ void *aux;
+ const char *pnp;
+{
+ struct frodo_attach_args *fa = aux;
+
+ if (pnp)
+ printf("%s at %s", fa->fa_name, pnp);
+ printf(" offset 0x%x", fa->fa_offset);
+ return (UNCONF);
+}
+
+void
+frodo_intr_establish(frdev, func, arg, line, priority)
+ struct device *frdev;
+ int (*func) __P((void *));
+ void *arg;
+ int line;
+ int priority;
+{
+ struct frodo_softc *sc = (struct frodo_softc *)frdev;
+ struct isr *isr = sc->sc_ih;
+
+ if (line < 0 || line >= FRODO_NINTR) {
+ printf("%s: bad interrupt line %d\n",
+ sc->sc_dev.dv_xname, line);
+ goto lose;
+ }
+ if (sc->sc_intr[line].isr_func != NULL) {
+ printf("%s: interrupt line %d already used\n",
+ sc->sc_dev.dv_xname, line);
+ goto lose;
+ }
+
+ /* Install the handler. */
+ sc->sc_intr[line].isr_func = func;
+ sc->sc_intr[line].isr_arg = arg;
+ sc->sc_intr[line].isr_priority = priority;
+
+ /*
+ * If this is the first one, establish the frodo
+ * interrupt handler. If not, reestablish at a
+ * higher priority if necessary.
+ */
+ if (isr == NULL || isr->isr_priority < priority) {
+ if (isr != NULL)
+ intr_disestablish(isr);
+ sc->sc_ih = intr_establish(frodointr, sc, 5, priority);
+ }
+
+ sc->sc_refcnt++;
+
+ /* Enable the interrupt line. */
+ frodo_imask(sc, (1 << line), 0);
+ return;
+ lose:
+ panic("frodo_intr_establish");
+}
+
+void
+frodo_intr_disestablish(frdev, line)
+ struct device *frdev;
+ int line;
+{
+ struct frodo_softc *sc = (struct frodo_softc *)frdev;
+ struct isr *isr = sc->sc_ih;
+ int newpri;
+
+ if (sc->sc_intr[line].isr_func == NULL) {
+ printf("%s: no handler for line %d\n",
+ sc->sc_dev.dv_xname, line);
+ panic("frodo_intr_disestablish");
+ }
+
+ sc->sc_intr[line].isr_func = NULL;
+ frodo_imask(sc, 0, (1 << line));
+
+ /* If this was the last, unhook ourselves. */
+ if (sc->sc_refcnt-- == 1) {
+ intr_disestablish(isr);
+ return;
+ }
+
+ /* Lower our priority, if appropriate. */
+ for (newpri = 0, line = 0; line < FRODO_NINTR; line++)
+ if (sc->sc_intr[line].isr_func != NULL &&
+ sc->sc_intr[line].isr_priority > newpri)
+ newpri = sc->sc_intr[line].isr_priority;
+
+ if (newpri != isr->isr_priority) {
+ intr_disestablish(isr);
+ sc->sc_ih = intr_establish(frodointr, sc, 5, newpri);
+ }
+}
+
+int
+frodointr(arg)
+ void *arg;
+{
+ struct frodo_softc *sc = arg;
+ struct frodo_isr *fisr;
+ int line, taken = 0;
+
+ /* Any interrupts pending? */
+ if (FRODO_GETPEND(sc) == 0)
+ return (0);
+
+ do {
+ /*
+ * Get pending interrupt; this also clears it for us.
+ */
+ line = FRODO_IPEND(sc);
+ fisr = &sc->sc_intr[line];
+ if (fisr->isr_func == NULL ||
+ (*fisr->isr_func)(fisr->isr_arg) == 0)
+ printf("%s: spurious interrupt on line %d\n",
+ sc->sc_dev.dv_xname, line);
+ if (taken++ > 100)
+ panic("frodointr: looping!");
+ } while (FRODO_GETPEND(sc) != 0);
+
+ return (1);
+}
+
+void
+frodo_imask(sc, set, clear)
+ struct frodo_softc *sc;
+ u_int16_t set, clear;
+{
+ u_int16_t imask;
+
+ imask = FRODO_GETMASK(sc);
+
+ imask |= set;
+ imask &= ~clear;
+
+ FRODO_SETMASK(sc, imask);
+}
diff --git a/sys/arch/hp300/dev/frodoreg.h b/sys/arch/hp300/dev/frodoreg.h
new file mode 100644
index 00000000000..c99c753b449
--- /dev/null
+++ b/sys/arch/hp300/dev/frodoreg.h
@@ -0,0 +1,123 @@
+/* $OpenBSD: frodoreg.h,v 1.1 1997/07/06 08:01:51 downsj Exp $ */
+/* $NetBSD: frodoreg.h,v 1.1 1997/05/12 08:03:49 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1997 Michael Smith. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/* Base address of the Frodo part */
+#define FRODO_BASE (INTIOBASE + 0x1c000)
+
+/*
+ * Where we find the 8250-like APCI ports, and how far apart they are.
+ */
+#define FRODO_APCIBASE 0x0
+#define FRODO_APCISPACE 0x20
+#define FRODO_APCI_OFFSET(x) (FRODO_APCIBASE + ((x) * FRODO_APCISPACE))
+
+/*
+ * Other items in the Frodo part
+ */
+
+/* An mc146818-like calendar, but no battery... lame */
+#define FRODO_CALENDAR 0x80
+
+#define FRODO_TIMER 0xa0 /* 8254-like timer */
+#define FRODO_T1_CTR 0xa0 /* counter 1 */
+#define FRODO_T2_CTR 0xa4 /* counter 2 */
+#define FRODO_T3_CTR 0xa8 /* counter 3 */
+#define FRODO_T_CTRL 0xac /* control register */
+#define FRODO_T_PSCALE 0xb0 /* prescaler */
+#define FRODO_T_PCOUNT 0xb4 /* precounter ? */
+#define FRODO_T_OVCOUNT 0xb8 /* overflow counter (0, 1, 2) */
+
+#define FRODO_PIO 0xc0 /* programmable i/o registers start
+ here */
+#define FRODO_IISR 0xc0 /* ISA Interrupt Status Register
+ (also PIR) */
+#define FRODO_IISR_SERVICE (1<<0) /* service switch "on" if 0 */
+#define FRODO_IISR_ILOW (1<<1) /* IRQ 3,4,5 or 6 on ISA if 1 */
+#define FRODO_IISR_IMID (1<<2) /* IRQ 7,9,10 or 11 on ISA if 1 */
+#define FRODO_IISR_IHI (1<<3) /* IRQ 12,13,14 or 15 on ISA if 1 */
+ /* bits 4 and 5 are DN2500 SCSI interrupts */
+ /* bit 6 is unused */
+#define FRODO_IISR_IOCHK (1<<7) /* ISA board asserted IOCHK if low */
+
+#define FRODO_PIO_IPR 0xc4 /* input polarity register
+ (ints 7->0) */
+
+#define FRODO_PIO_IELR 0xc8 /* input edge/level register */
+
+/* This is probably not used on the 4xx */
+#define FRODO_DIAGCTL 0xd0 /* Diagnostic Control Register */
+
+#define FRODO_PIC_MU 0xe0 /* upper Interrupt Mask register */
+#define FRODO_PIC_ML 0xe4 /* lower Interrupt Mask register */
+#define FRODO_PIC_PU 0xe8 /* upper Interrupt Pending register */
+#define FRODO_PIC_PL 0xec /* lower Interrupt Pending register */
+#define FRODO_PIC_IVR 0xf8 /* Interrupt Vector register */
+#define FRODO_PIC_ACK 0xf8 /* Interrupt Acknowledge */
+
+/* Shorthand for register access. */
+#define FRODO_READ(sc, reg) ((sc)->sc_regs[(reg)])
+#define FRODO_WRITE(sc, reg, val) (sc)->sc_regs[(reg)] = (val)
+
+/* manipulate interrupt registers */
+#define FRODO_GETMASK(sc) \
+ ((FRODO_READ((sc), FRODO_PIC_MU) << 8) | \
+ FRODO_READ((sc), FRODO_PIC_ML))
+#define FRODO_SETMASK(sc, val) do { \
+ FRODO_WRITE((sc), FRODO_PIC_MU, ((val) >> 8) & 0xff); \
+ FRODO_WRITE((sc), FRODO_PIC_ML, (val) & 0xff); } while (0)
+
+#define FRODO_GETPEND(sc) \
+ ((FRODO_READ((sc), FRODO_PIC_PU) << 8) | \
+ FRODO_READ((sc), FRODO_PIC_PL))
+#define FRODO_IPEND(sc) \
+ (FRODO_READ((sc), FRODO_PIC_ACK) & 0x0f)
+
+/*
+ * Interrupt lines. Use FRODO_INTR_BIT() below to get a bit
+ * suitable for one of the interrupt mask registers. Yes, line
+ * 0 is unused.
+ */
+#define FRODO_INTR_ILOW 1
+#define FRODO_INTR_IMID 2
+#define FRODO_INTR_IHI 3
+#define FRODO_INTR_SCSIDMA 4 /* DN2500 only */
+#define FRODO_INTR_SCSI 5 /* DN2500 only */
+#define FRODO_INTR_HORIZ 6
+#define FRODO_INTR_IOCHK 7
+#define FRODO_INTR_CALENDAR 8
+#define FRODO_INTR_TIMER0 9
+#define FRODO_INTR_TIMER1 10
+#define FRODO_INTR_TIMER2 11
+#define FRODO_INTR_APCI0 12
+#define FRODO_INTR_APCI1 13
+#define FRODO_INTR_APCI2 14
+#define FRODO_INTR_APCI3 15
+
+#define FRODO_NINTR 16
+
+#define FRODO_INTR_BIT(line) (1 << (line))
diff --git a/sys/arch/hp300/dev/frodovar.h b/sys/arch/hp300/dev/frodovar.h
new file mode 100644
index 00000000000..7cd5dde1b3c
--- /dev/null
+++ b/sys/arch/hp300/dev/frodovar.h
@@ -0,0 +1,49 @@
+/* $OpenBSD: frodovar.h,v 1.1 1997/07/06 08:01:51 downsj Exp $ */
+/* $NetBSD: frodovar.h,v 1.1 1997/05/12 08:03:50 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
+ * Copyright (c) 1997 Michael Smith. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 Frodo ASIC in
+ * the HP9000/4xx series.
+ */
+
+/*
+ * Arguments used to attach Frodo subdevices.
+ */
+struct frodo_attach_args {
+ const char *fa_name; /* device name */
+ int fa_offset; /* offset from Frodo base */
+ int fa_line; /* Frodo interrupt line */
+};
+
+#define frodocf_offset cf_loc[0]
+#define FRODO_UNKNOWN_OFFSET -1
+
+void frodo_intr_establish __P((struct device *, int (*func)(void *),
+ void *, int, int));
+void frodo_intr_disestablish __P((struct device *, int));
diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c
index 7c2b3966638..586e421a7ae 100644
--- a/sys/arch/hp300/dev/hd.c
+++ b/sys/arch/hp300/dev/hd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hd.c,v 1.4 1997/04/16 11:56:06 downsj Exp $ */
-/* $NetBSD: rd.c,v 1.30 1997/04/09 20:01:04 thorpej Exp $ */
+/* $OpenBSD: hd.c,v 1.5 1997/07/06 08:01:52 downsj Exp $ */
+/* $NetBSD: rd.c,v 1.32 1997/06/24 00:44:03 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -65,15 +65,17 @@
#include <hp300/dev/hdreg.h>
#include <hp300/dev/hdvar.h>
-#ifdef USELEDS
-#include <hp300/hp300/led.h>
-#endif
-
#include <vm/vm_param.h>
#include <vm/lock.h>
#include <vm/vm_prot.h>
#include <vm/pmap.h>
+#include "opt_useleds.h"
+
+#ifdef USELEDS
+#include <hp300/hp300/leds.h>
+#endif
+
int hderrthresh = HDRETRY-1; /* when to start reporting errors */
#ifdef DEBUG
@@ -824,8 +826,7 @@ hdgo(arg)
disk_busy(&rs->sc_dkdev);
#ifdef USELEDS
- if (inledcontrol == 0)
- ledcontrol(0, 0, LED_DISK);
+ ledcontrol(0, 0, LED_DISK);
#endif
hpibgo(ctlr, slave, C_EXEC, rs->sc_addr, rs->sc_resid, rw, rw != 0);
}
@@ -1166,7 +1167,8 @@ hdsize(dev)
return(-1);
didopen = 1;
}
- psize = rs->sc_dkdev.dk_label->d_partitions[hdpart(dev)].p_size;
+ psize = rs->sc_dkdev.dk_label->d_partitions[hdpart(dev)].p_size *
+ (rs->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
if (didopen)
(void) hdclose(dev, FREAD|FWRITE, S_IFBLK, NULL);
return (psize);
diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c
index a15e590f1cd..234318413ca 100644
--- a/sys/arch/hp300/dev/hpib.c
+++ b/sys/arch/hp300/dev/hpib.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hpib.c,v 1.7 1997/04/16 11:56:09 downsj Exp $ */
-/* $NetBSD: hpib.c,v 1.15 1997/04/14 02:31:33 thorpej Exp $ */
+/* $OpenBSD: hpib.c,v 1.8 1997/07/06 08:01:53 downsj Exp $ */
+/* $NetBSD: hpib.c,v 1.16 1997/04/27 20:58:57 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -52,6 +52,7 @@
#include <hp300/dev/hpibvar.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
int hpibbusmatch __P((struct device *, void *, void *));
void hpibbusattach __P((struct device *, struct device *, void *));
diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c
index 602e03704f0..2901aa4045b 100644
--- a/sys/arch/hp300/dev/if_le.c
+++ b/sys/arch/hp300/dev/if_le.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_le.c,v 1.9 1997/04/16 11:56:10 downsj Exp $ */
-/* $NetBSD: if_le.c,v 1.41 1997/04/14 02:33:20 thorpej Exp $ */
+/* $OpenBSD: if_le.c,v 1.10 1997/07/06 08:01:54 downsj Exp $ */
+/* $NetBSD: if_le.c,v 1.43 1997/05/05 21:05:32 thorpej Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@@ -60,10 +60,6 @@
#include <machine/cpu.h>
#include <machine/intr.h>
-#ifdef USELEDS
-#include <hp300/hp300/led.h>
-#endif
-
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
@@ -73,6 +69,11 @@
#include <hp300/dev/if_lereg.h>
#include <hp300/dev/if_levar.h>
+#include "opt_useleds.h"
+#ifdef USELEDS
+#include <hp300/hp300/leds.h>
+#endif
+
int lematch __P((struct device *, void *, void *));
void leattach __P((struct device *, struct device *, void *));
@@ -197,7 +198,7 @@ leattach(parent, self, aux)
am7990_config(sc);
/* Establish the interrupt handler. */
- (void) intr_establish(leintr, sc, ipl, IPL_NET);
+ (void) dio_intr_establish(leintr, sc, ipl, IPL_NET);
ler0->ler0_status = LE_IE;
}
@@ -206,21 +207,19 @@ leintr(arg)
void *arg;
{
struct am7990_softc *sc = arg;
+#ifdef USELEDS
u_int16_t isr;
-#ifdef USELEDS
isr = lerdcsr(sc, LE_CSR0);
if ((isr & LE_C0_INTR) == 0)
return (0);
if (isr & LE_C0_RINT)
- if (inledcontrol == 0)
- ledcontrol(0, 0, LED_LANRCV);
+ ledcontrol(0, 0, LED_LANRCV);
if (isr & LE_C0_TINT)
- if (inledcontrol == 0)
- ledcontrol(0, 0, LED_LANXMT);
+ ledcontrol(0, 0, LED_LANXMT);
#endif /* USELEDS */
return (am7990_intr(sc));
diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c
index 5860be568eb..d9978bf0075 100644
--- a/sys/arch/hp300/dev/nhpib.c
+++ b/sys/arch/hp300/dev/nhpib.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: nhpib.c,v 1.7 1997/04/16 11:56:13 downsj Exp $ */
-/* $NetBSD: nhpib.c,v 1.16 1997/04/14 02:33:21 thorpej Exp $ */
+/* $OpenBSD: nhpib.c,v 1.8 1997/07/06 08:01:54 downsj Exp $ */
+/* $NetBSD: nhpib.c,v 1.17 1997/05/05 21:06:41 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -177,8 +177,7 @@ nhpibattach(parent, self, aux)
printf(" ipl %d: %s\n", ipl, desc);
/* Establish the interrupt handler. */
- (void) intr_establish(nhpibintr, sc, ipl, IPL_BIO);
- dmacomputeipl();
+ (void) dio_intr_establish(nhpibintr, sc, ipl, IPL_BIO);
ha.ha_ops = &nhpib_controller;
ha.ha_type = type; /* XXX */
diff --git a/sys/arch/hp300/dev/scsi.c b/sys/arch/hp300/dev/scsi.c
index 9197142c940..98bd898d591 100644
--- a/sys/arch/hp300/dev/scsi.c
+++ b/sys/arch/hp300/dev/scsi.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: scsi.c,v 1.9 1997/07/02 12:21:46 downsj Exp $ */
-/* $NetBSD: scsi.c,v 1.19 1997/04/14 02:33:22 thorpej Exp $ */
+/* $OpenBSD: scsi.c,v 1.10 1997/07/06 08:01:55 downsj Exp $ */
+/* $NetBSD: scsi.c,v 1.21 1997/05/05 21:08:26 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -55,6 +55,7 @@
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/intr.h>
+#include <machine/hp300spu.h>
#include <hp300/dev/dioreg.h>
#include <hp300/dev/diovar.h>
@@ -318,8 +319,7 @@ scsiattach(parent, self, aux)
hs->sc_regs = hd;
/* Establish the interrupt handler. */
- (void) intr_establish(scsiintr, hs, ipl, IPL_BIO);
- dmacomputeipl();
+ (void) dio_intr_establish(scsiintr, hs, ipl, IPL_BIO);
/* Reset the controller. */
scsireset(unit);
diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c
index ec0a5846610..e9bd3e8119a 100644
--- a/sys/arch/hp300/dev/sd.c
+++ b/sys/arch/hp300/dev/sd.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: sd.c,v 1.10 1997/04/16 11:56:15 downsj Exp $ */
-/* $NetBSD: sd.c,v 1.31 1997/04/02 22:37:36 scottr Exp $ */
+/* $OpenBSD: sd.c,v 1.11 1997/07/06 08:01:56 downsj Exp $ */
+/* $NetBSD: sd.c,v 1.33 1997/06/24 00:44:05 thorpej Exp $ */
/*
* Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -59,15 +59,18 @@
#include <hp300/dev/scsireg.h>
#include <hp300/dev/scsivar.h>
#include <hp300/dev/sdvar.h>
-#ifdef USELEDS
-#include <hp300/hp300/led.h>
-#endif
#include <vm/vm_param.h>
#include <vm/lock.h>
#include <vm/vm_prot.h>
#include <vm/pmap.h>
+#include "opt_useleds.h"
+
+#ifdef USELEDS
+#include <hp300/hp300/leds.h>
+#endif
+
/*
extern void disksort();
extern void biodone();
@@ -899,8 +902,7 @@ sdgo(arg)
sc->sc_stats.sdtransfers++;
}
#ifdef USELEDS
- if (inledcontrol == 0)
- ledcontrol(0, 0, LED_DISK);
+ ledcontrol(0, 0, LED_DISK);
#endif
if (scsigo(sc->sc_dev.dv_parent->dv_unit, sc->sc_target, sc->sc_lun,
bp, cmd, pad) == 0) {
@@ -1123,7 +1125,8 @@ sdsize(dev)
return(-1);
didopen = 1;
}
- psize = sc->sc_dkdev.dk_label->d_partitions[sdpart(dev)].p_size;
+ psize = sc->sc_dkdev.dk_label->d_partitions[sdpart(dev)].p_size *
+ (sc->sc_dkdev.dk_label->d_secsize / DEV_BSIZE);
if (didopen)
(void) sdclose(dev, FREAD|FWRITE, S_IFBLK, NULL);
return (psize);