diff options
59 files changed, 1196 insertions, 975 deletions
diff --git a/sys/arch/sun3/dev/bw2.c b/sys/arch/sun3/dev/bw2.c index 3ce58a1061b..63f28bc5bbc 100644 --- a/sys/arch/sun3/dev/bw2.c +++ b/sys/arch/sun3/dev/bw2.c @@ -1,4 +1,4 @@ -/* $NetBSD: bw2.c,v 1.8 1996/10/13 03:47:25 christos Exp $ */ +/* $NetBSD: bw2.c,v 1.9 1996/12/17 21:10:37 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -51,24 +51,28 @@ */ #include <sys/param.h> +#include <sys/systm.h> +#include <sys/conf.h> #include <sys/device.h> #include <sys/ioctl.h> #include <sys/malloc.h> #include <sys/mman.h> +#include <sys/proc.h> #include <sys/tty.h> #include <vm/vm.h> +#include <machine/autoconf.h> +#include <machine/control.h> #include <machine/cpu.h> #include <machine/fbio.h> -#include <machine/autoconf.h> +#include <machine/idprom.h> #include <machine/pmap.h> -#include <machine/control.h> #include "fbvar.h" #include "bw2reg.h" -extern unsigned char cpu_machine_id; +cdev_decl(bw2); /* per-display variables */ struct bw2_softc { @@ -91,17 +95,14 @@ struct cfdriver bwtwo_cd = { /* XXX we do not handle frame buffer interrupts */ -/* frame buffer generic driver */ -int bw2open(), bw2close(), bw2ioctl(), bw2mmap(); - -static int bw2gvideo __P((struct fbdevice *, int *)); -static int bw2svideo __P((struct fbdevice *, int *)); +static int bw2gvideo __P((struct fbdevice *, void *)); +static int bw2svideo __P((struct fbdevice *, void *)); static struct fbdriver bw2fbdriver = { bw2open, bw2close, bw2mmap, - enoioctl, /* gattr */ + fb_noioctl, bw2gvideo, bw2svideo, - enoioctl, enoioctl }; + fb_noioctl, fb_noioctl, }; static int bw2match(parent, vcf, args) @@ -145,7 +146,6 @@ bw2attach(parent, self, args) struct fbdevice *fb = &sc->sc_fb; struct confargs *ca = args; struct fbtype *fbt; - int ramsize; sc->sc_phys = ca->ca_paddr; @@ -239,10 +239,11 @@ bw2mmap(dev, off, prot) } /* FBIOGVIDEO: */ -static int bw2gvideo(fb, on) +static int bw2gvideo(fb, data) struct fbdevice *fb; - int *on; + void *data; { + int *on = data; int s, ena; s = splhigh(); @@ -254,10 +255,11 @@ static int bw2gvideo(fb, on) } /* FBIOSVIDEO */ -static int bw2svideo(fb, on) +static int bw2svideo(fb, data) struct fbdevice *fb; - int *on; + void *data; { + int *on = data; int s, ena; s = splhigh(); diff --git a/sys/arch/sun3/dev/cg2.c b/sys/arch/sun3/dev/cg2.c index 0567eed2b29..369e9283dd9 100644 --- a/sys/arch/sun3/dev/cg2.c +++ b/sys/arch/sun3/dev/cg2.c @@ -1,4 +1,4 @@ -/* $NetBSD: cg2.c,v 1.7 1996/10/13 03:47:26 christos Exp $ */ +/* $NetBSD: cg2.c,v 1.8 1996/12/17 21:10:38 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -53,10 +53,13 @@ */ #include <sys/param.h> +#include <sys/systm.h> +#include <sys/conf.h> #include <sys/device.h> #include <sys/ioctl.h> #include <sys/malloc.h> #include <sys/mman.h> +#include <sys/proc.h> #include <sys/tty.h> #include <vm/vm.h> @@ -68,6 +71,8 @@ #include "fbvar.h" +cdev_decl(cg2); + #define CMSIZE 256 /* offset to and size of mapped part of frame buffer */ @@ -102,21 +107,17 @@ struct cfdriver cgtwo_cd = { NULL, "cgtwo", DV_DULL }; -/* frame buffer generic driver */ -int cg2open(), cg2close(), cg2mmap(); - -static int cg2gattr __P((struct fbdevice *, struct fbgattr *)); -static int cg2gvideo __P((struct fbdevice *, int *)); -static int cg2svideo __P((struct fbdevice *, int *)); -static int cg2getcmap __P((struct fbdevice *, struct fbcmap *)); -static int cg2putcmap __P((struct fbdevice *, struct fbcmap *)); +static int cg2gattr __P((struct fbdevice *, void *)); +static int cg2gvideo __P((struct fbdevice *, void *)); +static int cg2svideo __P((struct fbdevice *, void *)); +static int cg2getcmap __P((struct fbdevice *, void *)); +static int cg2putcmap __P((struct fbdevice *, void *)); static struct fbdriver cg2fbdriver = { cg2open, cg2close, cg2mmap, cg2gattr, cg2gvideo, cg2svideo, cg2getcmap, cg2putcmap }; -static void cg2loadcmap __P((struct cg2_softc *, int, int)); static int cg2intr __P((void*)); /* @@ -158,7 +159,6 @@ cg2attach(parent, self, args) struct fbdevice *fb = &sc->sc_fb; struct confargs *ca = args; struct fbtype *fbt; - int i, ramsize, pa; sc->sc_phys = ca->ca_paddr; sc->sc_pmtype = PMAP_NC | PMAP_VME16; @@ -238,7 +238,6 @@ cg2mmap(dev, off, prot) int off, prot; { struct cg2_softc *sc = cgtwo_cd.cd_devs[minor(dev)]; - int realoff; if (off & PGOFSET) panic("cg2mmap"); @@ -258,10 +257,11 @@ cg2mmap(dev, off, prot) */ /* FBIOGATTR: */ -static int cg2gattr(fb, fba) +static int cg2gattr(fb, data) struct fbdevice *fb; - struct fbgattr *fba; + void *data; { + struct fbgattr *fba = data; fba->real_type = fb->fb_fbtype.fb_type; fba->owner = 0; /* XXX - TIOCCONS stuff? */ @@ -275,10 +275,11 @@ static int cg2gattr(fb, fba) } /* FBIOGVIDEO: */ -static int cg2gvideo(fb, on) +static int cg2gvideo(fb, data) struct fbdevice *fb; - int *on; + void *data; { + int *on = data; struct cg2_softc *sc = fb->fb_private; *on = sc->sc_ctlreg->status.reg.video_enab; @@ -286,10 +287,11 @@ static int cg2gvideo(fb, on) } /* FBIOSVIDEO: */ -static int cg2svideo(fb, on) +static int cg2svideo(fb, data) struct fbdevice *fb; - int *on; + void *data; { + int *on = data; struct cg2_softc *sc = fb->fb_private; sc->sc_ctlreg->status.reg.video_enab = (*on) & 1; @@ -298,10 +300,11 @@ static int cg2svideo(fb, on) } /* FBIOGETCMAP: */ -static int cg2getcmap(fb, cmap) +static int cg2getcmap(fb, data) struct fbdevice *fb; - struct fbcmap *cmap; + void *data; { + struct fbcmap *cmap = data; struct cg2_softc *sc = fb->fb_private; u_char red[CMSIZE], green[CMSIZE], blue[CMSIZE]; int error, start, count, ecount; @@ -339,10 +342,11 @@ static int cg2getcmap(fb, cmap) } /* FBIOPUTCMAP: */ -static int cg2putcmap(fb, cmap) +static int cg2putcmap(fb, data) struct fbdevice *fb; - struct fbcmap *cmap; + void *data; { + struct fbcmap *cmap = data; struct cg2_softc *sc = fb->fb_private; u_char red[CMSIZE], green[CMSIZE], blue[CMSIZE]; int error, start, count, ecount; diff --git a/sys/arch/sun3/dev/cg4.c b/sys/arch/sun3/dev/cg4.c index 960e7bdb0fe..170621cab8f 100644 --- a/sys/arch/sun3/dev/cg4.c +++ b/sys/arch/sun3/dev/cg4.c @@ -1,4 +1,4 @@ -/* $NetBSD: cg4.c,v 1.11 1996/10/29 19:54:19 gwr Exp $ */ +/* $NetBSD: cg4.c,v 1.12 1996/12/17 21:10:39 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -60,17 +60,20 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/conf.h> #include <sys/device.h> #include <sys/ioctl.h> #include <sys/malloc.h> #include <sys/mman.h> +#include <sys/proc.h> #include <sys/tty.h> #include <vm/vm.h> +#include <machine/autoconf.h> #include <machine/cpu.h> #include <machine/fbio.h> -#include <machine/autoconf.h> +#include <machine/idprom.h> #include <machine/pmap.h> #include "fbvar.h" @@ -78,6 +81,8 @@ #include "btvar.h" #include "cg4reg.h" +cdev_decl(cg4); + #define CG4_MMAP_SIZE (CG4_OVERLAY_SIZE + CG4_ENABLE_SIZE + CG4_PIXMAP_SIZE) extern unsigned char cpu_machine_id; @@ -116,14 +121,11 @@ struct cfdriver cgfour_cd = { NULL, "cgfour", DV_DULL }; -/* frame buffer generic driver */ -int cg4open(), cg4close(), cg4mmap(); - -static int cg4gattr __P((struct fbdevice *, struct fbgattr *)); -static int cg4gvideo __P((struct fbdevice *, int *)); -static int cg4svideo __P((struct fbdevice *, int *)); -static int cg4getcmap __P((struct fbdevice *, struct fbcmap *)); -static int cg4putcmap __P((struct fbdevice *, struct fbcmap *)); +static int cg4gattr __P((struct fbdevice *, void *)); +static int cg4gvideo __P((struct fbdevice *, void *)); +static int cg4svideo __P((struct fbdevice *, void *)); +static int cg4getcmap __P((struct fbdevice *, void *)); +static int cg4putcmap __P((struct fbdevice *, void *)); static void cg4a_init __P((struct cg4_softc *)); static void cg4a_svideo __P((struct cg4_softc *, int)); @@ -343,10 +345,11 @@ cg4mmap(dev, off, prot) */ /* FBIOGATTR: */ -static int cg4gattr(fb, fba) +static int cg4gattr(fb, data) struct fbdevice *fb; - struct fbgattr *fba; + void *data; { + struct fbgattr *fba = data; fba->real_type = fb->fb_fbtype.fb_type; fba->owner = 0; /* XXX - TIOCCONS stuff? */ @@ -360,10 +363,11 @@ static int cg4gattr(fb, fba) } /* FBIOGVIDEO: */ -static int cg4gvideo(fb, on) +static int cg4gvideo(fb, data) struct fbdevice *fb; - int *on; + void *data; { + int *on = data; struct cg4_softc *sc = fb->fb_private; *on = !sc->sc_blanked; @@ -371,10 +375,11 @@ static int cg4gvideo(fb, on) } /* FBIOSVIDEO: */ -static int cg4svideo(fb, on) +static int cg4svideo(fb, data) struct fbdevice *fb; - int *on; + void *data; { + int *on = data; struct cg4_softc *sc = fb->fb_private; int state; @@ -390,10 +395,11 @@ static int cg4svideo(fb, on) * FBIOGETCMAP: * Copy current colormap out to user space. */ -static int cg4getcmap(fb, fbcm) +static int cg4getcmap(fb, data) struct fbdevice *fb; - struct fbcmap *fbcm; + void *data; { + struct fbcmap *fbcm = data; struct cg4_softc *sc = fb->fb_private; struct soft_cmap *cm = &sc->sc_cmap; int error, start, count; @@ -420,10 +426,11 @@ static int cg4getcmap(fb, fbcm) * FBIOPUTCMAP: * Copy new colormap from user space and load. */ -static int cg4putcmap(fb, fbcm) +static int cg4putcmap(fb, data) struct fbdevice *fb; - struct fbcmap *fbcm; + void *data; { + struct fbcmap *fbcm = data; struct cg4_softc *sc = fb->fb_private; struct soft_cmap *cm = &sc->sc_cmap; int error, start, count; diff --git a/sys/arch/sun3/dev/eeprom.c b/sys/arch/sun3/dev/eeprom.c index 4277845016f..f5c94b506b7 100644 --- a/sys/arch/sun3/dev/eeprom.c +++ b/sys/arch/sun3/dev/eeprom.c @@ -1,9 +1,12 @@ -/* $NetBSD: eeprom.c,v 1.8 1996/03/26 15:16:06 gwr Exp $ */ +/* $NetBSD: eeprom.c,v 1.13 1996/12/17 21:10:40 gwr Exp $ */ -/* - * Copyright (c) 1994 Gordon W. Ross +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -12,19 +15,25 @@ * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * 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. */ /* @@ -33,6 +42,9 @@ * handle the painful task of updating the EEPROM contents. * After a write, it must not be touched for 10 milliseconds. * (See the Sun-3 Architecture Manual sec. 5.9) + * + * XXX: Should just keep a copy of the EEPROM contents in RAM + * (read it once at init time) to avoid the eeprom_uio hair. */ #include <sys/param.h> @@ -41,6 +53,7 @@ #include <sys/conf.h> #include <sys/buf.h> #include <sys/malloc.h> +#include <sys/proc.h> #include <machine/autoconf.h> #include <machine/obio.h> @@ -55,7 +68,7 @@ static int ee_update(caddr_t buf, int off, int cnt); static char *eeprom_va; static int ee_busy, ee_want; -static int eeprom_match __P((struct device *, void *vcf, void *args)); +static int eeprom_match __P((struct device *, void *, void *)); static void eeprom_attach __P((struct device *, struct device *, void *)); struct cfattach eeprom_ca = { @@ -78,23 +91,15 @@ eeprom_match(parent, vcf, args) struct device *parent; void *vcf, *args; { - struct cfdata *cf = vcf; + struct cfdata *cf = vcf; struct confargs *ca = args; - int pa; /* This driver only supports one unit. */ if (cf->cf_unit != 0) return (0); - if ((pa = cf->cf_paddr) == -1) { - /* Use our default PA. */ - pa = OBIO_EEPROM; - } else { - /* Validate the given PA. */ - if (pa != OBIO_EEPROM) - return (0); - } - if (pa != ca->ca_paddr) + /* Validate the given address. */ + if (ca->ca_paddr != OBIO_EEPROM) return (0); if (eeprom_va == NULL) @@ -109,13 +114,14 @@ eeprom_attach(parent, self, args) struct device *self; void *args; { - struct confargs *ca = args; printf("\n"); } -static int ee_take() /* Take the lock. */ +/* Take the lock. */ +static int +ee_take __P((void)) { int error = 0; while (ee_busy) { @@ -130,7 +136,9 @@ static int ee_take() /* Take the lock. */ return error; } -static void ee_give() /* Give the lock. */ +/* Give the lock. */ +static void +ee_give __P((void)) { ee_busy = 0; if (ee_want) { @@ -139,7 +147,11 @@ static void ee_give() /* Give the lock. */ } } -int eeprom_uio(struct uio *uio) +/* + * XXX - Just keep a soft copy of the eeprom? + */ +int +eeprom_uio(struct uio *uio) { int error; int off; /* NOT off_t */ @@ -190,7 +202,8 @@ int eeprom_uio(struct uio *uio) /* * Update the EEPROM from the passed buf. */ -static int ee_update(char *buf, int off, int cnt) +static int +ee_update(char *buf, int off, int cnt) { volatile char *ep; char *bp; diff --git a/sys/arch/sun3/dev/fb.c b/sys/arch/sun3/dev/fb.c index dea031c9798..afa12f78f52 100644 --- a/sys/arch/sun3/dev/fb.c +++ b/sys/arch/sun3/dev/fb.c @@ -1,4 +1,4 @@ -/* $NetBSD: fb.c,v 1.3 1995/04/10 05:45:56 mycroft Exp $ */ +/* $NetBSD: fb.c,v 1.4 1996/12/17 21:10:41 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -49,6 +49,7 @@ */ #include <sys/param.h> +#include <sys/systm.h> #include <sys/conf.h> #include <sys/device.h> #include <sys/ioctl.h> @@ -58,6 +59,8 @@ #include "fbvar.h" +cdev_decl(fb); + static struct fbdevice *devfb; static int fbpriority; @@ -117,16 +120,6 @@ fbmmap(dev, off, prot) return ((*devfb->fb_driver->fbd_mmap)(dev, off, prot)); } -void -fb_unblank() -{ - int on = 1; - - if (devfb) { - (void) fbioctlfb(devfb, FBIOSVIDEO, (caddr_t)&on); - } -} - /* * Common fb ioctl function */ @@ -137,33 +130,34 @@ fbioctlfb(fb, cmd, data) caddr_t data; { struct fbdriver *fbd = fb->fb_driver; + void *vp = (void *)data; int error; switch (cmd) { case FBIOGTYPE: - *(struct fbtype *)data = fb->fb_fbtype; + *(struct fbtype *)vp = fb->fb_fbtype; error = 0; break; case FBIOGATTR: - error = (*fbd->fbd_gattr)(fb, (struct fbgattr *)data); + error = (*fbd->fbd_gattr)(fb, vp); break; case FBIOGVIDEO: - error = (*fbd->fbd_gvideo)(fb, (int *)data); + error = (*fbd->fbd_gvideo)(fb, vp); break; case FBIOSVIDEO: - error = (*fbd->fbd_svideo)(fb, (int *)data); + error = (*fbd->fbd_svideo)(fb, vp); break; case FBIOGETCMAP: - error = (*fbd->fbd_getcmap)(fb, (struct fbcmap *)data); + error = (*fbd->fbd_getcmap)(fb, vp); break; case FBIOPUTCMAP: - error = (*fbd->fbd_putcmap)(fb, (struct fbcmap *)data); + error = (*fbd->fbd_putcmap)(fb, vp); break; default: @@ -171,3 +165,27 @@ fbioctlfb(fb, cmd, data) } return (error); } + +void +fb_unblank() +{ + int on = 1; + + if (devfb == NULL) + return; + + (*devfb->fb_driver->fbd_svideo)(devfb, (void *)&on); +} + +/* + * Default ioctl function to put in struct fbdriver + * for functions that are not supported. + */ +int +fb_noioctl(fbd, vp) + struct fbdevice *fbd; + void *vp; +{ + return ENOTTY; +} + diff --git a/sys/arch/sun3/dev/fbvar.h b/sys/arch/sun3/dev/fbvar.h index aae60c99151..6a8b64e2bb4 100644 --- a/sys/arch/sun3/dev/fbvar.h +++ b/sys/arch/sun3/dev/fbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: fbvar.h,v 1.3 1996/10/29 19:27:37 gwr Exp $ */ +/* $NetBSD: fbvar.h,v 1.4 1996/12/17 21:10:42 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -49,6 +49,8 @@ * following in order to participate. */ +struct fbcmap; + struct fbdevice { struct fbtype fb_fbtype; /* see fbio.h */ struct fbdriver *fb_driver; /* pointer to driver */ @@ -71,13 +73,16 @@ struct fbdriver { int (*fbd_close) __P((dev_t, int, int, struct proc *)); int (*fbd_mmap) __P((dev_t, int, int)); /* These are the internal ioctl functions */ - int (*fbd_gattr) __P((struct fbdevice *, struct fbgattr *)); - int (*fbd_gvideo) __P((struct fbdevice *, int *)); - int (*fbd_svideo) __P((struct fbdevice *, int *)); - int (*fbd_getcmap) __P((struct fbdevice *, struct fbcmap *)); - int (*fbd_putcmap) __P((struct fbdevice *, struct fbcmap *)); + int (*fbd_gattr) __P((struct fbdevice *, void *)); + int (*fbd_gvideo) __P((struct fbdevice *, void *)); + int (*fbd_svideo) __P((struct fbdevice *, void *)); + int (*fbd_getcmap) __P((struct fbdevice *, void *)); + int (*fbd_putcmap) __P((struct fbdevice *, void *)); }; -void fb_attach __P((struct fbdevice *, int)); int fbioctlfb __P((struct fbdevice *, u_long, caddr_t)); -extern int enoioctl(); + +void fb_attach __P((struct fbdevice *, int)); +int fb_noioctl __P((struct fbdevice *, void *)); +void fb_unblank __P((void)); + diff --git a/sys/arch/sun3/dev/i82586.h b/sys/arch/sun3/dev/i82586.h index 748ab762647..7eb5fa190aa 100644 --- a/sys/arch/sun3/dev/i82586.h +++ b/sys/arch/sun3/dev/i82586.h @@ -1,4 +1,4 @@ -/* $NetBSD: i82586.h,v 1.3 1995/10/08 23:41:36 gwr Exp $ */ +/* $NetBSD: i82586.h,v 1.4 1996/12/13 19:54:08 gwr Exp $ */ /*- * Copyright (c) 1992, University of Vermont and State Agricultural College. @@ -236,7 +236,7 @@ struct ie_xmit_buf { * Multicast setup command. */ -#define MAXMCAST 50 /* must fit in transmit buffer */ +#define MAXMCAST 250 /* must fit in transmit buffer */ struct ie_mcast_cmd { struct ie_cmd_common com; /* common part */ diff --git a/sys/arch/sun3/dev/idprom.c b/sys/arch/sun3/dev/idprom.c index 70c9d2f2892..ead8f65c081 100644 --- a/sys/arch/sun3/dev/idprom.c +++ b/sys/arch/sun3/dev/idprom.c @@ -1,4 +1,4 @@ -/* $NetBSD: idprom.c,v 1.13 1996/11/20 18:56:50 gwr Exp $ */ +/* $NetBSD: idprom.c,v 1.15 1996/12/17 21:10:43 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -43,61 +43,25 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> +#include <sys/kernel.h> #include <machine/autoconf.h> #include <machine/control.h> #include <machine/idprom.h> #include <machine/mon.h> -extern long hostid; /* in kern_sysctl.c */ - /* * This structure is what this driver is all about. * It is copied from control space early in startup. */ struct idprom identity_prom; -int idpromopen(dev, oflags, devtype, p) - dev_t dev; - int oflags; - int devtype; - struct proc *p; -{ - return 0; -} - -int idpromclose(dev, fflag, devtype, p) - dev_t dev; - int fflag; - int devtype; - struct proc *p; -{ - return 0; -} - -idpromread(dev, uio, ioflag) - dev_t dev; - struct uio *uio; - int ioflag; -{ - int error, unit, length; - - error = 0; - while (uio->uio_resid > 0 && error == 0) { - if (uio->uio_offset >= IDPROM_SIZE) - break; /* past or at end */ - length = min(uio->uio_resid, - (IDPROM_SIZE - (int)uio->uio_offset)); - error = uiomove((caddr_t) &identity_prom, length, uio); - } - return error; -} - /* * This is called very early during startup to * get a copy of the idprom from control space. */ -int idprom_init() +int +idprom_init() { struct idprom *idp; char *src, *dst; diff --git a/sys/arch/sun3/dev/if_ie.c b/sys/arch/sun3/dev/if_ie.c index 32f52c05e8f..3486a1fa4c9 100644 --- a/sys/arch/sun3/dev/if_ie.c +++ b/sys/arch/sun3/dev/if_ie.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie.c,v 1.15 1996/10/30 00:24:33 gwr Exp $ */ +/* $NetBSD: if_ie.c,v 1.16 1996/12/17 21:10:44 gwr Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles Hannum. @@ -135,16 +135,16 @@ #include <vm/vm.h> +#include <machine/autoconf.h> +#include <machine/cpu.h> +#include <machine/pmap.h> + /* * ugly byte-order hack for SUNs */ -#define SWAP(x) ((u_short)(XSWAP((u_short)(x)))) #define XSWAP(y) ( ((y) >> 8) | ((y) << 8) ) - -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/pmap.h> +#define SWAP(x) ((u_short)(XSWAP((u_short)(x)))) #include "i82586.h" #include "if_iereg.h" @@ -172,15 +172,35 @@ int ieinit __P((struct ie_softc *)); int ieioctl __P((struct ifnet *, u_long, caddr_t)); void iestart __P((struct ifnet *)); void iereset __P((struct ie_softc *)); -static void ie_readframe __P((struct ie_softc *, int)); +int ie_setupram __P((struct ie_softc *sc)); + +static void chan_attn_timeout __P((void *arg)); +static int cmd_and_wait __P((struct ie_softc *, int, void *, int)); + static void ie_drop_packet_buffer __P((struct ie_softc *)); -static int command_and_wait __P((struct ie_softc *, int, - void volatile *, int)); +static void ie_readframe __P((struct ie_softc *, int)); +static void ie_setup_config __P((struct ie_config_cmd *, int, int)); + static void ierint __P((struct ie_softc *)); +static void iestop __P((struct ie_softc *)); static void ietint __P((struct ie_softc *)); -static void setup_bufs __P((struct ie_softc *)); +static void iexmit __P((struct ie_softc *)); + static int mc_setup __P((struct ie_softc *, void *)); static void mc_reset __P((struct ie_softc *)); +static void run_tdr __P((struct ie_softc *, struct ie_tdr_cmd *)); +static void setup_bufs __P((struct ie_softc *)); + +static inline caddr_t Align __P((caddr_t ptr)); +static inline void ie_ack __P((struct ie_softc *, u_int)); +static inline u_short ether_cmp __P((u_char *, u_char *)); +static inline int check_eh __P((struct ie_softc *, + struct ether_header *eh, int *)); +static inline int ie_buflen __P((struct ie_softc *, int)); +static inline int ie_packet_len __P((struct ie_softc *)); +static inline int ieget __P((struct ie_softc *sc, + struct mbuf **mp, struct ether_header *ehp, int *to_bpf)); + #ifdef IEDEBUG void print_rbd __P((volatile struct ie_recv_buf_desc *)); @@ -215,7 +235,7 @@ struct cfdriver ie_cd = { */ static inline void ie_setup_config(cmd, promiscuous, manchester) - volatile struct ie_config_cmd *cmd; + struct ie_config_cmd *cmd; int promiscuous, manchester; { @@ -253,7 +273,7 @@ ie_ack(sc, mask) { volatile struct ie_sys_ctl_block *scb = sc->scb; - command_and_wait(sc, scb->ie_status & mask, 0, 0); + cmd_and_wait(sc, scb->ie_status & mask, 0, 0); } @@ -349,8 +369,8 @@ ie_intr(v) volatile struct ievme *iev = (volatile struct ievme *)sc->sc_reg; if (iev->status & IEVME_PERR) { printf("%s: parity error (ctrl %x @ %02x%04x)\n", - iev->pectrl, iev->pectrl & IEVME_HADDR, - iev->peaddr); + sc->sc_dev.dv_xname, iev->pectrl, + iev->pectrl & IEVME_HADDR, iev->peaddr); iev->pectrl = iev->pectrl | IEVME_PARACK; } } @@ -437,7 +457,7 @@ ierint(sc) MK_16(sc->sc_maddr, sc->rbuffs[0]); scb->ie_recv_list = MK_16(sc->sc_maddr, sc->rframes[0]); - command_and_wait(sc, IE_RU_START, 0, 0); + cmd_and_wait(sc, IE_RU_START, 0, 0); } break; } @@ -455,7 +475,6 @@ ietint(sc) struct ie_softc *sc; { int status; - int i; sc->sc_arpcom.ac_if.if_timer = 0; sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; @@ -691,7 +710,7 @@ ie_packet_len(sc) * command to the chip to be executed. On the way, if we have a BPF listener * also give him a copy. */ -inline static void +static void iexmit(sc) struct ie_softc *sc; { @@ -722,7 +741,7 @@ iexmit(sc) sc->scb->ie_command_list = MK_16(sc->sc_maddr, sc->xmit_cmds[sc->xctail]); - command_and_wait(sc, IE_CU_START, 0, 0); + cmd_and_wait(sc, IE_CU_START, 0, 0); sc->xmit_busy = 1; sc->sc_arpcom.ac_if.if_timer = 5; @@ -1151,10 +1170,10 @@ iereset(sc) /* * Stop i82586 dead in its tracks. */ - if (command_and_wait(sc, IE_RU_ABORT | IE_CU_ABORT, 0, 0)) + if (cmd_and_wait(sc, IE_RU_ABORT | IE_CU_ABORT, 0, 0)) printf("%s: abort commands timed out\n", sc->sc_dev.dv_xname); - if (command_and_wait(sc, IE_RU_DISABLE | IE_CU_STOP, 0, 0)) + if (cmd_and_wait(sc, IE_RU_DISABLE | IE_CU_STOP, 0, 0)) printf("%s: disable commands timed out\n", sc->sc_dev.dv_xname); #ifdef notdef @@ -1172,10 +1191,10 @@ iereset(sc) * This is called if we time out. */ static void -chan_attn_timeout(rock) - caddr_t rock; +chan_attn_timeout(arg) + void *arg; { - *(int *) rock = 1; + *((int *)arg) = 1; } /* @@ -1188,10 +1207,10 @@ chan_attn_timeout(rock) * to become true. */ static int -command_and_wait(sc, cmd, pcmd, mask) +cmd_and_wait(sc, cmd, pcmd, mask) struct ie_softc *sc; int cmd; - volatile void *pcmd; + void * pcmd; int mask; { volatile struct ie_cmd_common *cc = pcmd; @@ -1216,7 +1235,7 @@ command_and_wait(sc, cmd, pcmd, mask) * .369 seconds, which we round up to .4. */ - timeout(chan_attn_timeout, (caddr_t)&timedout, 2 * hz / 5); + timeout(chan_attn_timeout, (void *)&timedout, 2 * hz / 5); /* * Now spin-lock waiting for status. This is not a very nice @@ -1229,7 +1248,7 @@ command_and_wait(sc, cmd, pcmd, mask) if ((cc->ie_cmd_status & mask) || timedout) break; - untimeout(chan_attn_timeout, (caddr_t)&timedout); + untimeout(chan_attn_timeout, (void *)&timedout); return timedout; } else { @@ -1262,7 +1281,7 @@ run_tdr(sc, cmd) sc->scb->ie_command_list = MK_16(sc->sc_maddr, cmd); cmd->ie_tdr_time = SWAP(0); - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) result = 0x10000; /* XXX */ else @@ -1307,9 +1326,7 @@ setup_bufs(sc) struct ie_softc *sc; { caddr_t ptr = sc->buf_area; /* memory pool */ - volatile struct ie_recv_frame_desc *rfd = (void *) ptr; - volatile struct ie_recv_buf_desc *rbd; - int n, r; + u_int n, r; /* * step 0: zero memory and figure out how many recv buffers and @@ -1318,14 +1335,16 @@ setup_bufs(sc) (sc->sc_bzero)(ptr, sc->buf_area_sz); ptr = Align(ptr); /* set alignment and stick with it */ - n = (int)Align(sizeof(struct ie_xmit_cmd)) + - (int)Align(sizeof(struct ie_xmit_buf)) + IE_TBUF_SIZE; + n = ALIGN(sizeof(struct ie_xmit_cmd)) + + ALIGN(sizeof(struct ie_xmit_buf)) + + IE_TBUF_SIZE; n *= NTXBUF; /* n = total size of xmit area */ n = sc->buf_area_sz - n;/* n = free space for recv stuff */ - r = (int)Align(sizeof(struct ie_recv_frame_desc)) + - (((int)Align(sizeof(struct ie_recv_buf_desc)) + IE_RBUF_SIZE) * B_PER_F); + r = ALIGN(sizeof(struct ie_recv_frame_desc)) + + ((ALIGN(sizeof(struct ie_recv_buf_desc)) + + IE_RBUF_SIZE) * B_PER_F); /* r = size of one R frame */ @@ -1436,7 +1455,7 @@ mc_setup(sc, ptr) struct ie_softc *sc; void *ptr; { - volatile struct ie_mcast_cmd *cmd = ptr; + struct ie_mcast_cmd *cmd = ptr; cmd->com.ie_cmd_status = SWAP(0); cmd->com.ie_cmd_cmd = IE_CMD_MCAST | IE_CMD_LAST; @@ -1449,7 +1468,7 @@ mc_setup(sc, ptr) SWAP(sc->mcast_count * ETHER_ADDR_LEN); /* grrr... */ sc->scb->ie_command_list = MK_16(sc->sc_maddr, cmd); - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { printf("%s: multicast address setup command failed\n", sc->sc_dev.dv_xname); @@ -1471,7 +1490,6 @@ ieinit(sc) { volatile struct ie_sys_ctl_block *scb = sc->scb; void *ptr; - int n; ptr = sc->buf_area; @@ -1479,7 +1497,7 @@ ieinit(sc) * Send the configure command first. */ { - volatile struct ie_config_cmd *cmd = ptr; + struct ie_config_cmd *cmd = ptr; scb->ie_command_list = MK_16(sc->sc_maddr, cmd); cmd->com.ie_cmd_status = SWAP(0); @@ -1488,7 +1506,7 @@ ieinit(sc) ie_setup_config(cmd, sc->promisc, 0); - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { printf("%s: configure command failed\n", sc->sc_dev.dv_xname); @@ -1500,7 +1518,7 @@ ieinit(sc) * Now send the Individual Address Setup command. */ { - volatile struct ie_iasetup_cmd *cmd = ptr; + struct ie_iasetup_cmd *cmd = ptr; scb->ie_command_list = MK_16(sc->sc_maddr, cmd); cmd->com.ie_cmd_status = SWAP(0); @@ -1510,7 +1528,7 @@ ieinit(sc) (sc->sc_bcopy)(sc->sc_arpcom.ac_enaddr, (caddr_t)&cmd->ie_address, sizeof cmd->ie_address); - if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { printf("%s: individual address setup command failed\n", sc->sc_dev.dv_xname); @@ -1537,7 +1555,7 @@ ieinit(sc) sc->sc_arpcom.ac_if.if_flags |= IFF_RUNNING; sc->scb->ie_recv_list = MK_16(sc->sc_maddr, sc->rframes[0]); - command_and_wait(sc, IE_RU_START, 0, 0); + cmd_and_wait(sc, IE_RU_START, 0, 0); ie_ack(sc, IE_ST_WHENCE); @@ -1552,7 +1570,7 @@ iestop(sc) struct ie_softc *sc; { - command_and_wait(sc, IE_RU_DISABLE, 0, 0); + cmd_and_wait(sc, IE_RU_DISABLE, 0, 0); } int diff --git a/sys/arch/sun3/dev/if_ie_obio.c b/sys/arch/sun3/dev/if_ie_obio.c index 76307fa0c92..773519e8d4a 100644 --- a/sys/arch/sun3/dev/if_ie_obio.c +++ b/sys/arch/sun3/dev/if_ie_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie_obio.c,v 1.6 1996/11/20 18:56:51 gwr Exp $ */ +/* $NetBSD: if_ie_obio.c,v 1.7 1996/12/17 21:10:45 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -58,7 +58,6 @@ #include <machine/autoconf.h> #include <machine/cpu.h> #include <machine/dvma.h> -#include <machine/isr.h> #include <machine/obio.h> #include <machine/idprom.h> #include <machine/vmparam.h> @@ -109,7 +108,6 @@ ie_obio_attach(parent, self, args) void *args; { struct ie_softc *sc = (void *) self; - struct cfdata *cf = self->dv_cfdata; struct confargs *ca = args; sc->hard_type = IE_OBIO; diff --git a/sys/arch/sun3/dev/if_ie_vmes.c b/sys/arch/sun3/dev/if_ie_vmes.c index 02dcc88e697..31403913eac 100644 --- a/sys/arch/sun3/dev/if_ie_vmes.c +++ b/sys/arch/sun3/dev/if_ie_vmes.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie_vmes.c,v 1.5 1996/11/20 18:56:51 gwr Exp $ */ +/* $NetBSD: if_ie_vmes.c,v 1.6 1996/12/17 21:10:46 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -58,7 +58,6 @@ #include <machine/autoconf.h> #include <machine/cpu.h> #include <machine/dvma.h> -#include <machine/isr.h> #include <machine/idprom.h> #include <machine/vmparam.h> @@ -74,7 +73,9 @@ static void ie_vmerun __P((struct ie_softc *)); * zero/copy functions: OBIO can use the normal functions, but VME * must do only byte or half-word (16 bit) accesses... */ -static void wcopy(), wzero(); +static void wcopy __P((const void *vb1, void *vb2, u_int l)); +static void wzero __P((void *vb, u_int l)); + /* * New-style autoconfig attachment @@ -93,8 +94,9 @@ ie_vmes_match(parent, vcf, args) struct device *parent; void *vcf, *args; { + struct cfdata *cf = vcf; struct confargs *ca = args; - int x, sz; + int x; #ifdef DIAGNOSTIC if (ca->ca_bustype != BUS_VME16) { diff --git a/sys/arch/sun3/dev/if_ievar.h b/sys/arch/sun3/dev/if_ievar.h index a68c5142d00..2923d0a21cd 100644 --- a/sys/arch/sun3/dev/if_ievar.h +++ b/sys/arch/sun3/dev/if_ievar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_ievar.h,v 1.6 1996/03/26 14:38:33 gwr Exp $ */ +/* $NetBSD: if_ievar.h,v 1.7 1996/12/17 21:10:47 gwr Exp $ */ /* * Machine-dependent glue for the Intel Ethernet (ie) driver. @@ -67,9 +67,11 @@ struct ie_softc { caddr_t sc_reg; /* KVA of card's register */ enum ie_hardware hard_type; /* card type */ - void (*reset_586)(); /* card dependent reset function */ - void (*chan_attn)(); /* card dependent attn function */ - void (*run_586)(); /* card dependent "go on-line" function */ + + /* card dependent functions: */ + void (*reset_586) __P((struct ie_softc *)); + void (*chan_attn) __P((struct ie_softc *)); + void (*run_586) __P((struct ie_softc *)); void (*sc_bcopy) __P((const void *, void *, u_int)); void (*sc_bzero) __P((void *, u_int)); diff --git a/sys/arch/sun3/dev/if_le.c b/sys/arch/sun3/dev/if_le.c index c4ae12b0394..b6085939fc8 100644 --- a/sys/arch/sun3/dev/if_le.c +++ b/sys/arch/sun3/dev/if_le.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le.c,v 1.33 1996/11/20 18:56:52 gwr Exp $ */ +/* $NetBSD: if_le.c,v 1.34 1996/12/17 21:10:48 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -55,7 +55,6 @@ #include <machine/autoconf.h> #include <machine/cpu.h> #include <machine/dvma.h> -#include <machine/isr.h> #include <machine/obio.h> #include <machine/idprom.h> @@ -141,7 +140,6 @@ le_attach(parent, self, aux) { struct le_softc *lesc = (struct le_softc *)self; struct am7990_softc *sc = &lesc->sc_am7990; - struct cfdata *cf = self->dv_cfdata; struct confargs *ca = aux; lesc->sc_r1 = (struct lereg1 *) diff --git a/sys/arch/sun3/dev/memerr.c b/sys/arch/sun3/dev/memerr.c index 0aafc273181..d5e8f4a1b61 100644 --- a/sys/arch/sun3/dev/memerr.c +++ b/sys/arch/sun3/dev/memerr.c @@ -1,4 +1,4 @@ -/* $NetBSD: memerr.c,v 1.6 1996/11/13 07:05:14 thorpej Exp $ */ +/* $NetBSD: memerr.c,v 1.7 1996/12/17 21:10:50 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -49,7 +49,9 @@ #include <sys/device.h> #include <machine/autoconf.h> +#include <machine/control.h> #include <machine/cpu.h> +#include <machine/idprom.h> #include <machine/obio.h> #include <machine/pte.h> @@ -71,7 +73,7 @@ struct memerr_softc { /* XXX: counters? */ }; -static int memerr_match __P((struct device *, void *vcf, void *args)); +static int memerr_match __P((struct device *, void *, void *)); static void memerr_attach __P((struct device *, struct device *, void *)); static int memerr_interrupt __P((void *)); static void memerr_correctable __P((struct memerr_softc *)); @@ -90,7 +92,7 @@ memerr_match(parent, vcf, args) struct device *parent; void *vcf, *args; { - struct cfdata *cf = vcf; + struct cfdata *cf = vcf; struct confargs *ca = args; /* This driver only supports one unit. */ @@ -170,7 +172,7 @@ memerr_interrupt(arg) { struct memerr_softc *sc = arg; volatile struct memerr *me = sc->sc_reg; - u_char csr, ctx, err; + u_char csr, ctx; u_int pa, va; int pte; diff --git a/sys/arch/sun3/dev/obio.c b/sys/arch/sun3/dev/obio.c index c015d61116c..e46e1db1389 100644 --- a/sys/arch/sun3/dev/obio.c +++ b/sys/arch/sun3/dev/obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: obio.c,v 1.23 1996/11/20 18:56:56 gwr Exp $ */ +/* $NetBSD: obio.c,v 1.25 1996/12/17 21:21:13 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -41,15 +41,15 @@ #include <sys/device.h> #include <machine/autoconf.h> +#include <machine/control.h> #include <machine/pte.h> #include <machine/mon.h> -#include <machine/isr.h> #include <machine/obio.h> static int obio_match __P((struct device *, void *, void *)); static void obio_attach __P((struct device *, struct device *, void *)); static int obio_print __P((void *, const char *parentname)); -static int obio_submatch __P((struct device *, void *, void *)); +static int obio_submatch __P((struct device *, void *, void *)); struct cfattach obio_ca = { sizeof(struct device), obio_match, obio_attach @@ -60,9 +60,9 @@ struct cfdriver obio_cd = { }; static int -obio_match(parent, vcf, aux) +obio_match(parent, cf, aux) struct device *parent; - void *vcf, *aux; + void *cf, *aux; { struct confargs *ca = aux; @@ -134,6 +134,11 @@ obio_submatch(parent, vcf, aux) * The address assignments are fixed for all time, * so our config files might as well reflect that. */ +#ifdef DIAGNOSTIC + if (cf->cf_paddr == -1) + panic("obio_submatch: invalid address for: %s%d\n", + cf->cf_driver->cd_name, cf->cf_unit); +#endif if (cf->cf_paddr != ca->ca_paddr) return 0; @@ -143,7 +148,7 @@ obio_submatch(parent, vcf, aux) panic("obio_submatch: no match function for: %s\n", cf->cf_driver->cd_name); - return ((*submatch)(parent, vcf, aux)); + return ((*submatch)(parent, cf, aux)); } @@ -190,14 +195,14 @@ caddr_t obio_find_mapping(int pa, int size) */ #define PGBITS (PG_VALID|PG_WRITE|PG_SYSTEM) -static void save_prom_mappings() +static void +save_prom_mappings __P((void)) { - vm_offset_t pa; - caddr_t segva, pgva; + vm_offset_t pa, segva, pgva; int pte, sme, i; - - segva = (caddr_t)MONSTART; - while (segva < (caddr_t)MONEND) { + + segva = (vm_offset_t)MONSTART; + while (segva < (vm_offset_t)MONEND) { sme = get_segmap(segva); if (sme == SEGINV) { segva += NBSG; @@ -222,7 +227,7 @@ static void save_prom_mappings() { i = pa >> SAVE_SHIFT; if (prom_mappings[i] == NULL) { - prom_mappings[i] = pgva; + prom_mappings[i] = (caddr_t)pgva; #ifdef DEBUG mon_printf("obio: found pa=0x%x\n", pa); #endif @@ -257,11 +262,11 @@ static vm_offset_t required_mappings[] = { (vm_offset_t)-1, /* end marker */ }; -static void make_required_mappings() +static void +make_required_mappings __P((void)) { - vm_offset_t pa, *rmp; - int idx; - + vm_offset_t *rmp; + rmp = required_mappings; while (*rmp != (vm_offset_t)-1) { if (!obio_find_mapping(*rmp, NBPG)) { @@ -280,17 +285,26 @@ static void make_required_mappings() /* - * this routine "configures" any internal OBIO devices which must be - * accessible before the mainline OBIO autoconfiguration as part of - * configure(). + * Find mappings for devices that are needed before autoconfiguration. + * We first look for and record any useful PROM mappings, then call + * the "init" functions for drivers that we need to use before the + * normal autoconfiguration calls configure(). */ -void obio_init() +void +obio_init() { save_prom_mappings(); make_required_mappings(); + + /* Init drivers that use the required OBIO mappings. */ + zs_init(); + eeprom_init(); + intreg_init(); + clock_init(); } -caddr_t obio_alloc(obio_addr, obio_size) +caddr_t +obio_alloc(obio_addr, obio_size) int obio_addr, obio_size; { caddr_t cp; diff --git a/sys/arch/sun3/dev/obmem.c b/sys/arch/sun3/dev/obmem.c index c5a0632bce0..90bdbc81970 100644 --- a/sys/arch/sun3/dev/obmem.c +++ b/sys/arch/sun3/dev/obmem.c @@ -1,4 +1,4 @@ -/* $NetBSD: obmem.c,v 1.11 1996/11/20 18:56:57 gwr Exp $ */ +/* $NetBSD: obmem.c,v 1.12 1996/12/17 21:10:52 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -60,9 +60,9 @@ struct cfdriver obmem_cd = { }; static int -obmem_match(parent, vcf, aux) +obmem_match(parent, cf, aux) struct device *parent; - void *vcf, *aux; + void *cf, *aux; { struct confargs *ca = aux; @@ -73,8 +73,7 @@ obmem_match(parent, vcf, aux) static void obmem_attach(parent, self, args) - struct device *parent; - struct device *self; + struct device *parent, *self; void *args; { printf("\n"); diff --git a/sys/arch/sun3/dev/si.c b/sys/arch/sun3/dev/si.c index 3047596157e..7baf362159c 100644 --- a/sys/arch/sun3/dev/si.c +++ b/sys/arch/sun3/dev/si.c @@ -1,4 +1,4 @@ -/* $NetBSD: si.c,v 1.31 1996/11/20 18:56:59 gwr Exp $ */ +/* $NetBSD: si.c,v 1.32 1996/12/17 21:10:53 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -91,8 +91,6 @@ #include <scsi/scsiconf.h> #include <machine/autoconf.h> -#include <machine/isr.h> -#include <machine/obio.h> #include <machine/dvma.h> #define DEBUG XXX @@ -144,6 +142,21 @@ struct cfdriver si_cd = { NULL, "si", DV_DULL }; +#ifdef __OpenBSD__ +int ncrprint __P((void *, const char *)); + +int +ncrprint(aux, name) + void *aux; + const char *name; +{ + + if (name != NULL) + printf("%s: scsibus ", name); + return UNCONF; +} +#endif + void si_attach(sc) @@ -172,7 +185,9 @@ si_attach(sc) /* * Fill in the prototype scsi_link. */ +#ifndef __OpenBSD__ ncr_sc->sc_link.channel = SCSI_CHANNEL_ONLY_ONE; +#endif ncr_sc->sc_link.adapter_softc = sc; ncr_sc->sc_link.adapter_target = 7; ncr_sc->sc_link.adapter = &si_ops; @@ -180,7 +195,7 @@ si_attach(sc) #ifdef DEBUG if (si_debug) - printf("si: Set TheSoftC=%x TheRegs=%x\n", sc, regs); + printf("si: Set TheSoftC=%p TheRegs=%p\n", sc, regs); ncr_sc->sc_link.flags |= si_link_flags; #endif @@ -213,7 +228,11 @@ si_attach(sc) si_reset_adapter(ncr_sc); ncr5380_init(ncr_sc); ncr5380_reset_scsibus(ncr_sc); +#ifdef __OpenBSD__ + config_found(&(ncr_sc->sc_dev), &(ncr_sc->sc_link), ncrprint); +#else config_found(&(ncr_sc->sc_dev), &(ncr_sc->sc_link), scsiprint); +#endif } static void @@ -402,7 +421,7 @@ found: dh->dh_dvma = (u_long) dvma_mapin((char *)addr, xlen); if (!dh->dh_dvma) { /* Can't remap segment */ - printf("si_dma_alloc: can't remap %x/%x\n", + printf("si_dma_alloc: can't remap %p/0x%x\n", dh->dh_addr, dh->dh_maplen); dh->dh_flags = 0; return; @@ -457,7 +476,6 @@ si_dma_poll(ncr_sc) { struct si_softc *sc = (struct si_softc *)ncr_sc; struct sci_req *sr = ncr_sc->sc_current; - struct si_dma_handle *dh = sr->sr_dma_hand; volatile struct si_regs *si = sc->sc_regs; int tmo; diff --git a/sys/arch/sun3/dev/si_obio.c b/sys/arch/sun3/dev/si_obio.c index 793c0a3b26c..7ab276ffba9 100644 --- a/sys/arch/sun3/dev/si_obio.c +++ b/sys/arch/sun3/dev/si_obio.c @@ -1,4 +1,4 @@ -/* $NetBSD: si_obio.c,v 1.7 1996/11/20 18:57:00 gwr Exp $ */ +/* $NetBSD: si_obio.c,v 1.8 1996/12/17 21:10:54 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -95,7 +95,6 @@ #include <scsi/scsiconf.h> #include <machine/autoconf.h> -#include <machine/isr.h> #include <machine/obio.h> #include <machine/dvma.h> @@ -118,6 +117,12 @@ void si_obio_dma_start __P((struct ncr5380_softc *)); void si_obio_dma_eop __P((struct ncr5380_softc *)); void si_obio_dma_stop __P((struct ncr5380_softc *)); +static __inline__ void si_obio_udc_write + __P((volatile struct si_regs *si, int regnum, int value)); +static __inline__ int si_obio_udc_read + __P((volatile struct si_regs *si, int regnum)); + + /* * New-style autoconfig attachment */ @@ -137,9 +142,8 @@ int si_obio_options = 1; /* XXX */ static int si_obio_match(parent, vcf, args) struct device *parent; - void *vcf, *args; + void *vcf, *args; { - struct cfdata *cf = vcf; struct confargs *ca = args; /* Make sure there is something there... */ @@ -258,7 +262,7 @@ si_obio_dma_setup(ncr_sc) #ifdef DEBUG if (si_debug & 2) { - printf("si_dma_setup: dh=0x%x, pa=0x%x, xlen=%d\n", + printf("si_dma_setup: dh=%p, pa=0x%x, xlen=0x%x\n", dh, data_pa, xlen); } #endif @@ -348,7 +352,7 @@ si_obio_dma_start(ncr_sc) #ifdef DEBUG if (si_debug & 2) { - printf("si_dma_start: sr=0x%x\n", sr); + printf("si_dma_start: sr=%p\n", sr); } #endif diff --git a/sys/arch/sun3/dev/si_vme.c b/sys/arch/sun3/dev/si_vme.c index 3b94011b255..1e61083dbb1 100644 --- a/sys/arch/sun3/dev/si_vme.c +++ b/sys/arch/sun3/dev/si_vme.c @@ -1,4 +1,4 @@ -/* $NetBSD: si_vme.c,v 1.7 1996/11/20 18:57:01 gwr Exp $ */ +/* $NetBSD: si_vme.c,v 1.8 1996/12/17 21:10:55 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -95,8 +95,6 @@ #include <scsi/scsiconf.h> #include <machine/autoconf.h> -#include <machine/isr.h> -#include <machine/obio.h> #include <machine/dvma.h> #define DEBUG XXX @@ -133,9 +131,8 @@ int si_vme_options = 3; static int si_vmes_match(parent, vcf, args) struct device *parent; - void *vcf, *args; + void *vcf, *args; { - struct cfdata *cf = vcf; struct confargs *ca = args; int probe_addr; @@ -306,7 +303,7 @@ si_vme_dma_setup(ncr_sc) #ifdef DEBUG if (si_debug & 2) { - printf("si_dma_setup: dh=0x%x, pa=0x%x, xlen=%d\n", + printf("si_dma_setup: dh=%p, pa=0x%x, xlen=0x%x\n", dh, data_pa, xlen); } #endif @@ -354,7 +351,6 @@ si_vme_dma_start(ncr_sc) struct sci_req *sr = ncr_sc->sc_current; struct si_dma_handle *dh = sr->sr_dma_hand; volatile struct si_regs *si = sc->sc_regs; - long data_pa; int s, xlen; xlen = sc->sc_reqlen; diff --git a/sys/arch/sun3/dev/zs.c b/sys/arch/sun3/dev/zs.c index da46ddf06b2..33739b038ba 100644 --- a/sys/arch/sun3/dev/zs.c +++ b/sys/arch/sun3/dev/zs.c @@ -62,7 +62,6 @@ #include <machine/autoconf.h> #include <machine/cpu.h> -#include <machine/isr.h> #include <machine/obio.h> #include <machine/mon.h> diff --git a/sys/arch/sun3/include/autoconf.h b/sys/arch/sun3/include/autoconf.h index e1322fc8f12..aecad6ea546 100644 --- a/sys/arch/sun3/include/autoconf.h +++ b/sys/arch/sun3/include/autoconf.h @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.h,v 1.12 1996/11/20 18:57:05 gwr Exp $ */ +/* $NetBSD: autoconf.h,v 1.13 1996/12/17 21:11:01 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -38,6 +38,7 @@ /* * Autoconfiguration information. + * (machdep parts of driver/kernel interface) */ /* These are the "bus" types: */ @@ -66,3 +67,16 @@ int bus_print __P((void *, const char *)); int bus_peek __P((int, int, int)); char * bus_mapin __P((int, int, int)); +/* These are how drivers connect interrupt handlers. */ +typedef int (*isr_func_t) __P((void *)); +void isr_add_autovect __P((isr_func_t, void *arg, int level)); +void isr_add_vectored __P((isr_func_t, void *arg, int pri, int vec)); +void isr_add_custom __P((int, void *)); + +/* These control the software interrupt register. */ +void isr_soft_request __P((int level)); +void isr_soft_clear __P((int level)); + +/* Bus-error tolerant access to mapped address. */ +int peek_byte __P((caddr_t)); +int peek_word __P((caddr_t)); diff --git a/sys/arch/sun3/include/conf.h b/sys/arch/sun3/include/conf.h index 62acb7fd7e9..69670cd4da5 100644 --- a/sys/arch/sun3/include/conf.h +++ b/sys/arch/sun3/include/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.2 1996/11/23 07:55:02 kstailey Exp $ */ +/* $OpenBSD: conf.h,v 1.3 1996/12/31 06:13:05 kstailey Exp $ */ /*- * Copyright (c) 1996 Kenneth Stailey. All rights reserved. @@ -67,8 +67,11 @@ cdev_decl(kd); /* frame-buffer devices */ cdev_decl(fb); #include "bwtwo.h" +#define bw2poll seltrue cdev_decl(bw2); #include "cgtwo.h" +#define cg2poll seltrue cdev_decl(cg2); #include "cgfour.h" +#define cg4poll seltrue cdev_decl(cg4); diff --git a/sys/arch/sun3/include/control.h b/sys/arch/sun3/include/control.h index 56c7d26bd67..bbd940478b6 100644 --- a/sys/arch/sun3/include/control.h +++ b/sys/arch/sun3/include/control.h @@ -1,4 +1,4 @@ -/* $NetBSD: control.h,v 1.14 1996/11/20 18:57:06 gwr Exp $ */ +/* $NetBSD: control.h,v 1.15 1996/12/17 21:11:02 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -84,17 +84,19 @@ #include <sys/types.h> +/* ctrlsp.S */ unsigned char get_control_byte __P((char *)); unsigned int get_control_word __P((char *)); void set_control_byte __P((char *, unsigned char)); void set_control_word __P((char *, unsigned int)); +/* control.c */ int get_context __P((void)); void set_context __P((int)); - + vm_offset_t get_pte __P((vm_offset_t va)); void set_pte __P((vm_offset_t, vm_offset_t)); - + unsigned char get_segmap __P((vm_offset_t)); void set_segmap __P((vm_offset_t va, unsigned char)); void set_segmap_allctx __P((vm_offset_t va, unsigned char)); diff --git a/sys/arch/sun3/include/cpu.h b/sys/arch/sun3/include/cpu.h index dfd987164cf..38cce484065 100644 --- a/sys/arch/sun3/include/cpu.h +++ b/sys/arch/sun3/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.20 1995/12/21 05:02:10 mycroft Exp $ */ +/* $NetBSD: cpu.h,v 1.21 1996/12/17 21:11:03 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -44,53 +44,58 @@ * cpu.h,v 1.2 1993/05/22 07:58:17 cgd Exp */ -#ifndef _SUN3_CPU_H_ -#define _SUN3_CPU_H_ - #ifdef _KERNEL /* - * Exported definitions unique to sun3/68k cpu support. + * External definitions unique to sun3/68k cpu support. + * These are the "public" declarations - those needed in + * machine-independent source code. The "priviate" ones + * are in machdep.h (used only inside sys/arch/sun3). + * + * Note that the name of this file is NOT meant to imply + * that it has anything to do with mc68020 CPU stuff. + * The name "cpu" is historical, and used in the common + * code to identify machine-dependent functions, etc. */ /* * definitions of cpu-dependent requirements * referenced in generic code */ -#define cpu_swapin(p) /* nothing */ #define cpu_wait(p) /* nothing */ /* * Arguments to hardclock and gatherstats encapsulate the previous * machine state in an opaque clockframe. One the sun3, we use - * what the hardware pushes on an interrupt (frame format 0). + * what the locore.s glue puts on the stack before calling C-code. */ struct clockframe { - u_short sr; /* sr at time of interrupt */ - u_long pc; /* pc at time of interrupt */ - u_short vo; /* vector offset (4-word frame) */ + u_int cf_regs[4]; /* d0,d1,a0,a1 */ + u_short cf_sr; /* sr at time of interrupt */ + u_long cf_pc; /* pc at time of interrupt */ + u_short cf_vo; /* vector offset (4-word frame) */ }; -#define CLKF_USERMODE(framep) (((framep)->sr & PSL_S) == 0) -#define CLKF_BASEPRI(framep) (((framep)->sr & PSL_IPL) == 0) -#define CLKF_PC(framep) ((framep)->pc) +#define CLKF_USERMODE(framep) (((framep)->cf_sr & PSL_S) == 0) +#define CLKF_BASEPRI(framep) (((framep)->cf_sr & PSL_IPL) == 0) +#define CLKF_PC(framep) ((framep)->cf_pc) #if 0 /* We would like to do it this way... */ -#define CLKF_INTR(framep) (((framep)->sr & PSL_M) == 0) +#define CLKF_INTR(framep) (((framep)->cf_sr & PSL_M) == 0) #else /* but until we start using PSL_M, we have to do this instead */ #define CLKF_INTR(framep) (0) /* XXX */ #endif extern int astpending; /* need to trap before returning to user mode */ -#define aston() (astpending++) +#define aston() (astpending = 1) /* * Preempt the current process if in interrupt from user mode, * or after the current trap/syscall if in system mode. */ extern int want_resched; /* resched() was called */ -#define need_resched() { want_resched++; aston(); } +#define need_resched() { want_resched = 1; aston(); } /* * Give a profiling tick to the current process when the user profiling @@ -111,6 +116,7 @@ extern int want_resched; /* resched() was called */ * isr_soft_request() so this scheme just multiplexes four * software interrupt `sources' on the level one handler. */ +extern void isr_soft_request __P((int level)); union sun3sir { int sir_any; char sir_which[4]; @@ -121,63 +127,10 @@ union sun3sir { #define SIR_SPARE2 2 #define SIR_SPARE3 3 -#define setsoftint() isr_soft_request(1) -#define setsoftnet() (sun3sir.sir_which[SIR_NET] = 1, setsoftint()) -#define setsoftclock() (sun3sir.sir_which[SIR_CLOCK] = 1, setsoftint()) - - -/* - * CTL_MACHDEP definitions. - */ -#define CPU_CONSDEV 1 /* dev_t: console terminal device */ -#define CPU_MAXID 2 /* number of valid machdep ids */ - -#define CTL_MACHDEP_NAMES { \ - { 0, 0 }, \ - { "console_device", CTLTYPE_STRUCT }, \ -} - -/* values for cpu_machine_id */ - -#define CPU_ARCH_MASK 0xf0 -#define SUN3_ARCH 0x10 -#define SUN3_IMPL_MASK 0x0f -#define SUN3_MACH_160 0x01 -#define SUN3_MACH_50 0x02 -#define SUN3_MACH_260 0x03 -#define SUN3_MACH_110 0x04 -#define SUN3_MACH_60 0x07 -#define SUN3_MACH_E 0x08 - -extern unsigned char cpu_machine_id; - -/* 680X0 function codes */ -#define FC_USERD 1 /* user data space */ -#define FC_USERP 2 /* user program space */ -#define FC_CONTROL 3 /* sun control space */ -#define FC_SUPERD 5 /* supervisor data space */ -#define FC_SUPERP 6 /* supervisor program space */ -#define FC_CPU 7 /* CPU space */ - -/* fields in the 68020 cache control register */ -#define IC_ENABLE 0x0001 /* enable instruction cache */ -#define IC_FREEZE 0x0002 /* freeze instruction cache */ -#define IC_CE 0x0004 /* clear instruction cache entry */ -#define IC_CLR 0x0008 /* clear entire instruction cache */ - -#define IC_CLEAR (IC_CLR|IC_ENABLE) +#define setsoftint(x) isr_soft_request(x) +#define setsoftnet() (sun3sir.sir_which[SIR_NET] = 1, setsoftint(1)) +#define setsoftclock() (sun3sir.sir_which[SIR_CLOCK] = 1, setsoftint(1)) #endif /* _KERNEL */ -/* - * CTL_MACHDEP definitions. - */ -#define CPU_CONSDEV 1 /* dev_t: console terminal device */ -#define CPU_MAXID 2 /* number of valid machdep ids */ - -#define CTL_MACHDEP_NAMES { \ - { 0, 0 }, \ - { "console_device", CTLTYPE_STRUCT }, \ -} - -#endif /* !_SUN3_CPU_H_ */ +#include <m68k/sysctl.h> diff --git a/sys/arch/sun3/include/db_machdep.h b/sys/arch/sun3/include/db_machdep.h index 543f101428a..ef71424516b 100644 --- a/sys/arch/sun3/include/db_machdep.h +++ b/sys/arch/sun3/include/db_machdep.h @@ -1,7 +1,14 @@ -/* $NetBSD: db_machdep.h,v 1.7 1995/02/07 04:34:45 gwr Exp $ */ +/* $NetBSD: db_machdep.h,v 1.8 1996/12/17 21:11:05 gwr Exp $ */ #include <m68k/db_machdep.h> /* This enables some code in db_command.c */ #define DB_MACHINE_COMMANDS +extern char *esym; /* end of symbols */ +void ddb_init __P((void)); +void db_machine_init __P((void)); + +/* These are in db_memrw.c */ +extern void db_read_bytes __P((vm_offset_t addr, size_t size, char *data)); +extern void db_write_bytes __P((vm_offset_t addr, size_t size, char *data)); diff --git a/sys/arch/sun3/include/dvma.h b/sys/arch/sun3/include/dvma.h index 796042aebac..9d6abdeb560 100644 --- a/sys/arch/sun3/include/dvma.h +++ b/sys/arch/sun3/include/dvma.h @@ -1,4 +1,4 @@ -/* $NetBSD: dvma.h,v 1.4 1996/11/20 18:57:08 gwr Exp $ */ +/* $NetBSD: dvma.h,v 1.5 1996/12/17 21:11:05 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -75,14 +75,16 @@ #define DVMA_SPACE_START 0x0FF00000 #define DVMA_SPACE_END 0x0FFFE000 +void dvma_init __P((void)); + /* Allocate/free actual pages of DVMA space. */ -caddr_t dvma_malloc(size_t bytes); +caddr_t dvma_malloc __P((size_t bytes)); void dvma_free(caddr_t addr, size_t bytes); /* Remap/unmap kernel memory in DVMA space. */ -caddr_t dvma_mapin(char *kva, int len); -void dvma_mapout(caddr_t dvma_addr, int len); +caddr_t dvma_mapin __P((char *kva, int len)); +void dvma_mapout __P((caddr_t dvma_addr, int len)); /* Convert a kernel DVMA pointer to a slave address. */ -long dvma_kvtopa(long kva, int bus); +long dvma_kvtopa __P((long kva, int bus)); diff --git a/sys/arch/sun3/include/idprom.h b/sys/arch/sun3/include/idprom.h index 42c30ce4ed1..2b8b682d18b 100644 --- a/sys/arch/sun3/include/idprom.h +++ b/sys/arch/sun3/include/idprom.h @@ -1,4 +1,4 @@ -/* $NetBSD: idprom.h,v 1.12 1996/11/20 18:57:10 gwr Exp $ */ +/* $NetBSD: idprom.h,v 1.13 1996/12/17 21:11:07 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -53,8 +53,24 @@ struct idprom { #define IDPROM_VERSION 1 #define IDPROM_SIZE (sizeof(struct idprom)) +/* values for cpu_machine_id */ + +#define CPU_ARCH_MASK 0xf0 +#define SUN3_ARCH 0x10 +#define SUN3_IMPL_MASK 0x0f +#define SUN3_MACH_160 0x01 +#define SUN3_MACH_50 0x02 +#define SUN3_MACH_260 0x03 +#define SUN3_MACH_110 0x04 +#define SUN3_MACH_60 0x07 +#define SUN3_MACH_E 0x08 + #ifdef _KERNEL + extern struct idprom identity_prom; -int idprom_init(); +extern u_char cpu_machine_id; + +int idprom_init __P((void)); void idprom_etheraddr __P((u_char *)); -#endif + +#endif /* _KERNEL */ diff --git a/sys/arch/sun3/include/mon.h b/sys/arch/sun3/include/mon.h index 447e1629524..fcf37ddfa84 100644 --- a/sys/arch/sun3/include/mon.h +++ b/sys/arch/sun3/include/mon.h @@ -1,4 +1,4 @@ -/* $NetBSD: mon.h,v 1.19 1996/11/20 18:57:12 gwr Exp $ */ +/* $NetBSD: mon.h,v 1.20 1996/12/17 21:11:08 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -103,44 +103,44 @@ typedef struct bootparam { * translate these structs into Sprite format. */ typedef struct { - char *initSp; /* Initial system stack ptr - * for hardware */ - int (*startMon)(); /* Initial PC for hardware */ + char *initSp; /* Initial system stack ptr + * for hardware */ + int (*startMon)__P((void)); /* Initial PC for hardware */ - int *diagberr; /* Bus err handler for diags */ + int *diagberr; /* Bus err handler for diags */ /* * Monitor and hardware revision and identification */ - struct bootparam **bootParam; /* Info for bootstrapped pgm */ - unsigned *memorySize; /* Usable memory in bytes */ + struct bootparam **bootParam; /* Info for bootstrapped pgm */ + u_int *memorySize; /* Usable memory in bytes */ /* * Single-character input and output */ - unsigned char (*getChar)(); /* Get char from input source */ - int (*putChar)(); /* Put char to output sink */ - int (*mayGet)(); /* Maybe get char, or -1 */ - int (*mayPut)(); /* Maybe put char, or -1 */ - unsigned char *echo; /* Should getchar echo? */ - unsigned char *inSource; /* Input source selector */ - unsigned char *outSink; /* Output sink selector */ + u_char (*getChar)__P((void)); /* Get char from input source */ + int (*putChar)__P((int)); /* Put char to output sink */ + int (*mayGet)__P((void)); /* Maybe get char, or -1 */ + int (*mayPut)__P((int)); /* Maybe put char, or -1 */ + u_char *echo; /* Should getchar echo? */ + u_char *inSource; /* Input source selector */ + u_char *outSink; /* Output sink selector */ /* * Keyboard input (scanned by monitor nmi routine) */ - int (*getKey)(); /* Get next key if one exists */ - int (*initGetKey)(); /* Initialize get key */ - unsigned int *translation; /* Kbd translation selector - (see keyboard.h in sun - monitor code) */ - unsigned char *keyBid; /* Keyboard ID byte */ - int *screen_x; /* V2: Screen x pos (R/O) */ - int *screen_y; /* V2: Screen y pos (R/O) */ - struct keybuf *keyBuf; /* Up/down keycode buffer */ + int (*getKey)__P((void)); /* Get next key if one exists */ + int (*initGetKey)__P((void*)); /* Initialize get key */ + u_int *translation; /* Kbd translation selector + (see keyboard.h in sun + monitor code) */ + u_char *keyBid; /* Keyboard ID byte */ + int *screen_x; /* V2: Screen x pos (R/O) */ + int *screen_y; /* V2: Screen y pos (R/O) */ + struct keybuf *keyBuf; /* Up/down keycode buffer */ /* * Monitor revision level. @@ -152,51 +152,52 @@ typedef struct { * Frame buffer output and terminal emulation */ - int (*fbWriteChar)(); /* Write a character to FB */ - int *fbAddr; /* Address of frame buffer */ - char **font; /* Font table for FB */ - int (*fbWriteStr)(); /* Quickly write string to FB */ + int (*fbWriteChar)__P((int)); /* Write a character to FB */ + int *fbAddr; /* Address of frame buffer */ + char **font; /* Font table for FB */ + /* Quickly write string to FB */ + int (*fbWriteStr)__P((char *buf, int len)); /* * Reboot interface routine -- resets and reboots system. No return. */ - int (*reBoot)(); /* e.g. reBoot("xy()vmunix") */ + int (*reBoot)__P((char *)); /* e.g. reBoot("xy()vmunix") */ /* * Line input and parsing */ - unsigned char *lineBuf; /* The line input buffer */ - unsigned char **linePtr; /* Cur pointer into linebuf */ - int *lineSize; /* length of line in linebuf */ - int (*getLine)(); /* Get line from user */ - unsigned char (*getNextChar)(); /* Get next char from linebuf */ - unsigned char (*peekNextChar)(); /* Peek at next char */ + u_char *lineBuf; /* The line input buffer */ + u_char **linePtr; /* Cur pointer into linebuf */ + int *lineSize; /* length of line in linebuf */ + int (*getLine)__P((int)); /* Get line from user */ + u_char (*getNextChar)__P((void)); /* Get next char from linebuf */ + u_char (*peekNextChar)__P((void)); /* Peek at next char */ int *fbThere; /* =1 if frame buffer there */ - int (*getNum)(); /* Grab hex num from line */ + int (*getNum)__P((void)); /* Grab hex num from line */ /* * Print formatted output to current output sink */ - int (*printf)(); /* Similar to "Kernel printf" */ - int (*printHex)(); /* Format N digits in hex */ + int (*printf)__P((char *, ...)); /* Like kernel printf */ + int (*printHex)__P((int,int)); /* Format N digits in hex */ /* * Led stuff */ - unsigned char *leds; /* RAM copy of LED register */ - int (*setLeds)(); /* Sets LED's and RAM copy */ + u_char *leds; /* RAM copy of LED register */ + int (*setLeds)__P((int)); /* Sets LED's and RAM copy */ /* * Non-maskable interrupt (nmi) information */ - int (*nmiAddr)(); /* Addr for level 7 vector */ - int (*abortEntry)(); /* Entry for keyboard abort */ - int *nmiClock; /* Counts up in msec */ + int (*nmiAddr)__P((void*)); /* Addr for level 7 vector */ + int (*abortEntry)__P((void*)); /* Entry for keyboard abort */ + int *nmiClock; /* Counts up in msec */ /* * Frame buffer type: see <sun/fbio.h> @@ -208,24 +209,28 @@ typedef struct { * Assorted other things */ - unsigned romvecVersion; /* Version # of Romvec */ - struct globram *globRam; /* monitor global variables */ - caddr_t kbdZscc; /* Addr of keyboard in use */ - - int *keyrInit; /* ms before kbd repeat */ - unsigned char *keyrTick; /* ms between repetitions */ - unsigned *memoryAvail; /* V1: Main mem usable size */ - long *resetAddr; /* where to jump on a reset */ - long *resetMap; /* pgmap entry for resetaddr */ - /* Really struct pgmapent * */ - int (*exitToMon)(); /* Exit from user program */ - unsigned char **memorybitmap; /* V1: &{0 or &bits} */ - void (*setcxsegmap)(); /* Set seg in any context */ - void (**vector_cmd)(); /* V2: Handler for 'v' cmd */ - int dummy1z; - int dummy2z; - int dummy3z; - int dummy4z; + u_int romvecVersion; /* Version # of Romvec */ + struct globram *globRam; /* monitor global variables */ + caddr_t kbdZscc; /* Addr of keyboard in use */ + + int *keyrInit; /* ms before kbd repeat */ + u_char *keyrTick; /* ms between repetitions */ + u_int *memoryAvail; /* V1: Main mem usable size */ + long *resetAddr; /* where to jump on a reset */ + long *resetMap; /* pgmap entry for resetaddr */ + /* Really struct pgmapent * */ + int (*exitToMon)__P((void)); /* Exit from user program */ + u_char **memorybitmap; /* V1: &{0 or &bits} */ + + /* Set seg in all contexts */ + void (*setcxsegmap)__P((int,int,int)); + + /* V2: Handler for 'v' cmd */ + void (**vector_cmd)__P((int, char*)); + int dummy1z; + int dummy2z; + int dummy3z; + int dummy4z; } MachMonRomVector; /* @@ -234,7 +239,7 @@ typedef struct { * * getChar -- Return the next character from the input source * - * unsigned char getChar() + * u_char getChar() * * putChar -- Write the given character to the output source. * @@ -265,12 +270,12 @@ typedef struct { * fbWriteChar -- Write a character to the frame buffer * * void fwritechar(ch) - * unsigned char ch; + * u_char ch; * * fbWriteStr -- Write a string to the frame buffer. * * void fwritestr(addr,len) - * register unsigned char *addr; / * String to be written * / + * register u_char *addr; / * String to be written * / * register short len; / * Length of string * / * * getLine -- read the next input line into a global buffer @@ -280,11 +285,11 @@ typedef struct { * * getNextChar -- return the next character from the global line buffer. * - * unsigned char getNextChar() + * u_char getNextChar() * * peekNextChar -- look at the next character in the global line buffer. * - * unsigned char peekNextChar() + * u_char peekNextChar() * * getNum -- Grab hex num from the global line buffer. * diff --git a/sys/arch/sun3/include/obio.h b/sys/arch/sun3/include/obio.h index e687a5a4206..2d2b118f320 100644 --- a/sys/arch/sun3/include/obio.h +++ b/sys/arch/sun3/include/obio.h @@ -1,4 +1,4 @@ -/* $NetBSD: obio.h,v 1.16 1996/11/20 18:57:14 gwr Exp $ */ +/* $NetBSD: obio.h,v 1.17 1996/12/17 21:11:09 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -65,21 +65,29 @@ #define OBIO_ZS_SIZE 0x00008 #define OBIO_EEPROM_SIZE 0x00800 #define OBIO_CLOCK_SIZE 0x00020 -#define OBIO_MEMERR_SIZE 0x00008 -#define OBIO_INTERREG_SIZE 0x00001 -#define OBIO_INTEL_ETHER_SIZE 0x00001 -#define OBIO_COLOR_MAP_SIZE 0x00400 -#define OBIO_EPROM_SIZE 0x10000 -#define OBIO_AMD_ETHER_SIZE 0x00004 -#define OBIO_NCR_SCSI_SIZE 0x00020 -#define OBIO_IO_BUS_SIZE 0x1000000 -#define OBIO_DES_SIZE 0x00004 -#define OBIO_ECCREG_SIZE 0x00100 +#define OBIO_MEMERR_SIZE 0x00008 +#define OBIO_INTERREG_SIZE 0x00001 +#define OBIO_INTEL_ETHER_SIZE 0x00001 +#define OBIO_COLOR_MAP_SIZE 0x00400 +#define OBIO_EPROM_SIZE 0x10000 +#define OBIO_AMD_ETHER_SIZE 0x00004 +#define OBIO_NCR_SCSI_SIZE 0x00020 +#define OBIO_DES_SIZE 0x00004 +#define OBIO_ECCREG_SIZE 0x00100 #ifdef _KERNEL -caddr_t obio_alloc __P((int, int)); -caddr_t obio_vm_alloc __P((int)); -caddr_t obio_find_mapping __P((int pa, int size)); +caddr_t obio_alloc __P((int, int)); +void obio_init __P((void)); +caddr_t obio_find_mapping __P((int pa, int size)); +caddr_t obio_vm_alloc __P((int)); + +/* + * These are some OBIO devices that need early init calls. + */ +void zs_init __P((void)); +void eeprom_init __P((void)); +void intreg_init __P((void)); +void clock_init __P((void)); #endif /* _KERNEL */ diff --git a/sys/arch/sun3/include/pmap.h b/sys/arch/sun3/include/pmap.h index 6f9c9ecb03c..0c4c3b274f9 100644 --- a/sys/arch/sun3/include/pmap.h +++ b/sys/arch/sun3/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.15 1996/11/20 18:57:16 gwr Exp $ */ +/* $NetBSD: pmap.h,v 1.16 1996/12/17 21:11:10 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -56,6 +56,9 @@ typedef struct pmap *pmap_t; #ifdef _KERNEL struct pmap kernel_pmap_store; +struct pcb; +void pmap_activate __P((pmap_t pmap, struct pcb *pcbp)); +void pmap_deactivate __P((pmap_t pmap, struct pcb *pcbp)); #define pmap_kernel() (&kernel_pmap_store) diff --git a/sys/arch/sun3/include/proc.h b/sys/arch/sun3/include/proc.h index 602aa3cbf65..9247a10294c 100644 --- a/sys/arch/sun3/include/proc.h +++ b/sys/arch/sun3/include/proc.h @@ -1,9 +1,8 @@ -/* $NetBSD: proc.h,v 1.7 1994/11/21 21:34:06 gwr Exp $ */ +/* $NetBSD: proc.h,v 1.8 1996/11/25 22:09:11 gwr Exp $ */ /* - * Copyright (c) 1994 Gordon W. Ross - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1991, 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 @@ -33,8 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 - * proc.h,v 1.2 1993/05/22 07:58:30 cgd Exp + * from: proc.h 8.1 (Berkeley) 6/10/93 */ /* @@ -43,7 +41,6 @@ struct mdproc { int *md_regs; /* registers on current frame */ int md_flags; /* machine-dependent flags */ - int md_upte[UPAGES]; /* ptes for mapping u page */ }; /* md_flags */ diff --git a/sys/arch/sun3/include/psl.h b/sys/arch/sun3/include/psl.h index 4fe2914b7d0..aee1c2c7d33 100644 --- a/sys/arch/sun3/include/psl.h +++ b/sys/arch/sun3/include/psl.h @@ -1,4 +1,4 @@ -/* $NetBSD: psl.h,v 1.10 1996/11/20 18:57:17 gwr Exp $ */ +/* $NetBSD: psl.h,v 1.11 1996/12/17 21:11:11 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -101,12 +101,12 @@ extern __inline__ int _spl(int new) #define splclock() spl5() #define splstatclock() splclock() -/* Zilog Serial hardware interrupts (hard-wired at 6) */ -#define splzs() spl6() - /* Block out all interrupts (except NMI of course). */ #define splhigh() spl7() #define splsched() spl7() +/* Get current sr value (debug, etc.) */ +extern int getsr __P((void)); + #endif /* KERNEL && !_LOCORE */ #endif /* PSL_C */ diff --git a/sys/arch/sun3/include/types.h b/sys/arch/sun3/include/types.h index db77cff88b8..10346b657af 100644 --- a/sys/arch/sun3/include/types.h +++ b/sys/arch/sun3/include/types.h @@ -1,3 +1,3 @@ -/* $NetBSD: types.h,v 1.8 1996/11/20 18:57:21 gwr Exp $ */ +/* $NetBSD: types.h,v 1.10 1996/12/17 21:11:12 gwr Exp $ */ #include <m68k/types.h> diff --git a/sys/arch/sun3/include/z8530var.h b/sys/arch/sun3/include/z8530var.h index 1164ad3f7f7..55bcf558709 100644 --- a/sys/arch/sun3/include/z8530var.h +++ b/sys/arch/sun3/include/z8530var.h @@ -80,3 +80,6 @@ void zs_abort(); */ #define ZSTTY_MAJOR 12 /* XXX */ #define ZSTTY_DEF_CFLAG (CREAD | CS8 | HUPCL) + +/* Zilog Serial hardware interrupts (hard-wired at 6) */ +#define splzs() spl6() diff --git a/sys/arch/sun3/sun3/autoconf.c b/sys/arch/sun3/sun3/autoconf.c index 144fa399c65..a373748e8d4 100644 --- a/sys/arch/sun3/sun3/autoconf.c +++ b/sys/arch/sun3/sun3/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.37 1996/11/20 18:57:22 gwr Exp $ */ +/* $NetBSD: autoconf.c,v 1.38 1996/12/17 21:11:14 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -46,11 +46,10 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/conf.h> #include <sys/device.h> #include <sys/map.h> -#include <sys/buf.h> #include <sys/dkstat.h> -#include <sys/conf.h> #include <sys/dmap.h> #include <sys/reboot.h> @@ -60,14 +59,11 @@ #include <machine/autoconf.h> #include <machine/cpu.h> -#include <machine/isr.h> +#include <machine/control.h> #include <machine/pte.h> #include <machine/pmap.h> -extern int soft1intr(); - -void swapgeneric(); -void swapconf(), dumpconf(); +#include "machdep.h" int cold; @@ -96,13 +92,13 @@ swapconf() struct swdevt *swp; u_int maj; int nblks; - + for (swp = swdevt; swp->sw_dev != NODEV; swp++) { maj = major(swp->sw_dev); if (maj > nblkdev) /* paranoid? */ break; - + if (bdevsw[maj].d_psize) { nblks = (*bdevsw[maj].d_psize)(swp->sw_dev); if (nblks > 0 && @@ -139,8 +135,6 @@ int bus_scan(parent, child, aux) cfmatch_t mf; #ifdef DIAGNOSTIC - if (parent->dv_cfdata->cf_driver->cd_indirect) - panic("bus_scan: indirect?"); if (cf->cf_fstate == FSTATE_STAR) panic("bus_scan: FSTATE_STAR"); #endif @@ -263,7 +257,7 @@ char * bus_mapin(bustype, paddr, sz) int bustype, paddr, sz; { - int off, pa, pgs, pmt; + int off, pa, pmt; vm_offset_t va, retval; if (bustype & ~3) @@ -296,4 +290,39 @@ bus_mapin(bustype, paddr, sz) #endif return ((char*)retval); -} +} + +int +peek_word(addr) + register caddr_t addr; +{ + label_t faultbuf; + register int x; + + nofault = &faultbuf; + if (setjmp(&faultbuf)) { + nofault = NULL; + return(-1); + } + x = *(volatile u_short *)addr; + nofault = NULL; + return(x); +} + +/* from hp300: badbaddr() */ +int +peek_byte(addr) + register caddr_t addr; +{ + label_t faultbuf; + register int x; + + nofault = &faultbuf; + if (setjmp(&faultbuf)) { + nofault = NULL; + return(-1); + } + x = *(volatile u_char *)addr; + nofault = NULL; + return(x); +} diff --git a/sys/arch/sun3/sun3/cache.c b/sys/arch/sun3/sun3/cache.c index 3ffce849895..08c093b76dd 100644 --- a/sys/arch/sun3/sun3/cache.c +++ b/sys/arch/sun3/sun3/cache.c @@ -1,4 +1,4 @@ -/* $NetBSD: cache.c,v 1.5 1996/11/20 18:57:24 gwr Exp $ */ +/* $NetBSD: cache.c,v 1.6 1996/12/17 21:11:16 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -57,12 +57,14 @@ #include <machine/control.h> #include <machine/vmparam.h> -#include "cache.h" +#include "machdep.h" #define CACHE_LINE 16 /* bytes */ #define VAC_FLUSH_INCR 512 /* bytes */ #define VADDR_MASK 0xfFFffFF /* 28 bits */ +static void cache_clear_tags __P((void)); + void cache_flush_page(pgva) vm_offset_t pgva; diff --git a/sys/arch/sun3/sun3/clock.c b/sys/arch/sun3/sun3/clock.c index 6517f3bf051..17555eb5ec4 100644 --- a/sys/arch/sun3/sun3/clock.c +++ b/sys/arch/sun3/sun3/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.31 1996/10/30 00:24:42 gwr Exp $ */ +/* $NetBSD: clock.c,v 1.32 1996/12/17 21:11:17 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -55,20 +55,23 @@ #include <sys/device.h> #include <machine/autoconf.h> -#include <machine/psl.h> +#include <machine/control.h> #include <machine/cpu.h> - #include <machine/mon.h> #include <machine/obio.h> -#include <machine/control.h> #include "intersil7170.h" #include "interreg.h" +#include "machdep.h" #define CLOCK_PRI 5 -extern volatile u_char *interrupt_reg; -volatile char *clock_va; +void _isr_clock __P((void)); /* in locore.s */ +void clock_intr __P((struct clockframe)); +static void frob_leds __P((struct clockframe *)); + +/* Note: this is used by locore.s:__isr_clock */ +static volatile char *clock_va; #define intersil_clock ((volatile struct intersil7170 *) clock_va) @@ -78,7 +81,7 @@ volatile char *clock_va; #define intersil_clear() (void)intersil_clock->clk_intr_reg -static int clock_match __P((struct device *, void *vcf, void *args)); +static int clock_match __P((struct device *, void *, void *)); static void clock_attach __P((struct device *, struct device *, void *)); struct cfattach clock_ca = { @@ -94,9 +97,8 @@ clock_match(parent, vcf, args) struct device *parent; void *vcf, *args; { - struct cfdata *cf = vcf; + struct cfdata *cf = vcf; struct confargs *ca = args; - int pa; /* This driver only supports one unit. */ if (cf->cf_unit != 0) @@ -119,14 +121,14 @@ clock_attach(parent, self, args) struct device *self; void *args; { - struct cfdata *cf = self->dv_cfdata; - struct confargs *ca = args; printf("\n"); /* - * Can not hook up the ISR until cpu_initclock() + * Can not hook up the ISR until cpu_initclocks() * because hardclock is not ready until then. + * For now, the handler is _isr_autovec(), which + * will complain if it gets clock interrupts. */ } @@ -135,6 +137,7 @@ clock_attach(parent, self, args) * register. We have to be extremely careful that we do it * in such a manner that we don't get ourselves lost. */ +void set_clk_mode(on, off, enable) u_char on, off; int enable; @@ -150,7 +153,7 @@ set_clk_mode(on, off, enable) panic("set_clk_mode: map"); /* - * make sure that we are only playing w/ + * make sure that we are only playing w/ * clock interrupt register bits */ on &= (IREG_CLOCK_ENAB_7 | IREG_CLOCK_ENAB_5); @@ -206,10 +209,6 @@ void clock_init() intersil_clear(); } -#ifdef DIAGNOSTIC -static int clk_intr_ready; -#endif - /* * Set up the real-time clock (enable clock interrupts). * Leave stathz 0 since there is no secondary clock available. @@ -219,16 +218,13 @@ void cpu_initclocks(void) { int s; - extern void _isr_clock(); if (!intersil_clock) panic("cpu_initclocks"); s = splhigh(); - isr_add_custom(5, _isr_clock); -#ifdef DIAGNOSTIC - clk_intr_ready = 1; -#endif + /* Install isr (in locore.s) that calls clock_intr(). */ + isr_add_custom(5, (void*)_isr_clock); /* Set the clock to interrupt 100 time per second. */ intersil_clock->clk_intr_reg = INTERSIL_INTER_CSECONDS; @@ -255,28 +251,39 @@ setstatclockrate(newhz) * This is is called by the "custom" interrupt handler * after it has reset the pending bit in the clock. */ -int clock_count = 0; -void clock_intr(frame) - struct clockframe *frame; +void +clock_intr(cf) + struct clockframe cf; { - static unsigned char led_pattern = 0xFE; + register volatile struct intersil7170 *clk = intersil_clock; + extern int ticks; -#ifdef DIAGNOSTIC - if (!clk_intr_ready) - panic("clock_intr"); -#endif + /* Read the clock interrupt register. */ + (void) clk->clk_intr_reg; + /* Pulse the clock intr. enable low. */ + *interrupt_reg &= ~IREG_CLOCK_ENAB_5; + *interrupt_reg |= IREG_CLOCK_ENAB_5; + /* Read the clock intr. reg AGAIN! */ + (void) clk->clk_intr_reg; - /* XXX - Move this LED frobbing to the idle loop? */ - clock_count++; - if ((clock_count & 7) == 0) { - led_pattern = (led_pattern << 1) | 1; - if (led_pattern == 0xFF) - led_pattern = 0xFE; - set_control_byte((char *) DIAG_REG, led_pattern); - } - hardclock(frame); + hardclock(&cf); + + if ((ticks & 7) == 0) + frob_leds(&cf); } +static void +frob_leds(cf) + struct clockframe *cf; +{ + static unsigned char led_pattern = 0xFE; + + /* XXX - Move this LED frobbing to the idle loop? */ + led_pattern = (led_pattern << 1) | 1; + if (led_pattern == 0xFF) + led_pattern = 0xFE; + set_control_byte((char *) DIAG_REG, led_pattern); +} /* * Return the best possible estimate of the time in the timeval @@ -378,7 +385,7 @@ void inittodr(fs_time) time.tv_sec = clk_time; } -/* +/* * Resettodr restores the time of day hardware after a time change. */ void resettodr() @@ -500,7 +507,7 @@ void gmt_to_dt(long *tp, struct date_time *dt) dt->dt_month = i; /* Days are what is left over (+1) from all that. */ - dt->dt_day = days + 1; + dt->dt_day = days + 1; } void dt_to_gmt(struct date_time *dt, long *tp) diff --git a/sys/arch/sun3/sun3/conf.c b/sys/arch/sun3/sun3/conf.c index c95f1100f90..7c95a5e51dd 100644 --- a/sys/arch/sun3/sun3/conf.c +++ b/sys/arch/sun3/sun3/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.51 1996/11/04 16:16:09 gwr Exp $ */ +/* $NetBSD: conf.c,v 1.52 1996/12/17 21:11:18 gwr Exp $ */ /*- * Copyright (c) 1994 Adam Glass, Gordon W. Ross @@ -46,8 +46,6 @@ #include <machine/conf.h> -int ttselect __P((dev_t, int, struct proc *)); - #include "bpfilter.h" #include "ccd.h" #include "cd.h" @@ -190,6 +188,7 @@ dev_t swapdev = makedev(4, 0); /* * Returns true if dev is /dev/mem or /dev/kmem. */ +int iskmemdev(dev) dev_t dev; { @@ -200,6 +199,7 @@ iskmemdev(dev) /* * Returns true if dev is /dev/zero. */ +int iszerodev(dev) dev_t dev; { @@ -287,6 +287,7 @@ static int chrtoblktbl[] = { /* * Convert a character device number to a block device number. */ +int chrtoblk(dev) dev_t dev; { diff --git a/sys/arch/sun3/sun3/db_machdep.c b/sys/arch/sun3/sun3/db_machdep.c index 5e35d0a7e93..e179c2f4322 100644 --- a/sys/arch/sun3/sun3/db_machdep.c +++ b/sys/arch/sun3/sun3/db_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.c,v 1.8 1996/11/20 18:57:27 gwr Exp $ */ +/* $NetBSD: db_machdep.c,v 1.9 1996/12/17 21:11:19 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -45,16 +45,26 @@ #include <vm/vm.h> +#include <machine/control.h> #include <machine/db_machdep.h> #include <ddb/db_command.h> +#include <ddb/db_output.h> #include <machine/pte.h> +#include "machdep.h" +static void db_mach_pagemap __P((db_expr_t, int, db_expr_t, char *)); +static void db_mach_abort __P((db_expr_t, int, db_expr_t, char *)); +static void db_mach_halt __P((db_expr_t, int, db_expr_t, char *)); +static void db_mach_reboot __P((db_expr_t, int, db_expr_t, char *)); + +static void pte_print __P((int)); static char *pgt_names[] = { "MEM", "OBIO", "VMES", "VMEL" }; -void pte_print(pte) +static void +pte_print(pte) int pte; { int t; @@ -80,8 +90,11 @@ void pte_print(pte) } static void -db_pagemap(addr) +db_mach_pagemap(addr, have_addr, count, modif) db_expr_t addr; + int have_addr; + db_expr_t count; + char * modif; { int pte, sme; @@ -102,20 +115,41 @@ db_pagemap(addr) * pgmap: Given addr, Print addr, segmap, pagemap, pte */ -extern void sun3_mon_abort(); -extern void sun3_mon_halt(); +static void +db_mach_abort(addr, have_addr, count, modif) + db_expr_t addr; + int have_addr; + db_expr_t count; + char * modif; +{ + sun3_mon_abort(); +} -void -db_mon_reboot() +static void +db_mach_halt(addr, have_addr, count, modif) + db_expr_t addr; + int have_addr; + db_expr_t count; + char * modif; +{ + sun3_mon_halt(); +} + +static void +db_mach_reboot(addr, have_addr, count, modif) + db_expr_t addr; + int have_addr; + db_expr_t count; + char * modif; { sun3_mon_reboot(""); } struct db_command db_machine_cmds[] = { - { "abort", sun3_mon_abort, 0, 0 }, - { "halt", sun3_mon_halt, 0, 0 }, - { "reboot", db_mon_reboot, 0, 0 }, - { "pgmap", db_pagemap, CS_SET_DOT, 0 }, + { "abort", db_mach_abort, 0, 0 }, + { "halt", db_mach_halt, 0, 0 }, + { "reboot", db_mach_reboot, 0, 0 }, + { "pgmap", db_mach_pagemap, CS_SET_DOT, 0 }, { (char *)0, } }; diff --git a/sys/arch/sun3/sun3/db_memrw.c b/sys/arch/sun3/sun3/db_memrw.c index 072cc1f5611..5b071d14412 100644 --- a/sys/arch/sun3/sun3/db_memrw.c +++ b/sys/arch/sun3/sun3/db_memrw.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_memrw.c,v 1.13 1996/11/20 18:57:28 gwr Exp $ */ +/* $NetBSD: db_memrw.c,v 1.14 1996/12/17 21:11:20 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -53,16 +53,24 @@ */ #include <sys/param.h> +#include <sys/systm.h> #include <sys/proc.h> #include <vm/vm.h> +#include <machine/control.h> #include <machine/pte.h> #include <machine/db_machdep.h> #include <ddb/db_access.h> -#include "cache.h" +#include "machdep.h" + +extern char etext[]; /* defined by the linker */ +extern char kernel_text[]; /* locore.s */ + +static void db_write_text __P((char *, size_t size, char *)); + /* * Read bytes from kernel address space for debugger. @@ -98,20 +106,18 @@ db_read_bytes(addr, size, data) * Makes text page writable temporarily. */ static void -db_write_text(addr, size, data) - vm_offset_t addr; +db_write_text(dst, size, data) + register char *dst; register size_t size; register char *data; { - register char *dst; - int ch, oldpte, tmppte; + int oldpte, tmppte; vm_offset_t pgva, prevpg; /* Prevent restoring a garbage PTE. */ if (size <= 0) return; - dst = (char*)addr; pgva = sun3_trunc_page((long)dst); goto firstpage; @@ -141,7 +147,7 @@ db_write_text(addr, size, data) #endif oldpte = get_pte(pgva); if ((oldpte & PG_VALID) == 0) { - printf(" address 0x%x not a valid page\n", dst); + printf(" address %p not a valid page\n", dst); return; } tmppte = oldpte | PG_WRITE | PG_NC; @@ -165,7 +171,6 @@ db_write_text(addr, size, data) /* * Write bytes to kernel address space for debugger. */ -extern char kernel_text[], etext[]; void db_write_bytes(addr, size, data) vm_offset_t addr; diff --git a/sys/arch/sun3/sun3/dvma.c b/sys/arch/sun3/sun3/dvma.c index 64c736e8103..7ec7ada5083 100644 --- a/sys/arch/sun3/sun3/dvma.c +++ b/sys/arch/sun3/sun3/dvma.c @@ -1,4 +1,4 @@ -/* $NetBSD: dvma.c,v 1.5 1996/11/20 18:57:29 gwr Exp $ */ +/* $NetBSD: dvma.c,v 1.6 1996/12/17 21:11:23 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -54,12 +54,13 @@ #include <machine/autoconf.h> #include <machine/cpu.h> +#include <machine/control.h> #include <machine/reg.h> #include <machine/pte.h> #include <machine/pmap.h> #include <machine/dvma.h> -#include "cache.h" +#include "machdep.h" /* Resource map used by dvma_mapin/dvma_mapout */ #define NUM_DVMA_SEGS 10 @@ -71,7 +72,8 @@ vm_size_t dvma_segmap_size = 6 * NBSG; /* Using phys_map to manage DVMA scratch-memory pages. */ /* Note: Could use separate pagemap for obio if needed. */ -void dvma_init() +void +dvma_init() { vm_offset_t segmap_addr; @@ -143,7 +145,7 @@ long dvma_kvtopa(kva, bustype) long kva; int bustype; { - long mask; + long mask = 0; if (kva < DVMA_SPACE_START || kva >= DVMA_SPACE_END) panic("dvma_kvtopa: bad dmva addr=0x%x\n", kva); diff --git a/sys/arch/sun3/sun3/fpu.c b/sys/arch/sun3/sun3/fpu.c index 1d56a0a9ed2..adb7d8656ac 100644 --- a/sys/arch/sun3/sun3/fpu.c +++ b/sys/arch/sun3/sun3/fpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.c,v 1.9 1996/11/20 18:57:29 gwr Exp $ */ +/* $NetBSD: fpu.c,v 1.10 1996/12/17 21:11:23 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -54,11 +54,9 @@ #include <machine/control.h> #include "interreg.h" +#include "machdep.h" -extern int fpu_type; -extern long *nofault; - -int fpu_probe(); +static int fpu_probe __P((void)); static char *fpu_descr[] = { #ifdef FPU_EMULATE @@ -70,7 +68,8 @@ static char *fpu_descr[] = { "mc68882", /* 2 */ "?" }; -void initfpu() +void +initfpu() { char *descr; int enab_reg; @@ -96,19 +95,20 @@ void initfpu() } } -int fpu_probe() +static int +fpu_probe() { label_t faultbuf; - int null_fpframe[2]; + struct fpframe null_fpf; - nofault = (long *) &faultbuf; + nofault = &faultbuf; if (setjmp(&faultbuf)) { nofault = NULL; return(0); } - null_fpframe[0] = 0; - null_fpframe[1] = 0; - m68881_restore(null_fpframe); + bzero(&null_fpf, sizeof(null_fpf)); + /* This will trap if there is no FPU present. */ + m68881_restore(&null_fpf); nofault = NULL; return(1); } diff --git a/sys/arch/sun3/sun3/genassym.c b/sys/arch/sun3/sun3/genassym.c index dcbee10994d..9b2eb8da0f8 100644 --- a/sys/arch/sun3/sun3/genassym.c +++ b/sys/arch/sun3/sun3/genassym.c @@ -1,4 +1,4 @@ -/* $NetBSD: genassym.c,v 1.32 1996/10/23 16:39:27 gwr Exp $ */ +/* $NetBSD: genassym.c,v 1.33 1996/12/17 21:11:25 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -56,9 +56,8 @@ #include <machine/vmparam.h> #include <machine/dvma.h> -#include "intersil7170.h" -#include "interreg.h" #include "buserr.h" +#include "machdep.h" #if 1 /* XXX - Temporary hack... */ /* @@ -84,6 +83,9 @@ struct mytrapframe { #define def1(name) def("name", name) #endif +extern void printf __P((char *fmt, ...)); +extern void exit __P((int)); + void def(what, val) char *what; @@ -99,15 +101,9 @@ main() struct pcb *pcb = (struct pcb *) 0; struct proc *p = (struct proc *) 0; struct vmspace *vms = (struct vmspace *) 0; - struct intersil7170 *intersil_addr = (struct intersil7170 *) 0; struct trapframe *tf = (struct trapframe *) 0; struct fpframe *fpf = (struct fpframe *) 0; - /* intersil clock internals */ - def("IREG_CLOCK_ENAB_5", IREG_CLOCK_ENAB_5); - def("INTERSIL_INTR_OFFSET", &intersil_addr->clk_intr_reg); - def1(INTERSIL_INTER_CSECONDS); - /* bus error stuff */ def1(BUSERR_REG); def1(BUSERR_MMU); @@ -150,7 +146,7 @@ main() def1(ENAMETOOLONG); /* trap types: locore.s includes trap.h */ - + /* * unix structure-isms */ diff --git a/sys/arch/sun3/sun3/interreg.h b/sys/arch/sun3/sun3/interreg.h index 6fe6c3896b3..fc5ba82cc56 100644 --- a/sys/arch/sun3/sun3/interreg.h +++ b/sys/arch/sun3/sun3/interreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: interreg.h,v 1.7 1996/11/20 18:57:30 gwr Exp $ */ +/* $NetBSD: interreg.h,v 1.8 1996/12/17 21:11:26 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -47,4 +47,6 @@ #define IREG_BITS "\20\8CLK7\7RSV6\6CLK5\5VIDEO\4SOFT3\3SOFT2\2SOFT1\1ALL\n" -int set_clk_mode(u_char on, u_char off, int enable); +extern volatile u_char *interrupt_reg; + +void set_clk_mode __P((u_char on, u_char off, int enable)); diff --git a/sys/arch/sun3/sun3/intersil7170.h b/sys/arch/sun3/sun3/intersil7170.h index 848765bbfe4..5ad4634fb4e 100644 --- a/sys/arch/sun3/sun3/intersil7170.h +++ b/sys/arch/sun3/sun3/intersil7170.h @@ -1,4 +1,4 @@ -/* $NetBSD: intersil7170.h,v 1.9 1996/11/20 18:57:31 gwr Exp $ */ +/* $NetBSD: intersil7170.h,v 1.10 1996/12/17 21:11:27 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ /* * Driver support for the intersil7170 used in sun[34]s to provide * real time clock and time-of-day support. - * + * * Derived from: datasheet "ICM7170 a uP-Compatible Real-Time Clock" * document #301680-005, Dec 85 */ @@ -63,7 +63,7 @@ struct intersil7170 { }; /* bit assignments for command register, p. 6 of 10, write-only */ -#define INTERSIL_CMD_FREQ_32K 0x0 +#define INTERSIL_CMD_FREQ_32K 0x0 #define INTERSIL_CMD_FREQ_1M 0x1 #define INTERSIL_CMD_FREQ_2M 0x2 #define INTERSIL_CMD_FREQ_4M 0x3 diff --git a/sys/arch/sun3/sun3/intreg.c b/sys/arch/sun3/sun3/intreg.c index fd10cd7ac43..40d6c243680 100644 --- a/sys/arch/sun3/sun3/intreg.c +++ b/sys/arch/sun3/sun3/intreg.c @@ -1,4 +1,4 @@ -/* $NetBSD: intreg.c,v 1.5 1996/11/20 18:57:32 gwr Exp $ */ +/* $NetBSD: intreg.c,v 1.6 1996/12/17 21:11:28 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -50,18 +50,18 @@ #include <machine/cpu.h> #include <machine/mon.h> #include <machine/obio.h> -#include <machine/isr.h> #include "interreg.h" +#include "machdep.h" struct intreg_softc { struct device sc_dev; volatile u_char *sc_reg; }; -static int intreg_match __P((struct device *, void *vcf, void *args)); +static int intreg_match __P((struct device *, void *, void *)); static void intreg_attach __P((struct device *, struct device *, void *)); -static int soft1intr(); +static int soft1intr __P((void *)); struct cfattach intreg_ca = { sizeof(struct intreg_softc), intreg_match, intreg_attach @@ -75,7 +75,8 @@ volatile u_char *interrupt_reg; /* called early (by internal_configure) */ -void intreg_init() +void +intreg_init() { interrupt_reg = obio_find_mapping(OBIO_INTERREG, 1); if (!interrupt_reg) @@ -90,9 +91,8 @@ intreg_match(parent, vcf, args) struct device *parent; void *vcf, *args; { - struct cfdata *cf = vcf; + struct cfdata *cf = vcf; struct confargs *ca = args; - int pa; /* This driver only supports one unit. */ if (cf->cf_unit != 0) @@ -113,7 +113,6 @@ intreg_attach(parent, self, args) void *args; { struct intreg_softc *sc = (void *)self; - struct cfdata *cf = self->dv_cfdata; printf("\n"); @@ -130,11 +129,12 @@ intreg_attach(parent, self, args) * Network software interrupt * Soft clock interrupt */ -int soft1intr(arg) +static int +soft1intr(arg) void *arg; { union sun3sir sir; - int n, s; + int s; s = splhigh(); sir.sir_any = sun3sir.sir_any; diff --git a/sys/arch/sun3/sun3/isr.c b/sys/arch/sun3/sun3/isr.c index f2ddb867afc..3fe28d94776 100644 --- a/sys/arch/sun3/sun3/isr.c +++ b/sys/arch/sun3/sun3/isr.c @@ -1,4 +1,4 @@ -/* $NetBSD: isr.c,v 1.25 1996/11/20 18:57:32 gwr Exp $ */ +/* $NetBSD: isr.c,v 1.26 1996/12/17 21:11:29 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -43,47 +43,75 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/device.h> #include <sys/malloc.h> #include <sys/vmmeter.h> #include <net/netisr.h> +#include <machine/autoconf.h> #include <machine/cpu.h> #include <machine/mon.h> #include <machine/obio.h> -#include <machine/isr.h> +#include "machdep.h" #include "vector.h" -#include "ether.h" /* for NETHER */ - extern int intrcnt[]; /* statistics */ #define NUM_LEVELS 8 struct isr { struct isr *isr_next; - int (*isr_intr)(); + isr_func_t isr_intr; void *isr_arg; int isr_ipl; }; -void set_vector_entry __P((int, void (*handler)())); -unsigned int get_vector_entry __P((int)); +void set_vector_entry __P((int, void *)); +void * get_vector_entry __P((int)); + +/* + * These are called from locore. The "struct clockframe" arg + * is really just the normal H/W interrupt frame format. + * (kern_clock really wants it to be named that...) + */ +void isr_autovec __P((struct clockframe)); +void isr_vectored __P((struct clockframe)); + -void isr_add_custom(level, handler) +void +isr_add_custom(level, handler) int level; - void (*handler)(); + void *handler; { set_vector_entry(AUTOVEC_BASE + level, handler); } + /* + * netisr junk... * XXX - This really belongs in some common file, * i.e. src/sys/net/netisr.c * Also, should use an array of chars instead of * a bitmask to avoid atomicity locking issues. */ + +#include "ether.h" /* for NETHER */ +#include "ppp.h" + +/* + * Declarations for the netisr functions... + * They are in the header files, but that's not + * really a good reason to drag all those in. + */ +void arpintr __P((void)); +void ipintr __P((void)); +void nsintr __P((void)); +void clnlintr __P((void)); +void ccittintr __P((void)); +void pppintr __P((void)); + void netintr() { int n, s; @@ -114,7 +142,6 @@ void netintr() ccittintr(); } #endif -#include "ppp.h" #if NPPP > 0 if (n & (1 << NETISR_PPP)) { pppintr(); @@ -129,13 +156,13 @@ static struct isr *isr_autovec_list[NUM_LEVELS]; * This is called by the assembly routines * for handling auto-vectored interupts. */ -void isr_autovec(evec) - int evec; /* format | vector offset */ +void isr_autovec(cf) + struct clockframe cf; { struct isr *isr; register int n, ipl, vec; - vec = (evec & 0xFFF) >> 2; + vec = (cf.cf_vo & 0xFFF) >> 2; if ((vec < AUTOVEC_BASE) || (vec >= (AUTOVEC_BASE+8))) panic("isr_autovec: bad vec"); ipl = vec - 0x18; @@ -166,7 +193,7 @@ void isr_autovec(evec) * Called by driver attach functions. */ void isr_add_autovect(handler, arg, level) - int (*handler)(); + isr_func_t handler; void *arg; int level; { @@ -186,9 +213,8 @@ void isr_add_autovect(handler, arg, level) isr_autovec_list[level] = new_isr; } -extern void badtrap(); struct vector_handler { - int (*func)(); + isr_func_t func; void *arg; }; static struct vector_handler isr_vector_handlers[192]; @@ -198,13 +224,13 @@ static struct vector_handler isr_vector_handlers[192]; * for handling vectored interupts. */ void -isr_vectored(evec) - int evec; /* format | vector offset */ +isr_vectored(cf) + struct clockframe cf; { struct vector_handler *vh; register int ipl, vec; - vec = (evec & 0xFFF) >> 2; + vec = (cf.cf_vo & 0xFFF) >> 2; ipl = getsr(); ipl = (ipl >> 8) & 7; @@ -218,7 +244,7 @@ isr_vectored(evec) vh = &isr_vector_handlers[vec - 64]; if (vh->func == NULL) { printf("isr_vectored: vector=0x%x (nul func)\n", vec); - set_vector_entry(vec, badtrap); + set_vector_entry(vec, (void *)badtrap); return; } @@ -231,9 +257,10 @@ isr_vectored(evec) * Establish an interrupt handler. * Called by driver attach functions. */ -extern void _isr_vectored(); -void isr_add_vectored(func, arg, level, vec) - int (*func)(); +extern void _isr_vectored __P((void)); +void +isr_add_vectored(func, arg, level, vec) + isr_func_t func; void *arg; int level, vec; { @@ -250,24 +277,27 @@ void isr_add_vectored(func, arg, level, vec) } vh->func = func; vh->arg = arg; - set_vector_entry(vec, _isr_vectored); + set_vector_entry(vec, (void *)_isr_vectored); } /* * XXX - could just kill these... */ -void set_vector_entry(entry, handler) +void +set_vector_entry(entry, handler) int entry; - void (*handler)(); + void *handler; { if ((entry <0) || (entry >= NVECTORS)) panic("set_vector_entry: setting vector too high or low\n"); - vector_table[entry] = handler; + vector_table[entry] = handler; } -unsigned int get_vector_entry(entry) + +void * +get_vector_entry(entry) int entry; { if ((entry <0) || (entry >= NVECTORS)) panic("get_vector_entry: setting vector too high or low\n"); - return (unsigned int) vector_table[entry]; + return ((void *) vector_table[entry]); } diff --git a/sys/arch/sun3/sun3/kgdb_stub.c b/sys/arch/sun3/sun3/kgdb_stub.c index ce3ed8f4703..12621266985 100644 --- a/sys/arch/sun3/sun3/kgdb_stub.c +++ b/sys/arch/sun3/sun3/kgdb_stub.c @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_stub.c,v 1.6 1996/10/23 16:30:48 gwr Exp $ */ +/* $NetBSD: kgdb_stub.c,v 1.7 1996/12/17 21:11:30 gwr Exp $ */ /* * Copyright (c) 1990, 1993 @@ -63,12 +63,9 @@ #include <machine/trap.h> #include <sun3/sun3/kgdb_proto.h> +#include <machine/db_machdep.h> #include <machine/remote-sl.h> -/* These are in db_memrw.c */ -extern void db_read_bytes __P((vm_offset_t addr, size_t size, char *data)); -extern void db_write_bytes __P((vm_offset_t addr, size_t size, char *data)); - #ifndef KGDBDEV #define KGDBDEV -1 #endif @@ -219,7 +216,7 @@ restart: * Translate a trap number into a unix compatible signal value. * (gdb only understands unix signal numbers). */ -static int +static int computeSignal(type) int type; { diff --git a/sys/arch/sun3/sun3/locore.s b/sys/arch/sun3/sun3/locore.s index 15794d5362f..b029428f68e 100644 --- a/sys/arch/sun3/sun3/locore.s +++ b/sys/arch/sun3/sun3/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.40 1996/11/06 20:19:54 cgd Exp $ */ +/* $NetBSD: locore.s,v 1.41 1996/12/17 21:11:31 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -134,9 +134,9 @@ L_high_code: * cpu_set_kpc() to arrange for a call to a kernel function * before the new process does its rte out to user mode. */ - clrw sp@- | vector offset/frame type + clrw sp@- | vector offset/frame type clrl sp@- | PC - filled in by "execve" - movw #PSL_USER,sp@- | in user mode + 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 | proc0 in a0 @@ -154,7 +154,7 @@ _proc_do_uret: movl a0,usp | user SP moveml sp@+,#0x7FFF | load most registers (all but SSP) addql #8,sp | pop SSP and stack adjust count - rte + rte /* * proc_trampoline: @@ -246,12 +246,12 @@ Lbe10: /* * the sun3 specific code - * + * * our mission: figure out whether what we are looking at is * bus error in the UNIX sense, or * a memory error i.e a page fault * - * [this code replaces similarly mmu specific code in the hp300 code] + * [this code replaces similarly mmu specific code in the hp300 code] */ sun3_mmu_specific: clrl d0 | make sure top bits are cleard too @@ -571,7 +571,7 @@ Lbrkpt2: jne Lbrkpt3 | yes, done #endif #ifdef DDB - | Let DDB handle it. + | Let DDB handle it. movl a2,sp@- | push frame ptr movl d2,sp@- | push trap type jbsr _kdb_trap | handle the trap @@ -616,6 +616,8 @@ _trap12: /* * Interrupt handlers. Most are auto-vectored, * and hard-wired the same way on all sun3 models. + * Format in the stack is: + * d0,d1,a0,a1, sr, pc, vo */ #define INTERRUPT_SAVEREG \ @@ -624,53 +626,36 @@ _trap12: #define INTERRUPT_RESTORE \ moveml sp@+,#0x0303 -.align 4 /* * This is the common auto-vector interrupt handler, * for which the CPU provides the vector=0x18+level. * These are installed in the interrupt vector table. */ - .globl __isr_autovec + .align 2 + .globl __isr_autovec, _isr_autovec __isr_autovec: INTERRUPT_SAVEREG - movw sp@(22),sp@- | push exception vector info - clrw sp@- - jbsr _isr_autovec | C dispatcher - addql #4,sp + jbsr _isr_autovec INTERRUPT_RESTORE - jra rei /* XXX - Just do rte here? */ + jra rei /* clock: see clock.c */ -.globl __isr_clock, _interrupt_reg, _clock_intr, _clock_va -.align 4 + .align 2 + .globl __isr_clock, _clock_intr __isr_clock: - INTERRUPT_SAVEREG | save a0, a1, d0, d1 - movl _clock_va, a0 - movl _interrupt_reg, a1 - tstb a0@(INTERSIL_INTR_OFFSET) - andb #~IREG_CLOCK_ENAB_5, a1@ - orb #IREG_CLOCK_ENAB_5, a1@ - tstb a0@(INTERSIL_INTR_OFFSET) -| used to have "timebomb" check here... - lea sp@(16),a1 | a1 = &clockframe - movl a1,sp@- + INTERRUPT_SAVEREG jbsr _clock_intr - addql #4,sp INTERRUPT_RESTORE jra rei | Handler for all vectored interrupts (i.e. VME interrupts) - .globl _isr_vectored - .globl __isr_vectored + .align 2 + .globl __isr_vectored, _isr_vectored __isr_vectored: INTERRUPT_SAVEREG - movw sp@(22),sp@- | push exception vector info - clrw sp@- - jbsr _isr_vectored | C dispatcher - addql #4,sp | + jbsr _isr_vectored INTERRUPT_RESTORE - jra rei | all done - + jra rei #undef INTERRUPT_SAVEREG #undef INTERRUPT_RESTORE @@ -951,7 +936,7 @@ ENTRY(switch_exit) .data .globl _Idle_count _Idle_count: - .long 0 + .long 0 .text .globl Idle @@ -959,7 +944,7 @@ Lidle: stop #PSL_LOWIPL Idle: movw #PSL_HIGHIPL,sr - addql #1, _Idle_count + addql #1, _Idle_count tstl _whichqs jeq Lidle movw #PSL_LOWIPL,sr @@ -972,7 +957,7 @@ Lbadsw: /* * cpu_switch() - * Hacked for sun3 + * Hacked for sun3 * XXX - Arg 1 is a proc pointer (curproc) but this doesn't use it. * XXX - Sould we use p->p_addr instead of curpcb? -gwr */ @@ -1234,8 +1219,6 @@ ENTRY(_remque) /* * Save and restore 68881 state. - * Pretty awful looking since our assembler does not - * recognize FP mnemonics. */ ENTRY(m68881_save) movl sp@(4),a0 | save area pointer diff --git a/sys/arch/sun3/sun3/machdep.c b/sys/arch/sun3/sun3/machdep.c index 70ddac1f9d4..2340df63410 100644 --- a/sys/arch/sun3/sun3/machdep.c +++ b/sys/arch/sun3/sun3/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.77 1996/10/13 03:47:51 christos Exp $ */ +/* $NetBSD: machdep.c,v 1.79 1996/12/17 21:35:30 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross @@ -78,34 +78,33 @@ #include <sys/shm.h> #endif -#include <machine/cpu.h> -#include <machine/reg.h> -#include <machine/psl.h> -#include <machine/pte.h> -#include <machine/mon.h> -#include <machine/isr.h> -#include <machine/kcore.h> - -#include <dev/cons.h> - #include <vm/vm.h> #include <vm/vm_map.h> #include <vm/vm_kern.h> #include <vm/vm_page.h> -#include <net/netisr.h> +#include <dev/cons.h> + +#include <machine/cpu.h> +#include <machine/reg.h> +#include <machine/psl.h> +#include <machine/pte.h> +#include <machine/mon.h> +#include <machine/dvma.h> +#include <machine/kcore.h> +#include <machine/db_machdep.h> -#include "cache.h" +#include "machdep.h" extern char *cpu_string; extern char version[]; extern short exframesize[]; -extern vm_offset_t vmmap; /* XXX - poor name. See mem.c */ -extern int cold; -int physmem; -int fpu_type; -int msgbufmapped; +int physmem; +int fpu_type; +int msgbufmapped; + +vm_offset_t vmmap; /* * safepri is a safe priority for sleep to set for a spin-wait @@ -127,9 +126,10 @@ int bufpages = BUFPAGES; #else int bufpages = 0; #endif -long *nofault; +label_t *nofault; -void identifycpu(); +static void identifycpu __P((void)); +static void initcpu __P((void)); /* * Console initialization: called early on from main, @@ -138,8 +138,7 @@ void identifycpu(); */ void consinit() { - extern void cninit(); - cninit(); + cninit(); #ifdef KGDB /* XXX - Ask on console for kgdb_dev? */ @@ -154,7 +153,7 @@ void consinit() ddb_init(); if (boothowto & RB_KDB) Debugger(); -#endif +#endif DDB } /* @@ -170,6 +169,7 @@ void consinit() */ #define valloc(name, type, num) \ v = (caddr_t)(((name) = (type *)v) + (num)) +static caddr_t allocsys __P((caddr_t)); static caddr_t allocsys(v) register caddr_t v; @@ -212,6 +212,8 @@ allocsys(v) if (nbuf < 16) nbuf = 16; } + if (nbuf > 200) /* XXX Sorry, our kvm space is too small */ + nbuf = 200; if (nswbuf == 0) { nswbuf = (nbuf / 2) &~ 1; /* force even */ if (nswbuf > 256) @@ -236,15 +238,15 @@ cpu_startup() { caddr_t v; int sz, i; - vm_size_t size; + vm_size_t size; int base, residual; vm_offset_t minaddr, maxaddr; - + /* * The msgbuf was set up earlier (in sun3_startup.c) * just because it was more convenient to do there. */ - + /* * Good {morning,afternoon,evening,night}. */ @@ -392,6 +394,7 @@ setregs(p, pack, stack, retval) if (fpu_type) { m68881_restore(&p->p_addr->u_pcb.pcb_fpregs); } + p->p_md.md_flags = 0; /* XXX - HPUX sigcode hack would go here... */ } @@ -421,6 +424,7 @@ identifycpu() /* * machine dependent system variables. */ +int cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) int *name; u_int namelen; @@ -430,6 +434,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) size_t newlen; struct proc *p; { + int error; dev_t consdev; /* all sysctl names at this level are terminal */ @@ -442,12 +447,24 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) consdev = cn_tab->cn_dev; else consdev = NODEV; - return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev, - sizeof consdev)); + error = sysctl_rdstruct(oldp, oldlenp, newp, + &consdev, sizeof consdev); + break; + +#if 0 /* XXX - Not yet... */ + case CPU_ROOT_DEVICE: + error = sysctl_rdstring(oldp, oldlenp, newp, root_device); + break; + + case CPU_BOOTED_KERNEL: + error = sysctl_rdstring(oldp, oldlenp, newp, booted_kernel); + break; +#endif + default: - return (EOPNOTSUPP); + error = EOPNOTSUPP; } - /* NOTREACHED */ + return (error); } #define SS_RTEFRAME 1 @@ -517,7 +534,7 @@ sendsig(catcher, sig, mask, code) psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)(frame->f_regs[SP] - fsize); - if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) (void)grow(p, (unsigned)fp); #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) @@ -543,7 +560,7 @@ sendsig(catcher, sig, mask, code) return; } kfp = (struct sigframe *)malloc((u_long)fsize, M_TEMP, M_WAITOK); - /* + /* * Build the argument list for the signal handler. */ kfp->sf_signum = sig; @@ -729,7 +746,7 @@ sys_sigreturn(p, v, retval) */ if (flags & SS_RTEFRAME) { register int sz; - + /* grab frame type and validate */ sz = tstate.ss_frame.f_format; if (sz > 15 || (sz = exframesize[sz]) < 0) @@ -770,7 +787,8 @@ sys_sigreturn(p, v, retval) * XXX - Put waittime checks in there too? */ int waittime = -1; /* XXX - Who else looks at this? -gwr */ -static void reboot_sync() +static void +reboot_sync __P((void)) { extern struct proc proc0; struct buf *bp; @@ -788,6 +806,7 @@ static void reboot_sync() /* * Common part of the BSD and SunOS reboot system calls. + * Warning: OpenBSD doesn't use a second arg to boot() */ int reboot2(howto, user_boot_string) int howto; @@ -887,7 +906,7 @@ long dumplo = 0; /* blocks */ vm_offset_t dumppage_va; vm_offset_t dumppage_pa; -#define DUMP_EXTRA 3 /* CPU-dependent extra pages */ +#define DUMP_EXTRA 3 /* CPU-dependent extra pages */ /* * This is called by cpu_startup to set dumplo, dumpsize. @@ -901,7 +920,7 @@ dumpconf() { int nblks; /* size of dump area */ int maj; - int (*getsize)(); + int (*getsize)__P((dev_t)); if (dumpdev == NODEV) return; @@ -917,7 +936,7 @@ dumpconf() return; /* Position dump image near end of space, page aligned. */ - dumpsize = physmem + DUMP_EXTRA; /* pages */ + dumpsize = physmem + DUMP_EXTRA; /* pages */ dumplo = nblks - ctod(dumpsize); dumplo &= ~(ctod(1)-1); @@ -940,11 +959,12 @@ extern vm_offset_t avail_start; * pagemap (2*NBPG) * physical memory... */ +void dumpsys() { struct bdevsw *dsw; kcore_seg_t *kseg_p; - cpu_kcore_hdr_t *chdr_p; + cpu_kcore_hdr_t *chdr_p; char *vaddr; vm_offset_t paddr; int psize, todo, chunk; @@ -957,7 +977,7 @@ dumpsys() if (dumppage_va == 0) return; - /* + /* * For dumps during autoconfiguration, * if dump device has already configured... */ @@ -998,14 +1018,14 @@ dumpsys() blkno += btodb(NBPG); /* translation RAM (page zero) */ - pmap_get_pagemap(vaddr, 0); + pmap_get_pagemap((int*)vaddr, 0); error = (*dsw->d_dump)(dumpdev, blkno, vaddr, NBPG); if (error) goto fail; blkno += btodb(NBPG); /* translation RAM (page one) */ - pmap_get_pagemap(vaddr, NBPG); + pmap_get_pagemap((int*)vaddr, NBPG); error = (*dsw->d_dump)(dumpdev, blkno, vaddr, NBPG); if (error) goto fail; @@ -1060,6 +1080,7 @@ fail: printf(" dump error=%d\n", error); } +static void initcpu() { /* XXX: Enable RAM parity/ECC checking? */ @@ -1072,57 +1093,32 @@ initcpu() #endif } +/* called from locore.s */ +void straytrap __P((struct trapframe)); +void straytrap(frame) - struct frame frame; + struct trapframe frame; { - printf("unexpected trap; vector offset 0x%x from 0x%x\n", - frame.f_vector, frame.f_pc); + printf("unexpected trap; vector=0x%x at pc=0x%x\n", + frame.tf_vector, frame.tf_pc); #ifdef DDB - kdb_trap(-1, &frame); + /* XXX - Yuck! Make DDB use "struct trapframe" instead! */ + kdb_trap(-1, (struct mc68020_saved_state *) &frame); #endif } /* from hp300: badaddr() */ -int -peek_word(addr) - register caddr_t addr; -{ - label_t faultbuf; - register int x; - - nofault = (long*)&faultbuf; - if (setjmp(&faultbuf)) { - nofault = NULL; - return(-1); - } - x = *(volatile u_short *)addr; - nofault = NULL; - return(x); -} - -/* from hp300: badbaddr() */ -int -peek_byte(addr) - register caddr_t addr; -{ - label_t faultbuf; - register int x; - - nofault = (long*)&faultbuf; - if (setjmp(&faultbuf)) { - nofault = NULL; - return(-1); - } - x = *(volatile u_char *)addr; - nofault = NULL; - return(x); -} +/* peek_byte(), peek_word() moved to autoconf.c */ /* XXX: parityenable() ? */ +static void dumpmem __P((int *, int, int)); +static char *hexstr __P((int, int)); + /* * Print a register and stack dump. */ +void regdump(fp, sbytes) struct frame *fp; /* must not be register */ int sbytes; @@ -1130,7 +1126,6 @@ regdump(fp, sbytes) static int doingdump = 0; register int i; int s; - extern char *hexstr(); if (doingdump) return; @@ -1166,12 +1161,12 @@ regdump(fp, sbytes) #define KSADDR ((int *)((u_int)curproc->p_addr + USPACE - NBPG)) +static void dumpmem(ptr, sz, ustack) register int *ptr; int sz, ustack; { register int i, val; - extern char *hexstr(); for (i = 0; i < sz; i++) { if ((i & 7) == 0) @@ -1192,7 +1187,7 @@ dumpmem(ptr, sz, ustack) printf("\n"); } -char * +static char * hexstr(val, len) register int val; int len; @@ -1215,10 +1210,11 @@ hexstr(val, len) /* * cpu_exec_aout_makecmds(): * cpu-dependent a.out format hook for execve(). - * + * * Determine if the given exec package refers to something which we * understand and, if so, set up the vmcmds for it. */ +int cpu_exec_aout_makecmds(p, epp) struct proc *p; struct exec_package *epp; diff --git a/sys/arch/sun3/sun3/mainbus.c b/sys/arch/sun3/sun3/mainbus.c index 44d0b7a3970..71734a9c694 100644 --- a/sys/arch/sun3/sun3/mainbus.c +++ b/sys/arch/sun3/sun3/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.4 1996/11/20 18:57:34 gwr Exp $ */ +/* $NetBSD: mainbus.c,v 1.5 1996/12/17 21:11:35 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -85,7 +85,6 @@ main_attach(parent, self, args) void *args; { struct confargs ca; - struct cfdata *new_match; int i; printf("\n"); diff --git a/sys/arch/sun3/sun3/mem.c b/sys/arch/sun3/sun3/mem.c index ab82bf26877..33ff44d0708 100644 --- a/sys/arch/sun3/sun3/mem.c +++ b/sys/arch/sun3/sun3/mem.c @@ -1,8 +1,8 @@ -/* $NetBSD: mem.c,v 1.19 1995/08/08 21:09:01 gwr Exp $ */ +/* $NetBSD: mem.c,v 1.20 1996/12/17 21:11:36 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross - * Copyright (c) 1993 Adam Glass + * Copyright (c) 1993 Adam Glass * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -47,34 +47,35 @@ */ #include <sys/param.h> -#include <sys/conf.h> -#include <sys/buf.h> #include <sys/systm.h> -#include <sys/uio.h> +#include <sys/buf.h> +#include <sys/conf.h> #include <sys/malloc.h> +#include <sys/proc.h> +#include <sys/uio.h> #include <vm/vm.h> #include <vm/vm_kern.h> #include <vm/vm_map.h> #include <machine/cpu.h> +#include <machine/eeprom.h> #include <machine/pte.h> #include <machine/pmap.h> -extern int eeprom_uio(); -extern vm_offset_t avail_start, avail_end; +#include "machdep.h" -vm_offset_t vmmap; /* XXX - poor name... - * It is a virtual page, not a map. - */ -caddr_t zeropage; +#define mmread mmrw +cdev_decl(mm); +static caddr_t zeropage; /*ARGSUSED*/ int -mmopen(dev, flag, mode) +mmopen(dev, flag, mode, p) dev_t dev; int flag, mode; + struct proc *p; { return (0); @@ -82,9 +83,10 @@ mmopen(dev, flag, mode) /*ARGSUSED*/ int -mmclose(dev, flag, mode) +mmclose(dev, flag, mode, p) dev_t dev; int flag, mode; + struct proc *p; { return (0); @@ -131,7 +133,7 @@ mmrw(dev, uio, flags) case 0: v = uio->uio_offset; /* allow reads only in RAM */ - if (v < 0 || v >= avail_end) { + if (v >= avail_end) { error = EFAULT; goto unlock; } diff --git a/sys/arch/sun3/sun3/pmap.c b/sys/arch/sun3/sun3/pmap.c index 01f3a4eadd0..dad84c28933 100644 --- a/sys/arch/sun3/sun3/pmap.c +++ b/sys/arch/sun3/sun3/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.64 1996/11/20 18:57:35 gwr Exp $ */ +/* $NetBSD: pmap.c,v 1.65 1996/12/17 21:11:38 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -57,6 +57,13 @@ */ /* + * Cache management: + * All sun3 cache implementations are write-back. + * Flushes must be done before removing translations + * from the MMU because the cache uses the MMU. + */ + +/* * wanted attributes: * pmegs that aren't needed by a pmap remain in the MMU. * quick context switches between pmaps @@ -83,26 +90,13 @@ #include <machine/dvma.h> #include <machine/pmap.h> -#include "cache.h" +#include "machdep.h" + #if (PMAP_OBIO << PG_MOD_SHIFT) != PGT_OBIO #error "PMAP_XXX definitions don't match pte.h!" #endif -/* - * Globals shared between here and sun3_startup: - * For simplicity, this interface retains the variables - * that were used in the old interface (without NONCONTIG). - * These are set in pmap_bootstrap() and used - * in pmap_next_page(). - */ -/* Kernel virtual address space available: */ -extern vm_offset_t virtual_avail, virtual_end; -/* Physical address space available: */ -extern vm_offset_t avail_start, avail_end; -/* The "hole" (used to skip the Sun3/50 video RAM) */ -extern vm_offset_t hole_start, hole_size; - /* statistics... */ struct pmap_stats { int ps_enter_firstpv; /* pv heads entered */ @@ -188,6 +182,7 @@ typedef struct pv_entry *pv_entry_t; pv_entry_t pv_head_table = NULL; #ifdef DIAGNOSTIC +static struct pv_entry * pa_to_pvp __P((vm_offset_t pa)); static struct pv_entry * pa_to_pvp(pa) vm_offset_t pa; @@ -310,6 +305,13 @@ struct pmeg_tailq pmeg_free_queue, pmeg_inactive_queue, static struct pmeg_state pmeg_array[NPMEG]; #ifdef PMAP_DEBUG +void pmap_print __P((pmap_t pmap)); +void pv_print __P((vm_offset_t pa)); + +static pmeg_t pmeg_p __P((int sme)); +static void pmeg_verify_empty __P((vm_offset_t va)); +static void pmeg_print __P((pmeg_t pmegp)); + static pmeg_t pmeg_p(sme) int sme; @@ -354,14 +356,12 @@ static void context_allocate __P((pmap_t pmap)); static void context_free __P((pmap_t pmap)); static void context_init __P((void)); -static void pmeg_flush __P((pmeg_t pmegp)); static pmeg_t pmeg_allocate __P((pmap_t pmap, vm_offset_t va)); static void pmeg_release __P((pmeg_t pmegp)); static void pmeg_free __P((pmeg_t pmegp, int segnum)); static pmeg_t pmeg_cache __P((pmap_t pmap, vm_offset_t va)); static void pmeg_set_wiring __P((pmeg_t pmegp, vm_offset_t va, int)); -static int pv_compute_cache __P((pv_entry_t head)); static int pv_link __P((pmap_t pmap, vm_offset_t, vm_offset_t, u_int)); static void pv_unlink __P((pmap_t, vm_offset_t, vm_offset_t)); static void pv_remove_all __P(( vm_offset_t pa)); @@ -369,8 +369,9 @@ static void pv_changepte __P((pv_entry_t, int, int)); static void pv_syncflags __P((pv_entry_t head)); static void pv_init __P((void)); -void sun3_pmeg_init __P((void)); -void sun3_reserve_pmeg __P((int pmeg_num)); +static void pmeg_clean __P((pmeg_t pmegp)); +static void pmeg_clean_free __P((void)); + void sun3_protection_init __P((void)); static void pmap_common_init __P((pmap_t pmap)); @@ -417,7 +418,6 @@ int pmap_db_watchpmeg = -1; #endif /* PMAP_DEBUG */ #ifdef PMAP_DEBUG /* XXX */ -extern int getsr(); #define CHECK_SPL() do { \ if ((getsr() & PSL_IPL) < PSL_IPL3) \ panic("pmap: bad spl, line %d", __LINE__); \ @@ -436,20 +436,22 @@ context_allocate(pmap) PMAP_LOCK(); #ifdef PMAP_DEBUG if (pmap_debug & PMD_CONTEXT) - printf("context_allocate: for pmap %x\n", pmap); + printf("context_allocate: for pmap %p\n", pmap); #endif if (pmap == kernel_pmap) panic("context_allocate: kernel_pmap"); if (has_context(pmap)) panic("pmap: pmap already has context allocated to it"); - if (TAILQ_EMPTY(&context_free_queue)) { - /* Steal one from the active queue. */ - if (TAILQ_EMPTY(&context_active_queue)) - panic("pmap: no contexts to be found"); - context_free((&context_active_queue)->tqh_first->context_upmap); + context = (&context_free_queue)->tqh_first; + if (context == NULL) { + /* Steal the head of the active queue. */ + context = (&context_active_queue)->tqh_first; + if (context == NULL) + panic("pmap: no contexts left?"); + context_free(context->context_upmap); #ifdef PMAP_DEBUG if (pmap_debug & PMD_CONTEXT) - printf("context_allocate: pmap %x, take context %x num %d\n", + printf("context_allocate: pmap %p, take context %p num %d\n", pmap, context, context->context_num); #endif } @@ -461,7 +463,7 @@ context_allocate(pmap) context->context_upmap = pmap; #ifdef PMAP_DEBUG if (pmap_debug & PMD_CONTEXT) - printf("context_allocate: pmap %x given context %x num %d\n", + printf("context_allocate: pmap %p given context %p num %d\n", pmap, context, context->context_num); #endif @@ -489,7 +491,7 @@ context_free(pmap) /* :) */ ctxnum = pmap->pm_ctxnum; #ifdef PMAP_DEBUG if (pmap_debug & PMD_CONTEXT) - printf("context_free: freeing context num %d of pmap 0x%x\n", + printf("context_free: freeing context num %d of pmap %p\n", ctxnum, pmap); #endif @@ -536,7 +538,7 @@ context_free(pmap) /* :) */ pmap->pm_ctxnum = CTXINVAL; #ifdef PMAP_DEBUG if (pmap_debug & PMD_CONTEXT) - printf("context_free: pmap %x context removed\n", pmap); + printf("context_free: pmap %p context removed\n", pmap); #endif PMAP_UNLOCK(); } @@ -556,21 +558,22 @@ context_init() context_link); #ifdef PMAP_DEBUG if (pmap_debug & PMD_CONTEXT) - printf("context_init: context num %d is %x\n", + printf("context_init: context num %d is %p\n", i, &context_array[i]); #endif } } #ifdef PMAP_DEBUG -void pmap_print(pmap) +void +pmap_print(pmap) pmap_t pmap; { printf(" pm_ctxnum=%d\n", pmap->pm_ctxnum); printf(" pm_version=0x%x\n", pmap->pm_version); - printf(" pm_segmap=0x%x\n", pmap->pm_segmap); + printf(" pm_segmap=%p\n", pmap->pm_segmap); } -#endif +#endif /* PMAP_DEBUG */ /* * Reserve a pmeg (forever) for use by PROM, etc. @@ -659,23 +662,24 @@ pmeg_verify_empty(va) panic("pmeg_verify_empty"); } } +#endif /* PMAP_DEBUG */ -static void +#ifdef PMAP_DEBUG +void pmeg_print(pmegp) pmeg_t pmegp; { - printf("link_next=0x%x link_prev=0x%x\n", - pmegp->pmeg_link.tqe_next, - pmegp->pmeg_link.tqe_prev); - printf("index=0x%x owner=0x%x own_vers=0x%x\n", - pmegp->pmeg_index, pmegp->pmeg_owner, - pmegp->pmeg_version); + printf("link_next=%p link_prev=%p\n", + pmegp->pmeg_link.tqe_next, + pmegp->pmeg_link.tqe_prev); + printf("index=0x%x owner=%p own_vers=0x%x\n", + pmegp->pmeg_index, pmegp->pmeg_owner, pmegp->pmeg_version); printf("va=0x%x wired=0x%x reserved=0x%x vpgs=0x%x qstate=0x%x\n", - pmegp->pmeg_va, pmegp->pmeg_wired, - pmegp->pmeg_reserved, pmegp->pmeg_vpages, - pmegp->pmeg_qstate); + pmegp->pmeg_va, pmegp->pmeg_wired, + pmegp->pmeg_reserved, pmegp->pmeg_vpages, + pmegp->pmeg_qstate); } -#endif +#endif /* PMAP_DEBUG */ /* * Allocate a PMEG by whatever means necessary. @@ -760,7 +764,7 @@ pmeg_allocate(pmap, va) pmegp->pmeg_qstate = PMEGQ_ACTIVE; #ifdef PMAP_DEBUG if (pmap_debug & PMD_SEGMAP) { - printf("pm_segmap: pmap=%x i=%x old=%x new=%x (pget)\n", + printf("pm_segmap: pmap=%p i=%x old=%x new=%x (pget)\n", pmap, VA_SEGNUM(va), pmap->pm_segmap[VA_SEGNUM(va)], pmegp->pmeg_index); @@ -963,7 +967,8 @@ sun3_pmeg_init() } #ifdef PMAP_DEBUG -static void +/* call from debugger */ +void pv_print(pa) vm_offset_t pa; { @@ -975,7 +980,7 @@ pv_print(pa) pv = pa_to_pvp(pa); printf("pv_list for pa %x: flags=%x\n", pa, pv->pv_flags); while (pv) { - printf("pv_entry %x pmap %x va %x next %x\n", + printf("pv_entry %p pmap %p va %x next %p\n", pv, pv->pv_pmap, pv->pv_va, pv->pv_next); pv = pv->pv_next; } @@ -1017,6 +1022,8 @@ pv_changepte(head, set_bits, clear_bits) for (pv = head; pv != NULL; pv = pv->pv_next) { pmap = pv->pv_pmap; va = pv->pv_va; + sme = SEGINV; /* kill warning */ + #ifdef DIAGNOSTIC /* * Only the head may have a null pmap, and @@ -1117,6 +1124,8 @@ pv_syncflags(head) for (pv = head; pv != NULL; pv = pv->pv_next) { pmap = pv->pv_pmap; va = pv->pv_va; + sme = SEGINV; /* kill warning */ + #ifdef DIAGNOSTIC /* * Only the head may have a null pmap, and @@ -1244,7 +1253,7 @@ pv_link(pmap, pa, va, flags) #ifdef PMAP_DEBUG if ((pmap_debug & PMD_LINK) || (va == pmap_db_watchva)) { - printf("pv_link(%x, %x, %x, %x)\n", pmap, pa, va, flags); + printf("pv_link(%p, %x, %x, %x)\n", pmap, pa, va, flags); /* pv_print(pa); */ } #endif @@ -1323,7 +1332,7 @@ pv_unlink(pmap, pa, va) if ((pmap_debug & PMD_UNLINK) || (va == pmap_db_watchva)) { - printf("pv_unlink(%x, %x, %x)\n", pmap, pa, va); + printf("pv_unlink(%p, %x, %x)\n", pmap, pa, va); } #endif head = pa_to_pvp(pa); @@ -1444,7 +1453,6 @@ pmap_common_init(pmap) void pmap_bootstrap() { - extern void vm_set_page_size(); /* * Reserve a segment for the kernel to use to access a pmeg @@ -1558,7 +1566,7 @@ int pmap_page_index(pa) vm_offset_t pa; { - u_long idx; + int idx; #ifdef DIAGNOSTIC if (pa < avail_start || pa >= avail_end) @@ -1570,7 +1578,8 @@ pmap_page_index(pa) } #endif - return (sun3_btop(pa)); + idx = sun3_btop(pa); + return (idx); } @@ -1682,7 +1691,7 @@ pmap_destroy(pmap) #ifdef PMAP_DEBUG if (pmap_debug & PMD_CREATE) - printf("pmap_destroy(%x)\n", pmap); + printf("pmap_destroy(%p)\n", pmap); #endif if (pmap == kernel_pmap) panic("pmap_destroy: kernel_pmap!"); @@ -1757,7 +1766,6 @@ pmap_remove_range_mmu(pmap, sva, eva) pmap_t pmap; vm_offset_t sva, eva; { - int old_ctx, i; pmeg_t pmegp; vm_offset_t va; int pte, sme; @@ -1766,7 +1774,7 @@ pmap_remove_range_mmu(pmap, sva, eva) #ifdef PMAP_DEBUG if ((pmap_debug & PMD_REMOVE) || ((sva <= pmap_db_watchva && eva > pmap_db_watchva))) - printf("pmap_remove_range_mmu(%x, %x, %x)\n", pmap, sva, eva); + printf("pmap_remove_range_mmu(%p, %x, %x)\n", pmap, sva, eva); #endif /* Interrupt level handled by caller. */ @@ -1841,7 +1849,7 @@ pmap_remove_range_mmu(pmap, sva, eva) } #ifdef PMAP_DEBUG if ((pmap_debug & PMD_SETPTE) || (va == pmap_db_watchva)) { - printf("pmap: set_pte pmap=%x va=%x old=%x new=%x (rrmmu)\n", + printf("pmap: set_pte pmap=%p va=%x old=%x new=%x (rrmmu)\n", pmap, va, pte, PG_INVAL); } #endif @@ -1855,7 +1863,7 @@ pmap_remove_range_mmu(pmap, sva, eva) if (is_pmeg_wired(pmegp)) { #ifdef PMAP_DEBUG if (pmap_debug & PMD_WIRING) { - printf("pmap: removing wired pmeg: 0x%x\n", pmegp); + printf("pmap: removing wired pmeg: %p\n", pmegp); Debugger(); /* XXX */ } #endif /* PMAP_DEBUG */ @@ -1894,7 +1902,7 @@ pmap_remove_range_noctx(pmap, sva, eva) #ifdef PMAP_DEBUG if ((pmap_debug & PMD_REMOVE) || ((sva <= pmap_db_watchva && eva > pmap_db_watchva))) - printf("pmap_remove_range_noctx(%x, %x, %x)\n", pmap, sva, eva); + printf("pmap_remove_range_noctx(%p, %x, %x)\n", pmap, sva, eva); #endif /* Interrupt level handled by caller. */ @@ -1922,7 +1930,7 @@ pmap_remove_range_noctx(pmap, sva, eva) } #ifdef PMAP_DEBUG if ((pmap_debug & PMD_SETPTE) || (va == pmap_db_watchva)) { - printf("pmap: set_pte pmap=%x va=%x old=%x new=%x (rrncx)\n", + printf("pmap: set_pte pmap=%p va=%x old=%x new=%x (rrncx)\n", pmap, va, pte, PG_INVAL); } #endif @@ -1947,7 +1955,7 @@ pmap_remove_range(pmap, sva, eva) pmap_t pmap; vm_offset_t sva, eva; { - int c, s, sme; + int s, sme; int old_ctx; boolean_t in_ctx; @@ -2054,8 +2062,7 @@ pmap_enter_kernel(va, pa, prot, wired, new_pte) boolean_t wired; int new_pte; { - int s, i, c; - int sme, old_pte; + int s, sme, old_pte; int nflags, do_pv; vm_offset_t seg_va; pmeg_t pmegp; @@ -2112,12 +2119,13 @@ pmap_enter_kernel(va, pa, prot, wired, new_pte) set_segmap_allctx(va, sme); #ifdef PMAP_DEBUG if (pmap_debug & PMD_SEGMAP) { - printf("pmap: set_segmap pmap=%x va=%x sme=%x (ek1)\n", + printf("pmap: set_segmap pmap=%p va=%x sme=%x (ek1)\n", kernel_pmap, seg_va, sme); } pmeg_verify_empty(sun3_trunc_seg(va)); #endif /* There are no existing mappings to deal with. */ + old_pte = 0; goto add_pte; } @@ -2190,7 +2198,7 @@ pmap_enter_kernel(va, pa, prot, wired, new_pte) } #ifdef PMAP_DEBUG if ((pmap_debug & PMD_SETPTE) || (va == pmap_db_watchva)) { - printf("pmap: set_pte pmap=%x va=%x old=%x new=%x (ek)\n", + printf("pmap: set_pte pmap=%p va=%x old=%x new=%x (ek)\n", kernel_pmap, va, old_pte, new_pte); } #endif @@ -2228,7 +2236,7 @@ pmap_enter_user(pmap, va, pa, prot, wired, new_pte) */ if (wired && (pmap_debug & PMD_WIRING)) { printf("pmap_enter_user: attempt to wire user page, ignored\n"); - printf("pmap=0x%x va=0x%x pa=0x%x\n", pmap, va, pa); + printf("pmap=%p va=0x%x pa=0x%x\n", pmap, va, pa); } #endif #ifdef DIAGNOSTIC @@ -2289,12 +2297,13 @@ pmap_enter_user(pmap, va, pa, prot, wired, new_pte) set_segmap(va, sme); #ifdef PMAP_DEBUG if (pmap_debug & PMD_SEGMAP) { - printf("pmap: set_segmap pmap=%x va=%x sme=%x (eu1)\n", + printf("pmap: set_segmap pmap=%p va=%x sme=%x (eu1)\n", pmap, seg_va, sme); } pmeg_verify_empty(seg_va); #endif /* There are no existing mappings to deal with. */ + old_pte = 0; goto add_pte; } @@ -2318,7 +2327,7 @@ pmap_enter_user(pmap, va, pa, prot, wired, new_pte) set_segmap(va, sme); #ifdef PMAP_DEBUG if (pmap_debug & PMD_SEGMAP) { - printf("pmap: set_segmap pmap=%x va=%x sme=%x (eu2)\n", + printf("pmap: set_segmap pmap=%p va=%x sme=%x (eu2)\n", pmap, seg_va, sme); } #endif @@ -2386,7 +2395,7 @@ pmap_enter_user(pmap, va, pa, prot, wired, new_pte) } #ifdef PMAP_DEBUG if ((pmap_debug & PMD_SETPTE) || (va == pmap_db_watchva)) { - printf("pmap: set_pte pmap=%x va=%x old=%x new=%x (eu)\n", + printf("pmap: set_pte pmap=%p va=%x old=%x new=%x (eu)\n", pmap, va, old_pte, new_pte); } #endif @@ -2431,7 +2440,7 @@ pmap_enter(pmap, va, pa, prot, wired) #ifdef PMAP_DEBUG if ((pmap_debug & PMD_ENTER) || (va == pmap_db_watchva)) - printf("pmap_enter(%x, %x, %x, %x, %x)\n", + printf("pmap_enter(%p, %x, %x, %x, %x)\n", pmap, va, pa, prot, wired); #endif @@ -2478,7 +2487,7 @@ int pmap_fault_reload(pmap, va, ftype) vm_offset_t va; vm_prot_t ftype; { - int rv, s, pte, chkpte, sme, segnum, ctx; + int rv, s, pte, chkpte, sme, ctx; vm_offset_t seg_va; pmeg_t pmegp; @@ -2529,7 +2538,7 @@ int pmap_fault_reload(pmap, va, ftype) rv = 1; } } - + PMAP_UNLOCK(); return (0); } @@ -2628,7 +2637,7 @@ pmap_activate(pmap, pcbp) context_allocate(pmap); #ifdef PMAP_DEBUG if (pmap_debug & PMD_SWITCH) - printf("pmap_activate(%x) takes context %d\n", + printf("pmap_activate(%p) takes context %d\n", pmap, pmap->pm_ctxnum); #endif } @@ -2637,7 +2646,7 @@ pmap_activate(pmap, pcbp) if (pmap_debug & PMD_SWITCH) { int old_ctx = get_context(); if (old_ctx != pmap->pm_ctxnum) { - printf("pmap_activate(%x) old_ctx=%d new_ctx=%d\n", + printf("pmap_activate(%p) old_ctx=%d new_ctx=%d\n", pmap, old_ctx, pmap->pm_ctxnum); } } @@ -2653,7 +2662,7 @@ pmap_deactivate(pmap, pcbp) { #ifdef PMAP_DEBUG if (pmap_debug & PMD_SWITCH) - printf("pmap_deactivate(%x, %x)\n", pmap, pcbp); + printf("pmap_deactivate(%p, %p)\n", pmap, pcbp); #endif /* Nothing to do really, and not called anyway... */ } @@ -2679,7 +2688,7 @@ pmap_change_wiring(pmap, va, wired) return; #ifdef PMAP_DEBUG if (pmap_debug & PMD_WIRING) - printf("pmap_change_wiring(pmap=0x%x, va=0x%x, wire=%d)\n", + printf("pmap_change_wiring(pmap=%p, va=0x%x, wire=%d)\n", pmap, va, wired); #endif /* @@ -2829,11 +2838,9 @@ pmap_protect_range_mmu(pmap, sva, eva) pmap_t pmap; vm_offset_t sva, eva; { - int old_ctx, i; pmeg_t pmegp; vm_offset_t va; int pte, sme; - int nflags; int flush_by_page = 0; /* Interrupt level handled by caller. */ @@ -2923,7 +2930,6 @@ pmap_protect_range_noctx(pmap, sva, eva) int pte, sme, ptenum, segnum; vm_offset_t va; pmeg_t pmegp; - int nflags; /* Interrupt level handled by caller. */ CHECK_SPL(); @@ -2964,7 +2970,7 @@ pmap_protect_range(pmap, sva, eva) pmap_t pmap; vm_offset_t sva, eva; { - int c, s, sme; + int s, sme; int old_ctx; boolean_t in_ctx; @@ -2973,7 +2979,7 @@ pmap_protect_range(pmap, sva, eva) #ifdef PMAP_DEBUG if ((pmap_debug & PMD_PROTECT) || ((sva <= pmap_db_watchva && eva > pmap_db_watchva))) - printf("pmap_protect_range(%x, %x, %x)\n", pmap, sva, eva); + printf("pmap_protect_range(%p, %x, %x)\n", pmap, sva, eva); #endif #ifdef DIAGNOSTIC if (sun3_trunc_seg(sva) != sun3_trunc_seg(eva-NBPG)) @@ -3034,7 +3040,7 @@ pmap_protect(pmap, sva, eva, prot) #ifdef PMAP_DEBUG if (pmap_debug & PMD_PROTECT) - printf("pmap_protect(%x, %x, %x, %x)\n", pmap, sva, eva, prot); + printf("pmap_protect(%p, %x, %x, %x)\n", pmap, sva, eva, prot); #endif if (pmap == NULL) @@ -3225,11 +3231,10 @@ pmap_prefer(fo, va) * Copy the kernel segmap into the passed buffer (256 bytes). */ void -pmap_get_ksegmap(vaddr) - vm_offset_t vaddr; +pmap_get_ksegmap(cp) + u_char *cp; { vm_offset_t va; - u_char *cp = (u_char*)vaddr; va = KERNBASE; do { @@ -3244,15 +3249,13 @@ pmap_get_ksegmap(vaddr) * starting at OFF in the pagemap RAM. */ void -pmap_get_pagemap(vaddr, off) - vm_offset_t vaddr; +pmap_get_pagemap(pt, off) + int *pt; int off; { vm_offset_t va, va_end; int sme, sme_end; /* SegMap Entry numbers */ - int *pt; - pt = (int*)vaddr; /* destination */ sme = (off >> 6); /* PMEG to start on */ sme_end = sme + 128; /* where to stop */ va_end = temp_seg_va + NBSG; diff --git a/sys/arch/sun3/sun3/sun3_startup.c b/sys/arch/sun3/sun3/sun3_startup.c index 08cd20db1c2..e689176c781 100644 --- a/sys/arch/sun3/sun3/sun3_startup.c +++ b/sys/arch/sun3/sun3/sun3_startup.c @@ -1,4 +1,4 @@ -/* $NetBSD: sun3_startup.c,v 1.55 1996/11/20 18:57:38 gwr Exp $ */ +/* $NetBSD: sun3_startup.c,v 1.56 1996/12/17 21:11:39 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -46,8 +46,8 @@ #include <vm/vm.h> #include <machine/control.h> -#include <machine/cpufunc.h> #include <machine/cpu.h> +#include <machine/db_machdep.h> #include <machine/dvma.h> #include <machine/mon.h> #include <machine/pte.h> @@ -58,6 +58,7 @@ #include "vector.h" #include "interreg.h" +#include "machdep.h" /* This is defined in locore.s */ extern char kernel_text[]; @@ -66,10 +67,12 @@ extern char kernel_text[]; extern char etext[], edata[], end[]; char *esym; /* DDB */ + /* - * Globals shared with the pmap code. - * XXX - should reexamine this... - */ + * Globals shared between pmap.c and sun3_startup.c (sigh). + * For simplicity, this interface retains the variables + * that were used in the old interface (without NONCONTIG). + */ vm_offset_t virtual_avail, virtual_end; vm_offset_t avail_start, avail_end; /* used to skip the Sun3/50 video RAM */ @@ -79,7 +82,8 @@ int cache_size; /* * Now our own stuff. */ -unsigned int *old_vector_table; +int cold = 1; +void **old_vector_table; unsigned char cpu_machine_id = 0; char *cpu_string = NULL; @@ -92,7 +96,6 @@ int msgbufmapped = 0; struct msgbuf *msgbufp = NULL; extern vm_offset_t tmp_vpages[]; extern int physmem; -unsigned char *interrupt_reg; vm_offset_t proc0_user_pa; struct user *proc0paddr; /* proc[0] pcb address (u-area VA) */ @@ -101,25 +104,27 @@ extern struct pcb *curpcb; extern vm_offset_t dumppage_pa; extern vm_offset_t dumppage_va; -/* - * Switch to our own interrupt vector table. - */ -static void initialize_vector_table() -{ - old_vector_table = getvbr(); - setvbr((unsigned int *) vector_table); -} +void sun3_bootstrap __P((struct exec)); + +static void sun3_mon_init __P((vm_offset_t sva, vm_offset_t eva, int keep)); +static void sun3_monitor_hooks __P((void)); +static void sun3_save_symtab __P((struct exec *kehp)); +static void sun3_verify_hardware __P((void)); +static void sun3_vm_init __P((struct exec *kehp)); +static void tracedump __P((int)); +static void v_handler __P((int addr, char *str)); -vm_offset_t high_segment_alloc(npages) + +vm_offset_t +high_segment_alloc(npages) int npages; { - int i; vm_offset_t va, tmp; - + if (npages == 0) mon_panic("panic: request for high segment allocation of 0 pages"); if (high_segment_free_start == high_segment_free_end) return NULL; - + va = high_segment_free_start + (npages*NBPG); if (va > high_segment_free_end) return NULL; tmp = high_segment_free_start; @@ -130,7 +135,8 @@ vm_offset_t high_segment_alloc(npages) /* * Prepare for running the PROM monitor */ -static void sun3_mode_monitor() +static void +sun3_mode_monitor __P((void)) { /* Install PROM vector table and enable NMI clock. */ /* XXX - Disable watchdog action? */ @@ -142,11 +148,12 @@ static void sun3_mode_monitor() /* * Prepare for running the kernel */ -static void sun3_mode_normal() +static void +sun3_mode_normal __P((void)) { /* Install our vector table and disable the NMI clock. */ set_clk_mode(0, IREG_CLOCK_ENAB_7, 0); - setvbr((unsigned int *) vector_table); + setvbr((void**)vector_table); set_clk_mode(IREG_CLOCK_ENAB_5, 0, 1); } @@ -173,7 +180,7 @@ void sun3_mon_abort() * stuff it into the PROM interrupt vector for trap zero * and then do a trap. Needs PROM vector table in RAM. */ - old_vector_table[32] = (int)romp->abortEntry; + old_vector_table[32] = (void*) romp->abortEntry; asm(" trap #0 ; _sun3_mon_continued: nop"); /* We have continued from a PROM abort! */ @@ -208,9 +215,10 @@ void sun3_mon_reboot(bootstring) * is identically mapped in all contexts. The PROM can * do the job using hardware-dependent tricks... */ -void sun3_context_equiv() +void +sun3_context_equiv __P((void)) { - unsigned int i, sme; + unsigned int sme; int x; vm_offset_t va; @@ -235,15 +243,15 @@ void sun3_context_equiv() static void sun3_mon_init(sva, eva, keep) -vm_offset_t sva, eva; -int keep; /* true: steal, false: clear */ + vm_offset_t sva, eva; + int keep; /* true: steal, false: clear */ { vm_offset_t pgva, endseg; int pte, valid; unsigned char sme; - + sva &= ~(NBSG-1); - + while (sva < eva) { sme = get_segmap(sva); if (sme != SEGINV) { @@ -273,6 +281,7 @@ int keep; /* true: steal, false: clear */ /* * Preserve DDB symbols and strings by setting esym. */ +static void sun3_save_symtab(kehp) struct exec *kehp; /* kernel exec header */ { @@ -347,10 +356,11 @@ sun3_save_symtab(kehp) * between [ KERNBASE .. virtual_avail ] and this is * checked in trap.c for kernel-mode MMU faults. */ -void sun3_vm_init(kehp) +static void +sun3_vm_init(kehp) struct exec *kehp; /* kernel exec header */ { - vm_offset_t va, eva, sva, pte, temp_seg; + vm_offset_t va, eva, pte; unsigned int sme; /* @@ -489,7 +499,7 @@ void sun3_vm_init(kehp) * segmap entries in the MMU unless pmeg_array records them. */ va = virtual_avail; - while (va < virtual_end) { + while (va < virtual_end) { set_segmap(va, SEGINV); va += NBSG; } @@ -607,7 +617,8 @@ void sun3_vm_init(kehp) */ int delay_divisor = 82; /* assume the fastest (3/260) */ -void sun3_verify_hardware() +static void +sun3_verify_hardware() { unsigned char machtype; int cpu_match = 0; @@ -686,8 +697,9 @@ struct funcall_frame { int fr_arg[1]; }; /*VARARGS0*/ +static void tracedump(x1) - caddr_t x1; + int x1; { struct funcall_frame *fp = (struct funcall_frame *)(&x1 - 2); u_int stackpage = ((u_int)fp) & ~PGOFSET; @@ -711,12 +723,12 @@ tracedump(x1) * For now we just implement the old "g0" and "g4" * commands and a printf hack. [lifted from freed cmu mach3 sun3 port] */ -void +static void v_handler(addr, str) -int addr; -char *str; + int addr; + char *str; { - + switch (*str) { case '\0': /* @@ -729,36 +741,36 @@ char *str; sun3_mode_normal(); panic("zero"); /*NOTREACHED*/ - + case 4: /* old g4 */ - tracedump(); - break; - + goto do_trace; + default: goto err; } break; - + case 'p': /* 'p'rint string command */ case 'P': mon_printf("%s\n", (char *)addr); break; - + case '%': /* p'%'int anything a la printf */ mon_printf(str, addr); mon_printf("\n"); break; - + + do_trace: case 't': /* 't'race kernel stack */ case 'T': - tracedump(); + tracedump(addr); break; - + case 'u': /* d'u'mp hack ('d' look like hex) */ case 'U': goto err; break; - + default: err: mon_printf("Don't understand 0x%x '%s'\n", addr, str); @@ -774,7 +786,8 @@ char *str; * argv[1] = options (i.e. "-ds" or NULL) * argv[2] = NULL */ -void sun3_monitor_hooks() +static void +sun3_monitor_hooks() { MachMonBootParam *bpp; char **argp; @@ -825,21 +838,6 @@ void sun3_monitor_hooks() } /* - * Find mappings for devices that are needed before autoconfiguration. - * First the obio module finds and records useful PROM mappings, then - * the necessary drivers are given a chance to use those recorded. - */ -void internal_configure() -{ - obio_init(); /* find and record PROM mappings in OBIO space */ - /* Drivers that use those OBIO mappings from the PROM */ - zs_init(); - eeprom_init(); - intreg_init(); - clock_init(); -} - -/* * This is called from locore.s just after the kernel is remapped * to its proper address, but before the call to main(). */ @@ -847,13 +845,11 @@ void sun3_bootstrap(keh) struct exec keh; /* kernel exec header */ { - int i; - extern int cold; /* First, Clear BSS. */ bzero(edata, end - edata); - cold = 1; + /* cold = 1; (now at compile time) */ sun3_monitor_hooks(); /* set v_handler, get boothowto */ @@ -863,15 +859,18 @@ sun3_bootstrap(keh) pmap_bootstrap(); /* bootstrap pmap module */ - internal_configure(); /* stuff that can't wait for configure() */ + obio_init(); /* stuff that can't wait for configure() */ /* - * Point interrupts/exceptions to our table. - * This is done after internal_configure/isr_init finds + * Point interrupts/exceptions to our vector table. + * (Until now, we use the one setup by the PROM.) + * + * This is done after obio_init() / intreg_init() finds * the interrupt register and disables the NMI clock so * it will not cause "spurrious level 7" complaints. */ - initialize_vector_table(); + old_vector_table = getvbr(); + setvbr((void **)vector_table); /* Interrupts are enabled in locore.s just after this return. */ } diff --git a/sys/arch/sun3/sun3/swapgeneric.c b/sys/arch/sun3/sun3/swapgeneric.c index c1f373ec184..0ede3626a82 100644 --- a/sys/arch/sun3/sun3/swapgeneric.c +++ b/sys/arch/sun3/sun3/swapgeneric.c @@ -1,9 +1,12 @@ -/* $NetBSD: swapgeneric.c,v 1.14 1995/04/26 23:30:08 gwr Exp $ */ +/* $NetBSD: swapgeneric.c,v 1.19 1996/12/17 21:11:41 gwr Exp $ */ -/* - * Copyright (c) 1994 Gordon W. Ross +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -12,22 +15,25 @@ * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * 4. All advertising materials mentioning features or use of this software + * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by Gordon W. Ross + * 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * 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. */ /* @@ -44,11 +50,20 @@ #include <sys/systm.h> #include <sys/reboot.h> +#include <dev/cons.h> + #include <machine/mon.h> - +#include "machdep.h" + +static int net_mkunit __P((int ctlr, int unit)); +static int sd_mkunit __P((int ctlr, int unit)); +static int xx_mkunit __P((int ctlr, int unit)); +static struct genconf * gc_lookup __P((char *)); + + #ifdef NFSCLIENT -extern char *nfsbootdevname; /* nfs_boot.c */ -#else /* NFSCLIENT */ +extern char *nfsbootdevname; /* nfs_boot.c */ +#endif /* NFSCLIENT */ int (*mountroot) __P((void)) = NULL; @@ -66,14 +81,16 @@ char boot_ifname[NAMESZ]; /* * Functions to convert PROM ctlr/unit into our unit numbers */ -static int net_mkunit(ctlr, unit) +static int +net_mkunit(ctlr, unit) int ctlr, unit; { /* XXX - Not sure which is set. */ return (ctlr + unit); } -static int sd_mkunit(ctlr, unit) +static int +sd_mkunit(ctlr, unit) int ctlr, unit; { int target, lun; @@ -84,7 +101,8 @@ static int sd_mkunit(ctlr, unit) return (target * 2 + lun); } -static int xx_mkunit(ctlr, unit) +static int +xx_mkunit(ctlr, unit) int ctlr, unit; { return (ctlr * 2 + unit); @@ -97,14 +115,14 @@ static int xx_mkunit(ctlr, unit) static struct genconf { char gc_name[4]; int gc_major; - int (*gc_mkunit)(); + int (*gc_mkunit) __P((int, int)); } genconf[] = { - { "ie", -1, net_mkunit }, - { "le", -1, net_mkunit }, - { "sd", 7, sd_mkunit }, - { "xy", 3, xx_mkunit }, - { "xd", 10, xx_mkunit }, - { 0 }, + { {"ie"}, -1, net_mkunit }, + { {"le"}, -1, net_mkunit }, + { {"sd"}, 7, sd_mkunit }, + { {"xy"}, 3, xx_mkunit }, + { {"xd"}, 10, xx_mkunit }, + { {0}, 0, 0 }, }; static struct genconf * @@ -123,7 +141,8 @@ gc_lookup(name) return NULL; } -static void gc_print_all() +static void +gc_print_all __P((void)) { struct genconf *gc; @@ -137,7 +156,7 @@ static void gc_print_all() } printf("\n"); } - + struct devspec { int major; @@ -146,11 +165,20 @@ struct devspec { char name[4]; }; +static int ds_parse __P((struct devspec *, char *)); +static int ds_tostr __P((struct devspec *, char *)); +static void ds_from_boot __P((struct devspec *)); +static void ds_query __P((struct devspec *, char *)); +static dev_t ds_todev __P((struct devspec *)); +static void gets __P((char *cp)); + + /* * Set devspec from a string like: "sd0a" * Return length of recognized part. */ -static int ds_parse(ds, str) +static int +ds_parse(ds, str) struct devspec *ds; char *str; { @@ -194,11 +222,11 @@ static int ds_parse(ds, str) * Format a devspec into a string like: "sd0a" * Returns length of string. */ -static int ds_tostr(ds, str) +static int +ds_tostr(ds, str) struct devspec *ds; char *str; { - struct genconf *gc; int unit, part; char *p; @@ -230,7 +258,8 @@ static int ds_tostr(ds, str) * Set the devspec to the device we booted from. * (Just converts PROM boot parameters.) */ -static void ds_from_boot(ds) +static void +ds_from_boot(ds) struct devspec *ds; { MachMonBootParam *bpp; @@ -262,14 +291,13 @@ static void ds_from_boot(ds) * Fill in the devspec by asking the operator. * The ds passed may hold a default value. */ -static void ds_query(ds, what) +static void +ds_query(ds, what) struct devspec *ds; char *what; { - struct genconf *gc; - char *p; - int len, minor; char buf[64]; + int len; for (;;) { len = ds_tostr(ds, buf); @@ -288,7 +316,8 @@ static void ds_query(ds, what) } } -static dev_t ds_todev(ds) +static dev_t +ds_todev(ds) struct devspec *ds; { int minor; @@ -302,11 +331,9 @@ static dev_t ds_todev(ds) * Choose the root and swap device, either by asking, * (if RB_ASKNAME) or from the PROM boot parameters. */ +void swapgeneric() { - struct genconf *gc; - dev_t root, swap, dump; - int minor; struct devspec ds; char buf[NAMESZ]; @@ -365,6 +392,7 @@ swapgeneric() } /* XXX - Isn't this in some common file? */ +static void gets(cp) char *cp; { diff --git a/sys/arch/sun3/sun3/sys_machdep.c b/sys/arch/sun3/sun3/sys_machdep.c index 23a3ea0c7db..3881d412af8 100644 --- a/sys/arch/sun3/sun3/sys_machdep.c +++ b/sys/arch/sun3/sun3/sys_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_machdep.c,v 1.3 1995/10/27 15:58:23 gwr Exp $ */ +/* $NetBSD: sys_machdep.c,v 1.4 1996/12/17 21:11:41 gwr Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -47,10 +47,11 @@ #include <sys/buf.h> #include <sys/trace.h> #include <sys/mount.h> +#include <sys/syscallargs.h> #include <vm/vm.h> - -#include <sys/syscallargs.h> +#include <machine/cpu.h> +#include "machdep.h" #ifdef TRACE int nvualarm; @@ -110,8 +111,6 @@ vdoualarm(arg) } #endif -#include <machine/cpu.h> -#include "cache.h" /* XXX should be in an include file somewhere */ #define CC_PURGE 1 @@ -121,6 +120,7 @@ vdoualarm(arg) /* XXX end should be */ /*ARGSUSED1*/ +int cachectl(req, addr, len) int req; caddr_t addr; @@ -157,9 +157,10 @@ sys_sysarch(p, v, retval) register_t *retval; { struct sys_sysarch_args /* { - syscallarg(int) op; + syscallarg(int) op; syscallarg(char *) parms; } */ *uap = v; + (void)uap->op; /* kill warning */ return ENOSYS; } diff --git a/sys/arch/sun3/sun3/vector.c b/sys/arch/sun3/sun3/vector.c index d074cc1747b..d0eeb43edc7 100644 --- a/sys/arch/sun3/sun3/vector.c +++ b/sys/arch/sun3/sun3/vector.c @@ -1,4 +1,4 @@ -/* $NetBSD: vector.c,v 1.15 1996/11/20 18:57:40 gwr Exp $ */ +/* $NetBSD: vector.c,v 1.16 1996/12/17 21:11:43 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -50,12 +50,6 @@ badtrap, badtrap, badtrap, badtrap, \ badtrap, badtrap, badtrap, badtrap -void addrerr(), badtrap(), buserr(), chkinst(), coperr(), fmterr(), - fpfline(), fpunsupp(), illinst(), privinst(), trace(), trap0(), - trap1(), trap12(), trap15(), trap2(), trapvinst(), zerodiv(), fpfault(); - -void _isr_autovec(); - #define fpbsun fpfault #define fpdz fpfault #define fpinex fpfault @@ -64,7 +58,7 @@ void _isr_autovec(); #define fpsnan fpfault #define fpunfl fpfault -void (*vector_table[NVECTORS])() = { +void *vector_table[NVECTORS] = { (void*)0xfffe000, /* 0: NOT USED (reset SP) */ (void*)0xfef0000, /* 1: NOT USED (reset PC) */ buserr, /* 2: bus error */ diff --git a/sys/arch/sun3/sun3/vector.h b/sys/arch/sun3/sun3/vector.h index b8e83c4bf31..32f9bf76604 100644 --- a/sys/arch/sun3/sun3/vector.h +++ b/sys/arch/sun3/sun3/vector.h @@ -1,4 +1,4 @@ -/* $NetBSD: vector.h,v 1.10 1996/11/20 18:57:40 gwr Exp $ */ +/* $NetBSD: vector.h,v 1.11 1996/12/17 21:11:44 gwr Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -40,4 +40,26 @@ #define AUTOVEC_BASE 0x18 -extern void (*vector_table[])(); +extern void *vector_table[]; + +void _isr_autovec __P((void)); + +void addrerr __P((void)); +void badtrap __P((void)); +void buserr __P((void)); +void chkinst __P((void)); +void coperr __P((void)); +void fmterr __P((void)); +void fpfline __P((void)); +void fpunsupp __P((void)); +void illinst __P((void)); +void privinst __P((void)); +void trace __P((void)); +void trap0 __P((void)); +void trap1 __P((void)); +void trap12 __P((void)); +void trap15 __P((void)); +void trap2 __P((void)); +void trapvinst __P((void)); +void zerodiv __P((void)); +void fpfault __P((void)); diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index b6d2fcbdc2f..fa3af3b6ebf 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -1,8 +1,8 @@ -/* $NetBSD: vm_machdep.c,v 1.35 1996/04/26 18:38:06 gwr Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.36 1996/12/17 21:11:45 gwr Exp $ */ /* * Copyright (c) 1994, 1995 Gordon W. Ross - * Copyright (c) 1993 Adam Glass + * Copyright (c) 1993 Adam Glass * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -62,10 +62,12 @@ #include <machine/pte.h> #include <machine/pmap.h> -#include "cache.h" +#include "machdep.h" extern int fpu_type; +extern void proc_do_uret __P((void)); +extern void proc_trampoline __P((void)); /* * Finish a fork operation, with process p2 nearly set up. @@ -77,25 +79,26 @@ void cpu_fork(p1, p2) register struct proc *p1, *p2; { - register struct pcb *pcb2 = &p2->p_addr->u_pcb; + register struct pcb *p1pcb = &p1->p_addr->u_pcb; + register struct pcb *p2pcb = &p2->p_addr->u_pcb; register struct trapframe *p2tf; register struct switchframe *p2sf; - extern void proc_do_uret(), child_return(); /* * Before copying the PCB from the current process, * make sure it is up-to-date. (p1 == curproc) */ - savectx(curproc->p_addr); + if (p1 == curproc) + savectx(p1pcb); /* copy over the machdep part of struct proc */ p2->p_md.md_flags = p1->p_md.md_flags; /* Copy pcb from proc p1 to p2. */ - bcopy(&p1->p_addr->u_pcb, pcb2, sizeof(*pcb2)); + bcopy(p1pcb, p2pcb, sizeof(*p2pcb)); /* Child can start with low IPL (XXX - right?) */ - pcb2->pcb_ps = PSL_LOWIPL; + p2pcb->pcb_ps = PSL_LOWIPL; /* * Our cpu_switch MUST always call PMAP_ACTIVATE on a @@ -109,9 +112,9 @@ cpu_fork(p1, p2) * copy trapframe from parent so return to user mode * will be to right address, with correct registers. * Leave one word unused at the end of the kernel stack - * so the system stack pointer stays within its stack. + * so the system stack pointer stays within the page. */ - p2tf = (struct trapframe *)((char*)p2->p_addr + USPACE-4) - 1; + p2tf = (struct trapframe *)((char*)p2pcb + USPACE-4) - 1; p2->p_md.md_regs = (int *)p2tf; bcopy(p1->p_md.md_regs, p2tf, sizeof(*p2tf)); @@ -121,7 +124,7 @@ cpu_fork(p1, p2) */ p2sf = (struct switchframe *)p2tf - 1; p2sf->sf_pc = (u_int)proc_do_uret; - pcb2->pcb_regs[11] = (int)p2sf; /* SSP */ + p2pcb->pcb_regs[11] = (int)p2sf; /* SSP */ /* * This will "push a call" to an arbitrary kernel function @@ -158,8 +161,6 @@ cpu_set_kpc(proc, func) void (*func)(struct proc *); { struct pcb *pcbp; - struct switchframe *sf; - extern void proc_trampoline(); struct ksigframe { struct switchframe sf; void (*func)(struct proc *); @@ -215,6 +216,19 @@ cpu_swapout(p) } /* + * Do any additional state-restoration after swapin. + */ +void +cpu_swapin(p) + register struct proc *p; +{ + + /* + * XXX - Just for debugging... (later). + */ +} + +/* * Dump the machine specific segment at the start of a core dump. * This means the CPU and FPU registers. The format used here is * the same one ptrace uses, so gdb can be machine independent. @@ -235,7 +249,6 @@ cpu_coredump(p, vp, cred, chdr) struct md_core md_core; struct coreseg cseg; int error; - register i; /* XXX: Make sure savectx() was done? */ |