xref: /netbsd-src/sys/arch/pmax/pmax/memc_3max.c (revision 95d875fb90b1458e4f1de6950286ddcd6644bc61)
1 /*	$NetBSD: memc_3max.c,v 1.9 1999/08/16 13:13:01 simonb Exp $	*/
2 
3 /*
4  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by Jonathan Stone for
17  *      the NetBSD Project.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
34 
35 __KERNEL_RCSID(0, "$NetBSD: memc_3max.c,v 1.9 1999/08/16 13:13:01 simonb Exp $");
36 
37 #include <sys/types.h>
38 #include <sys/systm.h>
39 #include <sys/param.h>
40 
41 #include <machine/locore.h>		/* wbflush() */
42 
43 #include <pmax/pmax/kn02.h>	/* error-register defs copied into kn03.h */
44 #include <pmax/pmax/memc.h>
45 
46 /*
47  * the 3max and 3maxplus have compatible memory subsystems;
48  * we handle them both here.
49  */
50 
51 
52 void
53 dec_mtasic_err(erradr, errsyn, bnk32m)
54 	u_int32_t erradr, errsyn, bnk32m;
55 {
56 	u_int32_t physadr;
57 	int module;
58 	extern int physmem;
59 
60 	if (!(erradr & KN02_ERR_VALID))
61 		return;
62 	/* extract the physical word address and compensate for pipelining */
63 	physadr = erradr & KN02_ERR_ADDRESS;
64 	if (!(erradr & KN02_ERR_WRITE))
65 		physadr = (physadr & ~0xfff) | ((physadr & 0xfff) - 5);
66 	physadr <<= 2;
67 	printf("%s memory %s %s error at 0x%08x",
68 		(erradr & KN02_ERR_CPU) ? "CPU" : "DMA",
69 		(erradr & KN02_ERR_WRITE) ? "write" : "read",
70 		(erradr & KN02_ERR_ECCERR) ? "ECC" : "timeout",
71 		physadr);
72 	if (physadr <= ctob(physmem)) {
73 		if (bnk32m != 0)	/* 32MB modules? */
74 			module = physadr / ( 32 * 1024 * 1024);
75 		else
76 			module = physadr / (  8 * 1024 * 1024);
77 		printf(" module %d", module);
78 	}
79 	else {
80 		/* ECC error didn't occur in RAM */
81 		printf(" (no RAM)");
82 	}
83 	printf("\n");
84 	if (erradr & KN02_ERR_ECCERR) {
85 		u_int32_t errsyn_value = *(u_int32_t *)errsyn;
86 		*(u_int32_t *)errsyn = 0;
87 		wbflush();
88 		printf("   ECC 0x%08x\n", errsyn_value);
89 
90 		/* check for a corrected, single bit, read error */
91 		if (!(erradr & KN02_ERR_WRITE)) {
92 			if (physadr & 0x4) {
93 				/* check high word */
94 				if (errsyn_value & KN02_ECC_SNGHI)
95 					return;
96 			} else {
97 				/* check low word */
98 				if (errsyn_value & KN02_ECC_SNGLO)
99 					return;
100 			}
101 		}
102 		printf("\n");
103 	}
104 	else
105 		printf("\n");
106 	panic("panic(\"Mem error interrupt\");\n");
107 }
108 
109 /*
110  * Xxx noncontig memory probing with mixed-sized memory  boards
111  * XXX on 3max (kn02) or 3maxplus (kn03) belongs here.
112  */
113 
114 /*
115  * Xxx any support for NVRAM (PrestoServe) modules in
116  * XXX on 3max (kn02) or 3maxplus (kn03) memory slots probably belongs here,
117  * since we need to not probe it as normal RAM.
118  */
119