traps.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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/init.h>
  21. #include <linux/delay.h>
  22. #include <linux/spinlock.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/kallsyms.h>
  25. #include <linux/pci.h>
  26. #include <linux/kdebug.h>
  27. #include <linux/bug.h>
  28. #include <linux/irq.h>
  29. #include <linux/export.h>
  30. #include <asm/processor.h>
  31. #include <linux/uaccess.h>
  32. #include <asm/io.h>
  33. #include <linux/atomic.h>
  34. #include <asm/smp.h>
  35. #include <asm/pgalloc.h>
  36. #include <asm/cacheflush.h>
  37. #include <asm/cpu-regs.h>
  38. #include <asm/busctl-regs.h>
  39. #include <unit/leds.h>
  40. #include <asm/fpu.h>
  41. #include <asm/sections.h>
  42. #include <asm/debugger.h>
  43. #include "internal.h"
  44. #if (CONFIG_INTERRUPT_VECTOR_BASE & 0xffffff)
  45. #error "INTERRUPT_VECTOR_BASE not aligned to 16MiB boundary!"
  46. #endif
  47. int kstack_depth_to_print = 24;
  48. spinlock_t die_lock = __SPIN_LOCK_UNLOCKED(die_lock);
  49. struct exception_to_signal_map {
  50. u8 signo;
  51. u32 si_code;
  52. };
  53. static const struct exception_to_signal_map exception_to_signal_map[256] = {
  54. /* MMU exceptions */
  55. [EXCEP_ITLBMISS >> 3] = { 0, 0 },
  56. [EXCEP_DTLBMISS >> 3] = { 0, 0 },
  57. [EXCEP_IAERROR >> 3] = { 0, 0 },
  58. [EXCEP_DAERROR >> 3] = { 0, 0 },
  59. /* system exceptions */
  60. [EXCEP_TRAP >> 3] = { SIGTRAP, TRAP_BRKPT },
  61. [EXCEP_ISTEP >> 3] = { SIGTRAP, TRAP_TRACE }, /* Monitor */
  62. [EXCEP_IBREAK >> 3] = { SIGTRAP, TRAP_HWBKPT }, /* Monitor */
  63. [EXCEP_OBREAK >> 3] = { SIGTRAP, TRAP_HWBKPT }, /* Monitor */
  64. [EXCEP_PRIVINS >> 3] = { SIGILL, ILL_PRVOPC },
  65. [EXCEP_UNIMPINS >> 3] = { SIGILL, ILL_ILLOPC },
  66. [EXCEP_UNIMPEXINS >> 3] = { SIGILL, ILL_ILLOPC },
  67. [EXCEP_MEMERR >> 3] = { SIGSEGV, SEGV_ACCERR },
  68. [EXCEP_MISALIGN >> 3] = { SIGBUS, BUS_ADRALN },
  69. [EXCEP_BUSERROR >> 3] = { SIGBUS, BUS_ADRERR },
  70. [EXCEP_ILLINSACC >> 3] = { SIGSEGV, SEGV_ACCERR },
  71. [EXCEP_ILLDATACC >> 3] = { SIGSEGV, SEGV_ACCERR },
  72. [EXCEP_IOINSACC >> 3] = { SIGSEGV, SEGV_ACCERR },
  73. [EXCEP_PRIVINSACC >> 3] = { SIGSEGV, SEGV_ACCERR }, /* userspace */
  74. [EXCEP_PRIVDATACC >> 3] = { SIGSEGV, SEGV_ACCERR }, /* userspace */
  75. [EXCEP_DATINSACC >> 3] = { SIGSEGV, SEGV_ACCERR },
  76. [EXCEP_DOUBLE_FAULT >> 3] = { SIGILL, ILL_BADSTK },
  77. /* FPU exceptions */
  78. [EXCEP_FPU_DISABLED >> 3] = { SIGILL, ILL_COPROC },
  79. [EXCEP_FPU_UNIMPINS >> 3] = { SIGILL, ILL_COPROC },
  80. [EXCEP_FPU_OPERATION >> 3] = { SIGFPE, FPE_INTDIV },
  81. /* interrupts */
  82. [EXCEP_WDT >> 3] = { SIGALRM, 0 },
  83. [EXCEP_NMI >> 3] = { SIGQUIT, 0 },
  84. [EXCEP_IRQ_LEVEL0 >> 3] = { SIGINT, 0 },
  85. [EXCEP_IRQ_LEVEL1 >> 3] = { 0, 0 },
  86. [EXCEP_IRQ_LEVEL2 >> 3] = { 0, 0 },
  87. [EXCEP_IRQ_LEVEL3 >> 3] = { 0, 0 },
  88. [EXCEP_IRQ_LEVEL4 >> 3] = { 0, 0 },
  89. [EXCEP_IRQ_LEVEL5 >> 3] = { 0, 0 },
  90. [EXCEP_IRQ_LEVEL6 >> 3] = { 0, 0 },
  91. /* system calls */
  92. [EXCEP_SYSCALL0 >> 3] = { 0, 0 },
  93. [EXCEP_SYSCALL1 >> 3] = { SIGILL, ILL_ILLTRP },
  94. [EXCEP_SYSCALL2 >> 3] = { SIGILL, ILL_ILLTRP },
  95. [EXCEP_SYSCALL3 >> 3] = { SIGILL, ILL_ILLTRP },
  96. [EXCEP_SYSCALL4 >> 3] = { SIGILL, ILL_ILLTRP },
  97. [EXCEP_SYSCALL5 >> 3] = { SIGILL, ILL_ILLTRP },
  98. [EXCEP_SYSCALL6 >> 3] = { SIGILL, ILL_ILLTRP },
  99. [EXCEP_SYSCALL7 >> 3] = { SIGILL, ILL_ILLTRP },
  100. [EXCEP_SYSCALL8 >> 3] = { SIGILL, ILL_ILLTRP },
  101. [EXCEP_SYSCALL9 >> 3] = { SIGILL, ILL_ILLTRP },
  102. [EXCEP_SYSCALL10 >> 3] = { SIGILL, ILL_ILLTRP },
  103. [EXCEP_SYSCALL11 >> 3] = { SIGILL, ILL_ILLTRP },
  104. [EXCEP_SYSCALL12 >> 3] = { SIGILL, ILL_ILLTRP },
  105. [EXCEP_SYSCALL13 >> 3] = { SIGILL, ILL_ILLTRP },
  106. [EXCEP_SYSCALL14 >> 3] = { SIGILL, ILL_ILLTRP },
  107. [EXCEP_SYSCALL15 >> 3] = { SIGABRT, 0 },
  108. };
  109. /*
  110. * Handle kernel exceptions.
  111. *
  112. * See if there's a fixup handler we can force a jump to when an exception
  113. * happens due to something kernel code did
  114. */
  115. int die_if_no_fixup(const char *str, struct pt_regs *regs,
  116. enum exception_code code)
  117. {
  118. u8 opcode;
  119. int signo, si_code;
  120. if (user_mode(regs))
  121. return 0;
  122. peripheral_leds_display_exception(code);
  123. signo = exception_to_signal_map[code >> 3].signo;
  124. si_code = exception_to_signal_map[code >> 3].si_code;
  125. switch (code) {
  126. /* see if we can fixup the kernel accessing memory */
  127. case EXCEP_ITLBMISS:
  128. case EXCEP_DTLBMISS:
  129. case EXCEP_IAERROR:
  130. case EXCEP_DAERROR:
  131. case EXCEP_MEMERR:
  132. case EXCEP_MISALIGN:
  133. case EXCEP_BUSERROR:
  134. case EXCEP_ILLDATACC:
  135. case EXCEP_IOINSACC:
  136. case EXCEP_PRIVINSACC:
  137. case EXCEP_PRIVDATACC:
  138. case EXCEP_DATINSACC:
  139. if (fixup_exception(regs))
  140. return 1;
  141. break;
  142. case EXCEP_TRAP:
  143. case EXCEP_UNIMPINS:
  144. if (probe_kernel_read(&opcode, (u8 *)regs->pc, 1) < 0)
  145. break;
  146. if (opcode == 0xff) {
  147. if (notify_die(DIE_BREAKPOINT, str, regs, code, 0, 0))
  148. return 1;
  149. if (at_debugger_breakpoint(regs))
  150. regs->pc++;
  151. signo = SIGTRAP;
  152. si_code = TRAP_BRKPT;
  153. }
  154. break;
  155. case EXCEP_SYSCALL1 ... EXCEP_SYSCALL14:
  156. /* syscall return addr is _after_ the instruction */
  157. regs->pc -= 2;
  158. break;
  159. case EXCEP_SYSCALL15:
  160. if (report_bug(regs->pc, regs) == BUG_TRAP_TYPE_WARN)
  161. return 1;
  162. /* syscall return addr is _after_ the instruction */
  163. regs->pc -= 2;
  164. break;
  165. default:
  166. break;
  167. }
  168. if (debugger_intercept(code, signo, si_code, regs) == 0)
  169. return 1;
  170. if (notify_die(DIE_GPF, str, regs, code, 0, 0))
  171. return 1;
  172. /* make the process die as the last resort */
  173. die(str, regs, code);
  174. }
  175. /*
  176. * General exception handler
  177. */
  178. asmlinkage void handle_exception(struct pt_regs *regs, u32 intcode)
  179. {
  180. siginfo_t info;
  181. /* deal with kernel exceptions here */
  182. if (die_if_no_fixup(NULL, regs, intcode))
  183. return;
  184. /* otherwise it's a userspace exception */
  185. info.si_signo = exception_to_signal_map[intcode >> 3].signo;
  186. info.si_code = exception_to_signal_map[intcode >> 3].si_code;
  187. info.si_errno = 0;
  188. info.si_addr = (void *) regs->pc;
  189. force_sig_info(info.si_signo, &info, current);
  190. }
  191. /*
  192. * handle NMI
  193. */
  194. asmlinkage void nmi(struct pt_regs *regs, enum exception_code code)
  195. {
  196. /* see if gdbstub wants to deal with it */
  197. if (debugger_intercept(code, SIGQUIT, 0, regs))
  198. return;
  199. printk(KERN_WARNING "--- Register Dump ---\n");
  200. show_registers(regs);
  201. printk(KERN_WARNING "---------------------\n");
  202. }
  203. /*
  204. * show a stack trace from the specified stack pointer
  205. */
  206. void show_trace(unsigned long *sp)
  207. {
  208. unsigned long bottom, stack, addr, fp, raslot;
  209. printk(KERN_EMERG "\nCall Trace:\n");
  210. //stack = (unsigned long)sp;
  211. asm("mov sp,%0" : "=a"(stack));
  212. asm("mov a3,%0" : "=r"(fp));
  213. raslot = ULONG_MAX;
  214. bottom = (stack + THREAD_SIZE) & ~(THREAD_SIZE - 1);
  215. for (; stack < bottom; stack += sizeof(addr)) {
  216. addr = *(unsigned long *)stack;
  217. if (stack == fp) {
  218. if (addr > stack && addr < bottom) {
  219. fp = addr;
  220. raslot = stack + sizeof(addr);
  221. continue;
  222. }
  223. fp = 0;
  224. raslot = ULONG_MAX;
  225. }
  226. if (__kernel_text_address(addr)) {
  227. printk(" [<%08lx>]", addr);
  228. if (stack >= raslot)
  229. raslot = ULONG_MAX;
  230. else
  231. printk(" ?");
  232. print_symbol(" %s", addr);
  233. printk("\n");
  234. }
  235. }
  236. printk("\n");
  237. }
  238. /*
  239. * show the raw stack from the specified stack pointer
  240. */
  241. void show_stack(struct task_struct *task, unsigned long *sp)
  242. {
  243. unsigned long *stack;
  244. int i;
  245. if (!sp)
  246. sp = (unsigned long *) &sp;
  247. stack = sp;
  248. printk(KERN_EMERG "Stack:");
  249. for (i = 0; i < kstack_depth_to_print; i++) {
  250. if (((long) stack & (THREAD_SIZE - 1)) == 0)
  251. break;
  252. if ((i % 8) == 0)
  253. printk(KERN_EMERG " ");
  254. printk("%08lx ", *stack++);
  255. }
  256. show_trace(sp);
  257. }
  258. /*
  259. * dump the register file in the specified exception frame
  260. */
  261. void show_registers_only(struct pt_regs *regs)
  262. {
  263. unsigned long ssp;
  264. ssp = (unsigned long) regs + sizeof(*regs);
  265. printk(KERN_EMERG "PC: %08lx EPSW: %08lx SSP: %08lx mode: %s\n",
  266. regs->pc, regs->epsw, ssp, user_mode(regs) ? "User" : "Super");
  267. printk(KERN_EMERG "d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
  268. regs->d0, regs->d1, regs->d2, regs->d3);
  269. printk(KERN_EMERG "a0: %08lx a1: %08lx a2: %08lx a3: %08lx\n",
  270. regs->a0, regs->a1, regs->a2, regs->a3);
  271. printk(KERN_EMERG "e0: %08lx e1: %08lx e2: %08lx e3: %08lx\n",
  272. regs->e0, regs->e1, regs->e2, regs->e3);
  273. printk(KERN_EMERG "e4: %08lx e5: %08lx e6: %08lx e7: %08lx\n",
  274. regs->e4, regs->e5, regs->e6, regs->e7);
  275. printk(KERN_EMERG "lar: %08lx lir: %08lx mdr: %08lx usp: %08lx\n",
  276. regs->lar, regs->lir, regs->mdr, regs->sp);
  277. printk(KERN_EMERG "cvf: %08lx crl: %08lx crh: %08lx drq: %08lx\n",
  278. regs->mcvf, regs->mcrl, regs->mcrh, regs->mdrq);
  279. printk(KERN_EMERG "threadinfo=%p task=%p)\n",
  280. current_thread_info(), current);
  281. if ((unsigned long) current >= PAGE_OFFSET &&
  282. (unsigned long) current < (unsigned long)high_memory)
  283. printk(KERN_EMERG "Process %s (pid: %d)\n",
  284. current->comm, current->pid);
  285. #ifdef CONFIG_SMP
  286. printk(KERN_EMERG "CPUID: %08x\n", CPUID);
  287. #endif
  288. printk(KERN_EMERG "CPUP: %04hx\n", CPUP);
  289. printk(KERN_EMERG "TBR: %08x\n", TBR);
  290. printk(KERN_EMERG "DEAR: %08x\n", DEAR);
  291. printk(KERN_EMERG "sISR: %08x\n", sISR);
  292. printk(KERN_EMERG "NMICR: %04hx\n", NMICR);
  293. printk(KERN_EMERG "BCBERR: %08x\n", BCBERR);
  294. printk(KERN_EMERG "BCBEAR: %08x\n", BCBEAR);
  295. printk(KERN_EMERG "MMUFCR: %08x\n", MMUFCR);
  296. printk(KERN_EMERG "IPTEU : %08x IPTEL2: %08x\n", IPTEU, IPTEL2);
  297. printk(KERN_EMERG "DPTEU: %08x DPTEL2: %08x\n", DPTEU, DPTEL2);
  298. }
  299. /*
  300. * dump the registers and the stack
  301. */
  302. void show_registers(struct pt_regs *regs)
  303. {
  304. unsigned long sp;
  305. int i;
  306. show_registers_only(regs);
  307. if (!user_mode(regs))
  308. sp = (unsigned long) regs + sizeof(*regs);
  309. else
  310. sp = regs->sp;
  311. /* when in-kernel, we also print out the stack and code at the
  312. * time of the fault..
  313. */
  314. if (!user_mode(regs)) {
  315. printk(KERN_EMERG "\n");
  316. show_stack(current, (unsigned long *) sp);
  317. #if 0
  318. printk(KERN_EMERG "\nCode: ");
  319. if (regs->pc < PAGE_OFFSET)
  320. goto bad;
  321. for (i = 0; i < 20; i++) {
  322. unsigned char c;
  323. if (__get_user(c, &((unsigned char *) regs->pc)[i]))
  324. goto bad;
  325. printk("%02x ", c);
  326. }
  327. #else
  328. i = 0;
  329. #endif
  330. }
  331. printk("\n");
  332. return;
  333. #if 0
  334. bad:
  335. printk(KERN_EMERG " Bad PC value.");
  336. break;
  337. #endif
  338. }
  339. /*
  340. *
  341. */
  342. void show_trace_task(struct task_struct *tsk)
  343. {
  344. unsigned long sp = tsk->thread.sp;
  345. /* User space on another CPU? */
  346. if ((sp ^ (unsigned long) tsk) & (PAGE_MASK << 1))
  347. return;
  348. show_trace((unsigned long *) sp);
  349. }
  350. /*
  351. * note the untimely death of part of the kernel
  352. */
  353. void die(const char *str, struct pt_regs *regs, enum exception_code code)
  354. {
  355. console_verbose();
  356. spin_lock_irq(&die_lock);
  357. printk(KERN_EMERG "\n%s: %04x\n",
  358. str, code & 0xffff);
  359. show_registers(regs);
  360. if (regs->pc >= 0x02000000 && regs->pc < 0x04000000 &&
  361. (regs->epsw & (EPSW_IM | EPSW_IE)) != (EPSW_IM | EPSW_IE)) {
  362. printk(KERN_EMERG "Exception in usermode interrupt handler\n");
  363. printk(KERN_EMERG "\nPlease connect to kernel debugger !!\n");
  364. asm volatile ("0: bra 0b");
  365. }
  366. spin_unlock_irq(&die_lock);
  367. do_exit(SIGSEGV);
  368. }
  369. /*
  370. * display the register file when the stack pointer gets clobbered
  371. */
  372. asmlinkage void do_double_fault(struct pt_regs *regs)
  373. {
  374. struct task_struct *tsk = current;
  375. strcpy(tsk->comm, "emergency tsk");
  376. tsk->pid = 0;
  377. console_verbose();
  378. printk(KERN_EMERG "--- double fault ---\n");
  379. show_registers(regs);
  380. }
  381. /*
  382. * asynchronous bus error (external, usually I/O DMA)
  383. */
  384. asmlinkage void io_bus_error(u32 bcberr, u32 bcbear, struct pt_regs *regs)
  385. {
  386. console_verbose();
  387. printk(KERN_EMERG "Asynchronous I/O Bus Error\n");
  388. printk(KERN_EMERG "==========================\n");
  389. if (bcberr & BCBERR_BEME)
  390. printk(KERN_EMERG "- Multiple recorded errors\n");
  391. printk(KERN_EMERG "- Faulting Buses:%s%s%s\n",
  392. bcberr & BCBERR_BEMR_CI ? " CPU-Ins-Fetch" : "",
  393. bcberr & BCBERR_BEMR_CD ? " CPU-Data" : "",
  394. bcberr & BCBERR_BEMR_DMA ? " DMA" : "");
  395. printk(KERN_EMERG "- %s %s access made to %s at address %08x\n",
  396. bcberr & BCBERR_BEBST ? "Burst" : "Single",
  397. bcberr & BCBERR_BERW ? "Read" : "Write",
  398. bcberr & BCBERR_BESB_MON ? "Monitor Space" :
  399. bcberr & BCBERR_BESB_IO ? "Internal CPU I/O Space" :
  400. bcberr & BCBERR_BESB_EX ? "External I/O Bus" :
  401. bcberr & BCBERR_BESB_OPEX ? "External Memory Bus" :
  402. "On Chip Memory",
  403. bcbear
  404. );
  405. printk(KERN_EMERG "- Detected by the %s\n",
  406. bcberr&BCBERR_BESD ? "Bus Control Unit" : "Slave Bus");
  407. #ifdef CONFIG_PCI
  408. #define BRIDGEREGB(X) (*(volatile __u8 *)(0xBE040000 + (X)))
  409. #define BRIDGEREGW(X) (*(volatile __u16 *)(0xBE040000 + (X)))
  410. #define BRIDGEREGL(X) (*(volatile __u32 *)(0xBE040000 + (X)))
  411. printk(KERN_EMERG "- PCI Memory Paging Reg: %08x\n",
  412. *(volatile __u32 *) (0xBFFFFFF4));
  413. printk(KERN_EMERG "- PCI Bridge Base Address 0: %08x\n",
  414. BRIDGEREGL(PCI_BASE_ADDRESS_0));
  415. printk(KERN_EMERG "- PCI Bridge AMPCI Base Address: %08x\n",
  416. BRIDGEREGL(0x48));
  417. printk(KERN_EMERG "- PCI Bridge Command: %04hx\n",
  418. BRIDGEREGW(PCI_COMMAND));
  419. printk(KERN_EMERG "- PCI Bridge Status: %04hx\n",
  420. BRIDGEREGW(PCI_STATUS));
  421. printk(KERN_EMERG "- PCI Bridge Int Status: %08hx\n",
  422. BRIDGEREGL(0x4c));
  423. #endif
  424. printk(KERN_EMERG "\n");
  425. show_registers(regs);
  426. panic("Halted due to asynchronous I/O Bus Error\n");
  427. }
  428. /*
  429. * handle an exception for which a handler has not yet been installed
  430. */
  431. asmlinkage void uninitialised_exception(struct pt_regs *regs,
  432. enum exception_code code)
  433. {
  434. /* see if gdbstub wants to deal with it */
  435. if (debugger_intercept(code, SIGSYS, 0, regs) == 0)
  436. return;
  437. peripheral_leds_display_exception(code);
  438. printk(KERN_EMERG "Uninitialised Exception 0x%04x\n", code & 0xFFFF);
  439. show_registers(regs);
  440. for (;;)
  441. continue;
  442. }
  443. /*
  444. * set an interrupt stub to jump to a handler
  445. * ! NOTE: this does *not* flush the caches
  446. */
  447. void __init __set_intr_stub(enum exception_code code, void *handler)
  448. {
  449. unsigned long addr;
  450. u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code);
  451. addr = (unsigned long) handler - (unsigned long) vector;
  452. vector[0] = 0xdc; /* JMP handler */
  453. vector[1] = addr;
  454. vector[2] = addr >> 8;
  455. vector[3] = addr >> 16;
  456. vector[4] = addr >> 24;
  457. vector[5] = 0xcb;
  458. vector[6] = 0xcb;
  459. vector[7] = 0xcb;
  460. }
  461. /*
  462. * set an interrupt stub to jump to a handler
  463. */
  464. void __init set_intr_stub(enum exception_code code, void *handler)
  465. {
  466. unsigned long addr;
  467. u8 *vector = (u8 *)(CONFIG_INTERRUPT_VECTOR_BASE + code);
  468. unsigned long flags;
  469. addr = (unsigned long) handler - (unsigned long) vector;
  470. flags = arch_local_cli_save();
  471. vector[0] = 0xdc; /* JMP handler */
  472. vector[1] = addr;
  473. vector[2] = addr >> 8;
  474. vector[3] = addr >> 16;
  475. vector[4] = addr >> 24;
  476. vector[5] = 0xcb;
  477. vector[6] = 0xcb;
  478. vector[7] = 0xcb;
  479. arch_local_irq_restore(flags);
  480. #ifndef CONFIG_MN10300_CACHE_SNOOP
  481. mn10300_dcache_flush_inv();
  482. mn10300_icache_inv();
  483. #endif
  484. }
  485. /*
  486. * initialise the exception table
  487. */
  488. void __init trap_init(void)
  489. {
  490. set_excp_vector(EXCEP_TRAP, handle_exception);
  491. set_excp_vector(EXCEP_ISTEP, handle_exception);
  492. set_excp_vector(EXCEP_IBREAK, handle_exception);
  493. set_excp_vector(EXCEP_OBREAK, handle_exception);
  494. set_excp_vector(EXCEP_PRIVINS, handle_exception);
  495. set_excp_vector(EXCEP_UNIMPINS, handle_exception);
  496. set_excp_vector(EXCEP_UNIMPEXINS, handle_exception);
  497. set_excp_vector(EXCEP_MEMERR, handle_exception);
  498. set_excp_vector(EXCEP_MISALIGN, misalignment);
  499. set_excp_vector(EXCEP_BUSERROR, handle_exception);
  500. set_excp_vector(EXCEP_ILLINSACC, handle_exception);
  501. set_excp_vector(EXCEP_ILLDATACC, handle_exception);
  502. set_excp_vector(EXCEP_IOINSACC, handle_exception);
  503. set_excp_vector(EXCEP_PRIVINSACC, handle_exception);
  504. set_excp_vector(EXCEP_PRIVDATACC, handle_exception);
  505. set_excp_vector(EXCEP_DATINSACC, handle_exception);
  506. set_excp_vector(EXCEP_FPU_UNIMPINS, handle_exception);
  507. set_excp_vector(EXCEP_FPU_OPERATION, fpu_exception);
  508. set_excp_vector(EXCEP_NMI, nmi);
  509. set_excp_vector(EXCEP_SYSCALL1, handle_exception);
  510. set_excp_vector(EXCEP_SYSCALL2, handle_exception);
  511. set_excp_vector(EXCEP_SYSCALL3, handle_exception);
  512. set_excp_vector(EXCEP_SYSCALL4, handle_exception);
  513. set_excp_vector(EXCEP_SYSCALL5, handle_exception);
  514. set_excp_vector(EXCEP_SYSCALL6, handle_exception);
  515. set_excp_vector(EXCEP_SYSCALL7, handle_exception);
  516. set_excp_vector(EXCEP_SYSCALL8, handle_exception);
  517. set_excp_vector(EXCEP_SYSCALL9, handle_exception);
  518. set_excp_vector(EXCEP_SYSCALL10, handle_exception);
  519. set_excp_vector(EXCEP_SYSCALL11, handle_exception);
  520. set_excp_vector(EXCEP_SYSCALL12, handle_exception);
  521. set_excp_vector(EXCEP_SYSCALL13, handle_exception);
  522. set_excp_vector(EXCEP_SYSCALL14, handle_exception);
  523. set_excp_vector(EXCEP_SYSCALL15, handle_exception);
  524. }
  525. /*
  526. * determine if a program counter value is a valid bug address
  527. */
  528. int is_valid_bugaddr(unsigned long pc)
  529. {
  530. return pc >= PAGE_OFFSET;
  531. }