Module Name: src Committed By: hans Date: Thu Oct 7 19:55:02 UTC 2010
Modified Files: src/sys/arch/alpha/alpha: dec_6600.c src/sys/arch/alpha/include: alpha_cpu.h logout.h src/sys/arch/alpha/pci: tsc.c tsp_pci.c tsreg.h tsvar.h Log Message: Enable Pchip and Cchip error interrupts (machine checks) on DEC 6600 systems. Add some basic pretty-printing for those errors. Tested on a DS20. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/alpha/dec_6600.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/alpha/include/alpha_cpu.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/include/logout.h cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/pci/tsc.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/pci/tsp_pci.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/pci/tsreg.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/pci/tsvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/alpha/alpha/dec_6600.c diff -u src/sys/arch/alpha/alpha/dec_6600.c:1.29 src/sys/arch/alpha/alpha/dec_6600.c:1.30 --- src/sys/arch/alpha/alpha/dec_6600.c:1.29 Mon Sep 14 02:46:29 2009 +++ src/sys/arch/alpha/alpha/dec_6600.c Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: dec_6600.c,v 1.29 2009/09/14 02:46:29 mhitch Exp $ */ +/* $NetBSD: dec_6600.c,v 1.30 2010/10/07 19:55:02 hans Exp $ */ /* * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: dec_6600.c,v 1.29 2009/09/14 02:46:29 mhitch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dec_6600.c,v 1.30 2010/10/07 19:55:02 hans Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -44,6 +44,8 @@ #include <machine/autoconf.h> #include <machine/cpuconf.h> #include <machine/bus.h> +#include <machine/alpha.h> +#include <machine/logout.h> #include <dev/ic/comreg.h> #include <dev/ic/comvar.h> @@ -83,6 +85,10 @@ void dec_6600_init(void); static void dec_6600_cons_init(void); static void dec_6600_device_register(struct device *, void *); +static void dec_6600_mcheck(unsigned long, struct ev6_logout_area *); +static void dec_6600_mcheck_sys(unsigned int, struct ev6_logout_area *); +static void dec_6600_mcheck_handler(unsigned long, struct trapframe *, + unsigned long, unsigned long); #ifdef KGDB #include <machine/db_machdep.h> @@ -107,8 +113,11 @@ platform.iobus = "tsc"; platform.cons_init = dec_6600_cons_init; platform.device_register = dec_6600_device_register; - STQP(TS_C_DIM0) = 0UL; - STQP(TS_C_DIM1) = 0UL; + platform.mcheck_handler = dec_6600_mcheck_handler; + + /* enable Cchip and Pchip error interrupts */ + STQP(TS_C_DIM0) = 0xe000000000000000; + STQP(TS_C_DIM1) = 0xe000000000000000; } static void @@ -362,3 +371,85 @@ found = 1; } } + + +static void +dec_6600_mcheck(unsigned long vector, struct ev6_logout_area *la) +{ + const char *t = "Unknown", *c = ""; + + if (vector == ALPHA_SYS_ERROR || vector == ALPHA_PROC_ERROR) + c = " Correctable"; + + switch (vector) { + case ALPHA_SYS_ERROR: + case ALPHA_SYS_MCHECK: + t = "System"; + break; + + case ALPHA_PROC_ERROR: + case ALPHA_PROC_MCHECK: + t = "Processor"; + break; + + case ALPHA_ENV_MCHECK: + t = "Environmental"; + break; + } + + printf("\n%s%s Machine Check (%lx): " + "Rev 0x%x, Code 0x%x, Flags 0x%x\n\n", + t, c, vector, la->mchk_rev, la->mchk_code, la->la.la_flags); +} + +static void +dec_6600_mcheck_sys(unsigned int indent, struct ev6_logout_area *la) +{ + struct ev6_logout_sys *ls = + (struct ev6_logout_sys *)ALPHA_LOGOUT_SYSTEM_AREA(&la->la); + +#define FMT "%-30s = 0x%016lx\n" + + IPRINTF(indent, FMT, "Software Error Summary Flags", ls->flags); + + IPRINTF(indent, FMT, "CPU Device Interrupt Requests", ls->dir); + tsc_print_dir(indent + 1, ls->dir); + + IPRINTF(indent, FMT, "Cchip Miscellaneous Register", ls->misc); + tsc_print_misc(indent + 1, ls->misc); + + IPRINTF(indent, FMT, "Pchip 0 Error Register", ls->p0_error); + if (ls->flags & 0x5) + tsp_print_error(indent + 1, ls->p0_error); + + IPRINTF(indent, FMT, "Pchip 1 Error Register", ls->p1_error); + if (ls->flags & 0x6) + tsp_print_error(indent + 1, ls->p1_error); +} + +static void +dec_6600_mcheck_handler(unsigned long mces, struct trapframe *framep, + unsigned long vector, unsigned long param) +{ + struct mchkinfo *mcp; + struct ev6_logout_area *la = (struct ev6_logout_area *)param; + + /* + * If we expected a machine check, just go handle it in common code. + */ + mcp = &curcpu()->ci_mcinfo; + if (mcp->mc_expected) + machine_check(mces, framep, vector, param); + + dec_6600_mcheck(vector, la); + + switch (vector) { + case ALPHA_SYS_ERROR: + case ALPHA_SYS_MCHECK: + dec_6600_mcheck_sys(1, la); + break; + + } + + machine_check(mces, framep, vector, param); +} Index: src/sys/arch/alpha/include/alpha_cpu.h diff -u src/sys/arch/alpha/include/alpha_cpu.h:1.48 src/sys/arch/alpha/include/alpha_cpu.h:1.49 --- src/sys/arch/alpha/include/alpha_cpu.h:1.48 Thu Feb 16 20:17:13 2006 +++ src/sys/arch/alpha/include/alpha_cpu.h Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: alpha_cpu.h,v 1.48 2006/02/16 20:17:13 perry Exp $ */ +/* $NetBSD: alpha_cpu.h,v 1.49 2010/10/07 19:55:02 hans Exp $ */ /* * Copyright (c) 1996 Carnegie-Mellon University. @@ -183,6 +183,7 @@ #define ALPHA_PROC_ERROR 0x630 /* Processor correctable error */ #define ALPHA_SYS_MCHECK 0x660 /* System machine check */ #define ALPHA_PROC_MCHECK 0x670 /* Processor machine check */ +#define ALPHA_ENV_MCHECK 0x680 /* Environmental error */ /* * Virtual Memory Management definitions [OSF/1 PALcode Specific] Index: src/sys/arch/alpha/include/logout.h diff -u src/sys/arch/alpha/include/logout.h:1.6 src/sys/arch/alpha/include/logout.h:1.7 --- src/sys/arch/alpha/include/logout.h:1.6 Sun Dec 11 12:16:16 2005 +++ src/sys/arch/alpha/include/logout.h Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: logout.h,v 1.6 2005/12/11 12:16:16 christos Exp $ */ +/* $NetBSD: logout.h,v 1.7 2010/10/07 19:55:02 hans Exp $ */ /* * Copyright (c) 1998 by Matthew Jacob @@ -262,3 +262,41 @@ #ifdef _KERNEL extern void ev5_logout_print(mc_hdr_ev5 *, mc_uc_ev5 *); #endif + +/* + * EV6/67 specific Machine Check logout definitions + * from DS20E Service Guide, EK-K8F6W-SV. A01 + */ + +struct ev6_logout_area { + struct alpha_logout_area la; + uint32_t mchk_code; + uint32_t mchk_rev; +}; + +struct ev6_logout_proc { + uint64_t i_stat; + uint64_t dc_stat; + uint64_t c_addr; + uint64_t c_syndrome1; + uint64_t c_syndrome0; + uint64_t c_stat; + uint64_t c_sts; + uint64_t mm_stat; + uint64_t exc_addr; + uint64_t ier_cm; + uint64_t isum; + uint64_t _r; + uint64_t pal_base; + uint64_t i_ctl; + uint64_t pctx; +}; + +struct ev6_logout_sys { + uint64_t flags; + uint64_t dir; + uint64_t misc; + uint64_t p0_error; + uint64_t p1_error; +}; + Index: src/sys/arch/alpha/pci/tsc.c diff -u src/sys/arch/alpha/pci/tsc.c:1.17 src/sys/arch/alpha/pci/tsc.c:1.18 --- src/sys/arch/alpha/pci/tsc.c:1.17 Thu Apr 15 03:09:12 2010 +++ src/sys/arch/alpha/pci/tsc.c Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: tsc.c,v 1.17 2010/04/15 03:09:12 jakllsch Exp $ */ +/* $NetBSD: tsc.c,v 1.18 2010/10/07 19:55:02 hans Exp $ */ /*- * Copyright (c) 1999 by Ross Harvey. All rights reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.17 2010/04/15 03:09:12 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.18 2010/10/07 19:55:02 hans Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -244,3 +244,32 @@ return (0); } + +void +tsc_print_dir(unsigned int indent, unsigned long dir) +{ + char buf[60]; + + snprintb(buf, 60, + "\177\20" + "b\77Internal Cchip asynchronous error\0" + "b\76Pchip 0 error\0" + "b\75Pchip 1 error\0" + "b\74Pchip 2 error\0" + "b\73Pchip 3 error\0", + dir); + IPRINTF(indent, "DIR = %s\n", buf); +} + +void +tsc_print_misc(unsigned int indent, unsigned long misc) +{ + unsigned long tmp = MISC_NXM_SRC(misc); + + if (!MISC_NXM(misc)) + return; + + IPRINTF(indent, "NXM address detected\n"); + IPRINTF(indent, "NXM source = %s %lu\n", + tmp <= 3 ? "CPU" : "Pchip", tmp <= 3 ? tmp : tmp - 4); +} Index: src/sys/arch/alpha/pci/tsp_pci.c diff -u src/sys/arch/alpha/pci/tsp_pci.c:1.6 src/sys/arch/alpha/pci/tsp_pci.c:1.7 --- src/sys/arch/alpha/pci/tsp_pci.c:1.6 Sat Mar 14 21:04:02 2009 +++ src/sys/arch/alpha/pci/tsp_pci.c Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: tsp_pci.c,v 1.6 2009/03/14 21:04:02 dsl Exp $ */ +/* $NetBSD: tsp_pci.c,v 1.7 2010/10/07 19:55:02 hans Exp $ */ /*- * Copyright (c) 1999 by Ross Harvey. All rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tsp_pci.c,v 1.6 2009/03/14 21:04:02 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tsp_pci.c,v 1.7 2010/10/07 19:55:02 hans Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -130,3 +130,56 @@ *datap = data; alpha_mb(); } + +#define NTH_STR(n, ...) ((const char *[]){ __VA_ARGS__ }[n]) + +void +tsp_print_error(unsigned int indent, unsigned long p_error) +{ + char buf[40]; + + if (PER_INV(p_error)) { + IPRINTF(indent, "data invalid\n"); + return; + } + + if (!PER_ERR(p_error)) + return; + + snprintb(buf, 40, + "\177\20" + "b\0Error lost\0" + "b\1PCI SERR#\0" + "b\2PCI PERR#\0" + "b\3Delayed completion retry timeout\0" + "b\4Invalid S/G page table entry\0" + "b\5Address parity error\0" + "b\6Target abort\0" + "b\7PCI read data parity error\0" + "b\10no PCI DEVSEL#\0" + "b\11unknown\0" + "b\12Uncorrectable ECC\0" + "b\13Correctable ECC\0", + PER_ERR(p_error)); + IPRINTF(indent, "error = %s\n", buf); + + if (PER_ECC(p_error)) { + IPRINTF(indent, "address = 0x%09lx\n", PER_SADR(p_error)); + IPRINTF(indent, "command = 0x%lx<%s>\n", PER_CMD(p_error), + NTH_STR(PER_CMD(p_error) & 0x3, + "DMA read", "DMA RMW", "?", "S/G read")); + IPRINTF(indent, "syndrome = 0x%02lx\n", PER_SYN(p_error)); + } else { + IPRINTF(indent, "address = 0x%08lx, 0x%lx<%s>\n", + PER_PADR(p_error), PER_TRNS(p_error), + NTH_STR(PER_TRNS(p_error), "No DAC", "DAC SG Win3", + "Monster Window", "Monster Window")); + IPRINTF(indent, "command = 0x%lx<%s>\n", PER_CMD(p_error), + NTH_STR(PER_CMD(p_error), + "PCI IACK", "PCI special cycle", + "PCI I/O read", "PCI I/O write", "?", + "PCI PTP write", "PCI memory read", + "PCI memory write", "PCI CSR write", + "?", "?", "?", "?", "?", "?", "?")); + } +} Index: src/sys/arch/alpha/pci/tsreg.h diff -u src/sys/arch/alpha/pci/tsreg.h:1.3 src/sys/arch/alpha/pci/tsreg.h:1.4 --- src/sys/arch/alpha/pci/tsreg.h:1.3 Thu Jul 5 08:38:24 2001 +++ src/sys/arch/alpha/pci/tsreg.h Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: tsreg.h,v 1.3 2001/07/05 08:38:24 toshii Exp $ */ +/* $NetBSD: tsreg.h,v 1.4 2010/10/07 19:55:02 hans Exp $ */ /*- * Copyright (c) 1999 by Ross Harvey. All rights reserved. @@ -89,6 +89,8 @@ #define TS_C_MISC 0x101##a000##0080UL /* Miscellaneous Register */ +# define MISC_NXM(r) TSFIELD((r), 28, 1) +# define MISC_NXM_SRC(r) TSFIELD((r), 29, 3) # define MISC_REV(r) TSFIELD((r), 39, 8) #define TS_C_MPD 0x101##a000##00c0UL @@ -158,6 +160,15 @@ /* reserved 0x0380 */ #define P_PERROR 0x03c0 +# define PER_ERR(r) TSFIELD((r), 0, 12) +# define PER_ECC(r) TSFIELD((r), 10, 2) +# define PER_SADR(r) TSFIELD((r), 16, 34) +# define PER_PADR(r) (TSFIELD((r), 18, 32) << 2) +# define PER_TRNS(r) TSFIELD((r), 16, 2) +# define PER_INV(r) TSFIELD((r), 51, 1) +# define PER_CMD(r) TSFIELD((r), 52, 4) +# define PER_SYN(r) TSFIELD((r), 56, 8) + #define P_PERRMASK 0x0400 #define P_PERRSET 0x0440 #define P_TLBIV 0x0480 Index: src/sys/arch/alpha/pci/tsvar.h diff -u src/sys/arch/alpha/pci/tsvar.h:1.8 src/sys/arch/alpha/pci/tsvar.h:1.9 --- src/sys/arch/alpha/pci/tsvar.h:1.8 Thu Apr 15 03:09:12 2010 +++ src/sys/arch/alpha/pci/tsvar.h Thu Oct 7 19:55:02 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: tsvar.h,v 1.8 2010/04/15 03:09:12 jakllsch Exp $ */ +/* $NetBSD: tsvar.h,v 1.9 2010/10/07 19:55:02 hans Exp $ */ /*- * Copyright (c) 1999 by Ross Harvey. All rights reserved. @@ -77,3 +77,9 @@ void tsp_bus_mem_init(bus_space_tag_t, void *); void tsp_bus_mem_init2(bus_space_tag_t, void *); + +void tsp_print_error(unsigned int, unsigned long); +void tsc_print_misc(unsigned int, unsigned long); +void tsc_print_dir(unsigned int, unsigned long); + +#define IPRINTF(i, f, ...) printf("%*s" f, i * 4, "", ##__VA_ARGS__)