summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2000-01-31 16:07:00 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2000-01-31 16:07:00 +0000
commit87fd49747d8e4df1fa404cc0bbaa340d399002fc (patch)
treecbefb4ab2935696347ed1e075c2b43d8df5bee33 /sys/arch
parentf16f98cca156de2491d704e205937575664b04c0 (diff)
Clean up memerr*. (from NetBSD)
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc/sparc/cpu.c31
-rw-r--r--sys/arch/sparc/sparc/cpuvar.h32
-rw-r--r--sys/arch/sparc/sparc/genassym.cf3
-rw-r--r--sys/arch/sparc/sparc/locore.s24
-rw-r--r--sys/arch/sparc/sparc/memreg.c167
-rw-r--r--sys/arch/sparc/sparc/memreg.h5
-rw-r--r--sys/arch/sparc/sparc/trap.c4
7 files changed, 132 insertions, 134 deletions
diff --git a/sys/arch/sparc/sparc/cpu.c b/sys/arch/sparc/sparc/cpu.c
index 07106c79ef2..9556f108b32 100644
--- a/sys/arch/sparc/sparc/cpu.c
+++ b/sys/arch/sparc/sparc/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.21 2000/01/27 20:14:11 art Exp $ */
+/* $OpenBSD: cpu.c,v 1.22 2000/01/31 16:06:58 art Exp $ */
/* $NetBSD: cpu.c,v 1.56 1997/09/15 20:52:36 pk Exp $ */
/*
@@ -71,6 +71,7 @@
#include <sparc/sparc/cache.h>
#include <sparc/sparc/asm.h>
#include <sparc/sparc/cpuvar.h>
+#include <sparc/sparc/memreg.h>
/* The following are used externally (sysctl_hw). */
char machine[] = MACHINE; /* from <machine/param.h> */
@@ -423,7 +424,8 @@ struct module_info module_sun4 = {
sun4_vcache_flush_segment,
sun4_vcache_flush_region,
sun4_vcache_flush_context,
- noop_pcache_flush_line
+ noop_pcache_flush_line,
+ memerr4_4c
};
void
@@ -545,7 +547,8 @@ struct module_info module_sun4c = {
sun4_vcache_flush_segment,
sun4_vcache_flush_region,
sun4_vcache_flush_context,
- noop_pcache_flush_line
+ noop_pcache_flush_line,
+ memerr4_4c
};
void
@@ -739,7 +742,8 @@ struct module_info module_ms1 = {
noop_vcache_flush_segment,
noop_vcache_flush_region,
noop_vcache_flush_context,
- noop_pcache_flush_line
+ noop_pcache_flush_line,
+ memerr4m
};
void
@@ -763,7 +767,8 @@ struct module_info module_ms2 = { /* UNTESTED */
srmmu_vcache_flush_segment,
srmmu_vcache_flush_region,
srmmu_vcache_flush_context,
- noop_pcache_flush_line
+ noop_pcache_flush_line,
+ memerr4m
};
@@ -782,7 +787,8 @@ struct module_info module_swift = { /* UNTESTED */
srmmu_vcache_flush_segment,
srmmu_vcache_flush_region,
srmmu_vcache_flush_context,
- srmmu_pcache_flush_line
+ srmmu_pcache_flush_line,
+ memerr4m
};
void
@@ -826,7 +832,8 @@ struct module_info module_viking = { /* UNTESTED */
noop_vcache_flush_segment,
noop_vcache_flush_region,
noop_vcache_flush_context,
- viking_pcache_flush_line
+ viking_pcache_flush_line,
+ viking_memerr
};
void
@@ -905,7 +912,8 @@ struct module_info module_hypersparc = { /* UNTESTED */
srmmu_vcache_flush_segment,
srmmu_vcache_flush_region,
srmmu_vcache_flush_context,
- srmmu_pcache_flush_line
+ srmmu_pcache_flush_line,
+ hypersparc_memerr
};
void
@@ -950,7 +958,8 @@ struct module_info module_cypress = { /* UNTESTED */
srmmu_vcache_flush_segment,
srmmu_vcache_flush_region,
srmmu_vcache_flush_context,
- srmmu_pcache_flush_line
+ srmmu_pcache_flush_line,
+ memerr4m
};
/* Fujitsu Turbosparc */
@@ -969,7 +978,8 @@ struct module_info module_turbosparc = { /* UNTESTED */
srmmu_vcache_flush_segment,
srmmu_vcache_flush_region,
srmmu_vcache_flush_context,
- srmmu_pcache_flush_line
+ srmmu_pcache_flush_line,
+ memerr4m
};
void
@@ -1191,6 +1201,7 @@ getcpuinfo(sc, node)
MPCOPY(vcache_flush_region);
MPCOPY(vcache_flush_context);
MPCOPY(pcache_flush_line);
+ MPCOPY(memerr);
#undef MPCOPY
return;
}
diff --git a/sys/arch/sparc/sparc/cpuvar.h b/sys/arch/sparc/sparc/cpuvar.h
index a8ba8fbcb2b..8f3e436b0d8 100644
--- a/sys/arch/sparc/sparc/cpuvar.h
+++ b/sys/arch/sparc/sparc/cpuvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpuvar.h,v 1.1 1997/08/08 08:40:15 downsj Exp $ */
+/* $OpenBSD: cpuvar.h,v 1.2 2000/01/31 16:06:58 art Exp $ */
/* $NetBSD: cpuvar.h,v 1.4 1997/07/06 21:14:25 pk Exp $ */
/*
@@ -56,20 +56,22 @@ struct cpu_softc;
struct module_info {
int cpu_type;
enum vactype vactype;
- void (*cpu_match)__P((struct cpu_softc *, struct module_info *, int));
- void (*getcacheinfo)__P((struct cpu_softc *sc, int node));
+ void (*cpu_match) __P((struct cpu_softc *, struct module_info *, int));
+ void (*getcacheinfo) __P((struct cpu_softc *sc, int node));
void (*hotfix) __P((struct cpu_softc *));
- void (*mmu_enable)__P((void));
- void (*cache_enable)__P((void));
+ void (*mmu_enable) __P((void));
+ void (*cache_enable) __P((void));
int ncontext; /* max. # of contexts (we use) */
- void (*get_faultstatus)__P((void));
- void (*cache_flush)__P((caddr_t, u_int));
- void (*vcache_flush_page)__P((int));
- void (*vcache_flush_segment)__P((int, int));
- void (*vcache_flush_region)__P((int));
- void (*vcache_flush_context)__P((void));
- void (*pcache_flush_line)__P((int, int));
+ void (*get_faultstatus) __P((void));
+ void (*cache_flush) __P((caddr_t, u_int));
+ void (*vcache_flush_page) __P((int));
+ void (*vcache_flush_segment) __P((int, int));
+ void (*vcache_flush_region) __P((int));
+ void (*vcache_flush_context) __P((void));
+ void (*pcache_flush_line) __P((int, int));
+ void (*memerr) __P((unsigned, u_int, u_int, u_int, u_int,
+ struct trapframe *));
};
@@ -184,6 +186,12 @@ struct cpu_softc {
void (*mbusflush) __P((void));
#endif
+ /*
+ * Memory error handler; parity errors, unhandled NMIs and other
+ * unrecoverable faults end up here.
+ */
+ void (*memerr)__P((unsigned, u_int, u_int, u_int, u_int,
+ struct trapframe *));
/* XXX: Add more here! */
};
diff --git a/sys/arch/sparc/sparc/genassym.cf b/sys/arch/sparc/sparc/genassym.cf
index 24cb9af3f5e..4e13ea1f469 100644
--- a/sys/arch/sparc/sparc/genassym.cf
+++ b/sys/arch/sparc/sparc/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.3 1999/04/22 18:28:26 art Exp $
+# $OpenBSD: genassym.cf,v 1.4 2000/01/31 16:06:58 art Exp $
# $NetBSD: genassym.cf,v 1.2 1997/06/28 19:59:04 pk Exp $
#
@@ -113,6 +113,7 @@ endif
# CPU info structure
define CPUINFO_FAULTSTATUS offsetof(struct cpu_softc, get_faultstatus)
+define CPUINFO_MEMERR offsetof(struct cpu_softc, memerr)
# PTE bits and related information
define PG_W PG_W
diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s
index 2b98b97deb6..058ef7bf450 100644
--- a/sys/arch/sparc/sparc/locore.s
+++ b/sys/arch/sparc/sparc/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.28 1999/12/07 00:49:07 deraadt Exp $ */
+/* $OpenBSD: locore.s,v 1.29 2000/01/31 16:06:58 art Exp $ */
/* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */
/*
@@ -1734,7 +1734,9 @@ memfault_sun4:
/* memory error = death for now XXX */
clr %o3
clr %o4
- call _memerr ! (0, ser, sva, 0, 0)
+ set CPUINFO_VA+CPUINFO_MEMERR, %o0
+ ld [%o0], %o0
+ jmpl %o0, %o7 ! memerr(0, ser, sva, 0, 0)
clr %o0
call _callrom
nop
@@ -1835,7 +1837,9 @@ memfault_sun4c:
*/
wr %l0, PSR_ET, %psr
nop
- call _memerr ! memerr(0, ser, sva, aer, ava)
+ set CPUINFO_VA+CPUINFO_MEMERR, %o0
+ ld [%o0], %o0
+ jmpl %o0, %o7 ! memerr(0, ser, sva, 0, 0)
clr %o0
ld [%sp + CCFSZ + 20], %g1 ! restore g1 through g7
@@ -1855,7 +1859,9 @@ memfault_sun4c:
* %o1 through %o4 still hold the error reg contents.
*/
1:
- call _memerr ! memerr(1, ser, sva, aer, ava)
+ set CPUINFO_VA+CPUINFO_MEMERR, %o0
+ ld [%o0], %o0
+ jmpl %o0, %o7 ! memerr(0, ser, sva, 0, 0)
mov 1, %o0
ld [%sp + CCFSZ + 20], %g1 ! restore g1 through g7
@@ -2560,8 +2566,10 @@ nmi_sun4c:
nmi_common:
! and call C code
- call _memerr ! memerr(0, ser, sva, aer, ava)
- clr %o0
+ set CPUINFO_VA+CPUINFO_MEMERR, %o0
+ ld [%o0], %o0
+ jmpl %o0, %o7 ! memerr(0, ser, sva, 0, 0)
+ clr %o0
mov %l5, %g1 ! restore g1 through g7
ldd [%sp + CCFSZ + 0], %g2
@@ -2617,7 +2625,9 @@ nmi_sun4m:
mov %g7, %l7
clr %o5
- call _memerr4m ! memerr4m(0, sfsr, sfva, afsr, afva)
+ set CPUINFO_VA+CPUINFO_MEMERR, %o0
+ ld [%o0], %o0
+ jmpl %o0, %o7 ! memerr(0, ser, sva, 0, 0)
clr %o0
mov %l5, %g1 ! restore g1 through g7
diff --git a/sys/arch/sparc/sparc/memreg.c b/sys/arch/sparc/sparc/memreg.c
index 678bf299176..263b86c7b4b 100644
--- a/sys/arch/sparc/sparc/memreg.c
+++ b/sys/arch/sparc/sparc/memreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memreg.c,v 1.7 1997/11/11 10:53:12 niklas Exp $ */
+/* $OpenBSD: memreg.c,v 1.8 2000/01/31 16:06:59 art Exp $ */
/* $NetBSD: memreg.c,v 1.21 1997/07/29 09:42:08 fair Exp $ */
/*
@@ -73,9 +73,8 @@ struct cfdriver memreg_cd = {
0, "memreg", DV_DULL
};
-void memerr __P((int, u_int, u_int, u_int, u_int));
#if defined(SUN4M)
-void hardmemerr4m __P((int, u_int, u_int));
+void hardmemerr4m __P((u_int, u_int, u_int, u_int));
#endif
/*
@@ -126,58 +125,20 @@ memregattach(parent, self, aux)
*/
void
-memerr(issync, ser, sva, aer, ava)
- int issync;
+memerr4_4c(issync, ser, sva, aer, ava, tf)
+ unsigned int issync;
u_int ser, sva, aer, ava;
+ struct trapframe *tf; /* XXX - unused/invalid */
{
- /* XXX Ugh! Clean up this switch and all the ifdefs! */
- switch (cputyp) {
-#if defined(SUN4)
- case CPU_SUN4:
- if (par_err_reg) {
- printf("mem err: ser=%b sva=0x%x\n",
- ser, SER_BITS, sva);
- printf("parity error register = %b\n",
- *par_err_reg, PER_BITS);
- } else {
- printf("mem err: ser=? sva=?\n");
- printf("parity error register not mapped yet!\n"); /* XXX */
- }
-#ifdef DEBUG
- callrom();
-#else
- panic("memory error"); /* XXX */
-#endif
- break;
-#endif /* Sun4 */
-
-#if defined(SUN4C)
- case CPU_SUN4C:
- printf("%ssync mem arr: ser=%b sva=0x%x ",
- issync ? "" : "a", ser, SER_BITS, sva);
- printf("aer=%b ava=0x%x\n", aer & 0xff, AER_BITS, ava);
- if (par_err_reg)
- printf("parity error register = %b\n",
- *par_err_reg, PER_BITS);
-#ifdef DEBUG
- callrom();
-#else
- panic("memory error"); /* XXX */
-#endif
- break;
-#endif /* Sun4C */
-
-#if defined(SUN4M)
- case CPU_SUN4M:
- hardmemerr4m(2, ser, sva);
- break;
-#endif /* Sun4M */
- default:
- break;
- }
+ printf("%ssync mem err: ser=%b sva=0x%x ",
+ issync ? "" : "a", ser, SER_BITS, sva);
+ printf("aer=%b ava=0x%x\n", aer & 0xff, AER_BITS, ava);
+ if (par_err_reg)
+ printf("parity error register = %b\n",
+ *par_err_reg, PER_BITS);
+ panic("memory error"); /* XXX */
}
-
#if defined(SUN4M)
/*
* hardmemerr4m: called upon fatal memory error. Print a message and panic.
@@ -189,31 +150,14 @@ memerr(issync, ser, sva, aer, ava)
*/
void
-hardmemerr4m(issync, fsr, faddr)
- int issync;
- u_int fsr, faddr;
+hardmemerr4m(sfsr, sfva, afsr, afva)
+ u_int sfsr, sfva, afsr, afva;
{
- switch (issync) {
- case 1:
- if ((fsr & SFSR_FT) == SFSR_FT_NONE)
- return;
- printf("mem err: sfsr=%b sfaddr=0x%x\n", fsr, SFSR_BITS, faddr);
- break;
- case 0:
- if (!(fsr & AFSR_AFO))
- return;
- printf("async (HS) mem err: afsr=%b afaddr=0x%x physaddr=0x%x%x\n",
- fsr, AFSR_BITS, faddr,
- (fsr & AFSR_AFA) >> AFSR_AFA_RSHIFT, faddr);
- break;
- default: /* unknown; print both decodings*/
- printf("unknown mem err: if sync, fsr=%b fva=0x%x; ",
- fsr, SFSR_BITS, faddr);
- printf("if async, fsr=%b fa=0x%x pa=0x%x%x", fsr,
- AFSR_BITS, faddr, (fsr & AFSR_AFA) >> AFSR_AFA_RSHIFT,
- faddr);
- break;
- }
+ printf("memory error:");
+ printf("sfsr=%b sfva=0x%x", sfsr, SFSR_BITS, sfva);
+ printf("afsr=%b afva=0x%x", afsr, AFSR_BITS, afva);
+ if ((sfsr & SFSR_FT) == SFSR_FT_NONE && (afsr & AFSR_AFO) == 0)
+ return;
panic("hard memory error");
}
@@ -229,13 +173,13 @@ static int addroldtop = (int)0xdeadbeef;
static int oldtype = -1;
void
-memerr4m(type, sfsr, sfva, afsr, afva, tf)
- register unsigned type;
- register u_int sfsr;
- register u_int sfva;
- register u_int afsr;
- register u_int afva;
- register struct trapframe *tf;
+hypersparc_memerr(type, sfsr, sfva, afsr, afva, tf)
+ unsigned int type;
+ u_int sfsr;
+ u_int sfva;
+ u_int afsr;
+ u_int afva;
+ struct trapframe *tf;
{
if ((afsr & AFSR_AFO) != 0) { /* HS async fault! */
@@ -244,15 +188,26 @@ memerr4m(type, sfsr, sfva, afsr, afva, tf)
afva);
if (afva == addrold && (afsr & AFSR_AFA) == addroldtop)
- hardmemerr4m(0, afsr, afva);
- /* NOTREACHED */
+ hardmemerr4m(sfsr, sfva, afsr, afva);
oldtype = -1;
addrold = afva;
addroldtop = afsr & AFSR_AFA;
+ return;
+ }
+ memerr4m(type, sfsr, sfva, afsr, afva, tf);
+}
- } else if (type == T_STOREBUFFAULT && cpuinfo.cpu_vers == 4) {
-
+void
+viking_memerr(type, sfsr, sfva, afsr, afva, tf)
+ unsigned int type;
+ u_int sfsr;
+ u_int sfva;
+ u_int afsr;
+ u_int afva;
+ struct trapframe *tf;
+{
+ if (type == T_STOREBUFFAULT) {
/*
* On Supersparc, we try to reenable the store buffers
* to force a retry.
@@ -261,7 +216,7 @@ memerr4m(type, sfsr, sfva, afsr, afva, tf)
sfva);
if (oldtype == T_STOREBUFFAULT || addrold == sfva)
- hardmemerr4m(1, sfsr, sfva);
+ hardmemerr4m(sfsr, sfva, afsr, afva);
/* NOTREACHED */
oldtype = T_STOREBUFFAULT;
@@ -271,33 +226,43 @@ memerr4m(type, sfsr, sfva, afsr, afva, tf)
sta(SRMMU_PCR, ASI_SRMMU,
lda(SRMMU_PCR, ASI_SRMMU) | VIKING_PCR_SB);
- } else if (type == T_DATAFAULT && !(sfsr & SFSR_FAV)) { /* bizarre */
- /* XXX: Should handle better. See SuperSPARC manual pg. 9-35 */
+ } else if (type == T_DATAFAULT && !(sfsr & SFSR_FAV)) {
+ return;
+ }
+ memerr4m(type, sfsr, sfva, afsr, afva, tf);
+}
- printf("warning: got data fault with no faulting address."
- " Ignoring.\n");
+void
+memerr4m(type, sfsr, sfva, afsr, afva, tf)
+ unsigned int type;
+ u_int sfsr;
+ u_int sfva;
+ u_int afsr;
+ u_int afva;
+ struct trapframe *tf;
+{
+ if (type == T_DATAFAULT && !(sfsr & SFSR_FAV)) { /* bizarre */
+ /* XXX: Should handle better. See SuperSPARC manual pg. 9-35 */
+ printf("warning: got data fault with no faulting address."
+ " Ignoring.\n");
if (oldtype == T_DATAFAULT)
- hardmemerr4m(1, sfsr, sfva);
- /* NOTREACHED */
+ hardmemerr4m(sfsr, sfva, afsr, afva);
+ oldtype = T_DATAFAULT;
- oldtype = T_DATAFAULT;
} else if (type == 0) { /* NMI */
printf("ERROR: got NMI with sfsr=0x%b, sfva=0x%x, ",
sfsr, SFSR_BITS, sfva);
printf("afsr=0x%b, afaddr=0x%x. Retrying...\n",
afsr, AFSR_BITS, afva);
if (oldtype == 0 || addrold == sfva)
- hardmemerr4m(1, sfsr, sfva); /* XXX: async? */
- /* NOTREACHED */
+ hardmemerr4m(sfsr, sfva, afsr, afva);
oldtype = 0;
addrold = sfva;
- } else /* something we don't know about?!? */ {
- printf("unknown fatal memory error, type=%d, sfsr=%b, sfva=0x%x",
- type, sfsr, SFSR_BITS, sfva);
- printf(", afsr=%b, afaddr=0x%x\n", afsr, AFSR_BITS, afva);
- panic("memerr4m");
+ } else {
+ /* something we don't know about?!? */
+ hardmemerr4m(sfsr, sfva, afsr, afva);
}
return;
diff --git a/sys/arch/sparc/sparc/memreg.h b/sys/arch/sparc/sparc/memreg.h
index f27a5197621..d0efa4591ce 100644
--- a/sys/arch/sparc/sparc/memreg.h
+++ b/sys/arch/sparc/sparc/memreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: memreg.h,v 1.3 1997/08/08 08:27:33 downsj Exp $ */
+/* $OpenBSD: memreg.h,v 1.4 2000/01/31 16:06:59 art Exp $ */
/* $NetBSD: memreg.h,v 1.4 1996/03/31 22:52:13 pk Exp $ */
/*
@@ -72,4 +72,7 @@ volatile u_int *par_err_reg; /* virtual address; NULL if not yet mapped */
* sun4m ...
*/
struct trapframe;
+void memerr4_4c __P((unsigned, u_int, u_int, u_int, u_int, struct trapframe *));
void memerr4m __P((unsigned, u_int, u_int, u_int, u_int, struct trapframe *));
+void viking_memerr __P((unsigned, u_int, u_int, u_int, u_int, struct trapframe *));
+void hypersparc_memerr __P((unsigned, u_int, u_int, u_int, u_int, struct trapframe *));
diff --git a/sys/arch/sparc/sparc/trap.c b/sys/arch/sparc/sparc/trap.c
index ab949248f87..85d15bb8db0 100644
--- a/sys/arch/sparc/sparc/trap.c
+++ b/sys/arch/sparc/sparc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.20 2000/01/27 20:14:11 art Exp $ */
+/* $OpenBSD: trap.c,v 1.21 2000/01/31 16:06:59 art Exp $ */
/* $NetBSD: trap.c,v 1.58 1997/09/12 08:55:01 pk Exp $ */
/*
@@ -859,7 +859,7 @@ mem_access_fault4m(type, sfsr, sfva, afsr, afva, tf)
*/
if ((afsr & AFSR_AFO) != 0 || type == T_STOREBUFFAULT ||
(type == T_DATAFAULT && !(sfsr & SFSR_FAV))) {
- memerr4m(type, sfsr, sfva, afsr, afva, tf);
+ (*cpuinfo.memerr)(type, sfsr, sfva, afsr, afva, tf);
/*
* If we get here, exit the trap handler and wait for the
* trap to re-occur.