diff options
Diffstat (limited to 'sys')
31 files changed, 789 insertions, 998 deletions
diff --git a/sys/arch/sparc/conf/FLOPPY b/sys/arch/sparc/conf/FLOPPY index 75ab76c8c03..e609c89a6fb 100644 --- a/sys/arch/sparc/conf/FLOPPY +++ b/sys/arch/sparc/conf/FLOPPY @@ -1,4 +1,4 @@ -# $OpenBSD: FLOPPY,v 1.15 1997/06/23 19:05:41 kstailey Exp $ +# $OpenBSD: FLOPPY,v 1.16 1997/09/17 06:47:02 downsj Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -108,8 +108,8 @@ obio0 at mainbus0 # sun4 and sun4m iommu0 at mainbus0 # sun4m sbus0 at iommu0 # sun4m -#audio0 at mainbus0 # sun4c -#audio0 at obio0 # sun4m +#audioamd0 at mainbus0 # sun4c +#audioamd0 at obio0 # sun4m auxreg0 at mainbus0 # sun4c auxreg0 at obio0 # sun4m diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index 2d272b9b719..0fb4c192b85 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,5 +1,5 @@ -# $OpenBSD: GENERIC,v 1.18 1997/08/08 08:47:10 downsj Exp $ -# $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ +# $OpenBSD: GENERIC,v 1.19 1997/09/17 06:47:03 downsj Exp $ +# $NetBSD: GENERIC,v 1.48 1997/08/23 19:19:01 mjacob Exp $ # Machine architecture; required by config(8) machine sparc @@ -40,9 +40,9 @@ vmel0 at mainbus0 # sun4 iommu0 at mainbus0 # sun4m sbus0 at iommu0 # sun4m -audio0 at mainbus0 # sun4c -audio0 at obio0 # sun4m -audio0 at sbus0 slot ? offset ? # sun4m +audioamd0 at mainbus0 # sun4c +audioamd0 at obio0 # sun4m +audioamd0 at sbus0 slot ? offset ? # sun4m auxreg0 at mainbus0 # sun4c auxreg0 at obio0 # sun4m diff --git a/sys/arch/sparc/conf/GENERIC_SCSI3 b/sys/arch/sparc/conf/GENERIC_SCSI3 index c49a44ffed8..9454ab0850a 100644 --- a/sys/arch/sparc/conf/GENERIC_SCSI3 +++ b/sys/arch/sparc/conf/GENERIC_SCSI3 @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC_SCSI3,v 1.16 1997/08/08 08:47:11 downsj Exp $ +# $OpenBSD: GENERIC_SCSI3,v 1.17 1997/09/17 06:47:03 downsj Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -40,9 +40,9 @@ vmel0 at mainbus0 # sun4 iommu0 at mainbus0 # sun4m sbus0 at iommu0 # sun4m -audio0 at mainbus0 # sun4c -audio0 at obio0 # sun4m -audio0 at sbus0 slot ? offset ? # sun4m +audioamd0 at mainbus0 # sun4c +audioamd0 at obio0 # sun4m +audioamd0 at sbus0 slot ? offset ? # sun4m auxreg0 at mainbus0 # sun4c auxreg0 at obio0 # sun4m diff --git a/sys/arch/sparc/conf/RAMDISK b/sys/arch/sparc/conf/RAMDISK index c963e874815..3b0b8b23519 100644 --- a/sys/arch/sparc/conf/RAMDISK +++ b/sys/arch/sparc/conf/RAMDISK @@ -63,8 +63,8 @@ vmel0 at mainbus0 # sun4 iommu0 at mainbus0 # sun4m sbus0 at iommu0 # sun4m -audio0 at mainbus0 # sun4c -audio0 at obio0 # sun4m +audioamd0 at mainbus0 # sun4c +audioamd0 at obio0 # sun4m auxreg0 at mainbus0 # sun4c auxreg0 at obio0 # sun4m diff --git a/sys/arch/sparc/conf/SUN4C b/sys/arch/sparc/conf/SUN4C index 7b0cfb65285..ee1e5d80873 100644 --- a/sys/arch/sparc/conf/SUN4C +++ b/sys/arch/sparc/conf/SUN4C @@ -61,7 +61,7 @@ sbus0 at mainbus0 #vmes0 at mainbus0 #vmel0 at mainbus0 -audio0 at mainbus0 +audioamd0 at mainbus0 auxreg0 at mainbus0 clock0 at mainbus0 #clock0 at obio0 addr 0xf2000000 diff --git a/sys/arch/sparc/conf/SUN4M b/sys/arch/sparc/conf/SUN4M index 8957f6e6c15..2a8dbea1aa3 100644 --- a/sys/arch/sparc/conf/SUN4M +++ b/sys/arch/sparc/conf/SUN4M @@ -1,4 +1,4 @@ -# $OpenBSD: SUN4M,v 1.14 1997/08/08 09:56:05 downsj Exp $ +# $OpenBSD: SUN4M,v 1.15 1997/09/17 06:47:04 downsj Exp $ # $NetBSD: GENERIC,v 1.28.2.1 1996/07/02 23:55:22 jtc Exp $ # Machine architecture; required by config(8) @@ -32,8 +32,8 @@ obio0 at mainbus0 # sun4 and sun4m iommu0 at mainbus0 # sun4m sbus0 at iommu0 # sun4m -audio0 at obio0 # sun4m -audio0 at sbus0 slot ? offset ? # sun4m +audioamd0 at obio0 # sun4m +audioamd0 at sbus0 slot ? offset ? # sun4m auxreg0 at obio0 # sun4m diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index a2a926edeeb..dc6105a328a 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,5 +1,5 @@ -# $OpenBSD: files.sparc,v 1.13 1997/08/25 08:38:43 downsj Exp $ -# $NetBSD: files.sparc,v 1.40 1997/07/07 21:53:43 pk Exp $ +# $OpenBSD: files.sparc,v 1.14 1997/09/17 06:47:05 downsj Exp $ +# $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 # sparc-specific configuration info @@ -101,8 +101,8 @@ device esp: scsi, ncr53c9x attach esp at sbus, dma, obio file arch/sparc/dev/esp.c esp -device audio -attach audio at mainbus, obio, sbus +device audioamd: audio +attach audioamd at mainbus, obio, sbus file arch/sparc/dev/amd7930.c audio file arch/sparc/sparc/amd7930intr.s audio @@ -211,7 +211,7 @@ file arch/sparc/sparc/conf.c file arch/sparc/sparc/emul.c file arch/sparc/sparc/in_cksum.c file arch/sparc/sparc/intr.c -file arch/sparc/sparc/kgdb_stub.c +file arch/sparc/sparc/kgdb_machdep.c kgdb # sparc/sparc/locore.s is handled specially in the makefile, # because it must come first in the "ld" command line. file arch/sparc/sparc/locore2.c @@ -230,7 +230,7 @@ file arch/sparc/sparc/disksubr.c file kludge_for_in_proto.c hy needs-flag -file arch/sparc/sparc/db_interface.c ddb +file arch/sparc/sparc/db_interface.c ddb | kgdb file arch/sparc/sparc/db_trace.c ddb file arch/sparc/sparc/db_disasm.c ddb diff --git a/sys/arch/sparc/dev/amd7930.c b/sys/arch/sparc/dev/amd7930.c index 998e89f5d1f..f884efed46d 100644 --- a/sys/arch/sparc/dev/amd7930.c +++ b/sys/arch/sparc/dev/amd7930.c @@ -1,5 +1,5 @@ -/* $OpenBSD: amd7930.c,v 1.9 1997/08/08 08:24:37 downsj Exp $ */ -/* $NetBSD: amd7930.c,v 1.10 1996/03/31 22:38:29 pk Exp $ */ +/* $OpenBSD: amd7930.c,v 1.10 1997/09/17 06:47:06 downsj Exp $ */ +/* $NetBSD: amd7930.c,v 1.30 1997/08/27 22:42:23 augustss Exp $ */ /* * Copyright (c) 1995 Rolf Grossmann @@ -50,6 +50,8 @@ #include <dev/ic/am7930reg.h> #include <sparc/dev/amd7930var.h> +#define AUDIO_ROM_NAME "audio" + #ifdef AUDIO_DEBUG extern void Dprintf __P((const char *, ...)); @@ -84,16 +86,25 @@ struct amd7930_softc { /* sc_au is special in that the hardware interrupt handler uses it */ struct auio sc_au; /* recv and xmit buffers, etc */ -#define sc_intrcnt sc_au.au_intrcnt +#define sc_intrcnt sc_au.au_intrcnt /* statistics */ }; /* interrupt interfaces */ #ifdef AUDIO_C_HANDLER int amd7930hwintr __P((void *)); +#if defined(SUN4M) +#define AUDIO_SET_SWINTR do { \ + if (CPU_ISSUN4M) \ + raise(0, 4); \ + else \ + ienab_bis(IE_L4); \ +} while(0); +#else #define AUDIO_SET_SWINTR ienab_bis(IE_L4) +#endif /* defined(SUN4M) */ #else struct auio *auiop; -#endif +#endif /* AUDIO_C_HANDLER */ int amd7930swintr __P((void *)); /* forward declarations */ @@ -104,18 +115,18 @@ static void init_amd __P((volatile struct amd7930 *)); void amd7930attach __P((struct device *, struct device *, void *)); int amd7930match __P((struct device *, void *, void *)); -struct cfattach audio_ca = { +struct cfattach audioamd_ca = { sizeof(struct amd7930_softc), amd7930match, amd7930attach }; -struct cfdriver audio_cd = { - NULL, "audio", DV_DULL +struct cfdriver audioamd_cd = { + NULL, "audioamd", DV_DULL }; struct audio_device amd7930_device = { "amd7930", "x", - "audio" + "audioamd" }; /* Write 16 bits of data from variable v to the data port of the audio chip */ @@ -130,7 +141,7 @@ struct audio_device amd7930_device = { * -18 to 0dB in .16dB steps then 0 to 12dB in .08dB steps. */ static const u_short gx_coeff[256] = { - 0x9008, 0x8b7c, 0x8b51, 0x8b45, 0x8b42, 0x8b3b, 0x8b36, 0x8b33, + 0x9008, 0x8e7c, 0x8e51, 0x8e45, 0x8d42, 0x8d3b, 0x8c36, 0x8c33, 0x8b32, 0x8b2a, 0x8b2b, 0x8b2c, 0x8b25, 0x8b23, 0x8b22, 0x8b22, 0x9122, 0x8b1a, 0x8aa3, 0x8aa3, 0x8b1c, 0x8aa6, 0x912d, 0x912b, 0x8aab, 0x8b12, 0x8aaa, 0x8ab2, 0x9132, 0x8ab4, 0x913c, 0x8abb, @@ -274,13 +285,12 @@ amd7930match(parent, vcf, aux) struct device *parent; void *vcf, *aux; { - struct cfdata *cf = vcf; register struct confargs *ca = aux; register struct romaux *ra = &ca->ca_ra; if (CPU_ISSUN4) return (0); - return (strcmp(cf->cf_driver->cd_name, ra->ra_name) == 0); + return (strcmp(AUDIO_ROM_NAME, ra->ra_name) == 0); } /* @@ -366,9 +376,9 @@ amd7930_open(dev, flags) DPRINTF(("sa_open: unit %d\n",unit)); - if (unit >= audio_cd.cd_ndevs) + if (unit >= audioamd_cd.cd_ndevs) return (ENODEV); - if ((sc = audio_cd.cd_devs[unit]) == NULL) + if ((sc = audioamd_cd.cd_devs[unit]) == NULL) return (ENXIO); if (sc->sc_open) return (EBUSY); @@ -904,7 +914,7 @@ amd7930hwintr(au0) } } - (*au->au_intrcnt)++; + *(au->au_intrcnt)++; return (1); } #endif /* AUDIO_C_HANDLER */ diff --git a/sys/arch/sparc/dev/amd7930var.h b/sys/arch/sparc/dev/amd7930var.h index 8e6cf85e529..d397b51433a 100644 --- a/sys/arch/sparc/dev/amd7930var.h +++ b/sys/arch/sparc/dev/amd7930var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amd7930var.h,v 1.3 1997/08/08 08:24:38 downsj Exp $ */ +/* $OpenBSD: amd7930var.h,v 1.4 1997/09/17 06:47:07 downsj Exp $ */ /* $NetBSD: amd7930var.h,v 1.3 1996/02/01 22:32:25 mycroft Exp $ */ /* diff --git a/sys/arch/sparc/dev/cgsix.c b/sys/arch/sparc/dev/cgsix.c index f7cf868f8bb..38d5d8a0eef 100644 --- a/sys/arch/sparc/dev/cgsix.c +++ b/sys/arch/sparc/dev/cgsix.c @@ -1,5 +1,5 @@ -/* $OpenBSD: cgsix.c,v 1.8 1997/08/08 08:24:51 downsj Exp $ */ -/* $NetBSD: cgsix.c,v 1.32 1997/07/29 09:58:04 fair Exp $ */ +/* $OpenBSD: cgsix.c,v 1.9 1997/09/17 06:47:07 downsj Exp $ */ +/* $NetBSD: cgsix.c,v 1.33 1997/08/07 19:12:30 pk Exp $ */ /* * Copyright (c) 1993 @@ -142,8 +142,12 @@ static struct fbdriver cg6_fbdriver = { /* * Unlike the bw2 and cg3 drivers, we do not need to provide an rconsole - * interface, as the cg6 is fast enough. + * interface, as the cg6 is fast enough.. but provide a knob to turn it + * on anyway. */ +#ifdef RASTERCONSOLE +int cgsix_use_rasterconsole = 0; +#endif extern int fbnode; @@ -324,9 +328,12 @@ cgsixattach(parent, self, args) if (isconsole) { printf(" (console)\n"); #ifdef RASTERCONSOLE - sc->sc_fb.fb_pixels = (caddr_t) - mapiodev(ca->ca_ra.ra_reg, O(cg6_ram[0]), ramsize); - fbrcons_init(&sc->sc_fb); + if (cgsix_use_rasterconsole) { + sc->sc_fb.fb_pixels = (caddr_t) + mapiodev(ca->ca_ra.ra_reg, + O(cg6_ram[0]), ramsize); + fbrcons_init(&sc->sc_fb); + } #endif } else printf("\n"); diff --git a/sys/arch/sparc/dev/dma.c b/sys/arch/sparc/dev/dma.c index c01200a20c1..ecd8b077f5e 100644 --- a/sys/arch/sparc/dev/dma.c +++ b/sys/arch/sparc/dev/dma.c @@ -1,5 +1,5 @@ -/* $OpenBSD: dma.c,v 1.8 1997/08/08 08:24:57 downsj Exp $ */ -/* $NetBSD: dma.c,v 1.45 1997/07/29 09:58:06 fair Exp $ */ +/* $OpenBSD: dma.c,v 1.9 1997/09/17 06:47:08 downsj Exp $ */ +/* $NetBSD: dma.c,v 1.46 1997/08/27 11:24:16 bouyer Exp $ */ /* * Copyright (c) 1994 Paul Kranenburg. All rights reserved. diff --git a/sys/arch/sparc/dev/esp.c b/sys/arch/sparc/dev/esp.c index 48c211f8ea2..34e91117133 100644 --- a/sys/arch/sparc/dev/esp.c +++ b/sys/arch/sparc/dev/esp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: esp.c,v 1.10 1997/08/08 08:25:00 downsj Exp $ */ -/* $NetBSD: esp.c,v 1.68 1997/07/19 21:57:01 pk Exp $ */ +/* $OpenBSD: esp.c,v 1.11 1997/09/17 06:47:08 downsj Exp $ */ +/* $NetBSD: esp.c,v 1.69 1997/08/27 11:24:18 bouyer Exp $ */ /* * Copyright (c) 1997 Jason R. Thorpe. diff --git a/sys/arch/sparc/dev/if_le.c b/sys/arch/sparc/dev/if_le.c index b0bf63e56e6..e2842f36bad 100644 --- a/sys/arch/sparc/dev/if_le.c +++ b/sys/arch/sparc/dev/if_le.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_le.c,v 1.7 1997/08/08 08:25:12 downsj Exp $ */ -/* $NetBSD: if_le.c,v 1.49 1997/07/07 16:28:44 pk Exp $ */ +/* $OpenBSD: if_le.c,v 1.8 1997/09/17 06:47:09 downsj Exp $ */ +/* $NetBSD: if_le.c,v 1.50 1997/09/09 20:54:48 pk Exp $ */ /*- * Copyright (c) 1997 Jason R. Thorpe. All rights reserved. @@ -102,9 +102,19 @@ myleintr(arg) void *arg; { register struct le_softc *lesc = arg; +static int dodrain=0; - if (lesc->sc_dma->sc_regs->csr & D_ERR_PEND) + if (lesc->sc_dma->sc_regs->csr & D_ERR_PEND) { + dodrain = 1; return ledmaintr(lesc->sc_dma); + } + + if (dodrain) { /* XXX - is this necessary with D_DSBL_WRINVAL on? */ +#define E_DRAIN 0x400 /* XXX: fix dmareg.h */ + int i = 10; + while (i-- > 0 && (lesc->sc_dma->sc_regs->csr & D_DRAINING)) + delay(1); + } return (am7990_intr(arg)); } @@ -277,6 +287,9 @@ lehwreset(sc) DMA_RESET(lesc->sc_dma); lesc->sc_dma->sc_regs->en_bar = lesc->sc_laddr & 0xff000000; DMA_ENINTR(lesc->sc_dma); +#define D_DSBL_WRINVAL D_DSBL_SCSI_DRN /* XXX: fix dmareg.h */ + /* Disable E-cache invalidates on chip writes */ + lesc->sc_dma->sc_regs->csr |= D_DSBL_WRINVAL; } #endif } diff --git a/sys/arch/sparc/dev/isp_sbus.c b/sys/arch/sparc/dev/isp_sbus.c index 24fcb5caec2..a2d846f7b94 100644 --- a/sys/arch/sparc/dev/isp_sbus.c +++ b/sys/arch/sparc/dev/isp_sbus.c @@ -1,5 +1,5 @@ -/* $OpenBSD: isp_sbus.c,v 1.1 1997/08/08 08:25:15 downsj Exp $ */ -/* $NetBSD: isp_sbus.c,v 1.6 1997/06/08 06:35:45 thorpej Exp $ */ +/* $OpenBSD: isp_sbus.c,v 1.2 1997/09/17 06:47:10 downsj Exp $ */ +/* $NetBSD: isp_sbus.c,v 1.8 1997/08/27 11:24:19 bouyer Exp $ */ /* * SBus specific probe and attach routines for Qlogic ISP SCSI adapters. @@ -57,9 +57,9 @@ static u_int16_t isp_sbus_rd_reg __P((struct ispsoftc *, int)); static void isp_sbus_wr_reg __P((struct ispsoftc *, int, u_int16_t)); static int isp_sbus_mbxdma __P((struct ispsoftc *)); -static int isp_sbus_dmasetup __P((struct ispsoftc *, struct scsi_xfer *, +static int isp_sbus_dmasetup __P((struct ispsoftc *, struct scsipi_xfer *, ispreq_t *, u_int8_t *, u_int8_t)); -static void isp_sbus_dmateardown __P((struct ispsoftc *, struct scsi_xfer *, +static void isp_sbus_dmateardown __P((struct ispsoftc *, struct scsipi_xfer *, u_int32_t)); static struct ispmdvec mdvec = { @@ -70,19 +70,23 @@ static struct ispmdvec mdvec = { isp_sbus_dmateardown, NULL, NULL, + NULL, ISP_RISC_CODE, ISP_CODE_LENGTH, ISP_CODE_ORG, + ISP_CODE_VERSION, + 0, 0 }; struct isp_sbussoftc { struct ispsoftc sbus_isp; + sdparam sbus_dev; struct intrhand sbus_ih; volatile u_char *sbus_reg; int sbus_node; int sbus_pri; - vm_offset_t sbus_kdma_allocs[RQUEST_QUEUE_LEN]; + vm_offset_t sbus_kdma_allocs[MAXISPREQUEST]; }; @@ -137,6 +141,9 @@ isp_sbus_attach(parent, self, aux) sbc->sbus_node = ca->ca_ra.ra_node; sbc->sbus_isp.isp_mdvec = &mdvec; + sbc->sbus_isp.isp_type = ISP_HA_SCSI_UNKNOWN; + sbc->sbus_isp.isp_param = &sbc->sbus_dev; + bzero(sbc->sbus_isp.isp_param, sizeof (sdparam)); isp_reset(&sbc->sbus_isp); if (sbc->sbus_isp.isp_state != ISP_RESETSTATE) { return; @@ -224,7 +231,7 @@ isp_sbus_mbxdma(isp) /* * Allocate and map the request queue. */ - len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN); + len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); isp->isp_rquest = (volatile caddr_t)malloc(len, M_DEVBUF, M_NOWAIT); if (isp->isp_rquest == 0) return (1); @@ -236,7 +243,7 @@ isp_sbus_mbxdma(isp) /* * Allocate and map the result queue. */ - len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN); + len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)); isp->isp_result = (volatile caddr_t)malloc(len, M_DEVBUF, M_NOWAIT); if (isp->isp_result == 0) return (1); @@ -266,11 +273,11 @@ isp_sbus_dmasetup(isp, xs, rq, iptrp, optr) if (xs->datalen == 0) { rq->req_seg_count = 1; - rq->req_flags |= REQFLAG_DATA_IN; return (0); } - if (rq->req_handle >= RQUEST_QUEUE_LEN) { + if (rq->req_handle > RQUEST_QUEUE_LEN(isp) || + rq->req_handle < 1) { panic("%s: bad handle (%d) in isp_sbus_dmasetup\n", isp->isp_name, rq->req_handle); /* NOTREACHED */ @@ -285,11 +292,11 @@ isp_sbus_dmasetup(isp, xs, rq, iptrp, optr) kdvma = (vm_offset_t) xs->data; } - if (sbc->sbus_kdma_allocs[rq->req_handle] != (vm_offset_t) 0) { + if (sbc->sbus_kdma_allocs[rq->req_handle - 1] != (vm_offset_t) 0) { panic("%s: kdma handle already allocated\n", isp->isp_name); /* NOTREACHED */ } - sbc->sbus_kdma_allocs[rq->req_handle] = kdvma; + sbc->sbus_kdma_allocs[rq->req_handle - 1] = kdvma; if (xs->flags & SCSI_DATA_IN) { rq->req_flags |= REQFLAG_DATA_IN; } else { @@ -314,7 +321,7 @@ isp_sbus_dmateardown(isp, xs, handle) cpuinfo.cache_flush(xs->data, xs->datalen - xs->resid); } - if (handle >= RQUEST_QUEUE_LEN) { + if (handle >= RQUEST_QUEUE_LEN(isp)) { panic("%s: bad handle (%d) in isp_sbus_dmateardown\n", isp->isp_name, handle); /* NOTREACHED */ diff --git a/sys/arch/sparc/dev/kbd.c b/sys/arch/sparc/dev/kbd.c index 9bf291e0a43..b1914a7b09b 100644 --- a/sys/arch/sparc/dev/kbd.c +++ b/sys/arch/sparc/dev/kbd.c @@ -1,5 +1,5 @@ -/* $OpenBSD: kbd.c,v 1.6 1997/08/08 08:25:16 downsj Exp $ */ -/* $NetBSD: kbd.c,v 1.27 1996/10/13 03:00:01 christos Exp $ */ +/* $OpenBSD: kbd.c,v 1.7 1997/09/17 06:47:10 downsj Exp $ */ +/* $NetBSD: kbd.c,v 1.28 1997/09/13 19:12:18 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -288,6 +288,18 @@ kbdattach(kbd) if (ttyoutput(KBD_CMD_RESET, tp) >= 0) panic("kbdattach"); (*tp->t_oproc)(tp); /* get it going */ + + /* + * Wait here for the keyboard initialization to complete + * since subsequent kernel console access (ie. cnget()) + * may cause the PROM to interfere with the device. + */ + if (tsleep((caddr_t)&kbd_softc.k_state, + PZERO | PCATCH, devopn, hz) != 0) { + /* no response */ + printf("kbd: reset failed\n"); + kbd_reset(&kbd_softc.k_state); + } } } @@ -296,11 +308,9 @@ kbd_reset(ks) register struct kbd_state *ks; { /* - * On first identification, wake up anyone waiting for type - * and set up the table pointers. + * On first identification, set up the table pointers. */ if (ks->kbd_unshifted == NULL) { - wakeup((caddr_t)ks); ks->kbd_unshifted = kbd_unshifted; ks->kbd_shifted = kbd_shifted; ks->kbd_cur = ks->kbd_unshifted; @@ -447,7 +457,8 @@ kbd_rint(c) /* Arrange to get keyboard layout as well */ (void)ttyoutput(KBD_CMD_GLAYOUT, k->k_kbd); (*k->k_kbd->t_oproc)(k->k_kbd); - } + } else + wakeup((caddr_t)&k->k_state); return; } @@ -455,6 +466,10 @@ kbd_rint(c) if (k->k_state.kbd_pending == KBD_LAYOUT) { k->k_state.kbd_pending = 0; k->k_state.kbd_layout = c; + /* + * Wake up anyone waiting for type. + */ + wakeup((caddr_t)&k->k_state); return; } diff --git a/sys/arch/sparc/dev/sbusreg.h b/sys/arch/sparc/dev/sbusreg.h index 3455f5eb366..25e630e4862 100644 --- a/sys/arch/sparc/dev/sbusreg.h +++ b/sys/arch/sparc/dev/sbusreg.h @@ -1,5 +1,5 @@ -/* $OpenBSD: sbusreg.h,v 1.2 1997/08/08 08:25:27 downsj Exp $ */ -/* $NetBSD: sbusreg.h,v 1.2 1994/11/20 20:52:26 deraadt Exp $ */ +/* $OpenBSD: sbusreg.h,v 1.3 1997/09/17 06:47:11 downsj Exp $ */ +/* $NetBSD: sbusreg.h,v 1.3 1997/09/14 19:17:25 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -60,3 +60,14 @@ #define SBUS_ABS(a) ((unsigned)(a) >= SBUS_BASE) #define SBUS_ABS_TO_SLOT(a) (((a) - SBUS_BASE) >> 25) #define SBUS_ABS_TO_OFFSET(a) (((a) - SBUS_BASE) & 0x1ffffff) + +struct sbusreg { + u_int32_t sbus_afsr; /* M-to-S Asynchronous Fault Status */ + u_int32_t sbus_afar; /* M-to-S Asynchronous Fault Address */ + u_int32_t sbus_arbiter; /* Arbiter Enable */ + u_int32_t sbus_reserved1; + +#define NSBUSCFG 20 + /* Actual number dependent on machine model */ + u_int32_t sbus_sbuscfg[NSBUSCFG]; /* Sbus configuration control */ +}; diff --git a/sys/arch/sparc/dev/si.c b/sys/arch/sparc/dev/si.c index a96caafb133..26238e8442d 100644 --- a/sys/arch/sparc/dev/si.c +++ b/sys/arch/sparc/dev/si.c @@ -1,5 +1,5 @@ -/* $OpenBSD: si.c,v 1.10 1997/08/08 08:25:29 downsj Exp $ */ -/* $NetBSD: si.c,v 1.37 1997/07/29 09:58:13 fair Exp $ */ +/* $OpenBSD: si.c,v 1.11 1997/09/17 06:47:11 downsj Exp $ */ +/* $NetBSD: si.c,v 1.38 1997/08/27 11:24:20 bouyer Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. diff --git a/sys/arch/sparc/dev/zs.c b/sys/arch/sparc/dev/zs.c index 2361c3ea61e..96e095c2854 100644 --- a/sys/arch/sparc/dev/zs.c +++ b/sys/arch/sparc/dev/zs.c @@ -1,5 +1,5 @@ -/* $OpenBSD: zs.c,v 1.16 1997/08/25 08:38:45 downsj Exp $ */ -/* $NetBSD: zs.c,v 1.48 1997/07/29 09:58:18 fair Exp $ */ +/* $OpenBSD: zs.c,v 1.17 1997/09/17 06:47:12 downsj Exp $ */ +/* $NetBSD: zs.c,v 1.49 1997/08/31 21:26:37 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -80,6 +80,7 @@ #include <sparc/dev/zsvar.h> #ifdef KGDB +#include <sys/kgdb.h> #include <machine/remote-sl.h> #endif @@ -171,7 +172,7 @@ static int zsrint __P((struct zs_chanstate *, volatile struct zschan *)); static int zsxint __P((struct zs_chanstate *, volatile struct zschan *)); static int zssint __P((struct zs_chanstate *, volatile struct zschan *)); -void zsabort __P((void)); +void zsabort __P((int)); static void zsoverrun __P((int, long *, char *)); static volatile struct zsdevice *zsaddr[NZS]; /* XXX, but saves work */ @@ -902,7 +903,7 @@ zsrint(cs, zc) else if (c == (KBD_L1|KBD_UP)) conk->conk_l1 = 0; /* L1 went up */ else if (c == KBD_A && conk->conk_l1) { - zsabort(); + zsabort(cs->cs_unit); conk->conk_l1 = 0; /* we never see the up */ goto clearit; /* eat the A after L1-A */ } @@ -1006,17 +1007,20 @@ zssint(cs, zc) while (zc->zc_csr & ZSRR0_BREAK) ZS_DELAY(); } - zsabort(); + zsabort(cs->cs_unit); return (0); } return (ZRING_MAKE(ZRING_SINT, rr0)); } void -zsabort() +zsabort(unit) + int unit; { -#ifdef DDB +#if defined(KGDB) + zskgdb(unit); +#elif defined(DDB) Debugger(); #else printf("stopping on keyboard abort\n"); diff --git a/sys/arch/sparc/include/db_machdep.h b/sys/arch/sparc/include/db_machdep.h index f47524d9e80..02bf55ac08a 100644 --- a/sys/arch/sparc/include/db_machdep.h +++ b/sys/arch/sparc/include/db_machdep.h @@ -1,5 +1,5 @@ -/* $OpenBSD: db_machdep.h,v 1.4 1997/08/08 08:26:13 downsj Exp $ */ -/* $NetBSD: db_machdep.h,v 1.9 1997/06/26 01:27:00 thorpej Exp $ */ +/* $OpenBSD: db_machdep.h,v 1.5 1997/09/17 06:47:13 downsj Exp $ */ +/* $NetBSD: db_machdep.h,v 1.10 1997/08/31 21:23:40 pk Exp $ */ /* * Mach Operating System @@ -47,20 +47,25 @@ typedef vm_offset_t db_addr_t; /* address - unsigned */ typedef long db_expr_t; /* expression - signed */ typedef struct { - struct trapframe ddb_tf; - struct frame ddb_fr; + struct trapframe db_tf; + struct frame db_fr; } db_regs_t; db_regs_t ddb_regs; /* register state */ #define DDB_REGS (&ddb_regs) -#define DDB_TF (&ddb_regs.ddb_tf) -#define DDB_FR (&ddb_regs.ddb_fr) +#define DDB_TF (&ddb_regs.db_tf) +#define DDB_FR (&ddb_regs.db_fr) #if defined(lint) -#define PC_REGS(regs) ((regs)->ddb_tf.tf_pc) +#define PC_REGS(regs) ((regs)->db_tf.tf_pc) #else -#define PC_REGS(regs) ((db_addr_t)(regs)->ddb_tf.tf_pc) +#define PC_REGS(regs) ((db_addr_t)(regs)->db_tf.tf_pc) #endif +#define PC_ADVANCE(regs) do { \ + int n = (regs)->db_tf.tf_npc; \ + (regs)->db_tf.tf_pc = n; \ + (regs)->db_tf.tf_npc = n + 4; \ +} while(0) #define BKPT_INST 0x91d02001 /* breakpoint instruction */ #define BKPT_SIZE (4) /* size of breakpoint inst */ @@ -69,7 +74,8 @@ db_regs_t ddb_regs; /* register state */ #define db_clear_single_step(regs) (void) (0) #define db_set_single_step(regs) (void) (0) -#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT) +#define IS_BREAKPOINT_TRAP(type, code) \ + ((type) == T_BREAKPOINT || (type) == T_KGDB_EXEC) #define IS_WATCHPOINT_TRAP(type, code) (0) #define inst_trap_return(ins) ((ins)&0) @@ -88,4 +94,12 @@ int kdb_trap __P((int, struct trapframe *)); */ #define DB_AOUT_SYMBOLS + +/* + * KGDB definitions + */ +typedef u_long kgdb_reg_t; +#define KGDB_NUMREGS 72 +#define KGDB_BUFLEN 1024 + #endif /* _SPARC_DB_MACHDEP_H_ */ diff --git a/sys/arch/sparc/include/pmap.h b/sys/arch/sparc/include/pmap.h index 8e66fd2e655..af3b5e420a9 100644 --- a/sys/arch/sparc/include/pmap.h +++ b/sys/arch/sparc/include/pmap.h @@ -1,5 +1,5 @@ -/* $OpenBSD: pmap.h,v 1.5 1997/08/08 08:26:38 downsj Exp $ */ -/* $NetBSD: pmap.h,v 1.29 1997/07/06 23:57:16 pk Exp $ */ +/* $OpenBSD: pmap.h,v 1.6 1997/09/17 06:47:14 downsj Exp $ */ +/* $NetBSD: pmap.h,v 1.30 1997/08/04 20:00:47 pk Exp $ */ /* * Copyright (c) 1996 @@ -279,9 +279,8 @@ void kvm_uncache __P((caddr_t, int)); struct user; void switchexit __P((vm_map_t, struct user *, int)); int mmu_pagein __P((struct pmap *pm, int, int)); -#ifdef DEBUG -int mmu_pagein4m __P((struct pmap *pm, int, int)); -#endif +void pmap_writetext __P((unsigned char *, int)); + /* SUN4/SUN4C SPECIFIC DECLARATIONS */ diff --git a/sys/arch/sparc/include/pte.h b/sys/arch/sparc/include/pte.h index 3a7fd59a127..fb834b38a48 100644 --- a/sys/arch/sparc/include/pte.h +++ b/sys/arch/sparc/include/pte.h @@ -1,5 +1,5 @@ -/* $OpenBSD: pte.h,v 1.3 1997/08/08 08:26:42 downsj Exp $ */ -/* $NetBSD: pte.h,v 1.18 1997/05/15 22:25:45 pk Exp $ */ +/* $OpenBSD: pte.h,v 1.4 1997/09/17 06:47:14 downsj Exp $ */ +/* $NetBSD: pte.h,v 1.19 1997/08/05 11:00:10 pk Exp $ */ /* * Copyright (c) 1996 @@ -240,7 +240,7 @@ extern int mmu_has_hole; #if defined(SUN4M) /* Optimization: sun4m, sun4c have same page */ #if defined(SUN4) /* size, so they're used interchangeably */ #define VA_VPG(va) (cputyp==CPU_SUN4 ? VA_SUN4_VPG(va) : VA_SUN4C_VPG(va)) -#define VA_OFF(VA) (cputyp==CPU_SUN4 ? VA_SUN4_OFF(va) : VA_SUN4C_OFF(va)) +#define VA_OFF(va) (cputyp==CPU_SUN4 ? VA_SUN4_OFF(va) : VA_SUN4C_OFF(va)) #else #define VA_VPG(va) VA_SUN4M_VPG(va) #define VA_OFF(va) VA_SUN4M_OFF(va) diff --git a/sys/arch/sparc/sparc/amd7930intr.s b/sys/arch/sparc/sparc/amd7930intr.s index 001695ab6cf..295b72184c4 100644 --- a/sys/arch/sparc/sparc/amd7930intr.s +++ b/sys/arch/sparc/sparc/amd7930intr.s @@ -1,3 +1,5 @@ +/* $OpenBSD: amd7930intr.s,v 1.3 1997/09/17 06:47:15 downsj Exp $ */ +/* $NetBSD: amd7930intr.s,v 1.10 1997/03/11 01:03:07 pk Exp $ */ /* * Copyright (c) 1995 Rolf Grossmann. * Copyright (c) 1992, 1993 @@ -45,9 +47,39 @@ #ifndef AUDIO_C_HANDLER #include "assym.h" +#include <machine/param.h> #include <sparc/sparc/intreg.h> -/* XXX this goes in a header file -- currently, it's hidden in locore.s */ -#define INTREG_ADDR 0xf8002000 +#include <machine/psl.h> + +#define AUDIO_SET_SWINTR_4C \ + sethi %hi(INTRREG_VA), %l5; \ + ldub [%l5 + %lo(INTRREG_VA)], %l6; \ + or %l6, IE_L4, %l6; \ + stb %l6, [%l5 + %lo(INTRREG_VA)] + +! raise(0,PIL_AUSOFT) ! NOTE: CPU#0 and PIL_AUSOFT=4 +#define AUDIO_SET_SWINTR_4M \ + sethi %hi(1 << (16 + 4)), %l5; \ + set ICR_PI_SET, %l6; \ + st %l5, [%l6] + +/* set software interrupt */ +#if (defined(SUN4) || defined(SUN4C)) && !defined(SUN4M) +#define AUDIO_SET_SWINTR AUDIO_SET_SWINTR_4C +#elif !(defined(SUN4) || defined(SUN4C)) && defined(SUN4M) +#define AUDIO_SET_SWINTR AUDIO_SET_SWINTR_4M +#else +#define AUDIO_SET_SWINTR \ + sethi %hi(_cputyp), %l5; \ + ld [%l5 + %lo(_cputyp)], %l5; \ + cmp %l5, CPU_SUN4M; \ + be 8f; \ + AUDIO_SET_SWINTR_4C; \ + ba,a 9f; \ +8: \ + AUDIO_SET_SWINTR_4M; \ +9: +#endif #define R_amd %l2 #define R_data %l3 @@ -100,10 +132,7 @@ _amd7930_trap: bne 1f ! if (d == e) st R_data, [%l7 + AU_RDATA] - sethi %hi(INTREG_ADDR), %l5 - ldub [%l5 + %lo(INTREG_ADDR)], %l6 - or %l6, IE_L4, %l6 - stb %l6, [%l5 + %lo(INTREG_ADDR)] ! set software interrupt + AUDIO_SET_SWINTR 1: ! write outgoing data @@ -124,10 +153,7 @@ _amd7930_trap: bne 2f ! if (d == e) st R_data, [%l7 + AU_PDATA] - sethi %hi(INTREG_ADDR), %l5 - ldub [%l5 + %lo(INTREG_ADDR)], %l6 - or %l6, IE_L4, %l6 - stb %l6, [%l5 + %lo(INTREG_ADDR)] ! set software interrupt + AUDIO_SET_SWINTR 2: /* diff --git a/sys/arch/sparc/sparc/cpu.c b/sys/arch/sparc/sparc/cpu.c index b2c26dd0cf9..7ffdabc862b 100644 --- a/sys/arch/sparc/sparc/cpu.c +++ b/sys/arch/sparc/sparc/cpu.c @@ -1,5 +1,5 @@ -/* $OpenBSD: cpu.c,v 1.8 1997/09/11 20:31:33 deraadt Exp $ */ -/* $NetBSD: cpu.c,v 1.52 1997/07/29 09:41:58 fair Exp $ */ +/* $OpenBSD: cpu.c,v 1.9 1997/09/17 06:47:16 downsj Exp $ */ +/* $NetBSD: cpu.c,v 1.56 1997/09/15 20:52:36 pk Exp $ */ /* * Copyright (c) 1996 @@ -302,8 +302,8 @@ cache_print(sc) ci->c_totalsize/1024, ci->c_linesize); } else { /* combined, virtual */ - printf(" %d byte write-%s, %d bytes/line, %cw flush ", - ci->c_totalsize, + printf(" %dK byte write-%s, %d bytes/line, %cw flush ", + ci->c_totalsize/1024, (ci->c_vactype == VAC_WRITETHROUGH) ? "through" : "back", ci->c_linesize, ci->c_hwflush ? 'h' : 's'); @@ -459,21 +459,21 @@ cpumatch_sun4(sc, mp, node) sc->classlvl = 100; sc->mmu_ncontext = 8; sc->mmu_nsegment = 256; -/*XXX*/ sc->hz = 0; +/*XXX*/ sc->hz = 14280000; break; case ID_SUN4_200: sc->cpu_type = CPUTYP_4_200; sc->classlvl = 200; sc->mmu_nsegment = 512; sc->mmu_ncontext = 16; -/*XXX*/ sc->hz = 0; +/*XXX*/ sc->hz = 16670000; break; case ID_SUN4_300: sc->cpu_type = CPUTYP_4_300; sc->classlvl = 300; sc->mmu_nsegment = 256; sc->mmu_ncontext = 16; -/*XXX*/ sc->hz = 0; +/*XXX*/ sc->hz = 25000000; break; case ID_SUN4_400: sc->cpu_type = CPUTYP_4_400; @@ -481,7 +481,7 @@ cpumatch_sun4(sc, mp, node) sc->mmu_nsegment = 1024; sc->mmu_ncontext = 64; sc->mmu_nregion = 256; -/*XXX*/ sc->hz = 0; +/*XXX*/ sc->hz = 33000000; sc->sun4_mmu3l = 1; break; } @@ -575,7 +575,7 @@ sun4_hotfix(sc) { if ((sc->flags & CPUFLG_SUN4CACHEBUG) != 0) { kvm_uncache((caddr_t)trapbase, 1); - printf("cache chip bug; trap page uncached "); + printf(": cache chip bug; trap page uncached"); } } @@ -713,7 +713,7 @@ struct module_info module_ms2 = { /* UNTESTED */ VAC_WRITETHROUGH, 0, getcacheinfo_obp, - 0, + 0, /* was swift_hotfix, */ 0, swift_cache_enable, 256, @@ -846,7 +846,7 @@ struct module_info module_hypersparc = { /* UNTESTED */ srmmu_vcache_flush_segment, srmmu_vcache_flush_region, srmmu_vcache_flush_context, - noop_pcache_flush_line + srmmu_pcache_flush_line }; void @@ -856,11 +856,13 @@ cpumatch_hypersparc(sc, mp, node) int node; { sc->cpu_type = CPUTYP_HS_MBUS;/*XXX*/ + printf("warning: hypersparc support still under construction\n"); } void hypersparc_mmu_enable() { +#if 0 int pcr; pcr = lda(SRMMU_PCR, ASI_SRMMU); @@ -868,6 +870,7 @@ hypersparc_mmu_enable() pcr &= ~HYPERSPARC_PCR_CE; sta(SRMMU_PCR, ASI_SRMMU, pcr); +#endif } /* Cypress 605 */ @@ -991,7 +994,8 @@ struct cpu_conf { { CPU_SUN4M, 1, 1, 1, 0xc, "CY7C601/605 (v.c)", &module_cypress }, { CPU_SUN4M, 1, 1, 1, 0xf, "CY7C601/605 (v.f)", &module_cypress }, { CPU_SUN4M, 1, 3, 1, ANY, "CY7C611", &module_cypress }, - { CPU_SUN4M, 1, 0xf, 1, 1, "RT620/625", &module_hypersparc }, + { CPU_SUN4M, 1, 0xe, 1, 7, "RT620/625", &module_hypersparc }, + { CPU_SUN4M, 1, 0xf, 1, 7, "RT620/625", &module_hypersparc }, { CPU_SUN4M, 4, 0, 0, ANY, "TMS390Z50 v0 or TMS390Z55", &module_viking }, { CPU_SUN4M, 4, 1, 0, ANY, "TMS390Z50 v1", &module_viking }, { CPU_SUN4M, 4, 1, 4, ANY, "TMS390S10", &module_ms1 }, @@ -1164,6 +1168,7 @@ static struct info fpu_types[] = { * Vendor 1, IU ROSS0/1 or Pinnacle. */ { 1, 0x1, 0xf, 0, "on-chip" }, /* Pinnacle */ + { 1, 0x1, 0xe, 0, "on-chip" }, /* Hypersparc RT 625/626 */ { 1, 0x1, ANY, 0, "L64812 or ACT8847" }, { 1, 0x1, ANY, 1, "L64814" }, { 1, 0x1, ANY, 2, "TMS390C602A" }, diff --git a/sys/arch/sparc/sparc/db_interface.c b/sys/arch/sparc/sparc/db_interface.c index 0414ca1af53..0138a0028e8 100644 --- a/sys/arch/sparc/sparc/db_interface.c +++ b/sys/arch/sparc/sparc/db_interface.c @@ -1,5 +1,5 @@ -/* $OpenBSD: db_interface.c,v 1.5 1997/08/08 08:27:12 downsj Exp $ */ -/* $NetBSD: db_interface.c,v 1.15 1997/02/05 00:01:50 pk Exp $ */ +/* $OpenBSD: db_interface.c,v 1.6 1997/09/17 06:47:17 downsj Exp $ */ +/* $NetBSD: db_interface.c,v 1.18 1997/09/01 00:16:31 pk Exp $ */ /* * Mach Operating System @@ -42,16 +42,73 @@ #include <dev/cons.h> #include <machine/db_machdep.h> + +#include <ddb/db_access.h> + +#if defined(DDB) #include <ddb/db_command.h> #include <ddb/db_sym.h> #include <ddb/db_variables.h> #include <ddb/db_extern.h> -#include <ddb/db_access.h> #include <ddb/db_output.h> +#endif + #include <machine/bsd_openprom.h> #include <machine/ctlreg.h> #include <sparc/sparc/asm.h> + +/* + * Read bytes from kernel address space for debugger. + */ +void +db_read_bytes(addr, size, data) + vm_offset_t addr; + register size_t size; + register char *data; +{ + register char *src; + + src = (char *)addr; + while (size-- > 0) + *data++ = *src++; +} + +/* + * Write bytes to kernel address space for debugger. + */ +void +db_write_bytes(addr, size, data) + vm_offset_t addr; + register size_t size; + register char *data; +{ + extern char etext[]; + register char *dst; + + dst = (char *)addr; + while (size-- > 0) { + if ((dst >= (char *)VM_MIN_KERNEL_ADDRESS) && (dst < etext)) + pmap_writetext(dst, *data); + else + *dst = *data; + dst++, data++; + } + +} + + +#if defined(DDB) + +/* + * Data and functions used by DDB only. + */ +void +Debugger() +{ + asm("ta 0x81"); +} + static int nil; struct db_variable db_regs[] = { @@ -102,7 +159,6 @@ int db_active = 0; extern char *trap_type[]; void kdb_kbd_trap __P((struct trapframe *)); -static void db_write_text __P((unsigned char *, int)); void db_prom_cmd __P((db_expr_t, int, db_expr_t, char *)); /* @@ -143,8 +199,8 @@ kdb_trap(type, tf) /* Should switch to kdb`s own stack here. */ - ddb_regs.ddb_tf = *tf; - ddb_regs.ddb_fr = *(struct frame *)tf->tf_out[6]; + ddb_regs.db_tf = *tf; + ddb_regs.db_fr = *(struct frame *)tf->tf_out[6]; db_active++; cnpollc(TRUE); @@ -152,132 +208,12 @@ kdb_trap(type, tf) cnpollc(FALSE); db_active--; - *(struct frame *)tf->tf_out[6] = ddb_regs.ddb_fr; - *tf = ddb_regs.ddb_tf; + *(struct frame *)tf->tf_out[6] = ddb_regs.db_fr; + *tf = ddb_regs.db_tf; return (1); } -/* - * Read bytes from kernel address space for debugger. - */ -void -db_read_bytes(addr, size, data) - vm_offset_t addr; - register size_t size; - register char *data; -{ - register char *src; - - src = (char *)addr; - while (size-- > 0) - *data++ = *src++; -} - - -/* - * XXX - stolen from pmap.c - */ -#if defined(SUN4M) -#define getpte4m(va) lda((va & 0xFFFFF000) | ASI_SRMMUFP_L3, \ - ASI_SRMMUFP) -void setpte4m __P((vm_offset_t va, int pte)); - -#endif -#define getpte4(va) lda(va, ASI_PTE) -#define setpte4(va, pte) sta(va, ASI_PTE, pte) -#if defined(SUN4M) && !(defined(SUN4C) || defined(SUN4)) -#define getpte getpte4m -#define setpte setpte4m -#elif defined(SUN4M) -#define getpte(va) (cputyp==CPU_SUN4M ? getpte4m(va) : getpte4(va)) -#define setpte(va, pte) (cputyp==CPU_SUN4M ? setpte4m(va, pte) \ - : setpte4(va,pte)) -#else -#define getpte getpte4 -#define setpte setpte4 -#endif - -#define splpmap() splimp() - -static void -db_write_text(dst, ch) - unsigned char *dst; - int ch; -{ - int s, pte0, pte; - vm_offset_t va; - - s = splpmap(); - va = (unsigned long)dst & (~PGOFSET); - pte0 = getpte(va); - -#if defined(SUN4M) -#if defined(SUN4) || defined(SUN4C) - if (cputyp == CPU_SUN4M) { -#endif - if ((pte0 & SRMMU_TETYPE) != SRMMU_TEPTE) { - db_printf(" address %p not a valid page\n", dst); - splx(s); - return; - } - - pte = pte0 | PPROT_WRITE; - setpte(va, pte); - -#if defined(SUN4) || defined(SUN4C) - } else { -#endif -#endif /* 4m */ -#if defined(SUN4) || defined(SUN4C) - if ((pte0 & PG_V) == 0) { - db_printf(" address %p not a valid page\n", dst); - splx(s); - return; - } - - pte = pte0 | PG_W; - setpte(va, pte); -#if defined(SUN4M) - } -#endif -#endif /* 4/4c */ - - *dst = (unsigned char)ch; - - setpte(va, pte0); - splx(s); -} - -/* - * Write bytes to kernel address space for debugger. - */ -void -db_write_bytes(addr, size, data) - vm_offset_t addr; - register size_t size; - register char *data; -{ - extern char etext[]; - register char *dst; - - dst = (char *)addr; - while (size-- > 0) { - if ((dst >= (char *)VM_MIN_KERNEL_ADDRESS) && (dst < etext)) - db_write_text(dst, *data); - else - *dst = *data; - dst++, data++; - } - -} - -void -Debugger() -{ - asm("ta 0x81"); -} - void db_prom_cmd(addr, have_addr, count, modif) db_expr_t addr; @@ -298,3 +234,4 @@ db_machine_init() { db_machine_commands_install(sparc_db_command_table); } +#endif /* DDB */ diff --git a/sys/arch/sparc/sparc/iommureg.h b/sys/arch/sparc/sparc/iommureg.h index 021e32f09e0..c1021afcc55 100644 --- a/sys/arch/sparc/sparc/iommureg.h +++ b/sys/arch/sparc/sparc/iommureg.h @@ -1,5 +1,5 @@ -/* $OpenBSD: iommureg.h,v 1.2 1997/08/08 08:27:22 downsj Exp $ */ -/* $NetBSD: iommureg.h,v 1.2 1996/05/16 15:57:18 abrown Exp $ */ +/* $OpenBSD: iommureg.h,v 1.3 1997/09/17 06:47:17 downsj Exp $ */ +/* $NetBSD: iommureg.h,v 1.3 1997/09/14 19:16:04 pk Exp $ */ /* * Copyright (c) 1996 @@ -43,17 +43,6 @@ struct iommureg { u_int32_t io_fill1[3]; u_int32_t io_flashclear; /* Flush all TLB entries */ u_int32_t io_flushpage; /* Flush page from TLB */ - u_int32_t io_fill2[0x1000-28]; - u_int32_t io_afsr; /* Asynchronous Fault Status */ - u_int32_t io_afar; /* Asynchronous Fault Address */ - u_int32_t io_sbuscfg0; /* Sbus configuration control */ - u_int32_t io_sbuscfg1; - u_int32_t io_sbuscfg2; - u_int32_t io_sbuscfg3; - u_int32_t io_mfsr; /* Memory Fault Status */ - u_int32_t io_mfar; /* Memory Fault Address */ - u_int32_t io_fill3[0x1000-32]; - u_int32_t io_mid; /* it might be mud */ }; #define IOMMU_CTL_IMPL 0xf0000000 diff --git a/sys/arch/sparc/sparc/kgdb_machdep.c b/sys/arch/sparc/sparc/kgdb_machdep.c new file mode 100644 index 00000000000..7491852fbdd --- /dev/null +++ b/sys/arch/sparc/sparc/kgdb_machdep.c @@ -0,0 +1,331 @@ +/* $NetBSD: kgdb_machdep.c,v 1.1 1997/08/31 21:22:45 pk Exp $ */ +/*- + * Copyright (c) 1997 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION 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. + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1995 + * The President and Fellows of Harvard College. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgements: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * This product includes software developed by Harvard University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)kgdb_stub.c 8.1 (Berkeley) 6/11/93 + */ + +/* + * Machine dependent routines needed by kern/kgdb_stub.c + */ +#ifdef KGDB + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/buf.h> +#include <sys/kgdb.h> + +#include <vm/vm.h> + +#include <machine/ctlreg.h> +#include <machine/psl.h> +#include <machine/reg.h> +#include <machine/trap.h> +#include <machine/cpu.h> + +#include <sparc/sparc/asm.h> + +#if defined(SUN4M) +#define getpte4m(va) \ + lda(((vm_offset_t)va & 0xFFFFF000) | ASI_SRMMUFP_L3, ASI_SRMMUFP) +void setpte4m __P((vm_offset_t, int)); +#endif + +#if defined(SUN4) || defined(SUN4C) +#define getpte4(va) lda(va, ASI_PTE) +#define setpte4(va, pte) sta(va, ASI_PTE, pte) +#endif + +static __inline void kgdb_copy __P((char *, char *, int)); +static __inline void kgdb_zero __P((char *, int)); + +/* + * This little routine exists simply so that bcopy() can be debugged. + */ +static __inline void +kgdb_copy(src, dst, len) + register char *src, *dst; + register int len; +{ + + while (--len >= 0) + *dst++ = *src++; +} + +/* ditto for bzero */ +static __inline void +kgdb_zero(ptr, len) + register char *ptr; + register int len; +{ + while (--len >= 0) + *ptr++ = (char) 0; +} + +/* + * Trap into kgdb to wait for debugger to connect, + * noting on the console why nothing else is going on. + */ +void +kgdb_connect(verbose) + int verbose; +{ + + if (kgdb_dev < 0) + return; + fb_unblank(); + if (verbose) + printf("kgdb waiting..."); + __asm("ta %0" :: "n" (T_KGDB_EXEC)); /* trap into kgdb */ + + kgdb_debug_panic = 1; +} + +/* + * Decide what to do on panic. + */ +void +kgdb_panic() +{ + + if (kgdb_dev >= 0 && kgdb_debug_panic) + kgdb_connect(kgdb_active == 0); +} + +/* + * Translate a trap number into a unix compatible signal value. + * (gdb only understands unix signal numbers). + * XXX should this be done at the other end? + */ +int +kgdb_signal(type) + int type; +{ + int sigval; + + switch (type) { + + case T_AST: + sigval = SIGINT; + break; + + case T_TEXTFAULT: + case T_DATAFAULT: + sigval = SIGSEGV; + break; + + case T_ALIGN: + sigval = SIGBUS; + break; + + case T_ILLINST: + case T_PRIVINST: + case T_DIV0: + sigval = SIGILL; + break; + + case T_FPE: + sigval = SIGFPE; + break; + + case T_BREAKPOINT: + sigval = SIGTRAP; + break; + + case T_KGDB_EXEC: + sigval = SIGIOT; + break; + + default: + sigval = SIGEMT; + break; + } + return (sigval); +} + +/* + * Definitions exported from gdb (& then made prettier). + */ +#define GDB_G0 0 +#define GDB_O0 8 +#define GDB_L0 16 +#define GDB_I0 24 +#define GDB_FP0 32 +#define GDB_Y 64 +#define GDB_PSR 65 +#define GDB_WIM 66 +#define GDB_TBR 67 +#define GDB_PC 68 +#define GDB_NPC 69 +#define GDB_FSR 70 +#define GDB_CSR 71 + +#define REGISTER_BYTES (KGDB_NUMREGS * 4) +#define REGISTER_BYTE(n) ((n) * 4) + +/* + * Translate the values stored in the kernel regs struct to the format + * understood by gdb. + */ +void +kgdb_getregs(regs, gdb_regs) + db_regs_t *regs; + kgdb_reg_t *gdb_regs; +{ + struct trapframe *tf = ®s->db_tf; + + /* %g0..%g7 and %o0..%o7: from trapframe */ + gdb_regs[0] = 0; + kgdb_copy((caddr_t)&tf->tf_global[1], (caddr_t)&gdb_regs[1], 15 * 4); + + /* %l0..%l7 and %i0..%i7: from stack */ + kgdb_copy((caddr_t)tf->tf_out[6], (caddr_t)&gdb_regs[GDB_L0], 16 * 4); + + /* %f0..%f31 -- fake, kernel does not use FP */ + kgdb_zero((caddr_t)&gdb_regs[GDB_FP0], 32 * 4); + + /* %y, %psr, %wim, %tbr, %pc, %npc, %fsr, %csr */ + gdb_regs[GDB_Y] = tf->tf_y; + gdb_regs[GDB_PSR] = tf->tf_psr; + gdb_regs[GDB_WIM] = tf->tf_global[0]; /* input only! */ + gdb_regs[GDB_TBR] = 0; /* fake */ + gdb_regs[GDB_PC] = tf->tf_pc; + gdb_regs[GDB_NPC] = tf->tf_npc; + gdb_regs[GDB_FSR] = 0; /* fake */ + gdb_regs[GDB_CSR] = 0; /* fake */ +} + +/* + * Reverse the above. + */ +void +kgdb_setregs(regs, gdb_regs) + db_regs_t *regs; + kgdb_reg_t *gdb_regs; +{ + struct trapframe *tf = ®s->db_tf; + + kgdb_copy((caddr_t)&gdb_regs[1], (caddr_t)&tf->tf_global[1], 15 * 4); + kgdb_copy((caddr_t)&gdb_regs[GDB_L0], (caddr_t)tf->tf_out[6], 16 * 4); + tf->tf_y = gdb_regs[GDB_Y]; + tf->tf_psr = gdb_regs[GDB_PSR]; + tf->tf_pc = gdb_regs[GDB_PC]; + tf->tf_npc = gdb_regs[GDB_NPC]; +} + +/* + * Determine if memory at [va..(va+len)] is valid. + */ +int +kgdb_acc(va, len) + vm_offset_t va; + size_t len; +{ + int pte; + vm_offset_t eva; + + eva = round_page(va + len); + va = trunc_page(va); + + /* XXX icky: valid address but causes timeout */ + if (va >= (vm_offset_t)0xfffff000) + return (0); + + for (; va < eva; va += NBPG) { +#if defined(SUN4M) + if (CPU_ISSUN4M) { + pte = getpte4m(va); + if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE) + return (0); + } +#endif +#if defined(SUN4) || defined(SUN4C) + if (CPU_ISSUN4C || CPU_ISSUN4) { + pte = getpte4(va); + if ((pte & PG_V) == 0) + return (0); + } +#endif + } + + return (1); +} +#endif diff --git a/sys/arch/sparc/sparc/kgdb_stub.c b/sys/arch/sparc/sparc/kgdb_stub.c deleted file mode 100644 index 15f3f2b9d35..00000000000 --- a/sys/arch/sparc/sparc/kgdb_stub.c +++ /dev/null @@ -1,682 +0,0 @@ -/* $OpenBSD: kgdb_stub.c,v 1.3 1997/08/08 08:27:24 downsj Exp $ */ -/* $NetBSD: kgdb_stub.c,v 1.10 1996/10/13 03:00:36 christos Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * Copyright (c) 1995 - * The President and Fellows of Harvard College. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgements: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * This product includes software developed by Harvard University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kgdb_stub.c 8.1 (Berkeley) 6/11/93 - */ - -/* - * "Stub" to allow remote cpu to debug over a serial line using gdb. - */ -#ifdef KGDB - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/buf.h> - -#include <vm/vm.h> - -#include <machine/ctlreg.h> -#include <machine/psl.h> -#include <machine/reg.h> -#include <machine/remote-sl.h> -#include <machine/trap.h> -#include <machine/cpu.h> -#include <machine/autoconf.h> -#include <machine/bsd_openprom.h> - -#include <sparc/sparc/asm.h> -#include <sparc/sparc/kgdb_proto.h> - -#ifndef KGDBDEV -#define KGDBDEV -1 -#endif -#ifndef KGDBRATE -#define KGDBRATE 38400 -#endif - -int kgdb_dev = KGDBDEV; /* remote debugging device (-1 if none) */ -int kgdb_rate = KGDBRATE; /* remote debugging baud rate */ -int kgdb_active = 0; /* remote debugging active if != 0 */ -int kgdb_debug_panic = 0; /* != 0 waits for remote on panic */ - -#if defined(SUN4M) -#define getpte4m(va) lda(((vm_offset_t)va & 0xFFFFF000) | \ - ASI_SRMMUFP_L3, ASI_SRMMUFP) -void setpte4m __P((vm_offset_t, int)); -#endif - -#define getpte4(va) lda(va, ASI_PTE) -#define setpte4(va, pte) sta(va, ASI_PTE, pte) - -void kgdb_copy __P((char *, char *, int)); -void kgdb_zero __P((char *, int)); -static void kgdb_send __P((u_int, u_char *, int)); -static int kgdb_recv __P((u_char *, int *)); -static int computeSignal __P((int)); -void regs_to_gdb __P((struct trapframe *, u_long *)); -void gdb_to_regs __P((struct trapframe *, u_long *)); -int kgdb_trap __P((int, struct trapframe *)); -int kgdb_acc __P((caddr_t, int, int, int)); -void kdb_mkwrite __P((caddr_t, int)); - -/* - * This little routine exists simply so that bcopy() can be debugged. - */ -void -kgdb_copy(src, dst, len) - register char *src, *dst; - register int len; -{ - - while (--len >= 0) - *dst++ = *src++; -} - -/* ditto for bzero */ -void -kgdb_zero(ptr, len) - register char *ptr; - register int len; -{ - while (--len >= 0) - *ptr++ = (char) 0; -} - -static int (*kgdb_getc) __P((void *)); -static void (*kgdb_putc) __P((void *, int)); -static void *kgdb_ioarg; - -#define GETC() ((*kgdb_getc)(kgdb_ioarg)) -#define PUTC(c) ((*kgdb_putc)(kgdb_ioarg, c)) -#define PUTESC(c) { \ - if (c == FRAME_END) { \ - PUTC(FRAME_ESCAPE); \ - c = TRANS_FRAME_END; \ - } else if (c == FRAME_ESCAPE) { \ - PUTC(FRAME_ESCAPE); \ - c = TRANS_FRAME_ESCAPE; \ - } else if (c == FRAME_START) { \ - PUTC(FRAME_ESCAPE); \ - c = TRANS_FRAME_START; \ - } \ - PUTC(c); \ -} - -void -kgdb_attach(getfn, putfn, ioarg) - int (*getfn) __P((void *)); - void (*putfn) __P((void *, int)); - void *ioarg; -{ - - kgdb_getc = getfn; - kgdb_putc = putfn; - kgdb_ioarg = ioarg; -} - -/* - * Send a message. The host gets one chance to read it. - */ -static void -kgdb_send(type, bp, len) - register u_int type; - register u_char *bp; - register int len; -{ - register u_char csum; - register u_char *ep = bp + len; - - PUTC(FRAME_START); - PUTESC(type); - - csum = type; - while (bp < ep) { - type = *bp++; - csum += type; - PUTESC(type); - } - csum = -csum; - PUTESC(csum); - PUTC(FRAME_END); -} - -static int -kgdb_recv(bp, lenp) - u_char *bp; - int *lenp; -{ - register u_char c, csum; - register int escape, len; - register int type; - -restart: - csum = len = escape = 0; - type = -1; - while (1) { - c = GETC(); - switch (c) { - - case FRAME_ESCAPE: - escape = 1; - continue; - - case TRANS_FRAME_ESCAPE: - if (escape) - c = FRAME_ESCAPE; - break; - - case TRANS_FRAME_END: - if (escape) - c = FRAME_END; - break; - - case TRANS_FRAME_START: - if (escape) - c = FRAME_START; - break; - - case FRAME_START: - goto restart; - - case FRAME_END: - if (type < 0 || --len < 0) { - csum = len = escape = 0; - type = -1; - continue; - } - if (csum != 0) - return (0); - *lenp = len; - return (type); - } - csum += c; - if (type < 0) { - type = c; - escape = 0; - continue; - } - if (++len > SL_RPCSIZE) { - while (GETC() != FRAME_END) - continue; - return (0); - } - *bp++ = c; - escape = 0; - } -} - -/* - * Translate a trap number into a unix compatible signal value. - * (gdb only understands unix signal numbers). - * XXX should this be done at the other end? - */ -static int -computeSignal(type) - int type; -{ - int sigval; - - switch (type) { - - case T_AST: - sigval = SIGINT; - break; - - case T_TEXTFAULT: - case T_DATAFAULT: - sigval = SIGSEGV; - break; - - case T_ALIGN: - sigval = SIGBUS; - break; - - case T_ILLINST: - case T_PRIVINST: - case T_DIV0: - sigval = SIGILL; - break; - - case T_FPE: - sigval = SIGFPE; - break; - - case T_BREAKPOINT: - sigval = SIGTRAP; - break; - - case T_KGDB_EXEC: - sigval = SIGIOT; - break; - - default: - sigval = SIGEMT; - break; - } - return (sigval); -} - -/* - * Trap into kgdb to wait for debugger to connect, - * noting on the console why nothing else is going on. - */ -void -kgdb_connect(verbose) - int verbose; -{ - - if (kgdb_dev < 0 || kgdb_getc == NULL) - return; - fb_unblank(); - if (verbose) - printf("kgdb waiting..."); - __asm("ta %0" :: "n" (T_KGDB_EXEC)); /* trap into kgdb */ -} - -/* - * Decide what to do on panic. - */ -void -kgdb_panic() -{ - - if (kgdb_dev >= 0 && kgdb_getc != NULL && - kgdb_active == 0 && kgdb_debug_panic) - kgdb_connect(1); -} - -/* - * Definitions exported from gdb (& then made prettier). - */ -#define GDB_G0 0 -#define GDB_O0 8 -#define GDB_L0 16 -#define GDB_I0 24 -#define GDB_FP0 32 -#define GDB_Y 64 -#define GDB_PSR 65 -#define GDB_WIM 66 -#define GDB_TBR 67 -#define GDB_PC 68 -#define GDB_NPC 69 -#define GDB_FSR 70 -#define GDB_CSR 71 - -#define NUM_REGS 72 - -#define REGISTER_BYTES (NUM_REGS * 4) -#define REGISTER_BYTE(n) ((n) * 4) - -/* - * Translate the values stored in the kernel regs struct to the format - * understood by gdb. - */ -void -regs_to_gdb(tf, gdb_regs) - struct trapframe *tf; - u_long *gdb_regs; -{ - - /* %g0..%g7 and %o0..%o7: from trapframe */ - gdb_regs[0] = 0; - kgdb_copy((caddr_t)&tf->tf_global[1], (caddr_t)&gdb_regs[1], 15 * 4); - - /* %l0..%l7 and %i0..%i7: from stack */ - kgdb_copy((caddr_t)tf->tf_out[6], (caddr_t)&gdb_regs[GDB_L0], 16 * 4); - - /* %f0..%f31 -- fake, kernel does not use FP */ - kgdb_zero((caddr_t)&gdb_regs[GDB_FP0], 32 * 4); - - /* %y, %psr, %wim, %tbr, %pc, %npc, %fsr, %csr */ - gdb_regs[GDB_Y] = tf->tf_y; - gdb_regs[GDB_PSR] = tf->tf_psr; - gdb_regs[GDB_WIM] = tf->tf_global[0]; /* input only! */ - gdb_regs[GDB_TBR] = 0; /* fake */ - gdb_regs[GDB_PC] = tf->tf_pc; - gdb_regs[GDB_NPC] = tf->tf_npc; - gdb_regs[GDB_FSR] = 0; /* fake */ - gdb_regs[GDB_CSR] = 0; /* fake */ -} - -/* - * Reverse the above. - */ -void -gdb_to_regs(tf, gdb_regs) - struct trapframe *tf; - u_long *gdb_regs; -{ - - kgdb_copy((caddr_t)&gdb_regs[1], (caddr_t)&tf->tf_global[1], 15 * 4); - kgdb_copy((caddr_t)&gdb_regs[GDB_L0], (caddr_t)tf->tf_out[6], 16 * 4); - tf->tf_y = gdb_regs[GDB_Y]; - tf->tf_psr = gdb_regs[GDB_PSR]; - tf->tf_pc = gdb_regs[GDB_PC]; - tf->tf_npc = gdb_regs[GDB_NPC]; -} - -static u_long reg_cache[NUM_REGS]; -static u_char inbuffer[SL_RPCSIZE]; -static u_char outbuffer[SL_RPCSIZE]; - -/* - * This function does all command procesing for interfacing to - * a remote gdb. - */ -int -kgdb_trap(type, tf) - int type; - register struct trapframe *tf; -{ - register u_long len; - caddr_t addr; - register u_char *cp; - register u_char out, in; - register int outlen; - int inlen; - u_long gdb_regs[NUM_REGS]; - - if (kgdb_dev < 0 || kgdb_getc == NULL) { - /* not debugging */ - return (0); - } - if (kgdb_active == 0) { - if (type != T_KGDB_EXEC) { - /* No debugger active -- let trap handle this. */ - return (0); - } - - /* - * If the packet that woke us up isn't an exec packet, - * ignore it since there is no active debugger. Also, - * we check that it's not an ack to be sure that the - * remote side doesn't send back a response after the - * local gdb has exited. Otherwise, the local host - * could trap into gdb if it's running a gdb kernel too. - */ - in = GETC(); - /* - * If we came in asynchronously through the serial line, - * the framing character is eaten by the receive interrupt, - * but if we come in through a synchronous trap (i.e., via - * kgdb_connect()), we will see the extra character. - */ - if (in == FRAME_START) - in = GETC(); - - if (KGDB_CMD(in) != KGDB_EXEC || (in & KGDB_ACK) != 0) - return (0); - while (GETC() != FRAME_END) - continue; - /* - * Do the printf *before* we ack the message. This way - * we won't drop any inbound characters while we're - * doing the polling printf. - */ - printf("kgdb started from device %x\n", kgdb_dev); - kgdb_send(in | KGDB_ACK, (u_char *)0, 0); - kgdb_active = 1; - } - if (type == T_KGDB_EXEC) { - /* bypass the trap instruction that got us here */ - tf->tf_pc = tf->tf_npc; - tf->tf_npc += 4; - } else { - /* - * Only send an asynchronous SIGNAL message when we hit - * a breakpoint. Otherwise, we will drop the incoming - * packet while we output this one (and on entry the other - * side isn't interested in the SIGNAL type -- if it is, - * it will have used a signal packet.) - */ - outbuffer[0] = computeSignal(type); - kgdb_send(KGDB_SIGNAL, outbuffer, 1); - } - /* - * Stick frame regs into our reg cache then tell remote host - * that an exception has occured. - */ - regs_to_gdb(tf, gdb_regs); - - for (;;) { - in = kgdb_recv(inbuffer, &inlen); - if (in == 0 || (in & KGDB_ACK)) - /* Ignore inbound acks and error conditions. */ - continue; - - out = in | KGDB_ACK; - switch (KGDB_CMD(in)) { - - case KGDB_SIGNAL: - /* - * if this command came from a running gdb, - * answer it -- the other guy has no way of - * knowing if we're in or out of this loop - * when he issues a "remote-signal". (Note - * that without the length check, we could - * loop here forever if the output line is - * looped back or the remote host is echoing.) - */ - if (inlen == 0) { - outbuffer[0] = computeSignal(type); - kgdb_send(KGDB_SIGNAL, outbuffer, 1); - } - continue; - - case KGDB_REG_R: - case KGDB_REG_R | KGDB_DELTA: - cp = outbuffer; - outlen = 0; - for (len = inbuffer[0]; len < NUM_REGS; ++len) { - if (reg_cache[len] != gdb_regs[len] || - (in & KGDB_DELTA) == 0) { - if (outlen + 5 > SL_MAXDATA) { - out |= KGDB_MORE; - break; - } - cp[outlen] = len; - kgdb_copy((caddr_t)&gdb_regs[len], - (caddr_t)&cp[outlen + 1], 4); - reg_cache[len] = gdb_regs[len]; - outlen += 5; - } - } - break; - - case KGDB_REG_W: - case KGDB_REG_W | KGDB_DELTA: - cp = inbuffer; - for (len = 0; len < inlen; len += 5) { - register int j = cp[len]; - - kgdb_copy((caddr_t)&cp[len + 1], - (caddr_t)&gdb_regs[j], 4); - reg_cache[j] = gdb_regs[j]; - } - gdb_to_regs(tf, gdb_regs); - outlen = 0; - break; - - case KGDB_MEM_R: - len = inbuffer[0]; - kgdb_copy((caddr_t)&inbuffer[1], (caddr_t)&addr, 4); - if (len > SL_MAXDATA) { - outlen = 1; - outbuffer[0] = E2BIG; - } else if (!kgdb_acc(addr, len, B_READ, 1)) { - outlen = 1; - outbuffer[0] = EFAULT; - } else { - outlen = len + 1; - outbuffer[0] = 0; - kgdb_copy(addr, (caddr_t)&outbuffer[1], len); - } - break; - - case KGDB_MEM_W: - len = inlen - 4; - kgdb_copy((caddr_t)inbuffer, (caddr_t)&addr, 4); - outlen = 1; - if (!kgdb_acc(addr, len, B_READ, 0)) - outbuffer[0] = EFAULT; - else { - outbuffer[0] = 0; - if (!kgdb_acc(addr, len, B_WRITE, 0)) - kdb_mkwrite(addr, len); - kgdb_copy((caddr_t)&inbuffer[4], addr, len); - } - break; - - case KGDB_KILL: - kgdb_active = 0; - printf("kgdb detached\n"); - /* FALLTHROUGH */ - - case KGDB_CONT: - kgdb_send(out, 0, 0); - return (1); - - case KGDB_HALT: - kgdb_send(out, 0, 0); - callrom(); - /* NOTREACHED */ - - case KGDB_BOOT: - kgdb_send(out, 0, 0); - romboot(""); - /* NOTREACHED */ - - case KGDB_EXEC: - default: - /* Unknown command. Ack with a null message. */ - outlen = 0; - break; - } - /* Send the reply */ - kgdb_send(out, outbuffer, outlen); - } -} - -extern char *kernel_map; /* XXX! */ -extern char *curproc; /* XXX! */ - -/* - * XXX do kernacc and useracc calls if safe, otherwise use PTE protections. - * - * Note: kernacc fails currently on the Sun4M port--we use pte bits instead. - * Plus this lets us debug kernacc. (%%% XXX) - */ -int -kgdb_acc(addr, len, rw, usertoo) - caddr_t addr; - int len, rw, usertoo; -{ - int pte; - -#if defined(SUN4M) /* we just use ptes here...its easier */ - if (CPU_ISSUN4M) { - pte = getpte4m(addr); - if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE || - (rw == B_WRITE && (pte & PPROT_WRITE) == 0)) - return (0); - } -#endif - - /* XXX icky: valid address but causes timeout */ - if (addr >= (caddr_t)0xfffff000) - return (0); - if (kernel_map != NULL) { - if (kernacc(addr, len, rw)) - return (1); - if (usertoo && curproc && useracc(addr, len, rw)) - return (1); - } - addr = (caddr_t)((int)addr & ~PGOFSET); - for (; len > 0; len -= NBPG, addr += NBPG) { - if (((int)addr >> PG_VSHIFT) != 0 && - ((int)addr >> PG_VSHIFT) != -1) - return (0); -#if defined(SUN4M) - if (CPU_ISSUN4M) { - pte = getpte4m(addr); - if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE || - (rw == B_WRITE && (pte & PPROT_WRITE) == 0)) - return (0); - } else -#endif - { - pte = getpte4(addr); - if ((pte & PG_V) == 0 || - (rw == B_WRITE && (pte & PG_W) == 0)) - return (0); - } - } - return (1); -} - -void -kdb_mkwrite(addr, len) - register caddr_t addr; - register int len; -{ - if (CPU_ISSUN4OR4C && kernel_map != NULL) { - chgkprot(addr, len, B_WRITE); - return; - } - - addr = (caddr_t)((int)addr & ~PGOFSET); - for (; len > 0; len -= NBPG, addr += NBPG) -#if defined(SUN4M) - if (CPU_ISSUN4M) - setpte4m((vm_offset_t)addr, - getpte4m(addr) | PPROT_WRITE); - else -#endif - setpte4(addr, getpte4(addr) | PG_W); -} -#endif diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s index 8878d8048bc..239b6d737ad 100644 --- a/sys/arch/sparc/sparc/locore.s +++ b/sys/arch/sparc/sparc/locore.s @@ -1,5 +1,5 @@ -/* $OpenBSD: locore.s,v 1.17 1997/08/08 08:27:27 downsj Exp $ */ -/* $NetBSD: locore.s,v 1.72 1997/07/07 20:06:42 pk Exp $ */ +/* $OpenBSD: locore.s,v 1.18 1997/09/17 06:47:19 downsj Exp $ */ +/* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */ /* * Copyright (c) 1996 Paul Kranenburg @@ -3222,7 +3222,7 @@ dostart: * * We have been loaded in low RAM, at some address which * is page aligned (0x4000 actually) rather than where we - * want to run (0xf8004000). Until we get everything set, + * want to run (KERNBASE+0x4000). Until we get everything set, * we have to be sure to use only pc-relative addressing. */ @@ -3233,16 +3233,36 @@ dostart: * that know nothing about DDB symbol loading conventions. * Note: we don't touch %o1-%o3; SunOS bootloaders seem to use them * for their own mirky business. + * + * Pre-NetBSD 1.3 bootblocks had KERNBASE compiled in, and used + * it to compute the value of `_esym'. In order to successfully + * boot a kernel built with a different value for KERNBASE using + * old bootblocks, we fixup `_esym' here by the difference between + * KERNBASE and the old value (known to be 0xf8000000) compiled + * into pre-1.3 bootblocks. + * We use the magic number passed as the sixth argument to + * distinguish bootblock versions. */ - set 0x44444230, %l3 + mov %g0, %l4 + set 0x44444231, %l3 cmp %o5, %l3 ! chk magic - bne 1f + be 1f + + set 0x44444230, %l3 + cmp %o5, %l3 ! chk compat magic + bne 2f + + set KERNBASE, %l4 ! compat magic found + set 0xf8000000, %l5 ! compute correction term: + sub %l5, %l4, %l4 ! old KERNBASE (0xf8000000 ) - KERNBASE + +1: tst %o4 ! do we have the symbols? - bz 1f - nop + bz 2f + sub %o4, %l4, %o4 ! apply compat correction sethi %hi(_esym - KERNBASE), %l3 ! store _esym st %o4, [%l3 + %lo(_esym - KERNBASE)] -1: +2: #endif /* * Sun4 passes in the `load address'. Although possible, its highly diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index 27d65d8868e..9eeae6f112b 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,5 +1,5 @@ -/* $OpenBSD: machdep.c,v 1.28 1997/08/25 08:38:48 downsj Exp $ */ -/* $NetBSD: machdep.c,v 1.83 1997/07/29 10:04:44 fair Exp $ */ +/* $OpenBSD: machdep.c,v 1.29 1997/09/17 06:47:20 downsj Exp $ */ +/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */ /* * Copyright (c) 1992, 1993 diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c index 789619a78bc..14c3de9b933 100644 --- a/sys/arch/sparc/sparc/pmap.c +++ b/sys/arch/sparc/sparc/pmap.c @@ -1,5 +1,5 @@ -/* $OpenBSD: pmap.c,v 1.17 1997/08/08 08:27:36 downsj Exp $ */ -/* $NetBSD: pmap.c,v 1.91 1997/07/29 09:42:11 fair Exp $ */ +/* $OpenBSD: pmap.c,v 1.18 1997/09/17 06:47:21 downsj Exp $ */ +/* $NetBSD: pmap.c,v 1.96 1997/09/14 19:20:48 pk Exp $ */ /* * Copyright (c) 1996 @@ -638,7 +638,7 @@ setptesw4m(pm, va, pte) setpgt4m(sm->sg_pte + VA_SUN4M_VPG(va), pte); } -/* Set the page table entry for va to pte. Flushes cache. */ +/* Set the page table entry for va to pte. */ __inline void setpte4m(va, pte) register vm_offset_t va; @@ -649,11 +649,9 @@ setpte4m(va, pte) register struct segmap *sm; register union ctxinfo *c; - cache_flush_page(va); - /* - * Now walk tables to find pte. We use ctxinfo to locate the pmap - * from the current context + * Walk tables to find pte. We use ctxinfo to locate the pmap + * from the current context. */ #if 0 #ifdef DEBUG @@ -992,8 +990,8 @@ mmu_reservemon4_4c(nrp, nsp) /* * mmu_reservemon4m(): Copies the existing (ROM) page tables to kernel space, * converting any L1/L2 PTEs to L3 PTEs. Does *not* copy the L1 entry mapping - * the kernel at KERNBASE (0xf8000000) since we don't want to map 16M of - * physical memory for the kernel. Thus the kernel must be installed later! + * the kernel at KERNBASE since we don't want to map 16M of physical + * memory for the kernel. Thus the kernel must be installed later! * Also installs ROM mappings into the kernel pmap. * NOTE: This also revokes all user-mode access to the mapped regions. */ @@ -1070,10 +1068,11 @@ mmu_setup4m_L1(regtblptd, kpmap) /* * Here we scan the region table to copy any entries which appear. * We are only concerned with regions in kernel space and above - * (i.e. regions 0xf8 to 0xff). We also ignore region 0xf8, since - * that is the 16MB L1 mapping that the ROM used to map the kernel - * in initially. Later, we will rebuild a new L3 mapping for the - * kernel and install it before switching to the new pagetables. + * (i.e. regions VA_VREG(KERNBASE)+1 to 0xff). We ignore the first + * region (at VA_VREG(KERNBASE)), since that is the 16MB L1 mapping + * that the ROM used to map the kernel in initially. Later, we will + * rebuild a new L3 mapping for the kernel and install it before + * switching to the new pagetables. */ regtblrover = ((regtblptd & ~SRMMU_TETYPE) << SRMMU_PPNPASHIFT) + @@ -3075,7 +3074,7 @@ pmap_bootstrap4m(void) /* * Reserve memory for segment and page tables needed to map the entire - * kernel (from regions 0xf8 -> 0xff). This takes 130k of space, but + * kernel. This takes (2k + NKREG * 16k) of space, but * unfortunately is necessary since pmap_enk *must* be able to enter * a kernel mapping without resorting to malloc, or else the * possibility of deadlock arises (pmap_enk4m is called to enter a @@ -3126,28 +3125,27 @@ pmap_bootstrap4m(void) /* XXX:rethink - Store pointer to region table address */ cpuinfo.L1_ptps = pmap_kernel()->pm_reg_ptps; - for (reg = VA_VREG(KERNBASE); reg < NKREG+VA_VREG(KERNBASE); reg++) { + for (reg = 0; reg < NKREG; reg++) { struct regmap *rp; caddr_t kphyssegtbl; /* * Entering new region; install & build segtbl */ - int kregnum = reg - VA_VREG(KERNBASE); - rp = &pmap_kernel()->pm_regmap[reg]; + rp = &pmap_kernel()->pm_regmap[reg + VA_VREG(KERNBASE)]; kphyssegtbl = (caddr_t) - &kernel_segtable_store[kregnum * SRMMU_L2SIZE]; + &kernel_segtable_store[reg * SRMMU_L2SIZE]; - setpgt4m(&pmap_kernel()->pm_reg_ptps[reg], + setpgt4m(&pmap_kernel()->pm_reg_ptps[reg + VA_VREG(KERNBASE)], (VA2PA(kphyssegtbl) >> SRMMU_PPNPASHIFT) | SRMMU_TEPTD); rp->rg_seg_ptps = (int *)kphyssegtbl; if (rp->rg_segmap == NULL) { printf("rp->rg_segmap == NULL!\n"); - rp->rg_segmap = &kernel_segmap_store[kregnum * NSEGRG]; + rp->rg_segmap = &kernel_segmap_store[reg * NSEGRG]; } for (seg = 0; seg < NSEGRG; seg++) { @@ -3159,7 +3157,7 @@ pmap_bootstrap4m(void) sp = &rp->rg_segmap[seg]; kphyspagtbl = (caddr_t) &kernel_pagtable_store - [((kregnum * NSEGRG) + seg) * SRMMU_L3SIZE]; + [((reg * NSEGRG) + seg) * SRMMU_L3SIZE]; setpgt4m(&rp->rg_seg_ptps[seg], (VA2PA(kphyspagtbl) >> SRMMU_PPNPASHIFT) | @@ -5730,7 +5728,7 @@ pmap_extract4m(pm, va) if (rm == NULL) { #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) - printf("getptesw4m: no regmap entry"); + printf("pmap_extract: no regmap entry"); #endif return (0); } @@ -5738,7 +5736,7 @@ pmap_extract4m(pm, va) if (sm == NULL) { #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) - panic("getptesw4m: no segmap"); + panic("pmap_extract: no segmap"); #endif return (0); } @@ -5765,6 +5763,7 @@ pmap_extract4m(pm, va) * This routine is only advisory and need not do anything. */ /* ARGSUSED */ +int pmap_copy_disabled=0; void pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) struct pmap *dst_pmap, *src_pmap; @@ -5772,17 +5771,44 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) vm_size_t len; vm_offset_t src_addr; { -#if 0 +#if notyet + struct regmap *rm; + struct segmap *sm; + + if (pmap_copy_disabled) + return; +#ifdef DIAGNOSTIC + if (VA_OFF(src_addr) != 0) + printf("pmap_copy: addr not page aligned: 0x%lx\n", src_addr); + if ((len & (NBPG-1)) != 0) + printf("pmap_copy: length not page aligned: 0x%lx\n", len); +#endif + + if (src_pmap == NULL) + return; + if (CPU_ISSUN4M) { - register int i, pte; - for (i = 0; i < len/NBPG; i++) { - pte = getptesw4m(src_pmap, src_addr); + int i, npg, pte; + vm_offset_t pa; + + npg = len >> PGSHIFT; + for (i = 0; i < npg; i++) { + tlb_flush_page(src_addr); + rm = &src_pmap->pm_regmap[VA_VREG(src_addr)]; + if (rm == NULL) + continue; + sm = &rm->rg_segmap[VA_VSEG(src_addr)]; + if (sm == NULL || sm->sg_npte == 0) + continue; + pte = sm->sg_pte[VA_SUN4M_VPG(src_addr)]; + if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE) + continue; + + pa = ptoa((pte & SRMMU_PPNMASK) >> SRMMU_PPNSHIFT); pmap_enter(dst_pmap, dst_addr, - ptoa((pte & SRMMU_PPNMASK) >> - SRMMU_PPNSHIFT) | - VA_OFF(src_addr), + pa, (pte & PPROT_WRITE) - ? VM_PROT_WRITE| VM_PROT_READ + ? (VM_PROT_WRITE | VM_PROT_READ) : VM_PROT_READ, 0); src_addr += NBPG; @@ -6585,6 +6611,56 @@ out: return (error); } +/* + * Helper function for debuggers. + */ +void +pmap_writetext(dst, ch) + unsigned char *dst; + int ch; +{ + int s, pte0, pte, ctx; + vm_offset_t va; + + s = splpmap(); + va = (unsigned long)dst & (~PGOFSET); + cpuinfo.cache_flush(dst, 1); + + ctx = getcontext(); + setcontext(0); + +#if defined(SUN4M) + if (CPU_ISSUN4M) { + pte0 = getpte4m(va); + if ((pte0 & SRMMU_TETYPE) != SRMMU_TEPTE) { + splx(s); + return; + } + pte = pte0 | PPROT_WRITE; + setpte4m(va, pte); + *dst = (unsigned char)ch; + setpte4m(va, pte0); + + } +#endif +#if defined(SUN4) || defined(SUN4C) + if (CPU_ISSUN4C || CPU_ISSUN4) { + pte0 = getpte4(va); + if ((pte0 & PG_V) == 0) { + splx(s); + return; + } + pte = pte0 | PG_W; + setpte4(va, pte); + *dst = (unsigned char)ch; + setpte4(va, pte0); + } +#endif + cpuinfo.cache_flush(dst, 1); + setcontext(ctx); + splx(s); +} + #ifdef EXTREME_DEBUG static void test_region __P((int, int, int)); @@ -6613,8 +6689,8 @@ debug_pagetables() test_region(0xfe,0,16*1024*1024); printf("Testing region 0xff: "); test_region(0xff,0,16*1024*1024); - printf("Testing kernel region 0xf8: "); - test_region(0xf8, 4096, avail_start); + printf("Testing kernel region 0x%x: ", VA_VREG(KERNBASE)); + test_region(VA_VREG(KERNBASE), 4096, avail_start); cngetc(); for (i = 0; i < SRMMU_L1SIZE; i++) { @@ -6661,7 +6737,7 @@ VA2PAsw(ctx, addr, pte) return 0; } /* L1 */ - curtbl = ((curpte & ~0x3) << 4) | (0xf8 << RGSHIFT); /* correct for krn*/ + curtbl = ((curpte & ~0x3) << 4) | KERNBASE; /* correct for krn*/ *pte = curpte = curtbl[VA_VREG(addr)]; #ifdef EXTREME_EXTREME_DEBUG printf("L1 table at 0x%x.\nGot L1 pte 0x%x\n",curtbl,curpte); @@ -6675,7 +6751,7 @@ VA2PAsw(ctx, addr, pte) return 0; } /* L2 */ - curtbl = ((curpte & ~0x3) << 4) | (0xf8 << RGSHIFT); /* correct for krn*/ + curtbl = ((curpte & ~0x3) << 4) | KERNBASE; /* correct for krn*/ *pte = curpte = curtbl[VA_VSEG(addr)]; #ifdef EXTREME_EXTREME_DEBUG printf("L2 table at 0x%x.\nGot L2 pte 0x%x\n",curtbl,curpte); @@ -6689,7 +6765,7 @@ VA2PAsw(ctx, addr, pte) return 0; } /* L3 */ - curtbl = ((curpte & ~0x3) << 4) | (0xf8 << RGSHIFT); /* correct for krn*/ + curtbl = ((curpte & ~0x3) << 4) | KERNBASE; /* correct for krn*/ *pte = curpte = curtbl[VA_VPG(addr)]; #ifdef EXTREME_EXTREME_DEBUG printf("L3 table at 0x%x.\nGot L3 pte 0x%x\n",curtbl,curpte); @@ -6730,8 +6806,9 @@ void test_region(reg, start, stop) printf("Mismatch at address 0x%x.\n",addr); if (cngetc()=='q') break; } - if (reg == 0xf8) /* kernel permissions are different */ - continue; + if (reg == VA_VREG(KERNBASE)) + /* kernel permissions are different */ + continue; if ((pte&SRMMU_PROT_MASK)!=(ptesw&SRMMU_PROT_MASK)) { printf("Mismatched protections at address " "0x%x; pte=0x%x, ptesw=0x%x\n", diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c index 34c2f049c2a..bc43fd9ebfb 100644 --- a/sys/arch/sparc/sparc/trap.c +++ b/sys/arch/sparc/sparc/trap.c @@ -1,5 +1,5 @@ -/* $OpenBSD: trap.c,v 1.11 1997/08/08 08:27:46 downsj Exp $ */ -/* $NetBSD: trap.c,v 1.57 1997/07/29 09:42:15 fair Exp $ */ +/* $OpenBSD: trap.c,v 1.12 1997/09/17 06:47:22 downsj Exp $ */ +/* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */ /* * Copyright (c) 1996 @@ -1104,7 +1104,9 @@ syscall(code, tf, pc) rval[0] = 0; rval[1] = tf->tf_out[1]; error = (*callp->sy_call)(p, &args, rval); - if (error == 0) { + + switch (error) { + case 0: /* Note: fork() does not return here in the child */ tf->tf_out[0] = rval[0]; tf->tf_out[1] = rval[1]; @@ -1122,8 +1124,15 @@ syscall(code, tf, pc) } tf->tf_pc = i; tf->tf_npc = i + 4; - } else if (error > 0 /*error != ERESTART && error != EJUSTRETURN*/) { -bad: + break; + + case ERESTART: + case EJUSTRETURN: + /* nothing to do */ + break; + + default: + bad: if (p->p_emul->e_errno) error = p->p_emul->e_errno[error]; tf->tf_out[0] = error; @@ -1131,9 +1140,8 @@ bad: i = tf->tf_npc; tf->tf_pc = i; tf->tf_npc = i + 4; + break; } - /* else if (error == ERESTART || error == EJUSTRETURN) */ - /* nothing to do */ userret(p, pc, sticks); #ifdef KTRACE |