wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 1 | /* |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 2 | * linux/arch/powerpc/kernel/traps.c |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
| 5 | * |
| 6 | * Modified by Cort Dougan (cort@cs.nmt.edu) |
| 7 | * and Paul Mackerras (paulus@cs.anu.edu.au) |
| 8 | * |
| 9 | * (C) Copyright 2000 |
| 10 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 11 | * |
| 12 | * See file CREDITS for list of people who contributed to this |
| 13 | * project. |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License as |
| 17 | * published by the Free Software Foundation; either version 2 of |
| 18 | * the License, or (at your option) any later version. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, write to the Free Software |
| 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 28 | * MA 02111-1307 USA |
| 29 | */ |
| 30 | |
| 31 | /* |
| 32 | * This file handles the architecture-dependent parts of hardware exceptions |
| 33 | */ |
| 34 | |
| 35 | #include <common.h> |
| 36 | #include <command.h> |
Stefan Roese | 6f6c26e | 2010-01-26 13:33:29 +0100 | [diff] [blame] | 37 | #include <kgdb.h> |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 38 | #include <asm/processor.h> |
| 39 | |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 42 | /* Returns 0 if exception not found and fixup otherwise. */ |
| 43 | extern unsigned long search_exception_table(unsigned long); |
| 44 | |
| 45 | /* THIS NEEDS CHANGING to use the board info structure. |
| 46 | */ |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 47 | #define END_OF_MEM (gd->bd->bi_memstart + gd->bd->bi_memsize) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 48 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 49 | static __inline__ unsigned long get_esr(void) |
| 50 | { |
| 51 | unsigned long val; |
| 52 | |
| 53 | #if defined(CONFIG_440) |
| 54 | asm volatile("mfspr %0, 0x03e" : "=r" (val) :); |
| 55 | #else |
| 56 | asm volatile("mfesr %0" : "=r" (val) :); |
| 57 | #endif |
| 58 | return val; |
| 59 | } |
| 60 | |
| 61 | #define ESR_MCI 0x80000000 |
| 62 | #define ESR_PIL 0x08000000 |
| 63 | #define ESR_PPR 0x04000000 |
| 64 | #define ESR_PTR 0x02000000 |
| 65 | #define ESR_DST 0x00800000 |
| 66 | #define ESR_DIZ 0x00400000 |
| 67 | #define ESR_U0F 0x00008000 |
| 68 | |
Jon Loeliger | 3a1ed1e | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 69 | #if defined(CONFIG_CMD_BEDBUG) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 70 | extern void do_bedbug_breakpoint(struct pt_regs *); |
| 71 | #endif |
| 72 | |
| 73 | /* |
| 74 | * Trap & Exception support |
| 75 | */ |
| 76 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 77 | static void print_backtrace(unsigned long *sp) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 78 | { |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 79 | int cnt = 0; |
| 80 | unsigned long i; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 81 | |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 82 | printf("Call backtrace: "); |
| 83 | while (sp) { |
| 84 | if ((uint)sp > END_OF_MEM) |
| 85 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 86 | |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 87 | i = sp[1]; |
| 88 | if (cnt++ % 7 == 0) |
| 89 | printf("\n"); |
| 90 | printf("%08lX ", i); |
| 91 | if (cnt > 32) break; |
| 92 | sp = (unsigned long *)*sp; |
| 93 | } |
| 94 | printf("\n"); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 97 | void show_regs(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 98 | { |
| 99 | int i; |
| 100 | |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 101 | printf("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx DEAR: %08lX\n", |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 102 | regs->nip, regs->xer, regs->link, regs, regs->trap, regs->dar); |
| 103 | printf("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n", |
| 104 | regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0, |
| 105 | regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0, |
| 106 | regs->msr&MSR_IR ? 1 : 0, |
| 107 | regs->msr&MSR_DR ? 1 : 0); |
| 108 | |
| 109 | printf("\n"); |
| 110 | for (i = 0; i < 32; i++) { |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 111 | if ((i % 8) == 0) { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 112 | printf("GPR%02d: ", i); |
| 113 | } |
| 114 | |
| 115 | printf("%08lX ", regs->gpr[i]); |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 116 | if ((i % 8) == 7) { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 117 | printf("\n"); |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 123 | static void _exception(int signr, struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 124 | { |
| 125 | show_regs(regs); |
| 126 | print_backtrace((unsigned long *)regs->gpr[1]); |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 127 | panic("Exception"); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 130 | void MachineCheckException(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 131 | { |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 132 | unsigned long fixup, val; |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 133 | #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
| 134 | u32 value2; |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 135 | int corr_ecc = 0; |
| 136 | int uncorr_ecc = 0; |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 137 | #endif |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 138 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 139 | if ((fixup = search_exception_table(regs->nip)) != 0) { |
| 140 | regs->nip = fixup; |
Grzegorz Bernacki | c924098 | 2007-07-31 18:51:48 +0200 | [diff] [blame] | 141 | val = mfspr(MCSR); |
| 142 | /* Clear MCSR */ |
Stefan Roese | 9ca8d79 | 2007-08-02 08:33:56 +0200 | [diff] [blame] | 143 | mtspr(SPRN_MCSR, val); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 144 | return; |
| 145 | } |
| 146 | |
Jon Loeliger | 3a1ed1e | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 147 | #if defined(CONFIG_CMD_KGDB) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 148 | if (debugger_exception_handler && (*debugger_exception_handler)(regs)) |
| 149 | return; |
| 150 | #endif |
| 151 | |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 152 | printf("Machine Check Exception.\n"); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 153 | printf("Caused by (from msr): "); |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 154 | printf("regs %p ", regs); |
| 155 | |
| 156 | val = get_esr(); |
| 157 | |
Grant Erickson | c821b5f | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 158 | #if !defined(CONFIG_440) && !defined(CONFIG_405EX) |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 159 | if (val& ESR_IMCP) { |
| 160 | printf("Instruction"); |
| 161 | mtspr(ESR, val & ~ESR_IMCP); |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 162 | } else { |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 163 | printf("Data"); |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 164 | } |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 165 | printf(" machine check.\n"); |
| 166 | |
Grant Erickson | c821b5f | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 167 | #elif defined(CONFIG_440) || defined(CONFIG_405EX) |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 168 | if (val& ESR_IMCP){ |
| 169 | printf("Instruction Synchronous Machine Check exception\n"); |
| 170 | mtspr(SPRN_ESR, val & ~ESR_IMCP); |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 171 | } else { |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 172 | val = mfspr(MCSR); |
| 173 | if (val & MCSR_IB) |
| 174 | printf("Instruction Read PLB Error\n"); |
Grant Erickson | c821b5f | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 175 | #if defined(CONFIG_440) |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 176 | if (val & MCSR_DRB) |
| 177 | printf("Data Read PLB Error\n"); |
| 178 | if (val & MCSR_DWB) |
| 179 | printf("Data Write PLB Error\n"); |
Grant Erickson | c821b5f | 2008-05-22 14:44:14 -0700 | [diff] [blame] | 180 | #else |
| 181 | if (val & MCSR_DB) |
| 182 | printf("Data PLB Error\n"); |
| 183 | #endif |
Grzegorz Bernacki | efa35cf | 2007-06-15 11:19:28 +0200 | [diff] [blame] | 184 | if (val & MCSR_TLBP) |
| 185 | printf("TLB Parity Error\n"); |
| 186 | if (val & MCSR_ICP){ |
| 187 | /*flush_instruction_cache(); */ |
| 188 | printf("I-Cache Parity Error\n"); |
| 189 | } |
| 190 | if (val & MCSR_DCSP) |
| 191 | printf("D-Cache Search Parity Error\n"); |
| 192 | if (val & MCSR_DCFP) |
| 193 | printf("D-Cache Flush Parity Error\n"); |
| 194 | if (val & MCSR_IMPE) |
| 195 | printf("Machine Check exception is imprecise\n"); |
| 196 | |
| 197 | /* Clear MCSR */ |
| 198 | mtspr(SPRN_MCSR, val); |
| 199 | } |
Stefan Roese | be24ef6 | 2010-07-21 19:06:26 +0200 | [diff] [blame] | 200 | |
| 201 | #if defined(CONFIG_DDR_ECC) && defined(CONFIG_SDRAM_PPC4xx_IBM_DDR2) |
| 202 | /* |
| 203 | * Read and print ECC status register/info: |
| 204 | * The faulting address is only known upon uncorrectable ECC |
| 205 | * errors. |
| 206 | */ |
| 207 | mfsdram(SDRAM_ECCES, val); |
| 208 | if (val & SDRAM_ECCES_CE) |
| 209 | printf("ECC: Correctable error\n"); |
| 210 | if (val & SDRAM_ECCES_UE) { |
| 211 | printf("ECC: Uncorrectable error at 0x%02x%08x\n", |
| 212 | mfdcr(SDRAM_ERRADDULL), mfdcr(SDRAM_ERRADDLLL)); |
| 213 | } |
| 214 | #endif /* CONFIG_DDR_ECC ... */ |
| 215 | |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 216 | #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX) |
| 217 | mfsdram(DDR0_00, val) ; |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 218 | printf("DDR0: DDR0_00 %lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 219 | val = (val >> 16) & 0xff; |
| 220 | if (val & 0x80) |
| 221 | printf("DDR0: At least one interrupt active\n"); |
| 222 | if (val & 0x40) |
| 223 | printf("DDR0: DRAM initialization complete.\n"); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 224 | if (val & 0x20) { |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 225 | printf("DDR0: Multiple uncorrectable ECC events.\n"); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 226 | uncorr_ecc = 1; |
| 227 | } |
| 228 | if (val & 0x10) { |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 229 | printf("DDR0: Single uncorrectable ECC event.\n"); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 230 | uncorr_ecc = 1; |
| 231 | } |
| 232 | if (val & 0x08) { |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 233 | printf("DDR0: Multiple correctable ECC events.\n"); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 234 | corr_ecc = 1; |
| 235 | } |
| 236 | if (val & 0x04) { |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 237 | printf("DDR0: Single correctable ECC event.\n"); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 238 | corr_ecc = 1; |
| 239 | } |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 240 | if (val & 0x02) |
| 241 | printf("Multiple accesses outside the defined" |
| 242 | " physical memory space detected\n"); |
| 243 | if (val & 0x01) |
| 244 | printf("DDR0: Single access outside the defined" |
| 245 | " physical memory space detected.\n"); |
| 246 | |
| 247 | mfsdram(DDR0_01, val); |
| 248 | val = (val >> 8) & 0x7; |
| 249 | switch (val ) { |
| 250 | case 0: |
| 251 | printf("DDR0: Write Out-of-Range command\n"); |
| 252 | break; |
| 253 | case 1: |
| 254 | printf("DDR0: Read Out-of-Range command\n"); |
| 255 | break; |
| 256 | case 2: |
| 257 | printf("DDR0: Masked write Out-of-Range command\n"); |
| 258 | break; |
| 259 | case 4: |
| 260 | printf("DDR0: Wrap write Out-of-Range command\n"); |
| 261 | break; |
| 262 | case 5: |
| 263 | printf("DDR0: Wrap read Out-of-Range command\n"); |
| 264 | break; |
| 265 | default: |
| 266 | mfsdram(DDR0_01, value2); |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 267 | printf("DDR0: No DDR0 error know 0x%lx %x\n", val, value2); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 268 | } |
| 269 | mfsdram(DDR0_23, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 270 | if (((val >> 16) & 0xff) && corr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 271 | printf("DDR0: Syndrome for correctable ECC event 0x%lx\n", |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 272 | (val >> 16) & 0xff); |
| 273 | mfsdram(DDR0_23, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 274 | if (((val >> 8) & 0xff) && uncorr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 275 | printf("DDR0: Syndrome for uncorrectable ECC event 0x%lx\n", |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 276 | (val >> 8) & 0xff); |
| 277 | mfsdram(DDR0_33, val); |
| 278 | if (val) |
| 279 | printf("DDR0: Address of command that caused an " |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 280 | "Out-of-Range interrupt %lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 281 | mfsdram(DDR0_34, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 282 | if (val && uncorr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 283 | printf("DDR0: Address of uncorrectable ECC event %lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 284 | mfsdram(DDR0_35, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 285 | if (val && uncorr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 286 | printf("DDR0: Address of uncorrectable ECC event %lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 287 | mfsdram(DDR0_36, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 288 | if (val && uncorr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 289 | printf("DDR0: Data of uncorrectable ECC event 0x%08lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 290 | mfsdram(DDR0_37, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 291 | if (val && uncorr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 292 | printf("DDR0: Data of uncorrectable ECC event 0x%08lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 293 | mfsdram(DDR0_38, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 294 | if (val && corr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 295 | printf("DDR0: Address of correctable ECC event %lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 296 | mfsdram(DDR0_39, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 297 | if (val && corr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 298 | printf("DDR0: Address of correctable ECC event %lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 299 | mfsdram(DDR0_40, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 300 | if (val && corr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 301 | printf("DDR0: Data of correctable ECC event 0x%08lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 302 | mfsdram(DDR0_41, val); |
Stefan Roese | 27a528f | 2007-07-30 11:04:57 +0200 | [diff] [blame] | 303 | if (val && corr_ecc) |
Stefan Roese | b002144 | 2008-07-10 09:58:06 +0200 | [diff] [blame] | 304 | printf("DDR0: Data of correctable ECC event 0x%08lx\n", val); |
Niklaus Giger | a1bd620 | 2007-06-25 17:03:13 +0200 | [diff] [blame] | 305 | #endif /* CONFIG_440EPX */ |
| 306 | #endif /* CONFIG_440 */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 307 | show_regs(regs); |
| 308 | print_backtrace((unsigned long *)regs->gpr[1]); |
| 309 | panic("machine check"); |
| 310 | } |
| 311 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 312 | void AlignmentException(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 313 | { |
Jon Loeliger | 3a1ed1e | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 314 | #if defined(CONFIG_CMD_KGDB) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 315 | if (debugger_exception_handler && (*debugger_exception_handler)(regs)) |
| 316 | return; |
| 317 | #endif |
| 318 | |
| 319 | show_regs(regs); |
| 320 | print_backtrace((unsigned long *)regs->gpr[1]); |
| 321 | panic("Alignment Exception"); |
| 322 | } |
| 323 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 324 | void ProgramCheckException(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 325 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 326 | long esr_val; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 327 | |
Jon Loeliger | 3a1ed1e | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 328 | #if defined(CONFIG_CMD_KGDB) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 329 | if (debugger_exception_handler && (*debugger_exception_handler)(regs)) |
| 330 | return; |
| 331 | #endif |
| 332 | |
| 333 | show_regs(regs); |
| 334 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 335 | esr_val = get_esr(); |
| 336 | if( esr_val & ESR_PIL ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 337 | printf( "** Illegal Instruction **\n" ); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 338 | else if( esr_val & ESR_PPR ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 339 | printf( "** Privileged Instruction **\n" ); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 340 | else if( esr_val & ESR_PTR ) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 341 | printf( "** Trap Instruction **\n" ); |
| 342 | |
| 343 | print_backtrace((unsigned long *)regs->gpr[1]); |
| 344 | panic("Program Check Exception"); |
| 345 | } |
| 346 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 347 | void DecrementerPITException(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 348 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 349 | /* |
| 350 | * Reset PIT interrupt |
| 351 | */ |
Stefan Roese | f472069 | 2010-10-04 11:09:40 +0200 | [diff] [blame] | 352 | mtspr(SPRN_TSR, 0x08000000); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 353 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 354 | /* |
| 355 | * Call timer_interrupt routine in interrupts.c |
| 356 | */ |
| 357 | timer_interrupt(NULL); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 361 | void UnknownException(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 362 | { |
Jon Loeliger | 3a1ed1e | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 363 | #if defined(CONFIG_CMD_KGDB) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 364 | if (debugger_exception_handler && (*debugger_exception_handler)(regs)) |
| 365 | return; |
| 366 | #endif |
| 367 | |
| 368 | printf("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", |
| 369 | regs->nip, regs->msr, regs->trap); |
| 370 | _exception(0, regs); |
| 371 | } |
| 372 | |
Kim Phillips | 20051f2 | 2012-10-29 13:34:29 +0000 | [diff] [blame] | 373 | void DebugException(struct pt_regs *regs) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 374 | { |
| 375 | printf("Debugger trap at @ %lx\n", regs->nip ); |
| 376 | show_regs(regs); |
Jon Loeliger | 3a1ed1e | 2007-07-09 18:57:22 -0500 | [diff] [blame] | 377 | #if defined(CONFIG_CMD_BEDBUG) |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 378 | do_bedbug_breakpoint( regs ); |
| 379 | #endif |
| 380 | } |
| 381 | |
| 382 | /* Probe an address by reading. If not present, return -1, otherwise |
| 383 | * return 0. |
| 384 | */ |
| 385 | int |
| 386 | addr_probe(uint *addr) |
| 387 | { |
| 388 | #if 0 |
| 389 | int retval; |
| 390 | |
| 391 | __asm__ __volatile__( \ |
| 392 | "1: lwz %0,0(%1)\n" \ |
Wolfgang Denk | 83b4cfa | 2007-06-20 18:14:24 +0200 | [diff] [blame] | 393 | " eieio\n" \ |
| 394 | " li %0,0\n" \ |
| 395 | "2:\n" \ |
| 396 | ".section .fixup,\"ax\"\n" \ |
| 397 | "3: li %0,-1\n" \ |
| 398 | " b 2b\n" \ |
| 399 | ".section __ex_table,\"a\"\n" \ |
| 400 | " .align 2\n" \ |
| 401 | " .long 1b,3b\n" \ |
| 402 | ".text" \ |
| 403 | : "=r" (retval) : "r"(addr)); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 404 | |
| 405 | return (retval); |
| 406 | #endif |
| 407 | return 0; |
| 408 | } |