summaryrefslogtreecommitdiff
path: root/sys/arch/hp300
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/hp300')
-rw-r--r--sys/arch/hp300/conf/DISKLESS17
-rw-r--r--sys/arch/hp300/conf/GENERIC17
-rw-r--r--sys/arch/hp300/conf/RAMDISK4
-rw-r--r--sys/arch/hp300/conf/files.hp30083
-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
-rw-r--r--sys/arch/hp300/hp300/autoconf.c6
-rw-r--r--sys/arch/hp300/hp300/clock.c5
-rw-r--r--sys/arch/hp300/hp300/conf.c13
-rw-r--r--sys/arch/hp300/hp300/db_memrw.c7
-rw-r--r--sys/arch/hp300/hp300/genassym.cf78
-rw-r--r--sys/arch/hp300/hp300/hpux_machdep.c137
-rw-r--r--sys/arch/hp300/hp300/intr.c19
-rw-r--r--sys/arch/hp300/hp300/kgdb_glue.c154
-rw-r--r--sys/arch/hp300/hp300/kgdb_machdep.c (renamed from sys/arch/hp300/hp300/kgdb_proto.h)96
-rw-r--r--sys/arch/hp300/hp300/kgdb_stub.c547
-rw-r--r--sys/arch/hp300/hp300/leds.c (renamed from sys/arch/hp300/include/mtpr.h)67
-rw-r--r--sys/arch/hp300/hp300/leds.h (renamed from sys/arch/hp300/hp300/led.h)10
-rw-r--r--sys/arch/hp300/hp300/locore.s945
-rw-r--r--sys/arch/hp300/hp300/machdep.c270
-rw-r--r--sys/arch/hp300/hp300/mem.c6
-rw-r--r--sys/arch/hp300/hp300/pmap.c14
-rw-r--r--sys/arch/hp300/hp300/pmap_bootstrap.c25
-rw-r--r--sys/arch/hp300/hp300/sys_machdep.c12
-rw-r--r--sys/arch/hp300/hp300/trap.c8
-rw-r--r--sys/arch/hp300/hp300/vectors.s176
-rw-r--r--sys/arch/hp300/hp300/vm_machdep.c27
-rw-r--r--sys/arch/hp300/include/cpu.h74
-rw-r--r--sys/arch/hp300/include/hp300spu.h143
-rw-r--r--sys/arch/hp300/include/hpux_machdep.h6
-rw-r--r--sys/arch/hp300/include/param.h91
-rw-r--r--sys/arch/hp300/include/pmap.h6
48 files changed, 2800 insertions, 2017 deletions
diff --git a/sys/arch/hp300/conf/DISKLESS b/sys/arch/hp300/conf/DISKLESS
index 038ecd0d569..b2f28c67b1c 100644
--- a/sys/arch/hp300/conf/DISKLESS
+++ b/sys/arch/hp300/conf/DISKLESS
@@ -1,4 +1,4 @@
-# $OpenBSD: DISKLESS,v 1.14 1997/02/24 01:16:06 downsj Exp $
+# $OpenBSD: DISKLESS,v 1.15 1997/07/06 08:01:41 downsj Exp $
# $NetBSD: GENERIC,v 1.23 1997/01/31 06:12:57 thorpej Exp $
#
# Generic kernel - one size fits all.
@@ -13,11 +13,15 @@ include "../../../conf/GENERIC"
option HP320
option HP330 # includes 318, 319
option HP340
+option HP345
option HP350
option HP360
option HP370
-option HP375 # includes 345, 400t, 400s
-option HP380 # includes 425t, 425s, 433s
+option HP375
+option HP380
+option HP400
+option HP425
+option HP433
# Need to set locally
maxusers 8
@@ -54,6 +58,13 @@ mainbus0 at root # root "bus"
intio0 at mainbus0 # internal i/o space
dio0 at mainbus0 # DIO/DIO-II bus
+# Frodo utility chip found on 4xx's
+frodo0 at intio?
+
+# 8250-like serial ports found on Frodo ASIC
+#dnkbd0 at frodo? offset 0x0 # Domain keyboard flavor
+apci* at frodo? offset ? # tty flavor
+
# Davinci framebuffer
dvbox* at intio?
dvbox* at dio? scode ?
diff --git a/sys/arch/hp300/conf/GENERIC b/sys/arch/hp300/conf/GENERIC
index 197df929ca3..00472befa90 100644
--- a/sys/arch/hp300/conf/GENERIC
+++ b/sys/arch/hp300/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.20 1997/04/17 08:21:54 downsj Exp $
+# $OpenBSD: GENERIC,v 1.21 1997/07/06 08:01:42 downsj Exp $
# $NetBSD: GENERIC,v 1.23 1997/01/31 06:12:57 thorpej Exp $
#
# Generic kernel - one size fits all.
@@ -13,11 +13,15 @@ include "../../../conf/GENERIC"
option HP320
option HP330 # includes 318, 319
option HP340
+option HP345
option HP350
option HP360
option HP370
-option HP375 # includes 345, 400t, 400s
-option HP380 # includes 425t, 425s, 433s
+option HP375
+option HP380
+option HP400
+option HP425
+option HP433
# Need to set locally
maxusers 32
@@ -54,6 +58,13 @@ mainbus0 at root # root "bus"
intio0 at mainbus0 # internal i/o space
dio0 at mainbus0 # DIO/DIO-II bus
+# Frodo utility chip found on 4xx's
+frodo0 at intio?
+
+# 8250-like serial ports found on Frodo ASIC
+#dnkbd0 at frodo? offset 0x0 # Domain keyboard flavor
+apci* at frodo? offset ? # tty flavor
+
# Davinci framebuffer
dvbox* at intio?
dvbox* at dio? scode ?
diff --git a/sys/arch/hp300/conf/RAMDISK b/sys/arch/hp300/conf/RAMDISK
index 8636f12a9f8..27ec677bbb3 100644
--- a/sys/arch/hp300/conf/RAMDISK
+++ b/sys/arch/hp300/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.3 1997/04/17 08:21:55 downsj Exp $
+# $OpenBSD: RAMDISK,v 1.4 1997/07/06 08:01:43 downsj Exp $
#
# Ram disk kernel.
#
@@ -19,7 +19,7 @@ option HP375 # includes 345, 400t, 400s
option HP380 # includes 425t, 425s, 433s
# Need to set locally
-maxusers 16
+maxusers 8
# Options for HP hardware
option FPSP # floating point interface for 68040
diff --git a/sys/arch/hp300/conf/files.hp300 b/sys/arch/hp300/conf/files.hp300
index fc63b482565..1f6fe815e06 100644
--- a/sys/arch/hp300/conf/files.hp300
+++ b/sys/arch/hp300/conf/files.hp300
@@ -1,5 +1,5 @@
-# $OpenBSD: files.hp300,v 1.9 1997/04/16 11:55:55 downsj Exp $
-# $NetBSD: files.hp300,v 1.25 1997/04/14 02:28:53 thorpej Exp $
+# $OpenBSD: files.hp300,v 1.10 1997/07/06 08:01:43 downsj Exp $
+# $NetBSD: files.hp300,v 1.28 1997/05/12 08:23:28 thorpej Exp $
#
# hp300-specific configuration info
@@ -8,9 +8,63 @@ maxpartitions 16
maxusers 2 8 64
+# SPU configuration options.
+defopt HP320
+defopt HP330
+defopt HP340
+defopt HP345
+defopt HP350
+defopt HP360
+defopt HP370
+defopt HP375
+defopt HP380
+defopt HP400
+defopt HP425
+defopt HP433
+
+# Misc. options.
+defopt USELEDS # make the lights twinkle
+
# NOTE! The order of these lines is significant! Don't change them
# unless you absolutely know what you're doing!
+#
+# Mainbus
+#
+
+device mainbus { }
+attach mainbus at root
+
+#
+# Internal i/o space
+#
+
+device intio { }
+attach intio at mainbus
+file arch/hp300/dev/intio.c intio
+
+#
+# DIO bus
+#
+
+device dio { scode = -1 }
+attach dio at mainbus
+file arch/hp300/dev/dio.c dio
+
+#
+# Devices in Internal i/o space
+#
+
+# Apollo Utilility Chip (a.k.a. "Frodo") found on 4xx workstations
+device frodo { offset = -1 }
+attach frodo at intio
+file arch/hp300/dev/frodo.c frodo
+
+# Apollo APCI 8250-like UARTs
+device apci
+attach apci at frodo
+file arch/hp300/dev/apci.c apci needs-flag
+
# Frame buffer attribute
define grfdev { }
@@ -42,21 +96,6 @@ attach ite at grf
file arch/hp300/dev/ite.c ite needs-flag
file arch/hp300/dev/ite_subr.c ite
-#
-# Mainbus
-#
-
-device mainbus { }
-attach mainbus at root
-
-#
-# Internal i/o space
-#
-
-device intio { }
-attach intio at mainbus
-file arch/hp300/dev/intio.c intio
-
# Internal i/o framebuffer attachments
attach dvbox at intio with dvbox_intio
attach gbox at intio with gbox_intio
@@ -64,13 +103,9 @@ attach rbox at intio with rbox_intio
attach topcat at intio with topcat_intio
#
-# DIO bus
+# Devices on the DIO bus
#
-device dio { scode = -1 }
-attach dio at mainbus
-file arch/hp300/dev/dio.c dio
-
# DIO framebuffer attachments
attach dvbox at dio with dvbox_dio
attach gbox at dio with gbox_dio
@@ -167,10 +202,10 @@ file arch/hp300/hp300/clock.c
file arch/hp300/hp300/conf.c
file arch/hp300/hp300/db_memrw.c ddb | kgdb
file arch/hp300/hp300/dkbad.c
-file arch/hp300/hp300/kgdb_glue.c kgdb compile-with "${NORMAL_C} -fno-defer-pop"
-file arch/hp300/hp300/kgdb_stub.c kgdb
+file arch/hp300/hp300/kgdb_machdep.c kgdb
file arch/hp300/hp300/machdep.c
file arch/hp300/hp300/intr.c
+file arch/hp300/hp300/leds.c useleds
file arch/hp300/hp300/mem.c
file arch/hp300/hp300/pmap.c
file arch/hp300/hp300/pmap_bootstrap.c
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);
diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c
index 131c2b7b810..c1ba6fc94a3 100644
--- a/sys/arch/hp300/hp300/autoconf.c
+++ b/sys/arch/hp300/hp300/autoconf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: autoconf.c,v 1.15 1997/04/16 11:56:20 downsj Exp $ */
-/* $NetBSD: autoconf.c,v 1.36 1997/04/14 02:28:43 thorpej Exp $ */
+/* $OpenBSD: autoconf.c,v 1.16 1997/07/06 08:01:57 downsj Exp $ */
+/* $NetBSD: autoconf.c,v 1.38 1997/05/05 21:11:59 thorpej Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -83,6 +83,7 @@
#include <machine/autoconf.h>
#include <machine/vmparam.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
#include <machine/intr.h>
#include <machine/pte.h>
@@ -258,7 +259,6 @@ configure()
*/
hilsoftinit(0, HILADDR);
hilinit(0, HILADDR);
- dmainit();
(void)splhigh();
if (config_rootfound("mainbus", "mainbus") == NULL)
diff --git a/sys/arch/hp300/hp300/clock.c b/sys/arch/hp300/hp300/clock.c
index 61d3ab2f263..ebc4609b7e4 100644
--- a/sys/arch/hp300/hp300/clock.c
+++ b/sys/arch/hp300/hp300/clock.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: clock.c,v 1.4 1997/04/16 11:56:21 downsj Exp $ */
-/* $NetBSD: clock.c,v 1.19 1997/04/01 03:12:09 scottr Exp $ */
+/* $OpenBSD: clock.c,v 1.5 1997/07/06 08:01:58 downsj Exp $ */
+/* $NetBSD: clock.c,v 1.20 1997/04/27 20:43:38 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -58,6 +58,7 @@
#include <machine/psl.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
#include <hp300/dev/hilreg.h>
#include <hp300/dev/hilioctl.h>
diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c
index f4d88b1a692..aaf9b2f3b3c 100644
--- a/sys/arch/hp300/hp300/conf.c
+++ b/sys/arch/hp300/hp300/conf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: conf.c,v 1.15 1997/04/16 11:56:21 downsj Exp $ */
-/* $NetBSD: conf.c,v 1.38 1997/04/01 03:12:10 scottr Exp $ */
+/* $OpenBSD: conf.c,v 1.16 1997/07/06 08:01:58 downsj Exp $ */
+/* $NetBSD: conf.c,v 1.39 1997/05/12 08:17:53 thorpej Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -125,6 +125,8 @@ cdev_decl(grf);
cdev_decl(ppi);
#include "dca.h"
cdev_decl(dca);
+#include "apci.h"
+cdev_decl(apci);
#include "ite.h"
cdev_decl(ite);
/* XXX shouldn't this be optional? */
@@ -188,6 +190,7 @@ struct cdevsw cdevsw[] =
cdev_random_init(1,random), /* 32: random generator */
cdev_gen_ipf(NIPF,ipl), /* 33: ip filtering */
cdev_disk_init(NRD,rd), /* 34: RAM disk */
+ cdev_tty_init(NAPCI,apci), /* 35: Apollo APCI UARTs */
};
int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
@@ -337,6 +340,9 @@ cons_decl(topcat);
#define dcacnpollc nullcnpollc
cons_decl(dca);
+#define apcicnpollc nullcnpollc
+cons_decl(apci);
+
#define dcmcnpollc nullcnpollc
cons_decl(dcm);
@@ -367,6 +373,9 @@ struct consdev constab[] = {
#if NDCA > 0
cons_init(dca),
#endif
+#if NAPCI > 0
+ cons_init(apci),
+#endif
#if NDCM > 0
cons_init(dcm),
#endif
diff --git a/sys/arch/hp300/hp300/db_memrw.c b/sys/arch/hp300/hp300/db_memrw.c
index 35f4804078e..047c47cedc2 100644
--- a/sys/arch/hp300/hp300/db_memrw.c
+++ b/sys/arch/hp300/hp300/db_memrw.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: db_memrw.c,v 1.2 1997/04/16 11:56:22 downsj Exp $ */
-/* $NetBSD: db_memrw.c,v 1.3 1997/04/01 03:12:12 scottr Exp $ */
+/* $OpenBSD: db_memrw.c,v 1.3 1997/07/06 08:01:58 downsj Exp $ */
+/* $NetBSD: db_memrw.c,v 1.5 1997/06/10 18:48:47 veego Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@
#include <machine/pte.h>
#include <machine/db_machdep.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
#include <ddb/db_access.h>
@@ -124,7 +125,7 @@ db_write_text(addr, size, data)
/*
* Get the VA for the page.
*/
- pgva = hp300_trunc_page((u_long)dst);
+ pgva = m68k_trunc_page((u_long)dst);
/*
* Save this destination address, for TLB
diff --git a/sys/arch/hp300/hp300/genassym.cf b/sys/arch/hp300/hp300/genassym.cf
index 28b9c3e3dfa..688ad58a771 100644
--- a/sys/arch/hp300/hp300/genassym.cf
+++ b/sys/arch/hp300/hp300/genassym.cf
@@ -1,5 +1,5 @@
-# $OpenBSD: genassym.cf,v 1.3 1997/04/17 10:28:35 downsj Exp $
-# $NetBSD: genassym.cf,v 1.5 1997/03/16 09:40:01 thorpej Exp $
+# $OpenBSD: genassym.cf,v 1.4 1997/07/06 08:01:59 downsj Exp $
+# $NetBSD: genassym.cf,v 1.8 1997/05/13 18:01:01 gwr Exp $
#
# Copyright (c) 1982, 1990, 1993
@@ -47,34 +47,13 @@ include <sys/user.h>
include <vm/vm.h>
+include <machine/hp300spu.h>
include <machine/cpu.h>
include <machine/psl.h>
include <machine/reg.h>
include <machine/pte.h>
include <hp300/hp300/clockreg.h>
-include <hp300/hp300/led.h>
-
-define __XXX_BUG_FODDER 0
-
-# CPU options
-ifdef M68020
-define M68020 1
-endif
-ifdef M68030
-define M68030 1
-endif
-ifdef M68040
-define M68040 1
-endif
-
-# MMU options
-ifdef M68K_MMU_MOTOROLA
-define M68K_MMU_MOTOROLA 1
-endif
-ifdef M68K_MMU_HP
-define M68K_MMU_HP 1
-endif
# values for mmutype
define MMU_68040 MMU_68040
@@ -82,32 +61,73 @@ define MMU_68030 MMU_68030
define MMU_HP MMU_HP
define MMU_68851 MMU_68851
+# MMU configuration options
+ifdef M68K_MMU_HP
+define M68K_MMU_HP 1
+endif
+ifdef M68K_MMU_MOTOROLA
+define M68K_MMU_MOTOROLA 1
+endif
+
# values for cputype
define CPU_68020 CPU_68020
define CPU_68030 CPU_68030
define CPU_68040 CPU_68040
+# CPU configuration options
+ifdef M68020
+define M68020 1
+endif
+ifdef M68030
+define M68030 1
+endif
+ifdef M68040
+define M68040 1
+endif
+
# values for fputype
define FPU_68881 FPU_68881
+define FPU_68882 FPU_68882
define FPU_68040 FPU_68040
# values for machineid
define HP_320 HP_320
define HP_330 HP_330
+define HP_340 HP_340
+define HP_345 HP_345
define HP_350 HP_350
define HP_360 HP_360
define HP_370 HP_370
-define HP_340 HP_340
define HP_375 HP_375
define HP_380 HP_380
+define HP_400 HP_400
define HP_425 HP_425
define HP_433 HP_433
+# values for mmuid
+define MMUID_345 MMUID_345
+define MMUID_375 MMUID_375
+define MMUID_425_T MMUID_425_T
+define MMUID_425_S MMUID_425_S
+define MMUID_433_T MMUID_433_T
+define MMUID_433_S MMUID_433_S
+
+define MMUID_SHIFT MMUID_SHIFT
+define MMUID_MASK MMUID_MASK
+
# values for ectype
define EC_PHYS EC_PHYS
define EC_NONE EC_NONE
define EC_VIRT EC_VIRT
+# Cache type configuration options
+ifdef CACHE_HAVE_VAC
+define CACHE_HAVE_VAC 1
+endif
+ifdef CACHE_HAVE_PAC
+define CACHE_HAVE_PAC 1
+endif
+
# general constants
define UPAGES UPAGES
define USPACE USPACE
@@ -130,7 +150,7 @@ define SSLEEP SSLEEP
define SRUN SRUN
# VM structure fields
-define VM_PMAP offsetof(struct vmspace, vm_pmap)
+define VM_PMAP offsetof(struct vmspace, vm_map.pmap)
define PM_STCHG offsetof(struct pmap, pm_stchanged)
# interrupt/fault metering
@@ -213,9 +233,3 @@ define ENAMETOOLONG ENAMETOOLONG
define CLKSR CLKSR
define CLKMSB1 CLKMSB1
define CLKMSB3 CLKMSB3
-
-# LED stuff
-define LED_PULSE LED_PULSE
-define LED_DISK LED_DISK
-define LED_LANRCV LED_LANRCV
-define LED_LANXMT LED_LANXMT
diff --git a/sys/arch/hp300/hp300/hpux_machdep.c b/sys/arch/hp300/hp300/hpux_machdep.c
index 712fc4d25fa..4be537be0db 100644
--- a/sys/arch/hp300/hp300/hpux_machdep.c
+++ b/sys/arch/hp300/hp300/hpux_machdep.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hpux_machdep.c,v 1.6 1997/04/17 10:28:36 downsj Exp $ */
-/* $NetBSD: hpux_machdep.c,v 1.12 1997/04/02 22:41:34 scottr Exp $ */
+/* $OpenBSD: hpux_machdep.c,v 1.7 1997/07/06 08:01:59 downsj Exp $ */
+/* $NetBSD: hpux_machdep.c,v 1.13 1997/04/27 21:38:57 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Jason R. Thorpe. All rights reserved.
@@ -58,7 +58,6 @@
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/namei.h>
-#include <sys/namei.h>
#include <sys/poll.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
@@ -79,13 +78,6 @@
#include <vm/vm_param.h>
#include <vm/vm_map.h>
-#include <arch/hp300/dev/grfreg.h>
-#include <arch/hp300/dev/grfioctl.h>
-#include <arch/hp300/dev/grfvar.h>
-#include <arch/hp300/dev/hilreg.h>
-#include <arch/hp300/dev/hilioctl.h>
-#include <arch/hp300/dev/hilvar.h>
-
#include <sys/syscallargs.h>
#include <compat/hpux/hpux.h>
@@ -98,51 +90,30 @@
extern short exframesize[];
-#define NHIL 1 /* XXX */
-#include "grf.h"
-
-#if NGRF > 0
-extern int grfopen __P((dev_t dev, int oflags, int devtype, struct proc *p));
-#endif
-
-#if NHIL > 0
-extern int hilopen __P((dev_t dev, int oflags, int devtype, struct proc *p));
-#endif
-
struct valtostr {
int val;
const char *str;
};
-static struct valtostr machine_table[] = {
- { HP_320, "320" },
- { HP_330, "330" }, /* includes 318 and 319 */
- { HP_340, "340" },
- { HP_350, "350" },
- { HP_360, "360" },
- { HP_370, "370" },
- { HP_375, "375" }, /* includes 345 and 400 */
- { HP_380, "380" },
- { HP_425, "425" },
- { HP_433, "433" },
- { -1, "3?0" }, /* unknown system (???) */
-};
-
/*
* 6.0 and later context.
* XXX what are the HP-UX "localroot" semantics? Should we handle
* XXX diskless systems here?
*/
+static const char context_040[] =
+ "standalone HP-MC68040 HP-MC68881 HP-MC68020 HP-MC68010 localroot default";
+
+static const char context_fpu[] =
+ "standalone HP-MC68881 HP-MC68020 HP-MC68010 localroot default";
+
+static const char context_nofpu[] =
+ "standalone HP-MC68020 HP-MC68010 localroot default";
+
static struct valtostr context_table[] = {
- { FPU_68040,
- "standalone HP-MC68040 HP-MC68881 HP-MC68020 HP-MC68010 localroot default"
- },
- { FPU_68881,
- "standalone HP-MC68881 HP-MC68020 HP-MC68010 localroot default"
- },
- { FPU_NONE,
- "standalone HP-MC68020 HP-MC68010 localroot default"
- },
+ { FPU_68060, &context_040[0] },
+ { FPU_68040, &context_040[0] },
+ { FPU_68882, &context_fpu[0] },
+ { FPU_68881, &context_fpu[0] },
{ 0, NULL },
};
@@ -158,7 +129,6 @@ struct bsdfp {
/*
* m68k-specific setup for HP-UX executables.
- * XXX m68k/m68k/hpux_machdep.c?
*/
int
hpux_cpu_makecmds(p, epp)
@@ -206,75 +176,21 @@ hpux_cpu_vmcmd(p, ev)
}
/*
- * Machine-dependent stat structure conversion.
- */
-void
-hpux_cpu_bsd_to_hpux_stat(sb, hsb)
- struct stat *sb;
- struct hpux_stat *hsb;
-{
-
- /* XXX I don't want to talk about it... */
- if ((sb->st_mode & S_IFMT) == S_IFCHR) {
-#if NGRF > 0
- if (cdevsw[major(sb->st_rdev)].d_open == grfopen)
- hsb->hst_rdev = grfdevno(sb->st_rdev);
-#endif
-#if NHIL > 0
- if (cdevsw[major(sb->st_rdev)].d_open == hilopen)
- hsb->hst_rdev = hildevno(sb->st_rdev);
-#endif
- }
-}
-
-/*
- * Machine-dependent uname information.
- */
-void
-hpux_cpu_uname(ut)
- struct hpux_utsname *ut;
-{
- int i;
-
- bzero(ut->machine, sizeof(ut->machine));
-
- /*
- * Find the current machine-ID in the table and
- * copy the string into the uname.
- */
- for (i = 0; machine_table[i].val != -1; ++i)
- if (machine_table[i].val == machineid)
- break;
-
- sprintf(ut->machine, "9000/%s", machine_table[i].str);
-}
-
-/*
* Return arch-type for hpux_sys_sysconf()
*/
int
hpux_cpu_sysconf_arch()
{
- switch (machineid) {
- case HP_320:
- case HP_330:
- case HP_350:
+ switch (cputype) {
+ case CPU_68020:
return (HPUX_SYSCONF_CPUM020);
- case HP_340:
- case HP_360:
- case HP_370:
- case HP_375:
+ case CPU_68030:
return (HPUX_SYSCONF_CPUM030);
- case HP_380:
- case HP_425:
- case HP_433:
- return (HPUX_SYSCONF_CPUM040);
-
default:
- return (HPUX_SYSCONF_CPUM020); /* ??? */
+ return (HPUX_SYSCONF_CPUM040);
}
/* NOTREACHED */
}
@@ -323,25 +239,24 @@ hpux_sys_getcontext(p, v, retval)
register_t *retval;
{
struct hpux_sys_getcontext_args *uap = v;
+ const char *str;
int l, i, error = 0;
int len;
for (i = 0; context_table[i].str != NULL; i++)
if (context_table[i].val == fputype)
break;
- if (context_table[i].str == NULL) {
- /*
- * XXX What else? It's not like this can happen...
- */
- return (EINVAL);
- }
+ if (context_table[i].str == NULL)
+ str = &context_nofpu[0];
+ else
+ str = context_table[i].str;
/* + 1 ... count the terminating \0. */
- l = strlen(context_table[i].str) + 1;
+ l = strlen(str) + 1;
len = min(SCARG(uap, len), l);
if (len)
- error = copyout(context_table[i].str, SCARG(uap, buf), len);
+ error = copyout(str, SCARG(uap, buf), len);
if (error == 0)
*retval = l;
return (0);
diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c
index 3785d3cb314..2b22c14cd80 100644
--- a/sys/arch/hp300/hp300/intr.c
+++ b/sys/arch/hp300/hp300/intr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: intr.c,v 1.1 1997/04/16 11:56:24 downsj Exp $ */
-/* $NetBSD: intr.c,v 1.1 1997/04/14 02:28:44 thorpej Exp $ */
+/* $OpenBSD: intr.c,v 1.2 1997/07/06 08:02:00 downsj Exp $ */
+/* $NetBSD: intr.c,v 1.2 1997/05/01 16:24:26 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -180,18 +180,9 @@ intr_establish(func, arg, ipl, priority)
* Some devices are particularly sensitive to interrupt
* handling latency. The DCA, for example, can lose many
* characters if its interrupt isn't handled with reasonable
- * speed.
- *
- * To work around this problem, each device can give itself a
- * "priority". An unbuffered DCA would give itself a higher
- * priority than a SCSI device, for example.
- *
- * This is necessary because of the flat spl scheme employed by
- * the hp300. Each device can be set from ipl 3 to ipl 5, which
- * in turn means that splbio, splnet, and spltty must all be at
- * spl5.
- *
- * Don't blame me...I just work here.
+ * speed. For this reason, we sort ISRs by IPL_* priority,
+ * inserting higher priority interrupts before lower priority
+ * interrupts.
*/
/*
diff --git a/sys/arch/hp300/hp300/kgdb_glue.c b/sys/arch/hp300/hp300/kgdb_glue.c
deleted file mode 100644
index 5b849e05fb4..00000000000
--- a/sys/arch/hp300/hp300/kgdb_glue.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* $OpenBSD: kgdb_glue.c,v 1.3 1997/04/16 11:56:26 downsj Exp $ */
-/* $NetBSD: kgdb_glue.c,v 1.3 1997/04/01 03:12:19 scottr Exp $ */
-
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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, Lawrence Berkeley Laboratories.
- *
- * 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.
- *
- * @(#)kgdb_glue.c 8.2 (Berkeley) 1/12/94
- */
-
-/*
- * This file must be compiled with gcc -fno-defer-pop.
- */
-
-#ifdef KGDB
-
-#include <sys/param.h>
-
-#include <machine/frame.h>
-#include <machine/reg.h>
-
-#ifndef lint
-static char rcsid[] = "$NetBSD: kgdb_glue.c,v 1.3 1997/04/01 03:12:19 scottr Exp $";
-#endif
-
-#define KGDB_STACKSIZE 0x800
-#define KGDB_STACKWORDS (KGDB_STACKSIZE / sizeof(u_long))
-
-u_long kgdb_stack[KGDB_STACKWORDS];
-
-#define getsp(v) asm("movl sp, %0" : "=r" (v))
-#define setsp(v) asm("movl %0, sp" :: "r" (v))
-
-static inline void
-copywords(src, dst, nbytes)
- u_long *src, *dst;
- u_int nbytes;
-{
- u_long *limit = src + (nbytes / sizeof(u_long));
-
- do {
- *dst++ = *src++;
- } while (src < limit);
- if (nbytes & 2)
- *(u_short *)dst = *(u_short *)src;
-}
-
-kgdb_trap_glue(type, frame)
- int type;
- struct frame frame;
-{
- u_long osp, nsp;
- u_int fsize, s;
- extern short exframesize[];
-
- /*
- * After a kernel mode trap, the saved sp doesn't point to the right
- * place. The correct value is the top of the frame (i.e. before the
- * KGDB trap).
- *
- * XXX this may have to change if we implement an interrupt stack.
- */
- fsize = sizeof(frame) - sizeof(frame.F_u) + exframesize[frame.f_format];
- frame.f_regs[SP] = (u_long)&frame + fsize;
-
- /*
- * Copy the interrupt context and frame to the new stack.
- * We're throwing away trap()'s frame since we're going to do
- * our own rte.
- */
- nsp = (u_long)&kgdb_stack[KGDB_STACKWORDS] -
- roundup(fsize, sizeof(u_long));
-
- copywords((u_long *)&frame, (u_long *)nsp, fsize);
-
- s = splhigh();
-
- getsp(osp);
- setsp(nsp);
-
- if (kgdb_trap(type, (struct frame *)nsp) == 0) {
- /*
- * Get back on kernel stack. This thread of control
- * will return back up through trap(). If kgdb_trap()
- * returns 0, it didn't handle the trap at all so
- * the stack is still intact and everything will
- * unwind okay from here up.
- */
- setsp(osp);
- splx(s);
- return 0;
- }
- /*
- * Copy back context, which has possibly changed. Even the
- * sp might have changed.
- */
- osp = ((struct frame *)nsp)->f_regs[SP] - fsize;
- copywords((u_long *)nsp, (u_long *)osp, fsize);
- setsp(osp);
-
- /*
- * Restore the possible new context from frame, pop the
- * unneeded usp (we trapped from kernel mode) and pad word,
- * and return to the trapped thread.
- */
- asm("moveml sp@+,#0x7FFF; addql #8,sp; rte");
-}
-
-int kgdb_testval;
-
-kgdb_test(i)
- int i;
-{
- ++kgdb_testval;
- return (i + 1);
-}
-#endif /* KGDB */
diff --git a/sys/arch/hp300/hp300/kgdb_proto.h b/sys/arch/hp300/hp300/kgdb_machdep.c
index f03ec8288e1..1dd59c0af13 100644
--- a/sys/arch/hp300/hp300/kgdb_proto.h
+++ b/sys/arch/hp300/hp300/kgdb_machdep.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: kgdb_proto.h,v 1.2 1997/01/12 15:13:19 downsj Exp $ */
-/* $NetBSD: kgdb_proto.h,v 1.2 1994/10/26 07:25:40 cgd Exp $ */
+/* $OpenBSD: kgdb_machdep.c,v 1.1 1997/07/06 08:02:01 downsj Exp $ */
+/* $NetBSD: kgdb_machdep.c,v 1.1 1997/05/05 20:51:05 thorpej Exp $ */
-/*-
- * Copyright (c) 1991, 1993
+/*
+ * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
@@ -42,28 +42,80 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)kgdb_proto.h 8.1 (Berkeley) 6/10/93
+ * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
+ */
+
+/*
+ * Machine-dependent part of the KGDB remote "stub"
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kgdb.h>
+
+#include <machine/db_machdep.h>
+#include <machine/pte.h>
+
+#define INVOKE_KGDB() __asm __volatile("trap #15")
+
+/*
+ * Determine if the memory at va..(va+len) is valid.
*/
+int
+kgdb_acc(va, ulen)
+ vm_offset_t va;
+ size_t ulen;
+{
+ int len, pgoff;
+ pt_entry_t *pte;
+
+ len = (int)ulen;
+ pgoff = va & PGOFSET;
+ va -= pgoff;
+ len += pgoff;
+
+ while (len > 0) {
+ pte = kvtopte(va);
+ if ((*pte & PG_V) == 0)
+ return (0);
+ va += NBPG;
+ len -= NBPG;
+ }
+
+ return (1);
+}
/*
- * Message types.
+ * Trap into kgdb to wait for debugger to connect,
+ * noting on the console why nothing else is going on.
*/
-#define KGDB_MEM_R 0x01
-#define KGDB_MEM_W 0x02
-#define KGDB_REG_R 0x03
-#define KGDB_REG_W 0x04
-#define KGDB_CONT 0x05
-#define KGDB_STEP 0x06
-#define KGDB_KILL 0x07
-#define KGDB_SIGNAL 0x08
-#define KGDB_EXEC 0x09
-
-#define KGDB_CMD(x) ((x) & 0x0f)
+void
+kgdb_connect(verbose)
+ int verbose;
+{
+
+ if (kgdb_dev < 0)
+ return;
+
+ if (verbose)
+ printf("kgdb waiting...");
+
+ INVOKE_KGDB();
+
+ if (verbose)
+ printf("connected.\n");
+
+ kgdb_debug_panic = 1;
+}
/*
- * Message flags.
+ * Decide what to do on panic.
*/
-#define KGDB_ACK 0x80
-#define KGDB_DELTA 0x40
-#define KGDB_MORE 0x20
-#define KGDB_SEQ 0x10
+void
+kgdb_panic()
+{
+ if (kgdb_dev >= 0 && kgdb_debug_panic) {
+ printf("entering kgdb\n");
+ INVOKE_KGDB();
+ }
+}
diff --git a/sys/arch/hp300/hp300/kgdb_stub.c b/sys/arch/hp300/hp300/kgdb_stub.c
deleted file mode 100644
index 891ecc407b2..00000000000
--- a/sys/arch/hp300/hp300/kgdb_stub.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/* $OpenBSD: kgdb_stub.c,v 1.3 1997/04/16 11:56:26 downsj Exp $ */
-/* $NetBSD: kgdb_stub.c,v 1.7 1997/04/01 03:12:20 scottr Exp $ */
-
-/*
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This software was developed by the Computer Systems Engineering group
- * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
- * contributed to Berkeley.
- *
- * 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, Lawrence Berkeley Laboratories.
- *
- * 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.
- *
- * @(#)kgdb_stub.c 8.4 (Berkeley) 1/12/94
- */
-
-/*
- * "Stub" to allow remote cpu to debug over a serial line using gdb.
- */
-#ifdef KGDB
-#ifndef lint
-static char rcsid[] = "$NetBSD: kgdb_stub.c,v 1.7 1997/04/01 03:12:20 scottr Exp $";
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <machine/trap.h>
-#include <machine/cpu.h>
-#include <machine/psl.h>
-#include <machine/reg.h>
-#include <machine/frame.h>
-
-#include <sys/buf.h>
-#include <hp/dev/cons.h>
-
-#include <hp300/hp300/kgdb_proto.h>
-#include <machine/remote-sl.h>
-
-extern int kernacc();
-extern void chgkprot();
-
-#ifndef KGDBDEV
-#define KGDBDEV NODEV
-#endif
-#ifndef KGDBRATE
-#define KGDBRATE 9600
-#endif
-
-dev_t kgdb_dev = KGDBDEV; /* remote debugging device (NODEV if none) */
-int kgdb_rate = KGDBRATE; /* remote debugging baud rate */
-int kgdb_active = 0; /* remote debugging active if != 0 */
-int kgdb_debug_init = 0; /* != 0 waits for remote at system init */
-int kgdb_debug_panic = 1; /* != 0 waits for remote on panic */
-int kgdb_debug = 0;
-
-#define GETC ((*kgdb_getc)(kgdb_dev))
-#define PUTC(c) ((*kgdb_putc)(kgdb_dev, c))
-#define PUTESC(c) { \
- if (c == FRAME_END) { \
- PUTC(FRAME_ESCAPE); \
- c = TRANS_FRAME_END; \
- } else if (c == FRAME_ESCAPE) { \
- PUTC(FRAME_ESCAPE); \
- c = TRANS_FRAME_ESCAPE; \
- } else if (c == FRAME_START) { \
- PUTC(FRAME_ESCAPE); \
- c = TRANS_FRAME_START; \
- } \
- PUTC(c); \
-}
-static int (*kgdb_getc)();
-static int (*kgdb_putc)();
-
-/*
- * Send a message. The host gets one chance to read it.
- */
-static void
-kgdb_send(type, bp, len)
- u_char type;
- u_char *bp;
- int len;
-{
- u_char csum;
- u_char *ep = bp + len;
-
- PUTC(FRAME_START);
- PUTESC(type);
-
- csum = type;
- while (bp < ep) {
- type = *bp++;
- csum += type;
- PUTESC(type)
- }
- csum = -csum;
- PUTESC(csum)
- PUTC(FRAME_END);
-}
-
-static int
-kgdb_recv(bp, lenp)
- u_char *bp;
- int *lenp;
-{
- u_char c, csum;
- int escape, len;
- int type;
-
-restart:
- csum = len = escape = 0;
- type = -1;
- while (1) {
- c = GETC;
- switch (c) {
-
- case FRAME_ESCAPE:
- escape = 1;
- continue;
-
- case TRANS_FRAME_ESCAPE:
- if (escape)
- c = FRAME_ESCAPE;
- break;
-
- case TRANS_FRAME_END:
- if (escape)
- c = FRAME_END;
- break;
-
- case TRANS_FRAME_START:
- if (escape)
- c = FRAME_START;
- break;
-
- case FRAME_START:
- goto restart;
-
- case FRAME_END:
- if (type < 0 || --len < 0) {
- csum = len = escape = 0;
- type = -1;
- continue;
- }
- if (csum != 0) {
- return (0);
- }
- *lenp = len;
- return type;
- }
- csum += c;
- if (type < 0) {
- type = c;
- escape = 0;
- continue;
- }
- if (++len > SL_RPCSIZE) {
- while (GETC != FRAME_END)
- ;
- return (0);
- }
- *bp++ = c;
- escape = 0;
- }
-}
-
-/*
- * Translate a trap number into a unix compatible signal value.
- * (gdb only understands unix signal numbers).
- */
-static int
-computeSignal(type)
- int type;
-{
- int sigval;
-
- switch (type) {
- case T_BUSERR:
- case T_ADDRERR:
- sigval = SIGBUS;
- break;
- case T_ILLINST:
- case T_PRIVINST:
- sigval = SIGILL;
- break;
- case T_ZERODIV:
- case T_CHKINST:
- case T_TRAPVINST:
- sigval = SIGFPE;
- break;
- case T_TRACE:
- sigval = SIGTRAP;
- break;
- case T_MMUFLT:
- sigval = SIGSEGV;
- break;
- case T_SSIR:
- sigval = SIGSEGV;
- break;
- case T_FMTERR:
- sigval = SIGILL;
- break;
- case T_FPERR:
- case T_COPERR:
- sigval = SIGFPE;
- break;
- case T_ASTFLT:
- sigval = SIGINT;
- break;
- case T_TRAP15:
- sigval = SIGTRAP;
- break;
- default:
- sigval = SIGEMT;
- break;
- }
- return (sigval);
-}
-
-/*
- * Trap into kgdb to wait for debugger to connect,
- * noting on the console why nothing else is going on.
- */
-kgdb_connect(verbose)
- int verbose;
-{
-
- if (verbose)
- printf("kgdb waiting...");
- /* trap into kgdb */
- asm("trap #15;");
- if (verbose)
- printf("connected.\n");
-}
-
-/*
- * Decide what to do on panic.
- */
-kgdb_panic()
-{
-
- if (kgdb_active == 0 && kgdb_debug_panic && kgdb_dev != NODEV)
- kgdb_connect(1);
-}
-
-/*
- * Definitions exported from gdb.
- */
-#define NUM_REGS 18
-#define REGISTER_BYTES ((16+2)*4)
-#define REGISTER_BYTE(N) ((N)*4)
-
-#define GDB_SR 16
-#define GDB_PC 17
-
-static inline void
-kgdb_copy(src, dst, nbytes)
- u_char *src, *dst;
- u_int nbytes;
-{
- u_char *ep = src + nbytes;
-
- while (src < ep)
- *dst++ = *src++;
-}
-
-/*
- * There is a short pad word between SP (A7) and SR which keeps the
- * kernel stack long word aligned (note that this is in addition to
- * the stack adjust short that we treat as the upper half of a longword
- * SR). We must skip this when copying into and out of gdb.
- */
-static inline void
-regs_to_gdb(fp, regs)
- struct frame *fp;
- u_long *regs;
-{
- kgdb_copy((u_char *)fp->f_regs, (u_char *)regs, 16*4);
- kgdb_copy((u_char *)&fp->f_stackadj, (u_char *)&regs[GDB_SR], 2*4);
-}
-
-static inline void
-gdb_to_regs(fp, regs)
- struct frame *fp;
- u_long *regs;
-{
- kgdb_copy((u_char *)regs, (u_char *)fp->f_regs, 16*4);
- kgdb_copy((u_char *)&regs[GDB_SR], (u_char *)&fp->f_stackadj, 2*4);
-}
-
-static u_long reg_cache[NUM_REGS];
-static u_char inbuffer[SL_RPCSIZE+1];
-static u_char outbuffer[SL_RPCSIZE];
-
-/*
- * This function does all command procesing for interfacing to
- * a remote gdb.
- */
-int
-kgdb_trap(type, frame)
- int type;
- struct frame *frame;
-{
- u_long len;
- u_char *addr;
- u_char *cp;
- u_char out, in;
- int outlen;
- int inlen;
- u_long gdb_regs[NUM_REGS];
-
- if ((int)kgdb_dev < 0) {
- /* not debugging */
- return (0);
- }
- if (kgdb_active == 0) {
- if (type != T_TRAP15) {
- /* No debugger active -- let trap handle this. */
- return (0);
- }
- kgdb_getc = 0;
- for (inlen = 0; constab[inlen].cn_probe; inlen++)
- if (major(constab[inlen].cn_dev) == major(kgdb_dev)) {
- kgdb_getc = constab[inlen].cn_getc;
- kgdb_putc = constab[inlen].cn_putc;
- break;
- }
- if (kgdb_getc == 0 || kgdb_putc == 0)
- return (0);
- /*
- * If the packet that woke us up isn't an exec packet,
- * ignore it since there is no active debugger. Also,
- * we check that it's not an ack to be sure that the
- * remote side doesn't send back a response after the
- * local gdb has exited. Otherwise, the local host
- * could trap into gdb if it's running a gdb kernel too.
- */
- in = GETC;
- /*
- * If we came in asynchronously through the serial line,
- * the framing character is eaten by the receive interrupt,
- * but if we come in through a synchronous trap (i.e., via
- * kgdb_connect()), we will see the extra character.
- */
- if (in == FRAME_START)
- in = GETC;
-
- /*
- * Check that this is a debugger exec message. If so,
- * slurp up the entire message then ack it, and fall
- * through to the recv loop.
- */
- if (KGDB_CMD(in) != KGDB_EXEC || (in & KGDB_ACK) != 0)
- return (0);
- while (GETC != FRAME_END)
- ;
- /*
- * Do the printf *before* we ack the message. This way
- * we won't drop any inbound characters while we're
- * doing the polling printf.
- */
- printf("kgdb started from device %x\n", kgdb_dev);
- kgdb_send(in | KGDB_ACK, (u_char *)0, 0);
- kgdb_active = 1;
- }
- /*
- * Stick frame regs into our reg cache then tell remote host
- * that an exception has occured.
- */
- regs_to_gdb(frame, gdb_regs);
- if (type != T_TRAP15) {
- /*
- * Only send an asynchronous SIGNAL message when we hit
- * a breakpoint. Otherwise, we will drop the incoming
- * packet while we output this one (and on entry the other
- * side isn't interested in the SIGNAL type -- if it is,
- * it will have used a signal packet.)
- */
- outbuffer[0] = computeSignal(type);
- kgdb_send(KGDB_SIGNAL, outbuffer, 1);
- }
-
- while (1) {
- in = kgdb_recv(inbuffer, &inlen);
- if (in == 0 || (in & KGDB_ACK))
- /* Ignore inbound acks and error conditions. */
- continue;
-
- out = in | KGDB_ACK;
- switch (KGDB_CMD(in)) {
-
- case KGDB_SIGNAL:
- /*
- * if this command came from a running gdb,
- * answer it -- the other guy has no way of
- * knowing if we're in or out of this loop
- * when he issues a "remote-signal". (Note
- * that without the length check, we could
- * loop here forever if the ourput line is
- * looped back or the remote host is echoing.)
- */
- if (inlen == 0) {
- outbuffer[0] = computeSignal(type);
- kgdb_send(KGDB_SIGNAL, outbuffer, 1);
- }
- continue;
-
- case KGDB_REG_R:
- case KGDB_REG_R | KGDB_DELTA:
- cp = outbuffer;
- outlen = 0;
- for (len = inbuffer[0]; len < NUM_REGS; ++len) {
- if (reg_cache[len] != gdb_regs[len] ||
- (in & KGDB_DELTA) == 0) {
- if (outlen + 5 > SL_MAXDATA) {
- out |= KGDB_MORE;
- break;
- }
- cp[outlen] = len;
- kgdb_copy((u_char *)&gdb_regs[len],
- &cp[outlen + 1], 4);
- reg_cache[len] = gdb_regs[len];
- outlen += 5;
- }
- }
- break;
-
- case KGDB_REG_W:
- case KGDB_REG_W | KGDB_DELTA:
- cp = inbuffer;
- for (len = 0; len < inlen; len += 5) {
- int j = cp[len];
-
- kgdb_copy(&cp[len + 1],
- (u_char *)&gdb_regs[j], 4);
- reg_cache[j] = gdb_regs[j];
- }
- gdb_to_regs(frame, gdb_regs);
- outlen = 0;
- break;
-
- case KGDB_MEM_R:
- len = inbuffer[0];
- kgdb_copy(&inbuffer[1], (u_char *)&addr, 4);
- if (len > SL_MAXDATA) {
- outlen = 1;
- outbuffer[0] = E2BIG;
- } else if (!kgdb_acc(addr, len, B_READ)) {
- outlen = 1;
- outbuffer[0] = EFAULT;
- } else {
- outlen = len + 1;
- outbuffer[0] = 0;
- kgdb_copy(addr, &outbuffer[1], len);
- }
- break;
-
- case KGDB_MEM_W:
- len = inlen - 4;
- kgdb_copy(inbuffer, (u_char *)&addr, 4);
- outlen = 1;
- if (!kgdb_acc(addr, len, B_READ))
- outbuffer[0] = EFAULT;
- else {
- outbuffer[0] = 0;
- if (!kgdb_acc(addr, len, B_WRITE))
- chgkprot(addr, len, B_WRITE);
- kgdb_copy(&inbuffer[4], addr, len);
- ICIA();
- }
- break;
-
- case KGDB_KILL:
- kgdb_active = 0;
- printf("kgdb detached\n");
- /* fall through */
- case KGDB_CONT:
- kgdb_send(out, 0, 0);
- frame->f_sr &=~ PSL_T;
- return (1);
-
- case KGDB_STEP:
- kgdb_send(out, 0, 0);
- frame->f_sr |= PSL_T;
- return (1);
-
- case KGDB_EXEC:
- default:
- /* Unknown command. Ack with a null message. */
- outlen = 0;
- break;
- }
- /* Send the reply */
- kgdb_send(out, outbuffer, outlen);
- }
-}
-
-/*
- * XXX do kernacc call if safe, otherwise attempt
- * to simulate by simple bounds-checking.
- */
-kgdb_acc(addr, len, rw)
- caddr_t addr;
- int len, rw;
-{
- extern char proc0paddr[], kstack[]; /* XXX */
- extern char *kernel_map; /* XXX! */
-
- if (kernel_map != NULL)
- return (kernacc(addr, len, rw));
- if (addr < proc0paddr + USPACE ||
- kstack <= addr && addr < kstack + USPACE)
- return (1);
- return (0);
-}
-#endif /* KGDB */
diff --git a/sys/arch/hp300/include/mtpr.h b/sys/arch/hp300/hp300/leds.c
index 98a81be12be..cea0cdb65eb 100644
--- a/sys/arch/hp300/include/mtpr.h
+++ b/sys/arch/hp300/hp300/leds.c
@@ -1,10 +1,10 @@
-/* $OpenBSD: mtpr.h,v 1.2 1997/01/12 15:13:37 downsj Exp $ */
-/* $NetBSD: mtpr.h,v 1.4 1994/10/26 07:26:29 cgd Exp $ */
+/* $OpenBSD: leds.c,v 1.1 1997/07/06 08:02:03 downsj Exp $ */
+/* $NetBSD: leds.c,v 1.1 1997/05/05 20:54:35 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
@@ -38,20 +38,61 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: Utah Hdr: mtpr.h 1.1 90/07/09
+ * from: Utah $Hdr: machdep.c 1.74 92/12/20$
*
- * @(#)mtpr.h 7.2 (Berkeley) 11/3/90
+ * @(#)machdep.c 8.10 (Berkeley) 4/20/94
*/
+#include <sys/param.h>
+
+#include <vm/vm.h>
+
+#include <arch/hp300/hp300/leds.h>
+
+extern caddr_t ledbase; /* kva of LED page */
+u_int8_t *ledaddr; /* actual address of LEDs */
+static int inledcontrol; /* mutex */
+
/*
- * simulated software interrupt register
+ * Map the LED page and setup the KVA to access it.
*/
+void
+ledinit()
+{
-extern unsigned char ssir;
+ pmap_enter(pmap_kernel(), (vm_offset_t)ledbase, (vm_offset_t)LED_ADDR,
+ VM_PROT_READ|VM_PROT_WRITE, TRUE);
+ ledaddr = (u_int8_t *) ((long)ledbase | (LED_ADDR & PGOFSET));
+}
+
+/*
+ * Do lights:
+ * `ons' is a mask of LEDs to turn on,
+ * `offs' is a mask of LEDs to turn off,
+ * `togs' is a mask of LEDs to toggle.
+ * Note we don't use splclock/splx for mutual exclusion.
+ * They are expensive and we really don't need to be that precise.
+ * Besides we would like to be able to profile this routine.
+ */
+void
+ledcontrol(ons, offs, togs)
+ int ons, offs, togs;
+{
+ static u_int8_t currentleds;
+ u_int8_t leds;
-#define SIR_NET 0x1
-#define SIR_CLOCK 0x2
+ if (inledcontrol)
+ return;
-#define siroff(x) ssir &= ~(x)
-#define setsoftnet() ssir |= SIR_NET
-#define setsoftclock() ssir |= SIR_CLOCK
+ inledcontrol = 1;
+ leds = currentleds;
+ if (ons)
+ leds |= ons;
+ if (offs)
+ leds &= ~offs;
+ if (togs)
+ leds ^= togs;
+ currentleds = leds;
+ *ledaddr = ~leds;
+ inledcontrol = 0;
+}
diff --git a/sys/arch/hp300/hp300/led.h b/sys/arch/hp300/hp300/leds.h
index b7d928b4f81..718e6206f7a 100644
--- a/sys/arch/hp300/hp300/led.h
+++ b/sys/arch/hp300/hp300/leds.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: led.h,v 1.2 1997/01/12 15:13:20 downsj Exp $ */
-/* $NetBSD: led.h,v 1.4 1996/10/05 09:18:22 thorpej Exp $ */
+/* $OpenBSD: leds.h,v 1.1 1997/07/06 08:02:03 downsj Exp $ */
+/* $NetBSD: leds.h,v 1.1 1997/05/05 20:54:36 thorpej Exp $ */
/*
* Copyright (c) 1992 University of Utah.
@@ -50,9 +50,7 @@
#define LED_DISK 0x20 /* for disk activity */
#define LED_PULSE 0x10 /* heartbeat */
-#ifdef _KERNEL
-extern char *ledaddr;
-extern int inledcontrol;
-
+#if defined(_KERNEL) && !defined(_LOCORE)
+void ledinit __P((void));
void ledcontrol __P((int, int, int));
#endif
diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s
index 6c0e4875bb7..93965188dee 100644
--- a/sys/arch/hp300/hp300/locore.s
+++ b/sys/arch/hp300/hp300/locore.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: locore.s,v 1.17 1997/04/17 12:02:32 downsj Exp $ */
-/* $NetBSD: locore.s,v 1.67 1997/03/16 10:49:43 thorpej Exp $ */
+/* $OpenBSD: locore.s,v 1.18 1997/07/06 08:02:04 downsj Exp $ */
+/* $NetBSD: locore.s,v 1.74 1997/05/13 18:01:03 gwr Exp $ */
/*
* Copyright (c) 1997 Theo de Raadt
@@ -74,18 +74,23 @@
*/
#include "assym.h"
+#include <machine/asm.h>
#include <machine/trap.h>
-#define MMUADDR(ar) movl _MMUbase,ar
-#define CLKADDR(ar) movl _CLKbase,ar
+#include "opt_useleds.h"
+#ifdef USELEDS
+#include <hp300/hp300/leds.h>
+#endif
+
+#define MMUADDR(ar) movl _C_LABEL(MMUbase),ar
+#define CLKADDR(ar) movl _C_LABEL(CLKbase),ar
/*
* This is for kvm_mkdb, and should be the address of the beginning
* of the kernel text segment (not necessarily the same as kernbase).
*/
.text
- .globl _kernel_text
-_kernel_text:
+GLOBAL(kernel_text)
/*
* Clear and skip the first page of text; it will not be mapped.
@@ -100,19 +105,20 @@ _kernel_text:
*/
.data
.space NBPG
-tmpstk:
+ASLOCAL(tmpstk)
#include <hp300/hp300/vectors.s>
- .text
-
/*
* Macro to relocate a symbol, used before MMU is enabled.
*/
-#define RELOC(var, ar) \
+#define _RELOC(var, ar) \
lea var,ar; \
addl a5,ar
+#define RELOC(var, ar) _RELOC(_C_LABEL(var), ar)
+#define ASRELOC(var, ar) _RELOC(_ASM_LABEL(var), ar)
+
/*
* Initialization
*
@@ -122,24 +128,21 @@ tmpstk:
* through ROM until MMU is turned on at which time they will vector
* through our table (vectors.s).
*/
- .comm _lowram,4
- .comm _esym,4
- .text
- .globl _edata
- .globl _etext,_end
- .globl start
-start:
+BSS(lowram,4)
+BSS(esym,4)
+
+ASENTRY_NOPROFILE(start)
movw #PSL_HIGHIPL,sr | no interrupts
- RELOC(tmpstk, a0)
+ ASRELOC(tmpstk, a0)
movl a0,sp | give ourselves a temporary stack
- RELOC(_esym, a0)
+ RELOC(esym, a0)
#if 1
movl a4,a0@ | store end of symbol table
#else
clrl a0@ | no symbol table, yet
#endif
- RELOC(_lowram, a0)
+ RELOC(lowram, a0)
movl a5,a0@ | store start of physical memory
movl #CACHE_OFF,d0
movc d0,cacr | clear and disable on-chip cache(s)
@@ -147,13 +150,13 @@ start:
/* check for internal HP-IB in SYSFLAG */
btst #5,0xfffffed2 | internal HP-IB?
jeq Lhaveihpib | yes, have HP-IB just continue
- RELOC(_internalhpib, a0)
+ RELOC(internalhpib, a0)
movl #0,a0@ | no, clear associated address
Lhaveihpib:
- RELOC(_boothowto, a0) | save reboot flags
+ RELOC(boothowto, a0) | save reboot flags
movl d7,a0@
- RELOC(_bootdev, a0) | and boot device
+ RELOC(bootdev, a0) | and boot device
movl d6,a0@
/*
@@ -169,11 +172,16 @@ Lhaveihpib:
movc cacr,d0 | read it back
tstl d0 | zero?
jeq Lnot68030 | yes, we have 68020/68040
- RELOC(_mmutype, a0) | no, we have 68030
+
+ /*
+ * 68030 models
+ */
+
+ RELOC(mmutype, a0) | no, we have 68030
movl #MMU_68030,a0@ | set to reflect 68030 PMMU
- RELOC(_cputype, a0)
+ RELOC(cputype, a0)
movl #CPU_68030,a0@ | and 68030 CPU
- RELOC(_machineid, a0)
+ RELOC(machineid, a0)
movl #0x80,a1@(MMUCMD) | set magic cookie
movl a1@(MMUCMD),d0 | read it back
btst #7,d0 | cookie still on?
@@ -190,17 +198,34 @@ Lnot370:
movl a1@(MMUCMD),d0 | read it back
btst #16,d0 | still on?
jeq Lstart1 | no, must be a 360
- movl #HP_375,a0@ | yes, must be a 345/375
- RELOC(_mmuid, a0)
- lsrl #8,d0 | get apparent ID
- movl d0,a0@ | save MMU ID
+ RELOC(mmuid, a0) | save MMU ID
+ lsrl #MMUID_SHIFT,d0
+ andl #MMUID_MASK,d0
+ movl d0,a0@
+ RELOC(machineid, a0)
+ cmpb #MMUID_345,d0 | are we a 345?
+ beq Lisa345
+ cmpb #MMUID_375,d0 | how about a 375?
+ beq Lisa375
+ movl #HP_400,a0@ | must be a 400
+ jra Lhaspac
+Lisa345:
+ movl #HP_345,a0@
+ jra Lhaspac
+Lisa375:
+ movl #HP_375,a0@
jra Lhaspac
Lisa370:
movl #HP_370,a0@ | set to 370
Lhaspac:
- RELOC(_ectype, a0)
+ RELOC(ectype, a0)
movl #EC_PHYS,a0@ | also has a physical address cache
jra Lstart1
+
+ /*
+ * End of 68030 section
+ */
+
Lnot68030:
bset #31,d0 | data cache enable bit
movc d0,cacr | only exists on 68040
@@ -209,59 +234,80 @@ Lnot68030:
beq Lis68020 | yes, we have 68020
moveq #0,d0 | now turn it back off
movec d0,cacr | before we access any data
- RELOC(_mmutype, a0)
+
+ /*
+ * 68040 models
+ */
+
+ RELOC(mmutype, a0)
movl #MMU_68040,a0@ | with a 68040 MMU
- RELOC(_cputype, a0)
+ RELOC(cputype, a0)
movl #CPU_68040,a0@ | and a 68040 CPU
- RELOC(_fputype, a0)
+ RELOC(fputype, a0)
movl #FPU_68040,a0@ | ...and FPU
- RELOC(_ectype, a0)
+ RELOC(ectype, a0)
movl #EC_NONE,a0@ | and no cache (for now XXX)
- RELOC(_mmuid, a0)
+ RELOC(mmuid, a0)
movl a1@(MMUCMD),d0 | read MMU register
- lsrl #8,d0 | get apparent ID
+ lsrl #MMUID_SHIFT,d0
+ andl #MMUID_MASK,d0
movl d0,a0@ | save MMU ID
- RELOC(_machineid, a0)
- cmpb #4,d0 | id == 4?
- jeq Lis33mhz | yes, a 33MHz Strider (433t)
- cmpb #6,d0 | id == 6?
- jeq Lis33mhz | yes, a 33MHz Trailways (433s)
- cmpb #5,d0 | id == 5?
- jeq Lis25mhz | yes, a 25MHz Strider (425t)
- cmpb #7,d0 | id == 7?
- jeq Lis25mhz | yes, a 25MHz Trailways (425s)
- movl #HP_380,a0@ | no, we have a 380
+ RELOC(machineid, a0)
+ cmpb #MMUID_425_T,d0 | are we a 425t?
+ jeq Lisa425
+ cmpb #MMUID_425_S,d0 | how about 425s?
+ jeq Lisa425
+ cmpb #MMUID_433_T,d0 | or a 433t?
+ jeq Lisa433
+ cmpb #MMUID_433_S,d0 | last chance...
+ jeq Lisa433
+ movl #HP_380,a0@ | guess we're a 380
jra Lstart1
-Lis25mhz:
- movl #HP_425,a0@ | 425 of some sort
+Lisa425:
+ movl #HP_425,a0@
jra Lstart1
-Lis33mhz:
- movl #HP_433,a0@ | 433 of some sort
+Lisa433:
+ movl #HP_433,a0@
jra Lstart1
+
+ /*
+ * End of 68040 section
+ */
+
+ /*
+ * 68020 models
+ */
+
Lis68020:
+ RELOC(fputype, a0) | all of the 68020 systems
+ movl #FPU_68881,a0@ | have a 68881 FPU
movl #1,a1@(MMUCMD) | a 68020, write HP MMU location
movl a1@(MMUCMD),d0 | read it back
btst #0,d0 | non-zero?
jne Lishpmmu | yes, we have HP MMU
- RELOC(_mmutype, a0)
+ RELOC(mmutype, a0)
movl #MMU_68851,a0@ | no, we have PMMU
- RELOC(_machineid, a0)
+ RELOC(machineid, a0)
movl #HP_330,a0@ | and 330 CPU
jra Lstart1
Lishpmmu:
- RELOC(_ectype, a0) | 320 or 350
+ RELOC(ectype, a0) | 320 or 350
movl #EC_VIRT,a0@ | both have a virtual address cache
movl #0x80,a1@(MMUCMD) | set magic cookie
movl a1@(MMUCMD),d0 | read it back
btst #7,d0 | cookie still on?
jeq Lis320 | no, just a 320
- RELOC(_machineid, a0)
+ RELOC(machineid, a0)
movl #HP_350,a0@ | yes, a 350
jra Lstart1
Lis320:
- RELOC(_machineid, a0)
+ RELOC(machineid, a0)
movl #HP_320,a0@
+ /*
+ * End of 68020 section
+ */
+
Lstart1:
movl #0,a1@(MMUCMD) | clear out MMU again
/* initialize source/destination control registers for movs */
@@ -272,21 +318,21 @@ Lstart1:
movl #MAXADDR,d1 | last page
moveq #PGSHIFT,d2
lsrl d2,d1 | convert to page (click) number
- RELOC(_maxmem, a0)
+ RELOC(maxmem, a0)
movl d1,a0@ | save as maxmem
movl a5,d0 | lowram value from ROM via boot
lsrl d2,d0 | convert to page number
subl d0,d1 | compute amount of RAM present
- RELOC(_physmem, a0)
+ RELOC(physmem, a0)
movl d1,a0@ | and physmem
+
/* configure kernel and proc0 VA space so we can get going */
- .globl _Sysseg, _pmap_bootstrap, _avail_start
#ifdef DDB
- RELOC(_esym,a0) | end of static kernel test/data/syms
+ RELOC(esym,a0) | end of static kernel test/data/syms
movl a0@,d5
jne Lstart2
#endif
- movl #_end,d5 | end of static kernel text/data
+ movl #_C_LABEL(end),d5 | end of static kernel text/data
Lstart2:
addl #NBPG-1,d5
andl #PG_FRAME,d5 | round to a page
@@ -294,7 +340,7 @@ Lstart2:
addl a5,a4 | convert to PA
pea a5@ | firstpa
pea a4@ | nextpa
- RELOC(_pmap_bootstrap,a0)
+ RELOC(pmap_bootstrap,a0)
jbsr a0@ | pmap_bootstrap(firstpa, nextpa)
addql #8,sp
@@ -308,10 +354,10 @@ Lstart2:
*
* Is this all really necessary, or am I paranoid??
*/
- RELOC(_Sysseg, a0) | system segment table addr
+ RELOC(Sysseg, a0) | system segment table addr
movl a0@,d1 | read value (a KVA)
addl a5,d1 | convert to PA
- RELOC(_mmutype, a0)
+ RELOC(mmutype, a0)
tstl a0@ | HP MMU?
jeq Lhpmmu2 | yes, skip
cmpl #MMU_68040,a0@ | 68040?
@@ -319,7 +365,7 @@ Lstart2:
.long 0x4e7b1807 | movc d1,srp
jra Lstploaddone
Lmotommu1:
- RELOC(_protorp, a0)
+ RELOC(protorp, a0)
movl #0x80000202,a0@ | nolimit + share global + 4 byte PTEs
movl d1,a0@(4) | + segtable address
pmove a0@,srp | load the supervisor root pointer
@@ -331,8 +377,8 @@ Lhpmmu2:
movl d1,INTIOBASE+MMUBASE+MMUSSTP | load in sysseg table register
Lstploaddone:
lea MAXADDR,a2 | PA of last RAM page
- RELOC(Lhighcode, a1) | addr of high code
- RELOC(Lehighcode, a3) | end addr
+ ASRELOC(Lhighcode, a1) | addr of high code
+ ASRELOC(Lehighcode, a3) | end addr
Lcodecopy:
movw a1@+,a2@+ | copy a word
cmpl a3,a1 | done yet?
@@ -350,10 +396,10 @@ Lhighcode:
* Set up the vector table, and race to get the MMU
* enabled.
*/
- movl #_vectab,d0 | set Vector Base Register
+ movl #_C_LABEL(vectab),d0 | set Vector Base Register
movc d0,vbr
- RELOC(_mmutype, a0)
+ RELOC(mmutype, a0)
tstl a0@ | HP MMU?
jeq Lhpmmu3 | yes, skip
cmpl #MMU_68040,a0@ | 68040?
@@ -376,7 +422,7 @@ Lhighcode:
Lmotommu2:
movl #MMU_IEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD
| enable 68881 and i-cache
- RELOC(_prototc, a2)
+ RELOC(prototc, a2)
movl #0x82c0aa00,a2@ | value to load TC with
pmove a2@,tc | load it
jmp Lenab1
@@ -395,38 +441,38 @@ Lehighcode:
*/
Lenab1:
/* select the software page size now */
- lea tmpstk,sp | temporary stack
- jbsr _vm_set_page_size | select software page size
+ lea _ASM_LABEL(tmpstk),sp | temporary stack
+ jbsr _C_LABEL(vm_set_page_size) | select software page size
/* set kernel stack, user SP, and initial pcb */
- movl _proc0paddr,a1 | get proc0 pcb addr
+ movl _C_LABEL(proc0paddr),a1 | get proc0 pcb addr
lea a1@(USPACE-4),sp | set kernel stack to end of area
- lea _proc0,a2 | initialize proc0.p_addr so that
+ lea _C_LABEL(proc0),a2 | initialize proc0.p_addr so that
movl a1,a2@(P_ADDR) | we don't deref NULL in trap()
movl #USRSTACK-4,a2
movl a2,usp | init user SP
- movl a1,_curpcb | proc0 is running
+ movl a1,_C_LABEL(curpcb) | proc0 is running
- tstl _fputype | Have an FPU?
+ tstl _C_LABEL(fputype) | Have an FPU?
jeq Lenab2 | No, skip.
clrl a1@(PCB_FPCTX) | ensure null FP context
movl a1,sp@-
- jbsr _m68881_restore | restore it (does not kill a1)
+ jbsr _C_LABEL(m68881_restore) | restore it (does not kill a1)
addql #4,sp
Lenab2:
/* flush TLB and turn on caches */
- jbsr _TBIA | invalidate TLB
- cmpl #MMU_68040,_mmutype | 68040?
+ jbsr _C_LABEL(TBIA) | invalidate TLB
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jeq Lnocache0 | yes, cache already on
movl #CACHE_ON,d0
movc d0,cacr | clear cache(s)
- tstl _ectype
+ tstl _C_LABEL(ectype)
jeq Lnocache0
MMUADDR(a0)
orl #MMU_CEN,a0@(MMUCMD) | turn on external cache
Lnocache0:
/* Final setup for call to main(). */
- jbsr _intr_init | initialize interrupt handlers
- jbsr _hp300_calibrate_delay | calibrate delay() loop
+ jbsr _C_LABEL(intr_init) | initialize interrupt handlers
+ jbsr _C_LABEL(hp300_calibrate_delay) | calibrate delay() loop
/*
* Create a fake exception frame so that cpu_fork() can copy it.
@@ -438,20 +484,14 @@ Lnocache0:
movw #PSL_USER,sp@- | in user mode
clrl sp@- | stack adjust count and padding
lea sp@(-64),sp | construct space for D0-D7/A0-A7
- lea _proc0,a0 | save pointer to frame
+ lea _C_LABEL(proc0),a0 | save pointer to frame
movl sp,a0@(P_MD_REGS) | in proc0.p_md.md_regs
- jra _main | main()
-
- pea Lmainreturned | Yow! Main returned!
- jbsr _panic
+ jra _C_LABEL(main) | main()
+ PANIC("main() returned")
/* NOTREACHED */
-Lmainreturned:
- .asciz "main() returned"
- .even
- .globl _proc_trampoline
-_proc_trampoline:
+GLOBAL(proc_trampoline)
movl a3,sp@-
jbsr a2@
addql #4,sp
@@ -459,29 +499,29 @@ _proc_trampoline:
movl a0,usp | user SP
moveml sp@+,#0x7FFF | restore most user regs
addql #8,sp | toss SP and stack adjust
- jra rei | and return
+ jra _ASM_LABEL(rei) | and return
/*
* Trap/interrupt vector routines
*/
+#include <m68k/m68k/trap_subr.s>
- .globl _trap, _nofault, _longjmp
-_buserr:
+ENTRY_NOPROFILE(buserr)
/*
* XXX TODO: look at the mac68k _buserr and generalize
* XXX the saving of the fault address so this routine
* XXX can be shared.
*/
- tstl _nofault | device probe?
+ tstl _C_LABEL(nofault) | device probe?
jeq Lberr | no, handle as usual
- movl _nofault,sp@- | yes,
- jbsr _longjmp | longjmp(nofault)
+ movl _C_LABEL(nofault),sp@- | yes,
+ jbsr _C_LABEL(longjmp) | longjmp(nofault)
Lberr:
#if defined(M68040)
#if defined(M68020) || defined(M68030)
- cmpl #MMU_68040,_mmutype | 68040?
- jne _addrerr | no, skip
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
+ jne _C_LABEL(addrerr) | no, skip
#endif
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save user registers
@@ -509,7 +549,8 @@ Lberr2:
movw d0,sp@ | save (ONLY LOW 16 BITS!)
jra Lismerr
#endif
-_addrerr:
+
+ENTRY_NOPROFILE(addrerr)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save user registers
movl usp,a0 | save the user SP
@@ -517,7 +558,7 @@ _addrerr:
lea sp@(FR_HW),a1 | grab base of HW berr frame
#if defined(M68040)
#if defined(M68020) || defined(M68030)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lbenot040 | no, skip
#endif
movl a1@(8),sp@- | yes, push fault address
@@ -568,7 +609,7 @@ Lbe10:
jeq Lisaerr | yes, go to it
#if defined(M68K_MMU_MOTOROLA)
#if defined(M68K_MMU_HP)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lbehpmmu | yes, skip
#endif
movl d1,a0 | fault address
@@ -609,49 +650,28 @@ Lbehpmmu:
#endif
Lismerr:
movl #T_MMUFLT,sp@- | show that we are an MMU fault
- jra Ltrapnstkadj | and deal with it
+ jra _ASM_LABEL(faultstkadj) | and deal with it
Lisaerr:
movl #T_ADDRERR,sp@- | mark address error
- jra Ltrapnstkadj | and deal with it
+ jra _ASM_LABEL(faultstkadj) | and deal with it
Lisberr1:
clrw sp@ | re-clear pad word
Lisberr:
movl #T_BUSERR,sp@- | mark bus error
-Ltrapnstkadj:
- jbsr _trap | handle the error
- lea sp@(12),sp | pop value args
- movl sp@(FR_SP),a0 | restore user SP
- movl a0,usp | from save area
- movw sp@(FR_ADJ),d0 | need to adjust stack?
- jne Lstkadj | yes, go to it
- moveml sp@+,#0x7FFF | no, restore most user regs
- addql #8,sp | toss SSP and stkadj
- jra rei | all done
-Lstkadj:
- lea sp@(FR_HW),a1 | pointer to HW frame
- addql #8,a1 | source pointer
- movl a1,a0 | source
- addw d0,a0 | + hole size = dest pointer
- movl a1@-,a0@- | copy
- movl a1@-,a0@- | 8 bytes
- movl a0,sp@(FR_SP) | new SSP
- moveml sp@+,#0x7FFF | restore user registers
- movl sp@,sp | and our SP
- jra rei | all done
+ jra _ASM_LABEL(faultstkadj) | and deal with it
/*
* FP exceptions.
*/
-_fpfline: /* XXXthorpej - candidate for vector patch */
+ENTRY_NOPROFILE(fpfline)
#if defined(M68040)
- cmpl #FPU_68040,_fputype | 68040 FPU?
+ cmpl #FPU_68040,_C_LABEL(fputype) | 68040 FPU?
jne Lfp_unimp | no, skip FPSP
cmpw #0x202c,sp@(6) | format type 2?
- jne _illinst | no, not an FP emulation
+ jne _C_LABEL(illinst) | no, not an FP emulation
Ldofp_unimp:
#ifdef FPSP
- .globl fpsp_unimp
- jmp fpsp_unimp | yes, go handle it
+ jmp _ASM_LABEL(fpsp_unimp) | yes, go handle it
#endif
Lfp_unimp:
#endif /* M68040 */
@@ -659,18 +679,17 @@ Lfp_unimp:
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save registers
moveq #T_FPEMULI,d0 | denote as FP emulation trap
- jra fault | do it
+ jra _ASM_LABEL(fault) | do it
#else
- jra _illinst
+ jra _C_LABEL(illinst)
#endif
-_fpunsupp: /* XXXthorpej - candidate for vector patch */
+ENTRY_NOPROFILE(fpunsupp)
#if defined(M68040)
- cmpl #FPU_68040,_fputype | 68040 FPU?
- jne _illinst | no, treat as illinst
+ cmpl #FPU_68040,_C_LABEL(fputype) | 68040 FPU?
+ jne _C_LABEL(illinst) | no, treat as illinst
#ifdef FPSP
- .globl fpsp_unsupp
- jmp fpsp_unsupp | yes, go handle it
+ jmp _ASM_LABEL(fpsp_unsupp) | yes, go handle it
#endif
Lfp_unsupp:
#endif /* M68040 */
@@ -678,9 +697,9 @@ Lfp_unsupp:
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save registers
moveq #T_FPEMULD,d0 | denote as FP emulation trap
- jra fault | do it
+ jra _ASM_LABEL(fault) | do it
#else
- jra _illinst
+ jra _C_LABEL(illinst)
#endif
/*
@@ -689,19 +708,18 @@ Lfp_unsupp:
* and may cause signal delivery, we need to test for stack adjustment
* after the trap call.
*/
- .globl _fpfault
-_fpfault:
+ENTRY_NOPROFILE(fpfault)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save user registers
movl usp,a0 | and save
movl a0,sp@(FR_SP) | the user stack pointer
clrl sp@- | no VA arg
- movl _curpcb,a0 | current pcb
+ movl _C_LABEL(curpcb),a0 | current pcb
lea a0@(PCB_FPCTX),a0 | address of FP savearea
fsave a0@ | save state
#if defined(M68040) || defined(M68060)
/* always null state frame on 68040, 68060 */
- cmpl #CPU_68040,_cputype
+ cmpl #CPU_68040,_C_LABEL(cputype)
jle Lfptnull
#endif
tstb a0@ | null state frame?
@@ -713,108 +731,37 @@ Lfptnull:
fmovem fpsr,sp@- | push fpsr as code argument
frestore a0@ | restore state
movl #T_FPERR,sp@- | push type arg
- jra Ltrapnstkadj | call trap and deal with stack cleanup
-
-/*
- * Coprocessor and format errors can generate mid-instruction stack
- * frames and cause signal delivery hence we need to check for potential
- * stack adjustment.
- */
-_coperr:
- clrl sp@- | stack adjust count
- moveml #0xFFFF,sp@-
- movl usp,a0 | get and save
- movl a0,sp@(FR_SP) | the user stack pointer
- clrl sp@- | no VA arg
- clrl sp@- | or code arg
- movl #T_COPERR,sp@- | push trap type
- jra Ltrapnstkadj | call trap and deal with stack adjustments
-
-_fmterr:
- clrl sp@- | stack adjust count
- moveml #0xFFFF,sp@-
- movl usp,a0 | get and save
- movl a0,sp@(FR_SP) | the user stack pointer
- clrl sp@- | no VA arg
- clrl sp@- | or code arg
- movl #T_FMTERR,sp@- | push trap type
- jra Ltrapnstkadj | call trap and deal with stack adjustments
+ jra _ASM_LABEL(faultstkadj) | call trap and deal with stack cleanup
/*
* Other exceptions only cause four and six word stack frame and require
* no post-trap stack adjustment.
*/
-_illinst:
- clrl sp@-
- moveml #0xFFFF,sp@-
- moveq #T_ILLINST,d0
- jra fault
-
-_zerodiv:
- clrl sp@-
- moveml #0xFFFF,sp@-
- moveq #T_ZERODIV,d0
- jra fault
-
-_chkinst:
- clrl sp@-
- moveml #0xFFFF,sp@-
- moveq #T_CHKINST,d0
- jra fault
-
-_trapvinst:
- clrl sp@-
- moveml #0xFFFF,sp@-
- moveq #T_TRAPVINST,d0
- jra fault
-_privinst:
- clrl sp@-
- moveml #0xFFFF,sp@-
- moveq #T_PRIVINST,d0
- jra fault
-
- .globl fault
-fault:
- movl usp,a0 | get and save
- movl a0,sp@(FR_SP) | the user stack pointer
- clrl sp@- | no VA arg
- clrl sp@- | or code arg
- movl d0,sp@- | push trap type
- jbsr _trap | handle trap
- lea sp@(12),sp | pop value args
- movl sp@(FR_SP),a0 | restore
- movl a0,usp | user SP
- moveml sp@+,#0x7FFF | restore most user regs
- addql #8,sp | pop SP and stack adjust
- jra rei | all done
-
- .globl _straytrap
-_badtrap:
+ENTRY_NOPROFILE(badtrap)
moveml #0xC0C0,sp@- | save scratch regs
movw sp@(22),sp@- | push exception vector info
clrw sp@-
movl sp@(22),sp@- | and PC
- jbsr _straytrap | report
+ jbsr _C_LABEL(straytrap) | report
addql #8,sp | pop args
moveml sp@+,#0x0303 | restore regs
- jra rei | all done
+ jra _ASM_LABEL(rei) | all done
- .globl _syscall
-_trap0:
+ENTRY_NOPROFILE(trap0)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save user registers
movl usp,a0 | save the user SP
movl a0,sp@(FR_SP) | in the savearea
movl d0,sp@- | push syscall number
- jbsr _syscall | handle it
+ jbsr _C_LABEL(syscall) | handle it
addql #4,sp | pop syscall arg
- tstl _astpending
+ tstl _C_LABEL(astpending)
jne Lrei2
- tstb _ssir
+ tstb _C_LABEL(ssir)
jeq Ltrap1
movw #SPL1,sr
- tstb _ssir
+ tstb _C_LABEL(ssir)
jne Lsir1
Ltrap1:
movl sp@(FR_SP),a0 | grab and restore
@@ -826,41 +773,40 @@ Ltrap1:
/*
* Trap 1 - sigreturn
*/
-_trap1:
- jra sigreturn
+ENTRY_NOPROFILE(trap1)
+ jra _ASM_LABEL(sigreturn)
/*
* Trap 2 - trace trap
*/
-_trap2:
- jra _trace
+ENTRY_NOPROFILE(trap2)
+ jra _C_LABEL(trace)
/*
* Trap 12 is the entry point for the cachectl "syscall" (both HPUX & BSD)
* cachectl(command, addr, length)
* command in d0, addr in a1, length in d1
*/
- .globl _cachectl
-_trap12:
+ENTRY_NOPROFILE(trap12)
movl d1,sp@- | push length
movl a1,sp@- | push addr
movl d0,sp@- | push command
- jbsr _cachectl | do it
+ jbsr _C_LABEL(cachectl) | do it
lea sp@(12),sp | pop args
- jra rei | all done
+ jra _ASM_LABEL(rei) | all done
/*
* Trace (single-step) trap. Kernel-mode is special.
* User mode traps are simply passed on to trap().
*/
-_trace:
+ENTRY_NOPROFILE(trace)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
movw sp@(FR_HW),d1 | get PSW
andw #PSL_S,d1 | from system mode?
- jne kbrkpt | yes, kernel breakpoint
- jra fault | no, user-mode fault
+ jne Lkbrkpt | yes, kernel breakpoint
+ jra _ASM_LABEL(fault) | no, user-mode fault
/*
* Trap 15 is used for:
@@ -869,16 +815,16 @@ _trace:
* - trace traps for SUN binaries (not fully supported yet)
* User mode traps are simply passed to trap().
*/
-_trap15:
+ENTRY_NOPROFILE(trap15)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRAP15,d0
movw sp@(FR_HW),d1 | get PSW
andw #PSL_S,d1 | from system mode?
- jne kbrkpt | yes, kernel breakpoint
- jra fault | no, user-mode fault
+ jne Lkbrkpt | yes, kernel breakpoint
+ jra _ASM_LABEL(fault) | no, user-mode fault
-kbrkpt: | Kernel-mode breakpoint or trace trap. (d0=trap_type)
+Lkbrkpt: | Kernel-mode breakpoint or trace trap. (d0=trap_type)
| Save the system sp rather than the user sp.
movw #PSL_HIGHIPL,sr | lock out interrupts
lea sp@(FR_SIZE),a6 | Save stack pointer
@@ -887,11 +833,11 @@ kbrkpt: | Kernel-mode breakpoint or trace trap. (d0=trap_type)
| If were are not on tmpstk switch to it.
| (so debugger can change the stack pointer)
movl a6,d1
- cmpl #tmpstk,d1
+ cmpl #_ASM_LABEL(tmpstk),d1
jls Lbrkpt2 | already on tmpstk
| Copy frame to the temporary stack
movl sp,a0 | a0=src
- lea tmpstk-96,a1 | a1=dst
+ lea _ASM_LABEL(tmpstk)-96,a1 | a1=dst
movl a1,sp | sp=new frame
moveq #FR_SIZE,d1
Lbrkpt1:
@@ -913,7 +859,7 @@ Lbrkpt2:
| Let KGDB handle it (if connected)
movl a2,sp@- | push frame ptr
movl d2,sp@- | push trap type
- jbsr _kgdb_trap | handle the trap
+ jbsr _C_LABEL(kgdb_trap) | handle the trap
addql #8,sp | pop args
cmpl #0,d0 | did kgdb handle it?
jne Lbrkpt3 | yes, done
@@ -922,7 +868,7 @@ Lbrkpt2:
| Let DDB handle it
movl a2,sp@- | push frame ptr
movl d2,sp@- | push trap type
- jbsr _kdb_trap | handle the trap
+ jbsr _C_LABEL(kdb_trap) | handle the trap
addql #8,sp | pop args
#if 0 /* not needed on hp300 */
cmpl #0,d0 | did ddb handle it?
@@ -958,33 +904,29 @@ Lbrkpt3:
#define INTERRUPT_SAVEREG moveml #0xC0C0,sp@-
#define INTERRUPT_RESTOREREG moveml sp@+,#0x0303
- /* Externs. */
- .globl _hilint, _intr_dispatch, _nmihand
- .globl _hardclock, _statintr
+ENTRY_NOPROFILE(spurintr) /* level 0 */
+ addql #1,_C_LABEL(intrcnt)+0
+ addql #1,_C_LABEL(cnt)+V_INTR
+ jra _ASM_LABEL(rei)
-_spurintr: /* Level 0 */
- addql #1,_intrcnt+0
- addql #1,_cnt+V_INTR
- jra rei
-
-_lev1intr: /* Level 1: HIL XXX this needs to go away */
+ENTRY_NOPROFILE(lev1intr) /* level 1: HIL XXX this needs to go away */
INTERRUPT_SAVEREG
- jbsr _hilint
+ jbsr _C_LABEL(hilint)
INTERRUPT_RESTOREREG
- addql #1,_intrcnt+4
- addql #1,_cnt+V_INTR
- jra rei
+ addql #1,_C_LABEL(intrcnt)+4
+ addql #1,_C_LABEL(cnt)+V_INTR
+ jra _ASM_LABEL(rei)
-_intrhand: /* Levels 2 through 5 */
+ENTRY_NOPROFILE(intrhand) /* levels 2 through 5 */
INTERRUPT_SAVEREG
movw sp@(22),sp@- | push exception vector info
clrw sp@-
- jbsr _intr_dispatch | call dispatch routine
+ jbsr _C_LABEL(intr_dispatch) | call dispatch routine
addql #4,sp
INTERRUPT_RESTOREREG
- jra rei | all done
+ jra _ASM_LABEL(rei) | all done
-_lev6intr: /* Level 6: clock */
+ENTRY_NOPROFILE(lev6intr) /* level 6: clock */
INTERRUPT_SAVEREG
CLKADDR(a0)
movb a0@(CLKSR),d0 | read clock status
@@ -996,75 +938,71 @@ Lnotim1:
btst #2,d0 | timer3 interrupt?
jeq Lnotim3 | no, skip statclock
movpw a0@(CLKMSB3),d1 | clear timer3 interrupt
- addql #1,_intrcnt+28 | count clock interrupts
+ addql #1,_C_LABEL(intrcnt)+28 | count clock interrupts
lea sp@(16),a1 | a1 = &clockframe
movl d0,sp@- | save status
movl a1,sp@-
- jbsr _statintr | statintr(&frame)
+ jbsr _C_LABEL(statintr) | statintr(&frame)
addql #4,sp
movl sp@+,d0 | restore pre-statintr status
CLKADDR(a0)
Lnotim3:
btst #0,d0 | timer1 interrupt?
jeq Lrecheck | no, skip hardclock
- addql #1,_intrcnt+24 | count hardclock interrupts
+ addql #1,_C_LABEL(intrcnt)+24 | count hardclock interrupts
lea sp@(16),a1 | a1 = &clockframe
movl a1,sp@-
#ifdef USELEDS
- .globl _ledaddr, _inledcontrol, _ledcontrol, _hz
- tstl _ledaddr | using LEDs?
- jeq Lnoled0 | no, skip this code
- movl heartbeat,d0 | get tick count
+ tstl _C_LABEL(ledaddr) | using LEDs?
+ jeq Lnoleds0 | no, skip this code
+ movl _ASM_LABEL(heartbeat),d0 | get tick count
addql #1,d0 | increment
- movl _hz,d1
+ movl _C_LABEL(hz),d1
addl #50,d1 | get the timing a little closer
- cmpl #0,beatstatus | time to slow down?
- jeq SlowThrob
- lsrl #3,d1 | fast throb
-SlowThrob:
+ cmpl #0,_ASM_LABEL(beatstatus) | time to slow down?
+ jeq Lslowthrob | yes, slow down
+ lsrl #3,d1 | no, fast throb
+Lslowthrob:
lsrl #1,d1 | slow throb
cmpl d0,d1 | are we there yet?
- jne Lnoled1 | no, nothing to do
- tstl _inledcontrol | already updating LEDs?
- jne Lnoled2 | yes, skip it
- addl #1,beatstatus | incr beat status
- cmpl #3,beatstatus | time to reset?
- ble SkipReset
- movl #0,beatstatus | reset the status indicator
-SkipReset:
+ jne Lnoleds1 | no, nothing to do
+ addl #1,_ASM_LABEL(beatstatus) | incr beat status
+ cmpl #3,_ASM_LABEL(beatstatus) | time to reset?
+ ble Ltwinkle | no, twinkle the lights
+ movl #0,_ASM_LABEL(beatstatus) | reset the status indicator
+Ltwinkle:
movl #LED_PULSE,sp@-
movl #LED_DISK+LED_LANRCV+LED_LANXMT,sp@-
clrl sp@-
- jbsr _ledcontrol | toggle pulse, turn all others off
+ jbsr _C_LABEL(ledcontrol) | toggle pulse, turn all others off
lea sp@(12),sp
-Lnoled2:
movql #0,d0
-Lnoled1:
- movl d0,heartbeat
-Lnoled0:
-#endif
- jbsr _hardclock | hardclock(&frame)
+Lnoleds1:
+ movl d0,_ASM_LABEL(heartbeat)
+Lnoleds0:
+#endif /* USELEDS */
+ jbsr _C_LABEL(hardclock) | hardclock(&frame)
addql #4,sp
CLKADDR(a0)
Lrecheck:
- addql #1,_cnt+V_INTR | chalk up another interrupt
+ addql #1,_C_LABEL(cnt)+V_INTR | chalk up another interrupt
movb a0@(CLKSR),d0 | see if anything happened
jmi Lclkagain | while we were in hardclock/statintr
INTERRUPT_RESTOREREG
- jra rei | all done
+ jra _ASM_LABEL(rei) | all done
-_lev7intr: /* Level 7: Parity errors, reset key */
- addql #1,_intrcnt+32
+ENTRY_NOPROFILE(lev7intr) /* level 7: parity errors, reset key */
+ addql #1,_C_LABEL(intrcnt)+32
clrl sp@-
moveml #0xFFFF,sp@- | save registers
movl usp,a0 | and save
movl a0,sp@(FR_SP) | the user stack pointer
- jbsr _nmihand | call handler
+ jbsr _C_LABEL(nmihand) | call handler
movl sp@(FR_SP),a0 | restore
movl a0,usp | user SP
moveml sp@+,#0x7FFF | and remaining registers
addql #8,sp | pop SP and stack adjust
- jra rei | all done
+ jra _ASM_LABEL(rei) | all done
/*
* Emulation of VAX REI instruction.
@@ -1079,11 +1017,11 @@ _lev7intr: /* Level 7: Parity errors, reset key */
* This code is complicated by the fact that sendsig may have been called
* necessitating a stack cleanup.
*/
- .comm _ssir,1
- .globl _astpending
- .globl rei
-rei:
- tstl _astpending | AST pending?
+
+BSS(ssir,1)
+
+ASENTRY_NOPROFILE(rei)
+ tstl _C_LABEL(astpending) | AST pending?
jeq Lchksir | no, go check for SIR
Lrei1:
btst #5,sp@ | yes, are we returning to user mode?
@@ -1097,7 +1035,7 @@ Lrei2:
clrl sp@- | VA == none
clrl sp@- | code == none
movl #T_ASTFLT,sp@- | type == async system trap
- jbsr _trap | go handle it
+ jbsr _C_LABEL(trap) | go handle it
lea sp@(12),sp | pop value args
movl sp@(FR_SP),a0 | restore user SP
movl a0,usp | from save area
@@ -1118,7 +1056,7 @@ Laststkadj:
movl sp@,sp | and our SP
rte | and do real RTE
Lchksir:
- tstb _ssir | SIR pending?
+ tstb _C_LABEL(ssir) | SIR pending?
jeq Ldorte | no, all done
movl d0,sp@- | need a scratch register
movw sp@(4),d0 | get SR
@@ -1127,7 +1065,7 @@ Lchksir:
movl sp@+,d0 | restore scratch register
Lgotsir:
movw #SPL1,sr | prevent others from servicing int
- tstb _ssir | too late?
+ tstb _C_LABEL(ssir) | too late?
jeq Ldorte | yes, oh well...
clrl sp@- | stack adjust
moveml #0xFFFF,sp@- | save all registers
@@ -1137,7 +1075,7 @@ Lsir1:
clrl sp@- | VA == none
clrl sp@- | code == none
movl #T_SSIR,sp@- | type == software interrupt
- jbsr _trap | go handle it
+ jbsr _C_LABEL(trap) | go handle it
lea sp@(12),sp | pop value args
movl sp@(FR_SP),a0 | restore
movl a0,usp | user SP
@@ -1150,147 +1088,34 @@ Ldorte:
rte | real return
/*
- * Signal "trampoline" code (18 bytes). Invoked from RTE setup by sendsig().
- *
- * Stack looks like:
- *
- * sp+0 -> signal number
- * sp+4 pointer to siginfo (sip)
- * sp+8 pointer to signal context frame (scp)
- * sp+12 address of handler
- * sp+16 saved hardware state
- * .
- * .
- * scp+0-> beginning of signal context frame
+ * Use common m68k signal trampoline.
*/
- .globl _sigcode, _esigcode
- .data
-_sigcode:
- movl sp@(12),a0 | signal handler addr (4 bytes)
- jsr a0@ | call signal handler (2 bytes)
- addql #4,sp | pop signo (2 bytes)
- trap #1 | special syscall entry (2 bytes)
- movl d0,sp@(4) | save errno (4 bytes)
- moveq #1,d0 | syscall == exit (2 bytes)
- trap #0 | exit(errno) (2 bytes)
- .align 2
-_esigcode:
+#include <m68k/m68k/sigcode.s>
/*
* Primitives
*/
-#include <machine/asm.h>
-
/*
* Use common m68k support routines.
*/
#include <m68k/m68k/support.s>
/*
- * The following primitives manipulate the run queues. _whichqs tells which
- * of the 32 queues _qs have processes in them. Setrunqueue puts processes
- * into queues, remrunqueue removes them from queues. The running process is
- * on no queue, other processes are on a queue related to p->p_priority,
- * divided by 4 actually to shrink the 0-127 range of priorities into the 32
- * available queues.
- */
-
- .globl _whichqs,_qs,_cnt,_panic
- .globl _curproc,_want_resched
-
-/*
- * Setrunqueue(p)
- *
- * Call should be made at spl6(), and p->p_stat should be SRUN
- */
-ENTRY(setrunqueue)
- movl sp@(4),a0
-#ifdef DIAGNOSTIC
- tstl a0@(P_BACK)
- jne Lset1
- tstl a0@(P_WCHAN)
- jne Lset1
- cmpb #SRUN,a0@(P_STAT)
- jne Lset1
-#endif
- clrl d0
- movb a0@(P_PRIORITY),d0
- lsrb #2,d0
- movl _whichqs,d1
- bset d0,d1
- movl d1,_whichqs
- lslb #3,d0
- addl #_qs,d0
- movl d0,a0@(P_FORW)
- movl d0,a1
- movl a1@(P_BACK),a0@(P_BACK)
- movl a0,a1@(P_BACK)
- movl a0@(P_BACK),a1
- movl a0,a1@(P_FORW)
- rts
-#ifdef DIAGNOSTIC
-Lset1:
- movl #Lset2,sp@-
- jbsr _panic
-Lset2:
- .asciz "setrunqueue"
- .even
-#endif
-
-/*
- * Remrq(p)
- *
- * Call should be made at spl6().
+ * Use common m68k process manipulation routines.
*/
-ENTRY(remrunqueue)
- movl sp@(4),a0
- movb a0@(P_PRIORITY),d0
-#ifdef DIAGNOSTIC
- lsrb #2,d0
- movl _whichqs,d1
- btst d0,d1
- jeq Lrem2
-#endif
- movl a0@(P_BACK),a1
- clrl a0@(P_BACK)
- movl a0@(P_FORW),a0
- movl a0,a1@(P_FORW)
- movl a1,a0@(P_BACK)
- cmpal a0,a1
- jne Lrem1
-#ifndef DIAGNOSTIC
- lsrb #2,d0
- movl _whichqs,d1
-#endif
- bclr d0,d1
- movl d1,_whichqs
-Lrem1:
- rts
-#ifdef DIAGNOSTIC
-Lrem2:
- movl #Lrem3,sp@-
- jbsr _panic
-Lrem3:
- .asciz "remrunqueue"
- .even
-#endif
-
-Lsw0:
- .asciz "switch"
- .even
+#include <m68k/m68k/proc_subr.s>
- .globl _curpcb
- .globl _masterpaddr | XXX compatibility (debuggers)
.data
-_masterpaddr: | XXX compatibility (debuggers)
-_curpcb:
+GLOBAL(curpcb)
+GLOBAL(masterpaddr) | XXX compatibility (debuggers)
.long 0
-mdpflag:
+
+ASLOCAL(mdpflag)
.byte 0 | copy of proc md_flags low byte
.align 2
- .comm nullpcb,SIZEOF_PCB
- .text
+
+ASBSS(nullpcb,SIZEOF_PCB)
/*
* At exit of a process, do a switch for the last time.
@@ -1298,33 +1123,32 @@ mdpflag:
*/
ENTRY(switch_exit)
movl sp@(4),a0
- movl #nullpcb,_curpcb | save state into garbage pcb
- lea tmpstk,sp | goto a tmp stack
+ /* save state into garbage pcb */
+ movl #_ASM_LABEL(nullpcb),_C_LABEL(curpcb)
+ lea _ASM_LABEL(tmpstk),sp | goto a tmp stack
/* Free old process's resources. */
movl #USPACE,sp@- | size of u-area
movl a0@(P_ADDR),sp@- | address of process's u-area
- movl _kernel_map,sp@- | map it was allocated in
- jbsr _kmem_free | deallocate it
+ movl _C_LABEL(kernel_map),sp@- | map it was allocated in
+ jbsr _C_LABEL(kmem_free) | deallocate it
lea sp@(12),sp | pop args
- jra _cpu_switch
+ jra _C_LABEL(cpu_switch)
/*
* When no processes are on the runq, Swtch branches to Idle
* to wait for something to come ready.
*/
- .globl Idle
-Idle:
+ASENTRY_NOPROFILE(Idle)
stop #PSL_LOWIPL
movw #PSL_HIGHIPL,sr
- movl _whichqs,d0
- jeq Idle
+ movl _C_LABEL(whichqs),d0
+ jeq _ASM_LABEL(Idle)
jra Lsw1
Lbadsw:
- movl #Lsw0,sp@-
- jbsr _panic
+ PANIC("switch")
/*NOTREACHED*/
/*
@@ -1339,20 +1163,20 @@ Lbadsw:
* bit). For now, we just always flush the full ATC.
*/
ENTRY(cpu_switch)
- movl _curpcb,a0 | current pcb
+ movl _C_LABEL(curpcb),a0 | current pcb
movw sr,a0@(PCB_PS) | save sr before changing ipl
#ifdef notyet
- movl _curproc,sp@- | remember last proc running
+ movl _C_LABEL(curproc),sp@- | remember last proc running
#endif
- clrl _curproc
+ clrl _C_LABEL(curproc)
/*
* Find the highest-priority queue that isn't empty,
* then take the first proc from that queue.
*/
movw #PSL_HIGHIPL,sr | lock out interrupts
- movl _whichqs,d0
- jeq Idle
+ movl _C_LABEL(whichqs),d0
+ jeq _ASM_LABEL(Idle)
Lsw1:
movl d0,d1
negl d0
@@ -1362,7 +1186,7 @@ Lsw1:
movl d1,d0
lslb #3,d1 | convert queue number to index
- addl #_qs,d1 | locate queue (q)
+ addl #_C_LABEL(qs),d1 | locate queue (q)
movl d1,a1
movl a1@(P_FORW),a0 | p = q->p_forw
cmpal d1,a0 | anyone on queue?
@@ -1372,12 +1196,12 @@ Lsw1:
movl d1,a1@(P_BACK) | n->p_back = q
cmpal d1,a1 | anyone left on queue?
jne Lsw2 | yes, skip
- movl _whichqs,d1
+ movl _C_LABEL(whichqs),d1
bclr d0,d1 | no, clear bit
- movl d1,_whichqs
+ movl d1,_C_LABEL(whichqs)
Lsw2:
- movl a0,_curproc
- clrl _want_resched
+ movl a0,_C_LABEL(curproc)
+ clrl _C_LABEL(want_resched)
#ifdef notyet
movl sp@+,a1
cmpl a0,a1 | switching to same proc?
@@ -1386,12 +1210,12 @@ Lsw2:
/*
* Save state of previous process in its pcb.
*/
- movl _curpcb,a1
+ movl _C_LABEL(curpcb),a1
moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers
movl usp,a2 | grab USP (a2 has been saved)
movl a2,a1@(PCB_USP) | and save it
- tstl _fputype | Do we have an FPU?
+ tstl _C_LABEL(fputype) | Do we have an FPU?
jeq Lswnofpsave | No Then don't attempt save.
lea a1@(PCB_FPCTX),a2 | pointer to FP save area
fsave a2@ | save FP state
@@ -1410,7 +1234,7 @@ Lswnofpsave:
clrl a0@(P_BACK) | clear back link
movb a0@(P_MD_FLAGS+3),mdpflag | low byte of p_md.md_flags
movl a0@(P_ADDR),a1 | get p_addr
- movl a1,_curpcb
+ movl a1,_C_LABEL(curpcb)
/* see if pmap_activate needs to be called; should remove this */
movl a0@(P_VMSPACE),a0 | vmspace = p->p_vmspace
@@ -1418,20 +1242,20 @@ Lswnofpsave:
tstl a0 | map == VM_MAP_NULL?
jeq Lbadsw | panic
#endif
- lea a0@(VM_PMAP),a0 | pmap = &vmspace.vm_pmap
+ movl a0@(VM_PMAP),a0 | pmap = vmspace->vm_map.pmap
tstl a0@(PM_STCHG) | pmap->st_changed?
jeq Lswnochg | no, skip
pea a1@ | push pcb (at p_addr)
pea a0@ | push pmap
- jbsr _pmap_activate | pmap_activate(pmap, pcb)
+ jbsr _C_LABEL(pmap_activate) | pmap_activate(pmap, pcb)
addql #8,sp
- movl _curpcb,a1 | restore p_addr
+ movl _C_LABEL(curpcb),a1 | restore p_addr
Lswnochg:
- lea tmpstk,sp | now goto a tmp stack for NMI
+ lea _ASM_LABEL(tmpstk),sp | now goto a tmp stack for NMI
#if defined(M68040)
#if defined(M68020) || defined(M68030)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lres1a | no, skip
#endif
.word 0xf518 | yes, pflusha
@@ -1446,14 +1270,14 @@ Lres1a:
movc d0,cacr | invalidate cache(s)
#if defined(M68K_MMU_MOTOROLA)
#if defined(M68K_MMU_HP)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lhpmmu4 | yes, skip
#endif
pflusha | flush entire TLB
movl a1@(PCB_USTP),d0 | get USTP
moveq #PGSHIFT,d1
lsll d1,d0 | convert to addr
- lea _protorp,a0 | CRP prototype
+ lea _C_LABEL(protorp),a0 | CRP prototype
movl d0,a0@(4) | stash USTP
pmove a0@,crp | load new user root pointer
jra Lcxswdone | thats it
@@ -1462,7 +1286,7 @@ Lhpmmu4:
#if defined(M68K_MMU_HP)
MMUADDR(a0)
movl a0@(MMUTBINVAL),d1 | invalidate TLB
- tstl _ectype | got external VAC?
+ tstl _C_LABEL(ectype) | got external VAC?
jle Lnocache1 | no, skip
andl #~MMU_CEN,a0@(MMUCMD) | toggle cache enable
orl #MMU_CEN,a0@(MMUCMD) | to clear data cache
@@ -1474,14 +1298,14 @@ Lcxswdone:
movl a1@(PCB_USP),a0
movl a0,usp | and USP
- tstl _fputype | If we don't have an FPU,
+ tstl _C_LABEL(fputype) | If we don't have an FPU,
jeq Lnofprest | don't try to restore it.
lea a1@(PCB_FPCTX),a0 | pointer to FP save area
tstb a0@ | null state frame?
jeq Lresfprest | yes, easy
#if defined(M68040)
#if defined(M68020) || defined(M68030)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lresnot040 | no, skip
#endif
clrl sp@- | yes...
@@ -1509,7 +1333,7 @@ ENTRY(savectx)
movl a0,a1@(PCB_USP) | and save it
moveml #0xFCFC,a1@(PCB_REGS) | save non-scratch registers
- tstl _fputype | Do we have FPU?
+ tstl _C_LABEL(fputype) | Do we have FPU?
jeq Lsvnofpsave | No? Then don't save state.
lea a1@(PCB_FPCTX),a0 | pointer to FP save area
fsave a0@ | save FP state
@@ -1524,7 +1348,7 @@ Lsvnofpsave:
#if defined(M68040)
ENTRY(suline)
movl sp@(4),a0 | address to write
- movl _curpcb,a1 | current pcb
+ movl _C_LABEL(curpcb),a1 | current pcb
movl #Lslerr,a1@(PCB_ONFAULT) | where to return to on a fault
movl sp@(8),a1 | address of line
movl a1@+,d0 | get lword
@@ -1544,7 +1368,7 @@ ENTRY(suline)
Lslerr:
moveq #-1,d0
Lsldone:
- movl _curpcb,a1 | current pcb
+ movl _C_LABEL(curpcb),a1 | current pcb
clrl a1@(PCB_ONFAULT) | clear fault address
rts
#endif
@@ -1553,16 +1377,16 @@ Lsldone:
* Invalidate entire TLB.
*/
ENTRY(TBIA)
-__TBIA:
+_C_LABEL(_TBIA):
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lmotommu3 | no, skip
.word 0xf518 | yes, pflusha
rts
Lmotommu3:
#endif
#if defined(M68K_MMU_MOTOROLA)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lhpmmu6 | yes, skip
pflusha | flush entire TLB
jpl Lmc68851a | 68851 implies no d-cache
@@ -1577,8 +1401,8 @@ Lhpmmu6:
movl a0@(MMUTBINVAL),sp@- | do not ask me, this
addql #4,sp | is how hpux does it
#ifdef DEBUG
- tstl fullcflush
- jne __DCIA | XXX: invalidate entire cache
+ tstl _ASM_LABEL(fullcflush)
+ jne _C_LABEL(_DCIA) | XXX: invalidate entire cache
#endif
#endif
rts
@@ -1588,11 +1412,11 @@ Lhpmmu6:
*/
ENTRY(TBIS)
#ifdef DEBUG
- tstl fulltflush | being conservative?
- jne __TBIA | yes, flush entire TLB
+ tstl _ASM_LABEL(fulltflush) | being conservative?
+ jne _C_LABEL(_TBIA) | yes, flush entire TLB
#endif
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lmotommu4 | no, skip
movl sp@(4),a0
movc dfc,d1
@@ -1607,7 +1431,7 @@ ENTRY(TBIS)
Lmotommu4:
#endif
#if defined(M68K_MMU_MOTOROLA)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lhpmmu5 | yes, skip
movl sp@(4),a0 | get addr to flush
jpl Lmc68851b | is 68851?
@@ -1641,18 +1465,18 @@ Lhpmmu5:
*/
ENTRY(TBIAS)
#ifdef DEBUG
- tstl fulltflush | being conservative?
- jne __TBIA | yes, flush everything
+ tstl _ASM_LABEL(fulltflush) | being conservative?
+ jne _C_LABEL(_TBIA) | yes, flush everything
#endif
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lmotommu5 | no, skip
.word 0xf518 | yes, pflusha (for now) XXX
rts
Lmotommu5:
#endif
#if defined(M68K_MMU_MOTOROLA)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lhpmmu7 | yes, skip
jpl Lmc68851c | 68851?
pflush #4,#4 | flush supervisor TLB entries
@@ -1669,8 +1493,8 @@ Lhpmmu7:
movl #0x8000,d0 | more
movl d0,a0@(MMUTBINVAL) | HP magic
#ifdef DEBUG
- tstl fullcflush
- jne __DCIS | XXX: invalidate entire sup. cache
+ tstl _ASM_LABEL(fullcflush)
+ jne _C_LABEL(_DCIS) | XXX: invalidate entire sup. cache
#endif
#endif
rts
@@ -1680,18 +1504,18 @@ Lhpmmu7:
*/
ENTRY(TBIAU)
#ifdef DEBUG
- tstl fulltflush | being conservative?
- jne __TBIA | yes, flush everything
+ tstl _ASM_LABEL(fulltflush) | being conservative?
+ jne _C_LABEL(_TBIA) | yes, flush everything
#endif
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lmotommu6 | no, skip
.word 0xf518 | yes, pflusha (for now) XXX
rts
Lmotommu6:
#endif
#if defined(M68K_MMU_MOTOROLA)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lhpmmu8 | yes, skip
jpl Lmc68851d | 68851?
pflush #0,#4 | flush user TLB entries
@@ -1708,8 +1532,8 @@ Lhpmmu8:
moveq #0,d0 | more
movl d0,a0@(MMUTBINVAL) | HP magic
#ifdef DEBUG
- tstl fullcflush
- jne __DCIU | XXX: invalidate entire user cache
+ tstl _ASM_LABEL(fullcflush)
+ jne _C_LABEL(_DCIU) | XXX: invalidate entire user cache
#endif
#endif
rts
@@ -1720,7 +1544,7 @@ Lhpmmu8:
ENTRY(ICIA)
#if defined(M68040)
ENTRY(ICPA)
- cmpl #MMU_68040,_mmutype | 68040
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040
jne Lmotommu7 | no, skip
.word 0xf498 | cinva ic
rts
@@ -1741,14 +1565,14 @@ Lmotommu7:
ENTRY(DCIA)
__DCIA:
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040
jne Lmotommu8 | no, skip
/* XXX implement */
rts
Lmotommu8:
#endif
#if defined(M68K_MMU_HP)
- tstl _ectype | got external VAC?
+ tstl _C_LABEL(ectype) | got external VAC?
jle Lnocache2 | no, all done
MMUADDR(a0)
andl #~MMU_CEN,a0@(MMUCMD) | disable cache in MMU control reg
@@ -1758,16 +1582,16 @@ Lnocache2:
rts
ENTRY(DCIS)
-__DCIS:
+_C_LABEL(_DCIS):
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040
jne Lmotommu9 | no, skip
/* XXX implement */
rts
Lmotommu9:
#endif
#if defined(M68K_MMU_HP)
- tstl _ectype | got external VAC?
+ tstl _C_LABEL(ectype) | got external VAC?
jle Lnocache3 | no, all done
MMUADDR(a0)
movl a0@(MMUSSTP),d0 | read the supervisor STP
@@ -1777,16 +1601,16 @@ Lnocache3:
rts
ENTRY(DCIU)
-__DCIU:
+_C_LABEL(_DCIU):
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040
jne LmotommuA | no, skip
/* XXX implement */
rts
LmotommuA:
#endif
#if defined(M68K_MMU_HP)
- tstl _ectype | got external VAC?
+ tstl _C_LABEL(ectype) | got external VAC?
jle Lnocache4 | no, all done
MMUADDR(a0)
movl a0@(MMUUSTP),d0 | read the user STP
@@ -1828,7 +1652,7 @@ ENTRY(DCFP)
ENTRY(PCIA)
#if defined(M68040)
ENTRY(DCFA)
- cmpl #MMU_68040,_mmutype | 68040
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040
jne LmotommuB | no, skip
.word 0xf478 | cpusha dc
rts
@@ -1837,7 +1661,7 @@ LmotommuB:
#if defined(M68K_MMU_MOTOROLA)
movl #DC_CLEAR,d0
movc d0,cacr | invalidate on-chip d-cache
- tstl _ectype | got external PAC?
+ tstl _C_LABEL(ectype) | got external PAC?
jge Lnocache6 | no, all done
MMUADDR(a0)
andl #~MMU_CEN,a0@(MMUCMD) | disable cache in MMU control reg
@@ -1847,7 +1671,7 @@ Lnocache6:
rts
ENTRY(ecacheon)
- tstl _ectype
+ tstl _C_LABEL(ectype)
jeq Lnocache7
MMUADDR(a0)
orl #MMU_CEN,a0@(MMUCMD)
@@ -1855,18 +1679,18 @@ Lnocache7:
rts
ENTRY(ecacheoff)
- tstl _ectype
+ tstl _C_LABEL(ectype)
jeq Lnocache8
MMUADDR(a0)
andl #~MMU_CEN,a0@(MMUCMD)
Lnocache8:
rts
- .globl _getsfc, _getdfc
-_getsfc:
+ENTRY_NOPROFILE(getsfc)
movc sfc,d0
rts
-_getdfc:
+
+ENTRY_NOPROFILE(getdfc)
movc dfc,d0
rts
@@ -1875,19 +1699,19 @@ _getdfc:
*/
ENTRY(loadustp)
#if defined(M68K_MMU_MOTOROLA)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lhpmmu9 | yes, skip
movl sp@(4),d0 | new USTP
moveq #PGSHIFT,d1
lsll d1,d0 | convert to addr
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne LmotommuC | no, skip
.long 0x4e7b0806 | movc d0,urp
rts
LmotommuC:
#endif
- lea _protorp,a0 | CRP prototype
+ lea _C_LABEL(protorp),a0 | CRP prototype
movl d0,a0@(4) | stash USTP
pmove a0@,crp | load root pointer
movl #DC_CLEAR,d0
@@ -1905,11 +1729,11 @@ ENTRY(ploadw)
#if defined(M68K_MMU_MOTOROLA)
movl sp@(4),a0 | address to load
#if defined(M68K_MMU_HP)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq Lploadwskp | yes, skip
#endif
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jeq Lploadwskp | yes, skip
#endif
ploadw #1,a0@ | pre-load translation
@@ -1927,7 +1751,7 @@ ENTRY(spl0)
moveq #0,d0
movw sr,d0 | get old SR for return
movw #PSL_LOWIPL,sr | restore new SR
- tstb _ssir | software interrupt pending?
+ tstb _C_LABEL(ssir) | software interrupt pending?
jeq Lspldone | no, all done
subql #4,sp | make room for RTE frame
movl sp@(4),sp@(2) | position return address
@@ -1944,12 +1768,11 @@ Lspldone:
* This routine depends on the variable: delay_divisor
* which should be set based on the CPU clock rate.
*/
- .globl __delay
-__delay:
+ENTRY_NOPROFILE(_delay)
| d0 = arg = (usecs << 8)
movl sp@(4),d0
| d1 = delay_divisor
- movl _delay_divisor,d1
+ movl _C_LABEL(delay_divisor),d1
L_delay:
subl d1,d0
jgt L_delay
@@ -1988,22 +1811,21 @@ Lm68881rdone:
* is turned off. We have conveniently mapped the last page of physical
* memory this way.
*/
- .globl _doboot
-_doboot:
+ENTRY_NOPROFILE(doboot)
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jeq Lnocache5 | yes, skip
#endif
movl #CACHE_OFF,d0
movc d0,cacr | disable on-chip cache(s)
- tstl _ectype | external cache?
+ tstl _C_LABEL(ectype) | external cache?
jeq Lnocache5 | no, skip
MMUADDR(a0)
andl #~MMU_CEN,a0@(MMUCMD) | disable external cache
Lnocache5:
lea MAXADDR,a0 | last page of physical memory
- movl _boothowto,a0@+ | store howto
- movl _bootdev,a0@+ | and devtype
+ movl _C_LABEL(boothowto),a0@+ | store howto
+ movl _C_LABEL(bootdev),a0@+ | and devtype
lea Lbootcode,a1 | start of boot code
lea Lebootcode,a3 | end of boot code
Lbootcopy:
@@ -2011,7 +1833,7 @@ Lbootcopy:
cmpl a3,a1 | done yet?
jcs Lbootcopy | no, keep going
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne LmotommuE | no, skip
.word 0xf4f8 | cpusha bc
LmotommuE:
@@ -2028,7 +1850,7 @@ LmotommuE:
Lbootcode:
lea MAXADDR+0x800,sp | physical SP in case of NMI
#if defined(M68040)
- cmpl #MMU_68040,_mmutype | 68040?
+ cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne LmotommuF | no, skip
movl #0,d0
movc d0,cacr | caches off
@@ -2038,7 +1860,7 @@ Lbootcode:
LmotommuF:
#endif
#if defined(M68K_MMU_MOTOROLA)
- tstl _mmutype | HP MMU?
+ tstl _C_LABEL(mmutype) | HP MMU?
jeq LhpmmuB | yes, skip
movl #0,a0@ | value for pmove to TC (turn off MMU)
pmove a0@,tc | disable MMU
@@ -2055,66 +1877,82 @@ Lebootcode:
#undef DOREBOOT
+/*
+ * Misc. global variables.
+ */
.data
- .globl _machineid,_mmuid,_mmutype,_cputype,_ectype,_fputype
- .globl _protorp,_prototc
-_machineid:
+GLOBAL(machineid)
.long HP_320 | default to 320
-_mmuid:
+
+GLOBAL(mmuid)
.long 0 | default to nothing
-_mmutype:
+
+GLOBAL(mmutype)
.long MMU_HP | default to HP MMU
-_cputype:
+
+GLOBAL(cputype)
.long CPU_68020 | default to 68020 CPU
-_ectype:
+
+GLOBAL(ectype)
.long EC_NONE | external cache type, default to none
-_fputype:
- .long FPU_68881 | default to 68881 FPU
-_protorp:
+
+GLOBAL(fputype)
+ .long FPU_68882 | default to 68882 FPU
+
+GLOBAL(protorp)
.long 0,0 | prototype root pointer
-_prototc:
+
+GLOBAL(prototc)
.long 0 | prototype translation control
- .globl _internalhpib
-_internalhpib:
+
+GLOBAL(internalhpib)
.long 1 | has internal HP-IB, default to yes
- .globl _cold
-_cold:
+
+GLOBAL(cold)
.long 1 | cold start flag
- .globl _want_resched
-_want_resched:
+
+GLOBAL(want_resched)
.long 0
- .globl _intiobase, _intiolimit, _extiobase, _CLKbase, _MMUbase
- .globl _proc0paddr, _pagezero
-_proc0paddr:
+
+GLOBAL(proc0paddr)
.long 0 | KVA of proc0 u-area
-_intiobase:
+
+GLOBAL(intiobase)
.long 0 | KVA of base of internal IO space
-_intiolimit:
+
+GLOBAL(intiolimit)
.long 0 | KVA of end of internal IO space
-_extiobase:
+
+GLOBAL(extiobase)
.long 0 | KVA of base of external IO space
-_CLKbase:
+
+GLOBAL(CLKbase)
.long 0 | KVA of base of clock registers
-_MMUbase:
+
+GLOBAL(MMUbase)
.long 0 | KVA of base of HP MMU registers
-_pagezero:
+
+GLOBAL(pagezero)
.long 0 | PA of first page of kernel text
+
#ifdef USELEDS
-heartbeat:
+ASLOCAL(heartbeat)
.long 0 | clock ticks since last pulse of heartbeat
-beatstatus:
+
+ASLOCAL(beatstatus)
.long 0 | for determining a fast or slow throb
#endif
+
#ifdef DEBUG
- .globl fulltflush, fullcflush
-fulltflush:
+ASGLOBAL(fulltflush)
.long 0
-fullcflush:
+
+ASGLOBAL(fullcflush)
.long 0
#endif
+
/* interrupt counters */
- .globl _intrcnt,_eintrcnt,_intrnames,_eintrnames
-_intrnames:
+GLOBAL(intrnames)
.asciz "spur"
.asciz "hil"
.asciz "lev2"
@@ -2124,8 +1962,9 @@ _intrnames:
.asciz "clock"
.asciz "statclock"
.asciz "nmi"
-_eintrnames:
+GLOBAL(eintrnames)
.even
-_intrcnt:
+
+GLOBAL(intrcnt)
.long 0,0,0,0,0,0,0,0,0
-_eintrcnt:
+GLOBAL(eintrcnt)
diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c
index 159a5831740..8d8417c357f 100644
--- a/sys/arch/hp300/hp300/machdep.c
+++ b/sys/arch/hp300/hp300/machdep.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: machdep.c,v 1.26 1997/04/20 07:01:13 downsj Exp $ */
-/* $NetBSD: machdep.c,v 1.89 1997/04/09 20:05:20 thorpej Exp $ */
+/* $OpenBSD: machdep.c,v 1.27 1997/07/06 08:02:05 downsj Exp $ */
+/* $NetBSD: machdep.c,v 1.94 1997/06/12 15:46:29 mrg Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -85,6 +85,7 @@
#include <machine/autoconf.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
#include <machine/reg.h>
#include <machine/psl.h>
#include <machine/pte.h>
@@ -99,15 +100,17 @@
#include <vm/vm_kern.h>
#include <vm/vm_param.h>
+#include "opt_useleds.h"
+
#include <arch/hp300/dev/hilreg.h>
#include <arch/hp300/dev/hilioctl.h>
#include <arch/hp300/dev/hilvar.h>
#ifdef USELEDS
-#include <arch/hp300/hp300/led.h>
-#endif /* USELEDS */
+#include <arch/hp300/hp300/leds.h>
+#endif
/* the following is used externally (sysctl_hw) */
-char machine[] = "hp300"; /* cpu "architecture" */
+char machine[] = MACHINE; /* from <machine/param.h> */
vm_map_t buffer_map;
extern vm_offset_t avail_end;
@@ -152,7 +155,6 @@ int parityerror __P((struct frame *));
int parityerrorfind __P((void));
void identifycpu __P((void));
void initcpu __P((void));
-void ledinit __P((void));
void dumpmem __P((int *, int, int));
char *hexstr __P((int, int));
@@ -342,10 +344,10 @@ cpu_startup()
* Tell the VM system that writing to kernel text isn't allowed.
* If we don't, we might end up COW'ing the text segment!
*
- * XXX Should be hp300_trunc_page(&kernel_text) instead
+ * XXX Should be m68k_trunc_page(&kernel_text) instead
* XXX of NBPG.
*/
- if (vm_map_protect(kernel_map, NBPG, hp300_round_page(&etext),
+ if (vm_map_protect(kernel_map, NBPG, m68k_round_page(&etext),
VM_PROT_READ|VM_PROT_EXECUTE, TRUE) != KERN_SUCCESS)
panic("can't protect kernel text");
@@ -479,58 +481,83 @@ setregs(p, pack, stack, retval)
char cpu_model[120];
extern char version[];
+struct hp300_model {
+ int id;
+ const char *name;
+ const char *designation;
+ const char *speed;
+};
+
+struct hp300_model hp300_models[] = {
+ { HP_320, "320", " ", "16.67" },
+ { HP_330, "318/319/330", " ", "16.67" },
+ { HP_340, "340", " ", "16.67" },
+ { HP_345, "345", " ", "50" },
+ { HP_350, "350", " ", "25" },
+ { HP_360, "360", " ", "25" },
+ { HP_370, "370", " ", "33.33" },
+ { HP_375, "375", " ", "50" },
+ { HP_380, "380", " ", "25" },
+ { HP_400, "400", " ", "50" },
+ { HP_425, "425", " t s", "25" },
+ { HP_433, "433", " t s ", "33" },
+ { 0, NULL, NULL, NULL },
+};
+
void
identifycpu()
{
- char *t, *mc;
- int len;
+ const char *t, *mc, *s;
+ char td;
+ int i, len;
- switch (machineid) {
- case HP_320:
- t = "320 (16.67MHz";
- break;
- case HP_330:
- t = "318/319/330 (16.67MHz";
- break;
- case HP_340:
- t = "340 (16.67MHz";
- break;
- case HP_350:
- t = "350 (25MHz";
- break;
- case HP_360:
- t = "360 (25MHz";
- break;
- case HP_370:
- t = "370 (33.33MHz";
- break;
- case HP_375:
- t = "345/375 (50MHz";
- break;
- case HP_380:
- t = "380 (25MHz";
- break;
- case HP_425:
- if ((mmuid & 0xff) == 5) {
- t = "425t (25MHz";
- } else { /* == 7 */
- t = "425s (25MHz";
+ /*
+ * Find the model number.
+ */
+ for (t = s = NULL, i = 0; hp300_models[i].name != NULL; i++) {
+ if (hp300_models[i].id == machineid) {
+ t = hp300_models[i].name;
+ s = hp300_models[i].speed;
+
+ if (mmuid < strlen(hp300_models[i].designation)) {
+ td = (hp300_models[i].designation)[mmuid];
+ } else {
+ td = (hp300_models[i].designation)[0];
+ }
}
+ }
+ if (t == NULL) {
+ printf("\nunknown machineid %d\n", machineid);
+ goto lose;
+ }
+
+ /*
+ * ...and the CPU type.
+ */
+ switch (cputype) {
+ case CPU_68040:
+ mc = "40";
break;
- case HP_433:
- if ((mmuid & 0xff) == 4) {
- t = "433t (33MHz";
- } else { /* == 6 */
- t = "433s (33MHz";
- }
+ case CPU_68030:
+ mc = "30";
+ break;
+ case CPU_68020:
+ mc = "20";
break;
default:
- printf("\nunknown machine type %d\n", machineid);
- panic("startup");
+ printf("\nunknown cputype %d\n", cputype);
+ goto lose;
}
- mc = (mmutype == MMU_68040 ? "40" :
- (mmutype == MMU_68030 ? "30" : "20"));
- sprintf(cpu_model, "HP9000/%s MC680%s CPU", t, mc);
+
+ if (td != ' ')
+ sprintf(cpu_model, "HP 9000/%s%c (%sMHz MC680%s CPU", t, td,
+ s, mc);
+ else
+ sprintf(cpu_model, "HP 9000/%s (%sMHz MC680%s CPU", t, s, mc);
+
+ /*
+ * ...and the MMU type.
+ */
switch (mmutype) {
case MMU_68040:
case MMU_68030:
@@ -546,60 +573,104 @@ identifycpu()
printf("%s\nunknown MMU type %d\n", cpu_model, mmutype);
panic("startup");
}
+
len = strlen(cpu_model);
- if (mmutype == MMU_68040)
- len += sprintf(cpu_model + len,
- "+FPU, 4k on-chip physical I/D caches");
- else if (mmutype == MMU_68030)
- len += sprintf(cpu_model + len, ", %sMHz MC68882 FPU",
- machineid == HP_340 ? "16.67" :
- (machineid == HP_360 ? "25" :
- (machineid == HP_370 ? "33.33" : "50")));
- else
- len += sprintf(cpu_model + len, ", %sMHz MC68881 FPU",
- machineid == HP_350 ? "20" : "16.67");
- switch (ectype) {
- case EC_VIRT:
- sprintf(cpu_model + len, ", %dK virtual-address cache",
- machineid == HP_320 ? 16 : 32);
+
+ /*
+ * ...and the FPU type.
+ */
+ switch (fputype) {
+ case FPU_68040:
+ len += sprintf(cpu_model + len, "+FPU");
break;
- case EC_PHYS:
- sprintf(cpu_model + len, ", %dK physical-address cache",
- machineid == HP_370 ? 64 : 32);
+ case FPU_68882:
+ len += sprintf(cpu_model + len, ", %sMHz MC68882 FPU", s);
break;
+ case FPU_68881:
+ len += sprintf(cpu_model + len, ", %sMHz MC68881 FPU",
+ machineid == HP_350 ? "20" : "16.67");
+ break;
+ default:
+ len += sprintf(cpu_model + len, ", unknown FPU");
+ }
+
+ /*
+ * ...and finally, the cache type.
+ */
+ if (cputype == CPU_68040)
+ sprintf(cpu_model + len, ", 4k on-chip physical I/D caches");
+ else {
+ switch (ectype) {
+ case EC_VIRT:
+ sprintf(cpu_model + len,
+ ", %dK virtual-address cache",
+ machineid == HP_320 ? 16 : 32);
+ break;
+ case EC_PHYS:
+ sprintf(cpu_model + len,
+ ", %dK physical-address cache",
+ machineid == HP_370 ? 64 : 32);
+ break;
+ }
}
+
strcat(cpu_model, ")");
printf("%s\n", cpu_model);
- printf("delay constant for this cpu: %d MMU ID: %d\n",
- delay_divisor, mmuid & 0xff);
+ printf("cpu: delay divisor %d", delay_divisor);
+ if (mmuid)
+ printf(", mmuid %d", mmuid);
+ printf("\n");
+
/*
* Now that we have told the user what they have,
* let them know if that machine type isn't configured.
*/
switch (machineid) {
case -1: /* keep compilers happy */
-#if !defined(HP320) && !defined(HP350)
+#if !defined(HP320)
case HP_320:
- case HP_350:
#endif
-#ifndef HP330
+#if !defined(HP330)
case HP_330:
#endif
-#if !defined(HP340) && !defined(HP360) && !defined(HP370) && !defined(HP375)
+#if !defined(HP340)
case HP_340:
+#endif
+#if !defined(HP345)
+ case HP_345:
+#endif
+#if !defined(HP350)
+ case HP_350:
+#endif
+#if !defined(HP360)
case HP_360:
+#endif
+#if !defined(HP370)
case HP_370:
+#endif
+#if !defined(HP375)
case HP_375:
#endif
#if !defined(HP380)
case HP_380:
+#endif
+#if !defined(HP400)
+ case HP_400:
+#endif
+#if !defined(HP425)
case HP_425:
+#endif
+#if !defined(HP433)
case HP_433:
#endif
- panic("CPU type not configured");
+ panic("SPU type not configured");
default:
break;
}
+
+ return;
+lose:
+ panic("startup");
}
/*
@@ -635,53 +706,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
/* NOTREACHED */
}
-#ifdef USELEDS
-int inledcontrol = 0; /* 1 if we are in ledcontrol already, cheap mutex */
-char *ledaddr;
-
-/*
- * Map the LED page and setup the KVA to access it.
- */
-void
-ledinit()
-{
- extern caddr_t ledbase;
-
- pmap_enter(pmap_kernel(), (vm_offset_t)ledbase, (vm_offset_t)LED_ADDR,
- VM_PROT_READ|VM_PROT_WRITE, TRUE);
- ledaddr = (char *) ((int)ledbase | (LED_ADDR & PGOFSET));
-}
-
-/*
- * Do lights:
- * `ons' is a mask of LEDs to turn on,
- * `offs' is a mask of LEDs to turn off,
- * `togs' is a mask of LEDs to toggle.
- * Note we don't use splclock/splx for mutual exclusion.
- * They are expensive and we really don't need to be that precise.
- * Besides we would like to be able to profile this routine.
- */
-void
-ledcontrol(ons, offs, togs)
- int ons, offs, togs;
-{
- static char currentleds;
- char leds;
-
- inledcontrol = 1;
- leds = currentleds;
- if (ons)
- leds |= ons;
- if (offs)
- leds &= ~offs;
- if (togs)
- leds ^= togs;
- currentleds = leds;
- *ledaddr = ~leds;
- inledcontrol = 0;
-}
-#endif
-
int waittime = -1;
void
diff --git a/sys/arch/hp300/hp300/mem.c b/sys/arch/hp300/hp300/mem.c
index 725c10b6768..a2d2b58b08a 100644
--- a/sys/arch/hp300/hp300/mem.c
+++ b/sys/arch/hp300/hp300/mem.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: mem.c,v 1.5 1997/04/16 11:56:29 downsj Exp $ */
-/* $NetBSD: mem.c,v 1.16 1997/04/01 03:12:25 scottr Exp $ */
+/* $OpenBSD: mem.c,v 1.6 1997/07/06 08:02:06 downsj Exp $ */
+/* $NetBSD: mem.c,v 1.17 1997/06/10 18:51:31 veego Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -229,5 +229,5 @@ mmmmap(dev, off, prot)
*/
if ((unsigned)off < lowram || (unsigned)off >= 0xFFFFFFFC)
return (-1);
- return (hp300_btop(off));
+ return (m68k_btop(off));
}
diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c
index 02f4fd57397..42bc7c1b9f6 100644
--- a/sys/arch/hp300/hp300/pmap.c
+++ b/sys/arch/hp300/hp300/pmap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: pmap.c,v 1.7 1997/04/16 11:56:30 downsj Exp $ */
-/* $NetBSD: pmap.c,v 1.32 1997/04/02 22:41:39 scottr Exp $ */
+/* $OpenBSD: pmap.c,v 1.8 1997/07/06 08:02:07 downsj Exp $ */
+/* $NetBSD: pmap.c,v 1.36 1997/06/10 18:52:23 veego Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -95,6 +95,8 @@
* and to when physical maps must be made correct.
*/
+#include <machine/hp300spu.h> /* XXX param.h includes cpu.h */
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
@@ -369,7 +371,7 @@ pmap_init(phys_start, phys_end)
*/
addr = (vm_offset_t) intiobase;
(void) vm_map_find(kernel_map, NULL, (vm_offset_t) 0,
- &addr, hp300_ptob(IIOMAPSIZE+EIOMAPSIZE), FALSE);
+ &addr, m68k_ptob(IIOMAPSIZE+EIOMAPSIZE), FALSE);
if (addr != (vm_offset_t)intiobase)
goto bogons;
addr = (vm_offset_t) Sysmap;
@@ -1169,7 +1171,7 @@ pmap_enter(pmap, va, pa, prot, wired)
if (!pmap_ste_v(pmap, va))
pmap_enter_ptpage(pmap, va);
- pa = hp300_trunc_page(pa);
+ pa = m68k_trunc_page(pa);
pte = pmap_pte(pmap, va);
opa = pmap_pte_pa(pte);
#ifdef DEBUG
@@ -1924,7 +1926,7 @@ vm_offset_t
pmap_phys_address(ppn)
int ppn;
{
- return(hp300_ptob(ppn));
+ return(m68k_ptob(ppn));
}
#ifdef COMPAT_HPUX
@@ -2280,7 +2282,9 @@ pmap_changebit(pa, bit, setem)
pt_entry_t *pte, npte;
vm_offset_t va;
int s;
+#if defined(M68K_MMU_HP) || defined(M68040)
boolean_t firstpage = TRUE;
+#endif
#ifdef PMAPSTATS
struct chgstats *chgp;
#endif
diff --git a/sys/arch/hp300/hp300/pmap_bootstrap.c b/sys/arch/hp300/hp300/pmap_bootstrap.c
index 63df63ec17f..e737235de73 100644
--- a/sys/arch/hp300/hp300/pmap_bootstrap.c
+++ b/sys/arch/hp300/hp300/pmap_bootstrap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: pmap_bootstrap.c,v 1.4 1997/04/16 11:56:31 downsj Exp $ */
-/* $NetBSD: pmap_bootstrap.c,v 1.11 1997/04/01 03:12:29 scottr Exp $ */
+/* $OpenBSD: pmap_bootstrap.c,v 1.5 1997/07/06 08:02:08 downsj Exp $ */
+/* $NetBSD: pmap_bootstrap.c,v 1.13 1997/06/10 18:56:50 veego Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -46,6 +46,7 @@
#include <machine/frame.h>
#include <machine/cpu.h>
+#include <machine/hp300spu.h>
#include <machine/vmparam.h>
#include <machine/pte.h>
@@ -324,8 +325,8 @@ pmap_bootstrap(nextpa, firstpa)
* Validate PTEs for kernel text (RO). The first page
* of kernel text remains invalid; see locore.s
*/
- pte = &((u_int *)kptpa)[hp300_btop(KERNBASE + NBPG)];
- epte = &pte[hp300_btop(hp300_trunc_page(&etext))];
+ pte = &((u_int *)kptpa)[m68k_btop(KERNBASE + NBPG)];
+ epte = &pte[m68k_btop(m68k_trunc_page(&etext))];
protopte = (firstpa + NBPG) | PG_RO | PG_V;
while (pte < epte) {
*pte++ = protopte;
@@ -336,7 +337,7 @@ pmap_bootstrap(nextpa, firstpa)
* by us so far (nextpa - firstpa bytes), and pages for proc0
* u-area and page table allocated below (RW).
*/
- epte = &((u_int *)kptpa)[hp300_btop(nextpa - firstpa)];
+ epte = &((u_int *)kptpa)[m68k_btop(nextpa - firstpa)];
protopte = (protopte & ~PG_PROT) | PG_RW;
/*
* Enable copy-back caching of data pages
@@ -380,22 +381,22 @@ pmap_bootstrap(nextpa, firstpa)
* Immediately follows `nptpages' of static kernel page table.
*/
RELOC(Sysmap, pt_entry_t *) =
- (pt_entry_t *)hp300_ptob(nptpages * NPTEPG);
+ (pt_entry_t *)m68k_ptob(nptpages * NPTEPG);
/*
* intiobase, intiolimit: base and end of internal (DIO) IO space.
* IIOMAPSIZE pages prior to external IO space at end of static
* kernel page table.
*/
RELOC(intiobase, char *) =
- (char *)hp300_ptob(nptpages*NPTEPG - (IIOMAPSIZE+EIOMAPSIZE));
+ (char *)m68k_ptob(nptpages*NPTEPG - (IIOMAPSIZE+EIOMAPSIZE));
RELOC(intiolimit, char *) =
- (char *)hp300_ptob(nptpages*NPTEPG - EIOMAPSIZE);
+ (char *)m68k_ptob(nptpages*NPTEPG - EIOMAPSIZE);
/*
* extiobase: base of external (DIO-II) IO space.
* EIOMAPSIZE pages at the end of the static kernel page table.
*/
RELOC(extiobase, char *) =
- (char *)hp300_ptob(nptpages*NPTEPG - EIOMAPSIZE);
+ (char *)m68k_ptob(nptpages*NPTEPG - EIOMAPSIZE);
/*
* CLKbase, MMUbase: important registers in internal IO space
* accessed from assembly language.
@@ -436,9 +437,9 @@ pmap_bootstrap(nextpa, firstpa)
* page so the msgbuf can be preserved.
*/
RELOC(avail_start, vm_offset_t) = nextpa;
- RELOC(avail_end, vm_offset_t) = hp300_ptob(RELOC(maxmem, int)) -
- (hp300_round_page(sizeof(struct msgbuf)) + hp300_ptob(1));
- RELOC(mem_size, vm_size_t) = hp300_ptob(RELOC(physmem, int));
+ RELOC(avail_end, vm_offset_t) = m68k_ptob(RELOC(maxmem, int)) -
+ (m68k_round_page(sizeof(struct msgbuf)) + m68k_ptob(1));
+ RELOC(mem_size, vm_size_t) = m68k_ptob(RELOC(physmem, int));
RELOC(virtual_avail, vm_offset_t) =
VM_MIN_KERNEL_ADDRESS + (nextpa - firstpa);
RELOC(virtual_end, vm_offset_t) = VM_MAX_KERNEL_ADDRESS;
diff --git a/sys/arch/hp300/hp300/sys_machdep.c b/sys/arch/hp300/hp300/sys_machdep.c
index 30f17f56bd7..d8a5a99f233 100644
--- a/sys/arch/hp300/hp300/sys_machdep.c
+++ b/sys/arch/hp300/hp300/sys_machdep.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: sys_machdep.c,v 1.4 1997/04/16 11:56:31 downsj Exp $ */
-/* $NetBSD: sys_machdep.c,v 1.15 1997/04/06 21:40:38 mycroft Exp $ */
+/* $OpenBSD: sys_machdep.c,v 1.5 1997/07/06 08:02:08 downsj Exp $ */
+/* $NetBSD: sys_machdep.c,v 1.17 1997/05/19 10:15:00 veego Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -36,6 +36,8 @@
* @(#)sys_machdep.c 8.2 (Berkeley) 1/13/94
*/
+#include <machine/hp300spu.h> /* XXX param.h includes cpu.h */
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
@@ -174,7 +176,7 @@ cachectl(req, addr, len)
*/
if (!doall &&
(pa == 0 || ((int)addr & PGOFSET) == 0)) {
- pa = pmap_extract(&curproc->p_vmspace->vm_pmap,
+ pa = pmap_extract(curproc->p_vmspace->vm_map.pmap,
(vm_offset_t)addr);
if (pa == 0)
doall = 1;
@@ -229,7 +231,7 @@ cachectl(req, addr, len)
switch (req) {
case CC_EXTPURGE|CC_PURGE:
case CC_EXTPURGE|CC_FLUSH:
-#if defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375)
+#if defined(CACHE_HAVE_PAC)
if (ectype == EC_PHYS)
PCIA();
/* fall into... */
@@ -239,7 +241,7 @@ cachectl(req, addr, len)
DCIU();
break;
case CC_EXTPURGE|CC_IPURGE:
-#if defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375)
+#if defined(CACHE_HAVE_PAC)
if (ectype == EC_PHYS)
PCIA();
else
diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c
index fd121bad97a..21e7f6fb531 100644
--- a/sys/arch/hp300/hp300/trap.c
+++ b/sys/arch/hp300/hp300/trap.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: trap.c,v 1.10 1997/04/16 11:56:32 downsj Exp $ */
-/* $NetBSD: trap.c,v 1.52 1997/04/14 02:28:48 thorpej Exp $ */
+/* $OpenBSD: trap.c,v 1.11 1997/07/06 08:02:09 downsj Exp $ */
+/* $NetBSD: trap.c,v 1.54 1997/05/19 10:15:01 veego Exp $ */
/*
* Copyright (c) 1997 Theo de Raadt
@@ -72,6 +72,8 @@
* @(#)trap.c 8.5 (Berkeley) 1/4/94
*/
+#include <machine/hp300spu.h> /* XXX param.h includes cpu.h */
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
@@ -1011,7 +1013,7 @@ dumpwb(num, s, a, d)
num, a, d, f7sz[(s & SSW4_SZMASK) >> 5],
f7tt[(s & SSW4_TTMASK) >> 3], f7tm[s & SSW4_TMMASK]);
printf(" PA ");
- pa = pmap_extract(&p->p_vmspace->vm_pmap, (vm_offset_t)a);
+ pa = pmap_extract(p->p_vmspace->vm_map.pmap, (vm_offset_t)a);
if (pa == 0)
printf("<invalid address>");
else
diff --git a/sys/arch/hp300/hp300/vectors.s b/sys/arch/hp300/hp300/vectors.s
index 15e47cf82a7..8100db1f8ba 100644
--- a/sys/arch/hp300/hp300/vectors.s
+++ b/sys/arch/hp300/hp300/vectors.s
@@ -1,6 +1,7 @@
-| $OpenBSD: vectors.s,v 1.4 1997/01/12 15:13:29 downsj Exp $
-| $NetBSD: vectors.s,v 1.10 1996/10/14 22:11:18 thorpej Exp $
+| $OpenBSD: vectors.s,v 1.5 1997/07/06 08:02:09 downsj Exp $
+| $NetBSD: vectors.s,v 1.11 1997/04/25 02:16:38 thorpej Exp $
+| Copyright (c) 1997 Jason R. Thorpe. All rights reserved.
| Copyright (c) 1988 University of Utah
| Copyright (c) 1990, 1993
| The Regents of the University of California. All rights reserved.
@@ -36,99 +37,94 @@
| @(#)vectors.s 8.2 (Berkeley) 1/21/94
|
- .text
- .globl _buserr,_addrerr
- .globl _illinst,_zerodiv,_chkinst,_trapvinst,_privinst,_trace
- .globl _badtrap
- .globl _spurintr,_lev1intr,_lev6intr,_lev7intr
- .globl _intrhand
- .globl _trap0,_trap1,_trap2,_trap15
- .globl _fpfline, _fpunsupp
- .globl _trap12
+#define BADTRAP16 \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap) ; \
+ VECTOR(badtrap) ; VECTOR(badtrap)
- .globl _vectab
-_vectab:
- .long 0 /* 0: NOT USED (reset SSP) */
- .long 0 /* 1: NOT USED (reset PC) */
- .long _buserr /* 2: bus error */
- .long _addrerr /* 3: address error */
- .long _illinst /* 4: illegal instruction */
- .long _zerodiv /* 5: zero divide */
- .long _chkinst /* 6: CHK instruction */
- .long _trapvinst /* 7: TRAPV instruction */
- .long _privinst /* 8: privilege violation */
- .long _trace /* 9: trace */
- .long _illinst /* 10: line 1010 emulator */
- .long _fpfline /* 11: line 1111 emulator */
- .long _badtrap /* 12: unassigned, reserved */
- .long _coperr /* 13: coprocessor protocol violation */
- .long _fmterr /* 14: format error */
- .long _badtrap /* 15: uninitialized interrupt vector */
- .long _badtrap /* 16: unassigned, reserved */
- .long _badtrap /* 17: unassigned, reserved */
- .long _badtrap /* 18: unassigned, reserved */
- .long _badtrap /* 19: unassigned, reserved */
- .long _badtrap /* 20: unassigned, reserved */
- .long _badtrap /* 21: unassigned, reserved */
- .long _badtrap /* 22: unassigned, reserved */
- .long _badtrap /* 23: unassigned, reserved */
- .long _spurintr /* 24: spurious interrupt */
- .long _lev1intr /* 25: level 1 interrupt autovector */
- .long _intrhand /* 26: level 2 interrupt autovector */
- .long _intrhand /* 27: level 3 interrupt autovector */
- .long _intrhand /* 28: level 4 interrupt autovector */
- .long _intrhand /* 29: level 5 interrupt autovector */
- .long _lev6intr /* 30: level 6 interrupt autovector */
- .long _lev7intr /* 31: level 7 interrupt autovector */
- .long _trap0 /* 32: syscalls */
- .long _trap1 /* 33: sigreturn syscall or breakpoint */
- .long _trap2 /* 34: breakpoint or sigreturn syscall */
- .long _illinst /* 35: TRAP instruction vector */
- .long _illinst /* 36: TRAP instruction vector */
- .long _illinst /* 37: TRAP instruction vector */
- .long _illinst /* 38: TRAP instruction vector */
- .long _illinst /* 39: TRAP instruction vector */
- .long _illinst /* 40: TRAP instruction vector */
- .long _illinst /* 41: TRAP instruction vector */
- .long _illinst /* 42: TRAP instruction vector */
- .long _illinst /* 43: TRAP instruction vector */
- .long _trap12 /* 44: TRAP instruction vector */
- .long _illinst /* 45: TRAP instruction vector */
- .long _illinst /* 46: TRAP instruction vector */
- .long _trap15 /* 47: TRAP instruction vector */
+ .text
+GLOBAL(vectab)
+ VECTOR_UNUSED /* 0: NOT USED (reset SSP) */
+ VECTOR_UNUSED /* 1: NOT USED (reset PC) */
+ VECTOR(buserr) /* 2: bus error */
+ VECTOR(addrerr) /* 3: address error */
+ VECTOR(illinst) /* 4: illegal instruction */
+ VECTOR(zerodiv) /* 5: zero divide */
+ VECTOR(chkinst) /* 6: CHK instruction */
+ VECTOR(trapvinst) /* 7: TRAPV instruction */
+ VECTOR(privinst) /* 8: privilege violation */
+ VECTOR(trace) /* 9: trace */
+ VECTOR(illinst) /* 10: line 1010 emulator */
+ VECTOR(fpfline) /* 11: line 1111 emulator */
+ VECTOR(badtrap) /* 12: unassigned, reserved */
+ VECTOR(coperr) /* 13: coprocessor protocol violation */
+ VECTOR(fmterr) /* 14: format error */
+ VECTOR(badtrap) /* 15: uninitialized interrupt vector */
+ VECTOR(badtrap) /* 16: unassigned, reserved */
+ VECTOR(badtrap) /* 17: unassigned, reserved */
+ VECTOR(badtrap) /* 18: unassigned, reserved */
+ VECTOR(badtrap) /* 19: unassigned, reserved */
+ VECTOR(badtrap) /* 20: unassigned, reserved */
+ VECTOR(badtrap) /* 21: unassigned, reserved */
+ VECTOR(badtrap) /* 22: unassigned, reserved */
+ VECTOR(badtrap) /* 23: unassigned, reserved */
+ VECTOR(spurintr) /* 24: spurious interrupt */
+ VECTOR(lev1intr) /* 25: level 1 interrupt autovector */
+ VECTOR(intrhand) /* 26: level 2 interrupt autovector */
+ VECTOR(intrhand) /* 27: level 3 interrupt autovector */
+ VECTOR(intrhand) /* 28: level 4 interrupt autovector */
+ VECTOR(intrhand) /* 29: level 5 interrupt autovector */
+ VECTOR(lev6intr) /* 30: level 6 interrupt autovector */
+ VECTOR(lev7intr) /* 31: level 7 interrupt autovector */
+ VECTOR(trap0) /* 32: syscalls */
+ VECTOR(trap1) /* 33: sigreturn syscall or breakpoint */
+ VECTOR(trap2) /* 34: breakpoint or sigreturn syscall */
+ VECTOR(illinst) /* 35: TRAP instruction vector */
+ VECTOR(illinst) /* 36: TRAP instruction vector */
+ VECTOR(illinst) /* 37: TRAP instruction vector */
+ VECTOR(illinst) /* 38: TRAP instruction vector */
+ VECTOR(illinst) /* 39: TRAP instruction vector */
+ VECTOR(illinst) /* 40: TRAP instruction vector */
+ VECTOR(illinst) /* 41: TRAP instruction vector */
+ VECTOR(illinst) /* 42: TRAP instruction vector */
+ VECTOR(illinst) /* 43: TRAP instruction vector */
+ VECTOR(trap12) /* 44: TRAP instruction vector */
+ VECTOR(illinst) /* 45: TRAP instruction vector */
+ VECTOR(illinst) /* 46: TRAP instruction vector */
+ VECTOR(trap15) /* 47: TRAP instruction vector */
#ifdef FPSP
- .globl bsun, inex, dz, unfl, operr, ovfl, snan
- .long bsun /* 48: FPCP branch/set on unordered cond */
- .long inex /* 49: FPCP inexact result */
- .long dz /* 50: FPCP divide by zero */
- .long unfl /* 51: FPCP underflow */
- .long operr /* 52: FPCP operand error */
- .long ovfl /* 53: FPCP overflow */
- .long snan /* 54: FPCP signalling NAN */
+ ASVECTOR(bsun) /* 48: FPCP branch/set on unordered cond */
+ ASVECTOR(inex) /* 49: FPCP inexact result */
+ ASVECTOR(dz) /* 50: FPCP divide by zero */
+ ASVECTOR(unfl) /* 51: FPCP underflow */
+ ASVECTOR(operr) /* 52: FPCP operand error */
+ ASVECTOR(ovfl) /* 53: FPCP overflow */
+ ASVECTOR(snan) /* 54: FPCP signalling NAN */
#else
- .globl _fpfault
- .long _fpfault /* 48: FPCP branch/set on unordered cond */
- .long _fpfault /* 49: FPCP inexact result */
- .long _fpfault /* 50: FPCP divide by zero */
- .long _fpfault /* 51: FPCP underflow */
- .long _fpfault /* 52: FPCP operand error */
- .long _fpfault /* 53: FPCP overflow */
- .long _fpfault /* 54: FPCP signalling NAN */
+ VECTOR(fpfault) /* 48: FPCP branch/set on unordered cond */
+ VECTOR(fpfault) /* 49: FPCP inexact result */
+ VECTOR(fpfault) /* 50: FPCP divide by zero */
+ VECTOR(fpfault) /* 51: FPCP underflow */
+ VECTOR(fpfault) /* 52: FPCP operand error */
+ VECTOR(fpfault) /* 53: FPCP overflow */
+ VECTOR(fpfault) /* 54: FPCP signalling NAN */
#endif
- .long _fpunsupp /* 55: FPCP unimplemented data type */
- .long _badtrap /* 56: unassigned, reserved */
- .long _badtrap /* 57: unassigned, reserved */
- .long _badtrap /* 58: unassigned, reserved */
- .long _badtrap /* 59: unassigned, reserved */
- .long _badtrap /* 60: unassigned, reserved */
- .long _badtrap /* 61: unassigned, reserved */
- .long _badtrap /* 62: unassigned, reserved */
- .long _badtrap /* 63: unassigned, reserved */
-#define BADTRAP16 .long _badtrap,_badtrap,_badtrap,_badtrap,\
- _badtrap,_badtrap,_badtrap,_badtrap,\
- _badtrap,_badtrap,_badtrap,_badtrap,\
- _badtrap,_badtrap,_badtrap,_badtrap
+ VECTOR(fpunsupp) /* 55: FPCP unimplemented data type */
+ VECTOR(badtrap) /* 56: unassigned, reserved */
+ VECTOR(badtrap) /* 57: unassigned, reserved */
+ VECTOR(badtrap) /* 58: unassigned, reserved */
+ VECTOR(badtrap) /* 59: unassigned, reserved */
+ VECTOR(badtrap) /* 60: unassigned, reserved */
+ VECTOR(badtrap) /* 61: unassigned, reserved */
+ VECTOR(badtrap) /* 62: unassigned, reserved */
+ VECTOR(badtrap) /* 63: unassigned, reserved */
+
BADTRAP16 /* 64-255: user interrupt vectors */
BADTRAP16 /* 64-255: user interrupt vectors */
BADTRAP16 /* 64-255: user interrupt vectors */
diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c
index 862f58f65dc..1e06bbae5ca 100644
--- a/sys/arch/hp300/hp300/vm_machdep.c
+++ b/sys/arch/hp300/hp300/vm_machdep.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: vm_machdep.c,v 1.9 1997/04/16 11:56:32 downsj Exp $ */
-/* $NetBSD: vm_machdep.c,v 1.35 1997/04/01 03:12:33 scottr Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.10 1997/07/06 08:02:10 downsj Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.37 1997/05/26 00:27:43 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -61,8 +61,6 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
-void setredzone __P((pt_entry_t *, caddr_t));
-
/*
* Finish a fork operation, with process p2 nearly set up.
* Copy and update the kernel stack and pcb, making the child
@@ -88,7 +86,7 @@ cpu_fork(p1, p2)
savectx(curpcb);
*pcb = p1->p_addr->u_pcb;
- PMAP_ACTIVATE(&p2->p_vmspace->vm_pmap, pcb, 0);
+ PMAP_ACTIVATE(p2->p_vmspace->vm_map.pmap, pcb, 0);
/*
* Copy the trap frame, and arrange for the child to return directly
@@ -262,25 +260,6 @@ physunaccess(vaddr, size)
}
/*
- * Set a red zone in the kernel stack after the u. area.
- * We don't support a redzone right now. It really isn't clear
- * that it is a good idea since, if the kernel stack were to roll
- * into a write protected page, the processor would lock up (since
- * it cannot create an exception frame) and we would get no useful
- * post-mortem info. Currently, under the DEBUG option, we just
- * check at every clock interrupt to see if the current k-stack has
- * gone too far (i.e. into the "redzone" page) and if so, panic.
- * Look at _lev6intr in locore.s for more details.
- */
-/*ARGSUSED*/
-void
-setredzone(pte, vaddr)
- pt_entry_t *pte;
- caddr_t vaddr;
-{
-}
-
-/*
* Convert kernel VA to physical address
*/
int
diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h
index 51db1f37cbd..ba48571cc47 100644
--- a/sys/arch/hp300/include/cpu.h
+++ b/sys/arch/hp300/include/cpu.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: cpu.h,v 1.7 1997/04/17 10:28:40 downsj Exp $ */
-/* $NetBSD: cpu.h,v 1.24 1997/04/14 02:28:50 thorpej Exp $ */
+/* $OpenBSD: cpu.h,v 1.8 1997/07/06 08:02:11 downsj Exp $ */
+/* $NetBSD: cpu.h,v 1.25 1997/04/27 20:37:07 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -126,80 +126,12 @@ int want_resched; /* resched() was called */
{ "console_device", CTLTYPE_STRUCT }, \
}
-#ifdef _KERNEL
-/*
- * Associate HP 9000/300 models with CPU/MMU combinations.
- */
-
-/*
- * HP 68020-based computers. HP320 and HP350 have an HP MMU.
- * HP330 has a Motorola MMU.
- */
-#if (defined(HP320) || defined(HP330) || defined(HP350))
-#ifndef M68020
-#define M68020
-#endif /* ! M68020 */
-
-#if defined(HP330) && !defined(M68K_MMU_MOTOROLA)
-#define M68K_MMU_MOTOROLA
-#endif /* HP330 && ! M68K_MMU_MOTOROLA */
-
-#if (defined(HP320) || defined(HP350)) && !defined(M68K_MMU_HP)
-#define M68K_MMU_HP /* include cheezy VAC support */
-#endif /* (HP320 || HP350) && ! M68K_MMU_HP */
-#endif /* HP320 || HP330 || HP350 */
-
/*
- * HP 68030-based computers. HP375 includes support for the
- * 345, 400t, and 400s.
- */
-#if (defined(HP340) || defined(HP360) || defined(HP370) || defined(HP375))
-#ifndef M68030
-#define M68030
-#endif /* ! M68030 */
-
-#ifndef M68K_MMU_MOTOROLA
-#define M68K_MMU_MOTOROLA
-#endif /* ! M68K_MMU_MOTOROLA */
-#endif /* HP340 || HP360 || HP370 || HP375 */
-
-/*
- * HP 68040-based computers. HP380 includes support for the
- * 425t, 425s, and 433s.
- */
-#if defined(HP380)
-#ifndef M68040
-#define M68040
-#endif /* ! M68040 */
-
-#ifndef M68K_MMU_MOTOROLA
-#define M68K_MMU_MOTOROLA
-#endif /* ! M68K_MMU_MOTOROLA */
-#endif /* HP380 */
-#endif /* _KERNEL */
-
-/*
- * The rest of this should probably be moved to ../hp300/hp300cpu.h,
+ * The rest of this should probably be moved to <machine/hp300spu.h>,
* although some of it could probably be put into generic 68k headers.
*/
-/* values for machineid */
-#define HP_320 0 /* 16Mhz 68020+HP MMU+16K external cache */
-#define HP_330 1 /* 16Mhz 68020+68851 MMU */
-#define HP_350 2 /* 25Mhz 68020+HP MMU+32K external cache */
-#define HP_360 3 /* 25Mhz 68030 */
-#define HP_370 4 /* 33Mhz 68030+64K external cache */
-#define HP_340 5 /* 16Mhz 68030 */
-#define HP_375 6 /* 50Mhz 68030+32K external cache */
-#define HP_380 7 /* 25Mhz 68040 */
-#define HP_425 8 /* 25/33Mhz 68040 */
-#define HP_433 9 /* 33Mhz 68040 (maybe also 25MHz?) */
-
#ifdef _KERNEL
-extern int machineid; /* CPU model */
-extern int mmuid; /* MMU model */
-extern int cpuspeed; /* CPU speed, in MHz */
-
extern char *intiobase, *intiolimit;
extern void (*vectab[]) __P((void));
diff --git a/sys/arch/hp300/include/hp300spu.h b/sys/arch/hp300/include/hp300spu.h
new file mode 100644
index 00000000000..7e840442f58
--- /dev/null
+++ b/sys/arch/hp300/include/hp300spu.h
@@ -0,0 +1,143 @@
+/* $OpenBSD: hp300spu.h,v 1.1 1997/07/06 08:02:11 downsj Exp $ */
+/* $NetBSD: hp300spu.h,v 1.2 1997/05/01 05:26:48 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997 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.
+ */
+
+#ifndef _HP300_HP300SPU_H_
+#define _HP300_HP300SPU_H_
+
+/*
+ * This file describes various constants that describe and/or
+ * are unique to the HP 9000/300 or 400 SPUs.
+ */
+
+/* values for machineid */
+#define HP_320 0 /* 16MHz 68020+HP MMU+16K external cache */
+#define HP_330 1 /* 16MHz 68020+68851 MMU */
+#define HP_350 2 /* 25MHz 68020+HP MMU+32K external cache */
+#define HP_360 3 /* 25MHz 68030 */
+#define HP_370 4 /* 33MHz 68030+64K external cache */
+#define HP_340 5 /* 16MHz 68030 */
+#define HP_345 6 /* 50MHz 68030+32K external cache */
+#define HP_375 7 /* 50MHz 68030+32K external cache */
+#define HP_400 8 /* 50MHz 68030+32K external cache */
+#define HP_380 9 /* 25MHz 68040 */
+#define HP_425 10 /* 26MHz 68040 */
+#define HP_433 11 /* 33MHz 68040 */
+
+/* values for mmuid - used to differentiate similar CPU/cache combos */
+#define MMUID_345 1 /* 345 */
+#define MMUID_375 3 /* 375 */
+#define MMUID_425_T 5 /* 425t - 25MHz Trailways */
+#define MMUID_425_S 7 /* 425s - 25MHz Strider */
+#define MMUID_433_T 4 /* 433t - 33MHz Trailways */
+#define MMUID_433_S 6 /* 433s - 33MHz Strider */
+
+#define MMUID_SHIFT 8 /* left shift by this... */
+#define MMUID_MASK 0xff /* ...and mask with this to get mmuid */
+
+#if defined (_KERNEL) && !defined(_LOCORE)
+extern int machineid; /* CPU model */
+extern int cpuspeed; /* CPU speed, in MHz */
+extern int mmuid; /* MMU id */
+#endif /* _KERNEL && ! _LOCORE */
+
+#ifdef _KERNEL
+
+/*
+ * This section associates hp300 model configurations with certain
+ * combindations of CPU, MMU, and cache.
+ */
+
+/*
+ * Pull in user-defined SPU configuration options.
+ */
+#include "opt_hp320.h"
+#include "opt_hp330.h"
+#include "opt_hp340.h"
+#include "opt_hp345.h"
+#include "opt_hp350.h"
+#include "opt_hp360.h"
+#include "opt_hp370.h"
+#include "opt_hp375.h"
+#include "opt_hp380.h"
+#include "opt_hp400.h"
+#include "opt_hp425.h"
+#include "opt_hp433.h"
+
+/*
+ * CPU configuration.
+ */
+#if defined(HP320) || defined(HP330) || defined(HP350)
+#define M68020
+#endif
+
+#if defined(HP340) || defined(HP345) || defined(HP360) || defined(HP370) || \
+ defined(HP375) || defined(HP400)
+#define M68030
+#endif
+
+#if defined(HP380) || defined(HP425) || defined(HP433)
+#define M68040
+#endif
+
+/*
+ * MMU configuration.
+ */
+#if defined(HP320) || defined(HP350)
+#define M68K_MMU_HP
+#endif
+
+#if defined(HP330) || defined(M68030) || defined(M68040)
+#define M68K_MMU_MOTOROLA
+#endif
+
+/*
+ * Cache configuration.
+ */
+#if defined(M68K_MMU_HP)
+#define CACHE_HAVE_VAC
+#endif
+
+#if defined(HP345) || defined(HP360) || defined(HP370) || \
+ defined(HP375) || defined(HP400)
+#define CACHE_HAVE_PAC
+#endif
+
+#endif /* _KERNEL */
+
+#endif /* _HP300_HP300SPU_H_ */
diff --git a/sys/arch/hp300/include/hpux_machdep.h b/sys/arch/hp300/include/hpux_machdep.h
index 337986aa9fb..221b5a026ed 100644
--- a/sys/arch/hp300/include/hpux_machdep.h
+++ b/sys/arch/hp300/include/hpux_machdep.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: hpux_machdep.h,v 1.5 1997/04/16 11:56:34 downsj Exp $ */
-/* $NetBSD: hpux_machdep.h,v 1.7 1997/04/01 20:05:14 scottr Exp $ */
+/* $OpenBSD: hpux_machdep.h,v 1.6 1997/07/06 08:02:12 downsj Exp $ */
+/* $NetBSD: hpux_machdep.h,v 1.8 1997/04/27 21:38:58 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,8 +72,6 @@ struct exec_vmcmd;
int hpux_cpu_makecmds __P((struct proc *, struct exec_package *));
int hpux_cpu_vmcmd __P((struct proc *, struct exec_vmcmd *));
-void hpux_cpu_bsd_to_hpux_stat __P((struct stat *, struct hpux_stat *));
-void hpux_cpu_uname __P((struct hpux_utsname *));
int hpux_cpu_sysconf_arch __P((void));
int hpux_to_bsd_uoff __P((int *, int *, struct proc *));
diff --git a/sys/arch/hp300/include/param.h b/sys/arch/hp300/include/param.h
index 1d5f8e5baeb..a3c8014b130 100644
--- a/sys/arch/hp300/include/param.h
+++ b/sys/arch/hp300/include/param.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: param.h,v 1.7 1997/04/16 11:56:35 downsj Exp $ */
-/* $NetBSD: param.h,v 1.32 1997/04/14 02:28:51 thorpej Exp $ */
+/* $OpenBSD: param.h,v 1.8 1997/07/06 08:02:13 downsj Exp $ */
+/* $NetBSD: param.h,v 1.34 1997/06/10 18:59:12 veego Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -43,109 +43,36 @@
* @(#)param.h 8.1 (Berkeley) 6/10/93
*/
+#ifndef _MACHINE_PARAM_H_
+#define _MACHINE_PARAM_H_
+
/*
* Machine dependent constants for HP9000 series 300.
*/
#define _MACHINE hp300
#define MACHINE "hp300"
-#define _MACHINE_ARCH m68k
-#define MACHINE_ARCH "m68k"
-#define MID_MACHINE MID_M68K
/*
* Interrupt glue.
*/
#include <machine/intr.h>
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value for all
- * data types (int, long, ...). The result is u_int and must be cast to
- * any desired pointer type.
- */
-#define ALIGNBYTES (sizeof(int) - 1)
-#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-
#define PGSHIFT 12 /* LOG2(NBPG) */
-#define NBPG (1 << PGSHIFT) /* bytes/page */
-#define PGOFSET (NBPG-1) /* byte offset into page */
-#define NPTEPG (NBPG/(sizeof (pt_entry_t)))
+#define KERNBASE 0x00000000 /* start of kernel virtual */
#define SEGSHIFT 22 /* LOG2(NBSEG) */
#define NBSEG (1 << SEGSHIFT) /* bytes/segment */
#define SEGOFSET (NBSEG-1) /* byte offset into segment */
-#define KERNBASE 0x00000000 /* start of kernel virtual */
-#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
-
-#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
-#define DEV_BSIZE (1 << DEV_BSHIFT)
-#define BLKDEV_IOSIZE 2048
-#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
-
-#define CLSIZELOG2 0
-#define CLSIZE (1 << CLSIZELOG2)
-
-/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
-#define SSIZE 1 /* initial stack size/NBPG */
-#define SINCR 1 /* increment of stack/NBPG */
-#define UPAGES 2 /* pages of u-area */
-#define USPACE (UPAGES * NBPG) /* total size of u-area */
-
-/*
- * Constants related to network buffer management.
- * MCLBYTES must be no larger than CLBYTES (the software page size), and,
- * on machines that exchange pages of input or output buffers with mbuf
- * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
- * of the hardware page size.
- */
-#define MSIZE 128 /* size of an mbuf */
-#define MCLSHIFT 11
-#define MCLBYTES (1 << MCLSHIFT) /* large enough for ether MTU */
-#define MCLOFSET (MCLBYTES - 1)
-
-#ifndef NMBCLUSTERS
-#ifdef GATEWAY
-#define NMBCLUSTERS 512 /* map size, max cluster allocation */
-#else
-#define NMBCLUSTERS 256 /* map size, max cluster allocation */
-#endif
-#endif
+#include <m68k/param.h>
/*
* Size of kernel malloc arena in CLBYTES-sized logical pages
*/
#ifndef NKMEMCLUSTERS
-#define NKMEMCLUSTERS (2048 * 1024 / CLBYTES)
+# define NKMEMCLUSTERS (2048 * 1024 / CLBYTES)
#endif
-/* pages ("clicks") to disk blocks */
-#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
-#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
-
-/* pages to bytes */
-#define ctob(x) ((x) << PGSHIFT)
-#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
-
-/* bytes to disk blocks */
-#define dbtob(x) ((x) << DEV_BSHIFT)
-#define btodb(x) ((x) >> DEV_BSHIFT)
-
-/*
- * Map a ``block device block'' to a file system block.
- * This should be device dependent, and should use the bsize
- * field from the disk label.
- * For now though just use DEV_BSIZE.
- */
-#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
-
-/*
- * Mach derived conversion macros
- */
-#define hp300_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET)
-#define hp300_trunc_page(x) ((unsigned)(x) & ~PGOFSET)
-#define hp300_btop(x) ((unsigned)(x) >> PGSHIFT)
-#define hp300_ptob(x) ((unsigned)(x) << PGSHIFT)
-
#if defined(_KERNEL) && !defined(_LOCORE)
#define delay(us) _delay((us) << 8)
#define DELAY(us) delay(us)
@@ -166,3 +93,5 @@ void _delay __P((u_int));
#define HPMMBASEADDR(v) \
((unsigned)(v) & ~HPMMMASK)
#endif
+
+#endif /* !_MACHINE_PARAM_H_ */
diff --git a/sys/arch/hp300/include/pmap.h b/sys/arch/hp300/include/pmap.h
index a90af0d3711..2c71617d631 100644
--- a/sys/arch/hp300/include/pmap.h
+++ b/sys/arch/hp300/include/pmap.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: pmap.h,v 1.4 1997/03/26 08:32:46 downsj Exp $ */
-/* $NetBSD: pmap.h,v 1.12 1997/03/18 16:39:30 mycroft Exp $ */
+/* $OpenBSD: pmap.h,v 1.5 1997/07/06 08:02:13 downsj Exp $ */
+/* $NetBSD: pmap.h,v 1.13 1997/06/10 18:58:19 veego Exp $ */
/*
* Copyright (c) 1987 Carnegie-Mellon University
@@ -95,7 +95,7 @@ typedef struct pmap *pmap_t;
*/
#define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \
if ((pmapp)->pm_stchanged) { \
- (pcbp)->pcb_ustp = hp300_btop((vm_offset_t)(pmapp)->pm_stpa); \
+ (pcbp)->pcb_ustp = m68k_btop((vm_offset_t)(pmapp)->pm_stpa); \
if (iscurproc) \
loadustp((pcbp)->pcb_ustp); \
(pmapp)->pm_stchanged = FALSE; \