Home | History | Annotate | Line # | Download | only in pmax
      1 /*	$NetBSD: memc_3max.c,v 1.17 2011/07/09 17:32:31 matt 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.17 2011/07/09 17:32:31 matt Exp $");
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 
     40 #include <mips/locore.h>		/* wbflush() */
     41 
     42 #include <pmax/pmax/kn02.h>	/* error-register defs copied into kn03.h */
     43 #include <pmax/pmax/memc.h>
     44 
     45 /*
     46  * the 3max and 3maxplus have compatible memory subsystems;
     47  * we handle them both here.
     48  */
     49 
     50 
     51 void
     52 dec_mtasic_err(uint32_t erradr, vaddr_t errsyn, uint32_t bnk32m)
     53 {
     54 	uint32_t physadr;
     55 	int module;
     56 
     57 	if (!(erradr & KN02_ERR_VALID))
     58 		return;
     59 	/* extract the physical word address and compensate for pipelining */
     60 	physadr = erradr & KN02_ERR_ADDRESS;
     61 	if (!(erradr & KN02_ERR_WRITE))
     62 		physadr = (physadr & ~0xfff) | ((physadr & 0xfff) - 5);
     63 	physadr <<= 2;
     64 	printf("%s memory %s %s error at 0x%08x",
     65 		(erradr & KN02_ERR_CPU) ? "CPU" : "DMA",
     66 		(erradr & KN02_ERR_WRITE) ? "write" : "read",
     67 		(erradr & KN02_ERR_ECCERR) ? "ECC" : "timeout",
     68 		physadr);
     69 	if (physadr <= ctob(physmem)) {
     70 		if (bnk32m != 0)	/* 32MB modules? */
     71 			module = physadr / ( 32 * 1024 * 1024);
     72 		else
     73 			module = physadr / (  8 * 1024 * 1024);
     74 		printf(" module %d", module);
     75 	}
     76 	else {
     77 		/* ECC error didn't occur in RAM */
     78 		printf(" (no RAM)");
     79 	}
     80 	printf("\n");
     81 	if (erradr & KN02_ERR_ECCERR) {
     82 		uint32_t errsyn_value = *(uint32_t *)errsyn;
     83 		*(uint32_t *)errsyn = 0;
     84 		wbflush();
     85 		printf("   ECC 0x%08x\n", errsyn_value);
     86 
     87 		/* check for a corrected, single bit, read error */
     88 		if (!(erradr & KN02_ERR_WRITE)) {
     89 			if (physadr & 0x4) {
     90 				/* check high word */
     91 				if (errsyn_value & KN02_ECC_SNGHI)
     92 					return;
     93 			} else {
     94 				/* check low word */
     95 				if (errsyn_value & KN02_ECC_SNGLO)
     96 					return;
     97 			}
     98 		}
     99 		printf("\n");
    100 	}
    101 	else
    102 		printf("\n");
    103 	panic("Mem error interrupt");
    104 }
    105 
    106 /*
    107  * Xxx noncontig memory probing with mixed-sized memory  boards
    108  * XXX on 3max (kn02) or 3maxplus (kn03) belongs here.
    109  */
    110 
    111 /*
    112  * Xxx any support for NVRAM (PrestoServe) modules in
    113  * XXX on 3max (kn02) or 3maxplus (kn03) memory slots probably belongs here,
    114  * since we need to not probe it as normal RAM.
    115  */
    116