Commit | Line | Data |
---|---|---|
b920de1b DH |
1 | /* MN10300 Exception handling |
2 | * | |
3 | * Copyright (C) 2007 Matsushita Electric Industrial Co., Ltd. | |
4 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. | |
5 | * Modified by David Howells (dhowells@redhat.com) | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public Licence | |
9 | * as published by the Free Software Foundation; either version | |
10 | * 2 of the Licence, or (at your option) any later version. | |
11 | */ | |
12 | #include <linux/sched.h> | |
13 | #include <linux/kernel.h> | |
14 | #include <linux/string.h> | |
15 | #include <linux/errno.h> | |
16 | #include <linux/ptrace.h> | |
17 | #include <linux/timer.h> | |
18 | #include <linux/mm.h> | |
19 | #include <linux/smp.h> | |
20 | #include <linux/smp_lock.h> | |
21 | #include <linux/init.h> | |
22 | #include <linux/delay.h> | |
23 | #include <linux/spinlock.h> | |
24 | #include <linux/interrupt.h> | |
25 | #include <linux/kallsyms.h> | |
26 | #include <linux/pci.h> | |
27 | #include <linux/kdebug.h> | |
28 | #include <linux/bug.h> | |
29 | #include <linux/irq.h> | |
30 | #include <asm/processor.h> | |
31 | #include <asm/system.h> | |
32 | #include <asm/uaccess.h> | |
33 | #include <asm/io.h> | |
34 | #include <asm/atomic.h> | |
35 | #include <asm/smp.h> | |
36 | #include <asm/pgalloc.h> | |
37 | #include <asm/cacheflush.h> | |
38 | #include <asm/cpu-regs.h> | |
39 | #include <asm/busctl-regs.h> | |
2f2a2132 | 40 | #include <unit/leds.h> |
b920de1b DH |
41 | #include <asm/fpu.h> |
42 | #include <asm/gdb-stub.h> | |
43 | #include <asm/sections.h> | |
44 | ||
45 | #if (CONFIG_INTERRUPT_VECTOR_BASE & 0xffffff) | |
46 | #error "INTERRUPT_VECTOR_BASE not aligned to 16MiB boundary!" | |
47 | #endif | |
48 | ||
49 | struct pt_regs *__frame; /* current frame pointer */ | |
50 | EXPORT_SYMBOL(__frame); | |
51 | ||
52 | int kstack_depth_to_print = 24; | |
53 | ||
54 | spinlock_t die_lock = __SPIN_LOCK_UNLOCKED(die_lock); | |
55 | ||
56 | ATOMIC_NOTIFIER_HEAD(mn10300_die_chain); | |
57 | ||
58 | /* | |
59 | * These constants are for searching for possible module text | |
60 | * segments. MODULE_RANGE is a guess of how much space is likely | |
61 | * to be vmalloced. | |
62 | */ | |
63 | #define MODULE_RANGE (8 * 1024 * 1024) | |
64 | ||
65 | #define DO_ERROR(signr, prologue, str, name) \ | |
66 | asmlinkage void name(struct pt_regs *regs, u32 intcode) \ | |
67 | { \ | |
68 | prologue; \ | |
69 | if (die_if_no_fixup(str, regs, intcode)) \ | |
70 | return; \ | |
71 | force_sig(signr, current); \ | |
72 | } | |
73 | ||
74 | #define DO_EINFO(signr, prologue, str, name, sicode) \ | |
75 | asmlinkage void name(struct pt_regs *regs, u32 intcode) \ | |
76 | { \ | |
77 | siginfo_t info; \ | |
78 | prologue; \ | |
79 | if (die_if_no_fixup(str, regs, intcode)) \ | |
80 | return; \ | |
81 | info.si_signo = signr; \ | |
82 | if (signr == SIGILL && sicode == ILL_ILLOPC) { \ | |
83 | uint8_t opcode; \ | |
84 | if (get_user(opcode, (uint8_t __user *)regs->pc) == 0) \ | |
85 | if (opcode == 0xff) \ | |
86 | info.si_signo = SIGTRAP; \ | |
87 | } \ | |
88 | info.si_errno = 0; \ | |
89 | info.si_code = sicode; \ | |
90 | info.si_addr = (void *) regs->pc; \ | |
91 | force_sig_info(info.si_signo, &info, current); \ | |
92 | } | |
93 | ||
94 | DO_ERROR(SIGTRAP, {}, "trap", trap); | |
95 | DO_ERROR(SIGSEGV, {}, "ibreak", ibreak); | |
96 | DO_ERROR(SIGSEGV, {}, "obreak", obreak); | |
97 | DO_EINFO(SIGSEGV, {}, "access error", access_error, SEGV_ACCERR); | |
98 | DO_EINFO(SIGSEGV, {}, "insn access error", insn_acc_error, SEGV_ACCERR); | |
99 | DO_EINFO(SIGSEGV, {}, "data access error", data_acc_error, SEGV_ACCERR); | |
100 | DO_EINFO(SIGILL, {}, "privileged opcode", priv_op, ILL_PRVOPC); | |
101 | DO_EINFO(SIGILL, {}, "invalid opcode", invalid_op, ILL_ILLOPC); | |
102 | DO_EINFO(SIGILL, {}, "invalid ex opcode", invalid_exop, ILL_ILLOPC); | |
103 | DO_EINFO(SIGBUS, {}, "invalid address", mem_error, BUS_ADRERR); | |
104 | DO_EINFO(SIGBUS, {}, "bus error", bus_error, BUS_ADRERR); | |
105 | DO_EINFO(SIGILL, {}, "FPU invalid opcode", fpu_invalid_op, ILL_COPROC); | |
106 | ||
107 | DO_ERROR(SIGTRAP, | |
108 | #ifndef CONFIG_MN10300_USING_JTAG | |
109 | DCR &= ~0x0001, | |
110 | #else | |
111 | {}, | |
112 | #endif | |
113 | "single step", istep); | |
114 | ||
115 | /* | |
116 | * handle NMI | |
117 | */ | |
118 | asmlinkage void nmi(struct pt_regs *regs, enum exception_code code) | |
119 | { | |
120 | /* see if gdbstub wants to deal with it */ | |
121 | #ifdef CONFIG_GDBSTUB | |
122 | if (gdbstub_intercept(regs, code)) | |
123 | return; | |
124 | #endif | |
125 | ||
126 | printk(KERN_WARNING "--- Register Dump ---\n"); | |
127 | show_registers(regs); | |
128 | printk(KERN_WARNING "---------------------\n"); | |
129 | } | |
130 | ||
131 | /* | |
132 | * show a stack trace from the specified stack pointer | |
133 | */ | |
134 | void show_trace(unsigned long *sp) | |
135 | { | |
136 | unsigned long *stack, addr, module_start, module_end; | |
137 | int i; | |
138 | ||
ad361c98 | 139 | printk(KERN_EMERG "\nCall Trace:"); |
b920de1b DH |
140 | |
141 | stack = sp; | |
142 | i = 0; | |
143 | module_start = VMALLOC_START; | |
144 | module_end = VMALLOC_END; | |
145 | ||
146 | while (((long) stack & (THREAD_SIZE - 1)) != 0) { | |
147 | addr = *stack++; | |
148 | if (__kernel_text_address(addr)) { | |
149 | #if 1 | |
150 | printk(" [<%08lx>]", addr); | |
151 | print_symbol(" %s", addr); | |
152 | printk("\n"); | |
153 | #else | |
154 | if ((i % 6) == 0) | |
ad361c98 | 155 | printk(KERN_EMERG " "); |
b920de1b DH |
156 | printk("[<%08lx>] ", addr); |
157 | i++; | |
158 | #endif | |
159 | } | |
160 | } | |
161 | ||
162 | printk("\n"); | |
163 | } | |
164 | ||
165 | /* | |
166 | * show the raw stack from the specified stack pointer | |
167 | */ | |
168 | void show_stack(struct task_struct *task, unsigned long *sp) | |
169 | { | |
170 | unsigned long *stack; | |
171 | int i; | |
172 | ||
173 | if (!sp) | |
174 | sp = (unsigned long *) &sp; | |
175 | ||
176 | stack = sp; | |
177 | printk(KERN_EMERG "Stack:"); | |
178 | for (i = 0; i < kstack_depth_to_print; i++) { | |
179 | if (((long) stack & (THREAD_SIZE - 1)) == 0) | |
180 | break; | |
181 | if ((i % 8) == 0) | |
ad361c98 | 182 | printk(KERN_EMERG " "); |
b920de1b DH |
183 | printk("%08lx ", *stack++); |
184 | } | |
185 | ||
186 | show_trace(sp); | |
187 | } | |
188 | ||
189 | /* | |
190 | * the architecture-independent dump_stack generator | |
191 | */ | |
192 | void dump_stack(void) | |
193 | { | |
194 | unsigned long stack; | |
195 | ||
196 | show_stack(current, &stack); | |
197 | } | |
198 | EXPORT_SYMBOL(dump_stack); | |
199 | ||
200 | /* | |
201 | * dump the register file in the specified exception frame | |
202 | */ | |
203 | void show_registers_only(struct pt_regs *regs) | |
204 | { | |
205 | unsigned long ssp; | |
206 | ||
207 | ssp = (unsigned long) regs + sizeof(*regs); | |
208 | ||
209 | printk(KERN_EMERG "PC: %08lx EPSW: %08lx SSP: %08lx mode: %s\n", | |
210 | regs->pc, regs->epsw, ssp, user_mode(regs) ? "User" : "Super"); | |
211 | printk(KERN_EMERG "d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", | |
212 | regs->d0, regs->d1, regs->d2, regs->d3); | |
213 | printk(KERN_EMERG "a0: %08lx a1: %08lx a2: %08lx a3: %08lx\n", | |
214 | regs->a0, regs->a1, regs->a2, regs->a3); | |
215 | printk(KERN_EMERG "e0: %08lx e1: %08lx e2: %08lx e3: %08lx\n", | |
216 | regs->e0, regs->e1, regs->e2, regs->e3); | |
217 | printk(KERN_EMERG "e4: %08lx e5: %08lx e6: %08lx e7: %08lx\n", | |
218 | regs->e4, regs->e5, regs->e6, regs->e7); | |
219 | printk(KERN_EMERG "lar: %08lx lir: %08lx mdr: %08lx usp: %08lx\n", | |
220 | regs->lar, regs->lir, regs->mdr, regs->sp); | |
221 | printk(KERN_EMERG "cvf: %08lx crl: %08lx crh: %08lx drq: %08lx\n", | |
222 | regs->mcvf, regs->mcrl, regs->mcrh, regs->mdrq); | |
223 | printk(KERN_EMERG "threadinfo=%p task=%p)\n", | |
224 | current_thread_info(), current); | |
225 | ||
226 | if ((unsigned long) current >= 0x90000000UL && | |
227 | (unsigned long) current < 0x94000000UL) | |
228 | printk(KERN_EMERG "Process %s (pid: %d)\n", | |
229 | current->comm, current->pid); | |
230 | ||
231 | printk(KERN_EMERG "CPUP: %04hx\n", CPUP); | |
232 | printk(KERN_EMERG "TBR: %08x\n", TBR); | |
233 | printk(KERN_EMERG "DEAR: %08x\n", DEAR); | |
234 | printk(KERN_EMERG "sISR: %08x\n", sISR); | |
235 | printk(KERN_EMERG "NMICR: %04hx\n", NMICR); | |
236 | printk(KERN_EMERG "BCBERR: %08x\n", BCBERR); | |
237 | printk(KERN_EMERG "BCBEAR: %08x\n", BCBEAR); | |
238 | printk(KERN_EMERG "MMUFCR: %08x\n", MMUFCR); | |
239 | printk(KERN_EMERG "IPTEU : %08x IPTEL2: %08x\n", IPTEU, IPTEL2); | |
240 | printk(KERN_EMERG "DPTEU: %08x DPTEL2: %08x\n", DPTEU, DPTEL2); | |
241 | } | |
242 | ||
243 | /* | |
244 | * dump the registers and the stack | |
245 | */ | |
246 | void show_registers(struct pt_regs *regs) | |
247 | { | |
248 | unsigned long sp; | |
249 | int i; | |
250 | ||
251 | show_registers_only(regs); | |
252 | ||
253 | if (!user_mode(regs)) | |
254 | sp = (unsigned long) regs + sizeof(*regs); | |
255 | else | |
256 | sp = regs->sp; | |
257 | ||
258 | /* when in-kernel, we also print out the stack and code at the | |
259 | * time of the fault.. | |
260 | */ | |
261 | if (!user_mode(regs)) { | |
262 | printk(KERN_EMERG "\n"); | |
263 | show_stack(current, (unsigned long *) sp); | |
264 | ||
265 | #if 0 | |
ad361c98 | 266 | printk(KERN_EMERG "\nCode: "); |
b920de1b DH |
267 | if (regs->pc < PAGE_OFFSET) |
268 | goto bad; | |
269 | ||
270 | for (i = 0; i < 20; i++) { | |
271 | unsigned char c; | |
272 | if (__get_user(c, &((unsigned char *) regs->pc)[i])) | |
273 | goto bad; | |
274 | printk("%02x ", c); | |
275 | } | |
276 | #else | |
277 | i = 0; | |
278 | #endif | |
279 | } | |
280 | ||
281 | printk("\n"); | |
282 | return; | |
283 | ||
284 | #if 0 | |
285 | bad: | |
286 | printk(KERN_EMERG " Bad PC value."); | |
287 | break; | |
288 | #endif | |
289 | } | |
290 | ||
291 | /* | |
292 | * | |
293 | */ | |
294 | void show_trace_task(struct task_struct *tsk) | |
295 | { | |
296 | unsigned long sp = tsk->thread.sp; | |
297 | ||
298 | /* User space on another CPU? */ | |
299 | if ((sp ^ (unsigned long) tsk) & (PAGE_MASK << 1)) | |
300 | return; | |
301 | ||
302 | show_trace((unsigned long *) sp); | |
303 | } | |
304 | ||
305 | /* | |
306 | * note the untimely death of part of the kernel | |
307 | */ | |
308 | void die(const char *str, struct pt_regs *regs, enum exception_code code) | |
309 | { | |
310 | console_verbose(); | |
311 | spin_lock_irq(&die_lock); | |
ad361c98 | 312 | printk(KERN_EMERG "\n%s: %04x\n", |
b920de1b DH |
313 | str, code & 0xffff); |
314 | show_registers(regs); | |
315 | ||
316 | if (regs->pc >= 0x02000000 && regs->pc < 0x04000000 && | |
317 | (regs->epsw & (EPSW_IM | EPSW_IE)) != (EPSW_IM | EPSW_IE)) { | |
318 | printk(KERN_EMERG "Exception in usermode interrupt handler\n"); | |
ad361c98 | 319 | printk(KERN_EMERG "\nPlease connect to kernel debugger !!\n"); |
b920de1b DH |
320 | asm volatile ("0: bra 0b"); |
321 | } | |
322 | ||
323 | spin_unlock_irq(&die_lock); | |
324 | do_exit(SIGSEGV); | |
325 | } | |
326 | ||
327 | /* | |
328 | * see if there's a fixup handler we can force a jump to when an exception | |
329 | * happens due to something kernel code did | |
330 | */ | |
331 | int die_if_no_fixup(const char *str, struct pt_regs *regs, | |
332 | enum exception_code code) | |
333 | { | |
334 | if (user_mode(regs)) | |
335 | return 0; | |
336 | ||
337 | peripheral_leds_display_exception(code); | |
338 | ||
339 | switch (code) { | |
340 | /* see if we can fixup the kernel accessing memory */ | |
341 | case EXCEP_ITLBMISS: | |
342 | case EXCEP_DTLBMISS: | |
343 | case EXCEP_IAERROR: | |
344 | case EXCEP_DAERROR: | |
345 | case EXCEP_MEMERR: | |
346 | case EXCEP_MISALIGN: | |
347 | case EXCEP_BUSERROR: | |
348 | case EXCEP_ILLDATACC: | |
349 | case EXCEP_IOINSACC: | |
350 | case EXCEP_PRIVINSACC: | |
351 | case EXCEP_PRIVDATACC: | |
352 | case EXCEP_DATINSACC: | |
353 | if (fixup_exception(regs)) | |
354 | return 1; | |
355 | case EXCEP_UNIMPINS: | |
356 | if (regs->pc && *(uint8_t *)regs->pc == 0xff) | |
357 | if (notify_die(DIE_BREAKPOINT, str, regs, code, 0, 0)) | |
358 | return 1; | |
359 | break; | |
360 | default: | |
361 | break; | |
362 | } | |
363 | ||
364 | /* see if gdbstub wants to deal with it */ | |
365 | #ifdef CONFIG_GDBSTUB | |
366 | if (gdbstub_intercept(regs, code)) | |
367 | return 1; | |
368 | #endif | |
369 | ||
370 | if (notify_die(DIE_GPF, str, regs, code, 0, 0)) | |
371 | return 1; | |
372 | ||
373 | /* make the process die as the last resort */ | |
374 | die(str, regs, code); | |
375 | } | |
376 | ||
377 | /* | |
378 | * handle unsupported syscall instructions (syscall 1-15) | |
379 | */ | |
380 | static asmlinkage void unsupported_syscall(struct pt_regs *regs, | |
381 | enum exception_code code) | |
382 | { | |
383 | struct task_struct *tsk = current; | |
384 | siginfo_t info; | |
385 | ||
386 | /* catch a kernel BUG() */ | |
387 | if (code == EXCEP_SYSCALL15 && !user_mode(regs)) { | |
388 | if (report_bug(regs->pc, regs) == BUG_TRAP_TYPE_BUG) { | |
389 | #ifdef CONFIG_GDBSTUB | |
aa409e02 | 390 | gdbstub_intercept(regs, code); |
b920de1b DH |
391 | #endif |
392 | } | |
393 | } | |
394 | ||
395 | regs->pc -= 2; /* syscall return addr is _after_ the instruction */ | |
396 | ||
397 | die_if_no_fixup("An unsupported syscall insn was used by the kernel\n", | |
398 | regs, code); | |
399 | ||
400 | info.si_signo = SIGILL; | |
401 | info.si_errno = ENOSYS; | |
402 | info.si_code = ILL_ILLTRP; | |
403 | info.si_addr = (void *) regs->pc; | |
404 | force_sig_info(SIGILL, &info, tsk); | |
405 | } | |
406 | ||
407 | /* | |
408 | * display the register file when the stack pointer gets clobbered | |
409 | */ | |
410 | asmlinkage void do_double_fault(struct pt_regs *regs) | |
411 | { | |
412 | struct task_struct *tsk = current; | |
413 | ||
414 | strcpy(tsk->comm, "emergency tsk"); | |
415 | tsk->pid = 0; | |
416 | console_verbose(); | |
417 | printk(KERN_EMERG "--- double fault ---\n"); | |
418 | show_registers(regs); | |
419 | } | |
420 | ||
421 | /* | |
422 | * asynchronous bus error (external, usually I/O DMA) | |
423 | */ | |
424 | asmlinkage void io_bus_error(u32 bcberr, u32 bcbear, struct pt_regs *regs) | |
425 | { | |
426 | console_verbose(); | |
427 | ||
ad361c98 JP |
428 | printk(KERN_EMERG "Asynchronous I/O Bus Error\n"); |
429 | printk(KERN_EMERG "==========================\n"); | |
b920de1b DH |
430 | |
431 | if (bcberr & BCBERR_BEME) | |
432 | printk(KERN_EMERG "- Multiple recorded errors\n"); | |
433 | ||
434 | printk(KERN_EMERG "- Faulting Buses:%s%s%s\n", | |
435 | bcberr & BCBERR_BEMR_CI ? " CPU-Ins-Fetch" : "", | |
436 | bcberr & BCBERR_BEMR_CD ? " CPU-Data" : "", | |
437 | bcberr & BCBERR_BEMR_DMA ? " DMA" : ""); | |
438 | ||
439 | printk(KERN_EMERG "- %s %s access made to %s at address %08x\n", | |
440 | bcberr & BCBERR_BEBST ? "Burst" : "Single", | |
441 | bcberr & BCBERR_BERW ? "Read" : "Write", | |
442 | bcberr & BCBERR_BESB_MON ? "Monitor Space" : | |
443 | bcberr & BCBERR_BESB_IO ? "Internal CPU I/O Space" : | |
444 | bcberr & BCBERR_BESB_EX ? "External I/O Bus" : | |
445 | bcberr & BCBERR_BESB_OPEX ? "External Memory Bus" : | |
446 | "On Chip Memory", | |
447 | bcbear | |
448 | ); | |
449 | ||
450 | printk(KERN_EMERG "- Detected by the %s\n", | |
451 | bcberr&BCBERR_BESD ? "Bus Control Unit" : "Slave Bus"); | |
452 | ||
453 | #ifdef CONFIG_PCI | |
454 | #define BRIDGEREGB(X) (*(volatile __u8 *)(0xBE040000 + (X))) | |
455 | #define BRIDGEREGW(X) (*(volatile __u16 *)(0xBE040000 + (X))) | |
456 | #define BRIDGEREGL(X) (*(volatile __u32 *)(0xBE040000 + (X))) | |
457 | ||
458 | printk(KERN_EMERG "- PCI Memory Paging Reg: %08x\n", | |
459 | *(volatile __u32 *) (0xBFFFFFF4)); | |
460 | printk(KERN_EMERG "- PCI Bridge Base Address 0: %08x\n", | |
461 | BRIDGEREGL(PCI_BASE_ADDRESS_0)); | |
462 | printk(KERN_EMERG "- PCI Bridge AMPCI Base Address: %08x\n", | |
463 | BRIDGEREGL(0x48)); | |
464 | printk(KERN_EMERG "- PCI Bridge Command: %04hx\n", | |
465 | BRIDGEREGW(PCI_COMMAND)); | |
466 | printk(KERN_EMERG "- PCI Bridge Status: %04hx\n", | |
467 | BRIDGEREGW(PCI_STATUS)); | |
468 | printk(KERN_EMERG "- PCI Bridge Int Status: %08hx\n", | |
469 | BRIDGEREGL(0x4c)); | |
470 | #endif | |
471 | ||
472 | printk(KERN_EMERG "\n"); | |
473 | show_registers(regs); | |
474 | ||
475 | panic("Halted due to asynchronous I/O Bus Error\n"); | |
476 | } | |
477 | ||
478 | /* | |
479 | * handle an exception for which a handler has not yet been installed | |
480 | */ | |
481 | asmlinkage void uninitialised_exception(struct pt_regs *regs, | |
482 | enum exception_code code) | |
483 | { | |
484 | ||
485 | /* see if gdbstub wants to deal with it */ | |
486 | #ifdef CONFIG_GDBSTUB | |
487 | if (gdbstub_intercept(regs, code)) | |
488 | return; | |
489 | #endif | |
490 | ||
491 | peripheral_leds_display_exception(code); | |
492 | printk(KERN_EMERG "Uninitialised Exception 0x%04x\n", code & 0xFFFF); | |
493 | show_registers(regs); | |
494 | ||
495 | for (;;) | |
496 | continue; | |
497 | } | |
498 | ||
499 | /* | |
500 | * set an interrupt stub to jump to a handler | |
501 | * ! NOTE: this does *not* flush the caches | |
502 | */ | |
503 | void __init __set_intr_stub(enum exception_code code, void *handler) | |
504 | { | |
505 | unsigned long addr; | |
506 | u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code); | |
507 | ||
508 | addr = (unsigned long) handler - (unsigned long) vector; | |
509 | vector[0] = 0xdc; /* JMP handler */ | |
510 | vector[1] = addr; | |
511 | vector[2] = addr >> 8; | |
512 | vector[3] = addr >> 16; | |
513 | vector[4] = addr >> 24; | |
514 | vector[5] = 0xcb; | |
515 | vector[6] = 0xcb; | |
516 | vector[7] = 0xcb; | |
517 | } | |
518 | ||
519 | /* | |
520 | * set an interrupt stub to jump to a handler | |
521 | */ | |
522 | void __init set_intr_stub(enum exception_code code, void *handler) | |
523 | { | |
524 | unsigned long addr; | |
525 | u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code); | |
526 | ||
527 | addr = (unsigned long) handler - (unsigned long) vector; | |
528 | vector[0] = 0xdc; /* JMP handler */ | |
529 | vector[1] = addr; | |
530 | vector[2] = addr >> 8; | |
531 | vector[3] = addr >> 16; | |
532 | vector[4] = addr >> 24; | |
533 | vector[5] = 0xcb; | |
534 | vector[6] = 0xcb; | |
535 | vector[7] = 0xcb; | |
536 | ||
537 | mn10300_dcache_flush_inv(); | |
538 | mn10300_icache_inv(); | |
539 | } | |
540 | ||
541 | /* | |
542 | * set an interrupt stub to invoke the JTAG unit and then jump to a handler | |
543 | */ | |
544 | void __init set_jtag_stub(enum exception_code code, void *handler) | |
545 | { | |
546 | unsigned long addr; | |
547 | u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code); | |
548 | ||
549 | addr = (unsigned long) handler - ((unsigned long) vector + 1); | |
550 | vector[0] = 0xff; /* PI to jump into JTAG debugger */ | |
551 | vector[1] = 0xdc; /* jmp handler */ | |
552 | vector[2] = addr; | |
553 | vector[3] = addr >> 8; | |
554 | vector[4] = addr >> 16; | |
555 | vector[5] = addr >> 24; | |
556 | vector[6] = 0xcb; | |
557 | vector[7] = 0xcb; | |
558 | ||
559 | mn10300_dcache_flush_inv(); | |
560 | flush_icache_range((unsigned long) vector, (unsigned long) vector + 8); | |
561 | } | |
562 | ||
563 | /* | |
564 | * initialise the exception table | |
565 | */ | |
566 | void __init trap_init(void) | |
567 | { | |
568 | set_excp_vector(EXCEP_TRAP, trap); | |
569 | set_excp_vector(EXCEP_ISTEP, istep); | |
570 | set_excp_vector(EXCEP_IBREAK, ibreak); | |
571 | set_excp_vector(EXCEP_OBREAK, obreak); | |
572 | ||
573 | set_excp_vector(EXCEP_PRIVINS, priv_op); | |
574 | set_excp_vector(EXCEP_UNIMPINS, invalid_op); | |
575 | set_excp_vector(EXCEP_UNIMPEXINS, invalid_exop); | |
576 | set_excp_vector(EXCEP_MEMERR, mem_error); | |
577 | set_excp_vector(EXCEP_MISALIGN, misalignment); | |
578 | set_excp_vector(EXCEP_BUSERROR, bus_error); | |
579 | set_excp_vector(EXCEP_ILLINSACC, insn_acc_error); | |
580 | set_excp_vector(EXCEP_ILLDATACC, data_acc_error); | |
581 | set_excp_vector(EXCEP_IOINSACC, insn_acc_error); | |
582 | set_excp_vector(EXCEP_PRIVINSACC, insn_acc_error); | |
583 | set_excp_vector(EXCEP_PRIVDATACC, data_acc_error); | |
584 | set_excp_vector(EXCEP_DATINSACC, insn_acc_error); | |
585 | set_excp_vector(EXCEP_FPU_DISABLED, fpu_disabled); | |
586 | set_excp_vector(EXCEP_FPU_UNIMPINS, fpu_invalid_op); | |
587 | set_excp_vector(EXCEP_FPU_OPERATION, fpu_exception); | |
588 | ||
589 | set_excp_vector(EXCEP_NMI, nmi); | |
590 | ||
591 | set_excp_vector(EXCEP_SYSCALL1, unsupported_syscall); | |
592 | set_excp_vector(EXCEP_SYSCALL2, unsupported_syscall); | |
593 | set_excp_vector(EXCEP_SYSCALL3, unsupported_syscall); | |
594 | set_excp_vector(EXCEP_SYSCALL4, unsupported_syscall); | |
595 | set_excp_vector(EXCEP_SYSCALL5, unsupported_syscall); | |
596 | set_excp_vector(EXCEP_SYSCALL6, unsupported_syscall); | |
597 | set_excp_vector(EXCEP_SYSCALL7, unsupported_syscall); | |
598 | set_excp_vector(EXCEP_SYSCALL8, unsupported_syscall); | |
599 | set_excp_vector(EXCEP_SYSCALL9, unsupported_syscall); | |
600 | set_excp_vector(EXCEP_SYSCALL10, unsupported_syscall); | |
601 | set_excp_vector(EXCEP_SYSCALL11, unsupported_syscall); | |
602 | set_excp_vector(EXCEP_SYSCALL12, unsupported_syscall); | |
603 | set_excp_vector(EXCEP_SYSCALL13, unsupported_syscall); | |
604 | set_excp_vector(EXCEP_SYSCALL14, unsupported_syscall); | |
605 | set_excp_vector(EXCEP_SYSCALL15, unsupported_syscall); | |
606 | } | |
607 | ||
608 | /* | |
609 | * determine if a program counter value is a valid bug address | |
610 | */ | |
611 | int is_valid_bugaddr(unsigned long pc) | |
612 | { | |
613 | return pc >= PAGE_OFFSET; | |
614 | } |