traps.c 17 KB

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