|
| 1 | +/* |
| 2 | + * ip22-berr.c: Bus error handling. |
| 3 | + * |
| 4 | + * Copyright (C) 2002 Ladislav Michl |
| 5 | + */ |
| 6 | + |
| 7 | +#include <linux/init.h> |
| 8 | +#include <linux/kernel.h> |
| 9 | +#include <linux/sched.h> |
| 10 | + |
| 11 | +#include <asm/addrspace.h> |
| 12 | +#include <asm/system.h> |
| 13 | +#include <asm/traps.h> |
| 14 | +#include <asm/branch.h> |
| 15 | +#include <asm/sgi/mc.h> |
| 16 | +#include <asm/sgi/hpc3.h> |
| 17 | + |
| 18 | + |
| 19 | +static unsigned int cpu_err_stat; /* Status reg for CPU */ |
| 20 | +static unsigned int gio_err_stat; /* Status reg for GIO */ |
| 21 | +static unsigned int cpu_err_addr; /* Error address reg for CPU */ |
| 22 | +static unsigned int gio_err_addr; /* Error address reg for GIO */ |
| 23 | + |
| 24 | +static void save_and_clear_buserr(void) |
| 25 | +{ |
| 26 | + /* save memory controler's error status registers */ |
| 27 | + cpu_err_addr = sgimc->cerr; |
| 28 | + cpu_err_stat = sgimc->cstat; |
| 29 | + gio_err_addr = sgimc->gerr; |
| 30 | + gio_err_stat = sgimc->gstat; |
| 31 | + |
| 32 | + sgimc->cstat = sgimc->gstat = 0; |
| 33 | +} |
| 34 | + |
| 35 | +#define GIO_ERRMASK 0xff00 |
| 36 | +#define CPU_ERRMASK 0x3f00 |
| 37 | + |
| 38 | +static void print_buserr(void) |
| 39 | +{ |
| 40 | + if (cpu_err_stat & CPU_ERRMASK) |
| 41 | + printk(KERN_ALERT "CPU error 0x%x<%s%s%s%s%s%s> @ 0x%08x\n", |
| 42 | + cpu_err_stat, |
| 43 | + cpu_err_stat & SGIMC_CSTAT_RD ? "RD " : "", |
| 44 | + cpu_err_stat & SGIMC_CSTAT_PAR ? "PAR " : "", |
| 45 | + cpu_err_stat & SGIMC_CSTAT_ADDR ? "ADDR " : "", |
| 46 | + cpu_err_stat & SGIMC_CSTAT_SYSAD_PAR ? "SYSAD " : "", |
| 47 | + cpu_err_stat & SGIMC_CSTAT_SYSCMD_PAR ? "SYSCMD " : "", |
| 48 | + cpu_err_stat & SGIMC_CSTAT_BAD_DATA ? "BAD_DATA " : "", |
| 49 | + cpu_err_addr); |
| 50 | + if (gio_err_stat & GIO_ERRMASK) |
| 51 | + printk(KERN_ALERT "GIO error 0x%x:<%s%s%s%s%s%s%s%s> @ 0x08%x\n", |
| 52 | + gio_err_stat, |
| 53 | + gio_err_stat & SGIMC_GSTAT_RD ? "RD " : "", |
| 54 | + gio_err_stat & SGIMC_GSTAT_WR ? "WR " : "", |
| 55 | + gio_err_stat & SGIMC_GSTAT_TIME ? "TIME " : "", |
| 56 | + gio_err_stat & SGIMC_GSTAT_PROM ? "PROM " : "", |
| 57 | + gio_err_stat & SGIMC_GSTAT_ADDR ? "ADDR " : "", |
| 58 | + gio_err_stat & SGIMC_GSTAT_BC ? "BC " : "", |
| 59 | + gio_err_stat & SGIMC_GSTAT_PIO_RD ? "PIO_RD " : "", |
| 60 | + gio_err_stat & SGIMC_GSTAT_PIO_WR ? "PIO_WR " : "", |
| 61 | + gio_err_addr); |
| 62 | +} |
| 63 | + |
| 64 | +/* |
| 65 | + * MC sends an interrupt whenever bus or parity errors occur. In addition, |
| 66 | + * if the error happened during a CPU read, it also asserts the bus error |
| 67 | + * pin on the R4K. Code in bus error handler save the MC bus error registers |
| 68 | + * and then clear the interrupt when this happens. |
| 69 | + */ |
| 70 | + |
| 71 | +void ip22_be_interrupt(int irq, struct pt_regs *regs) |
| 72 | +{ |
| 73 | + save_and_clear_buserr(); |
| 74 | + print_buserr(); |
| 75 | + panic("Bus error, epc == %08lx, ra == %08lx", |
| 76 | + regs->cp0_epc, regs->regs[31]); |
| 77 | +} |
| 78 | + |
| 79 | +int ip22_be_handler(struct pt_regs *regs, int is_fixup) |
| 80 | +{ |
| 81 | + save_and_clear_buserr(); |
| 82 | + if (is_fixup) |
| 83 | + return MIPS_BE_FIXUP; |
| 84 | + print_buserr(); |
| 85 | + return MIPS_BE_FATAL; |
| 86 | +} |
| 87 | + |
| 88 | +void __init ip22_be_init(void) |
| 89 | +{ |
| 90 | + board_be_handler = ip22_be_handler; |
| 91 | +} |
0 commit comments