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