traps.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. /*
  2. * File: arch/blackfin/kernel/traps.c
  3. * Based on:
  4. * Author: Hamish Macdonald
  5. *
  6. * Created:
  7. * Description: uses S/W interrupt 15 for the system calls
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/uaccess.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/module.h>
  32. #include <linux/kallsyms.h>
  33. #include <linux/fs.h>
  34. #include <asm/traps.h>
  35. #include <asm/cacheflush.h>
  36. #include <asm/cplb.h>
  37. #include <asm/blackfin.h>
  38. #include <asm/irq_handler.h>
  39. #include <linux/irq.h>
  40. #include <asm/trace.h>
  41. #include <asm/fixed_code.h>
  42. #include <asm/dma.h>
  43. #ifdef CONFIG_KGDB
  44. # include <linux/debugger.h>
  45. # include <linux/kgdb.h>
  46. # define CHK_DEBUGGER_TRAP() \
  47. do { \
  48. CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \
  49. } while (0)
  50. # define CHK_DEBUGGER_TRAP_MAYBE() \
  51. do { \
  52. if (kgdb_connected) \
  53. CHK_DEBUGGER_TRAP(); \
  54. } while (0)
  55. #else
  56. # define CHK_DEBUGGER_TRAP() do { } while (0)
  57. # define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
  58. #endif
  59. /* Initiate the event table handler */
  60. void __init trap_init(void)
  61. {
  62. CSYNC();
  63. bfin_write_EVT3(trap);
  64. CSYNC();
  65. }
  66. unsigned long saved_icplb_fault_addr, saved_dcplb_fault_addr;
  67. static void decode_address(char *buf, unsigned long address)
  68. {
  69. struct vm_list_struct *vml;
  70. struct task_struct *p;
  71. struct mm_struct *mm;
  72. unsigned long flags, offset;
  73. unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic();
  74. #ifdef CONFIG_KALLSYMS
  75. unsigned long symsize;
  76. const char *symname;
  77. char *modname;
  78. char *delim = ":";
  79. char namebuf[128];
  80. /* look up the address and see if we are in kernel space */
  81. symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
  82. if (symname) {
  83. /* yeah! kernel space! */
  84. if (!modname)
  85. modname = delim = "";
  86. sprintf(buf, "<0x%p> { %s%s%s%s + 0x%lx }",
  87. (void *)address, delim, modname, delim, symname,
  88. (unsigned long)offset);
  89. return;
  90. }
  91. #endif
  92. /* Problem in fixed code section? */
  93. if (address >= FIXED_CODE_START && address < FIXED_CODE_END) {
  94. sprintf(buf, "<0x%p> /* Maybe fixed code section */", (void *)address);
  95. return;
  96. }
  97. /* Problem somewhere before the kernel start address */
  98. if (address < CONFIG_BOOT_LOAD) {
  99. sprintf(buf, "<0x%p> /* Maybe null pointer? */", (void *)address);
  100. return;
  101. }
  102. /* looks like we're off in user-land, so let's walk all the
  103. * mappings of all our processes and see if we can't be a whee
  104. * bit more specific
  105. */
  106. write_lock_irqsave(&tasklist_lock, flags);
  107. for_each_process(p) {
  108. mm = (in_atomic ? p->mm : get_task_mm(p));
  109. if (!mm)
  110. continue;
  111. vml = mm->context.vmlist;
  112. while (vml) {
  113. struct vm_area_struct *vma = vml->vma;
  114. if (address >= vma->vm_start && address < vma->vm_end) {
  115. char _tmpbuf[256];
  116. char *name = p->comm;
  117. struct file *file = vma->vm_file;
  118. if (file)
  119. name = d_path(&file->f_path, _tmpbuf,
  120. sizeof(_tmpbuf));
  121. /* FLAT does not have its text aligned to the start of
  122. * the map while FDPIC ELF does ...
  123. */
  124. /* before we can check flat/fdpic, we need to
  125. * make sure current is valid
  126. */
  127. if ((unsigned long)current >= FIXED_CODE_START &&
  128. !((unsigned long)current & 0x3)) {
  129. if (current->mm &&
  130. (address > current->mm->start_code) &&
  131. (address < current->mm->end_code))
  132. offset = address - current->mm->start_code;
  133. else
  134. offset = (address - vma->vm_start) +
  135. (vma->vm_pgoff << PAGE_SHIFT);
  136. sprintf(buf, "<0x%p> [ %s + 0x%lx ]",
  137. (void *)address, name, offset);
  138. } else
  139. sprintf(buf, "<0x%p> [ %s vma:0x%lx-0x%lx]",
  140. (void *)address, name,
  141. vma->vm_start, vma->vm_end);
  142. if (!in_atomic)
  143. mmput(mm);
  144. if (!strlen(buf))
  145. sprintf(buf, "<0x%p> [ %s ] dynamic memory", (void *)address, name);
  146. goto done;
  147. }
  148. vml = vml->next;
  149. }
  150. if (!in_atomic)
  151. mmput(mm);
  152. }
  153. /* we were unable to find this address anywhere */
  154. sprintf(buf, "<0x%p> /* kernel dynamic memory */", (void *)address);
  155. done:
  156. write_unlock_irqrestore(&tasklist_lock, flags);
  157. }
  158. asmlinkage void double_fault_c(struct pt_regs *fp)
  159. {
  160. console_verbose();
  161. oops_in_progress = 1;
  162. printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n");
  163. dump_bfin_process(fp);
  164. dump_bfin_mem(fp);
  165. show_regs(fp);
  166. panic("Double Fault - unrecoverable event\n");
  167. }
  168. asmlinkage void trap_c(struct pt_regs *fp)
  169. {
  170. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
  171. int j;
  172. #endif
  173. int sig = 0;
  174. siginfo_t info;
  175. unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
  176. trace_buffer_save(j);
  177. /* Important - be very careful dereferncing pointers - will lead to
  178. * double faults if the stack has become corrupt
  179. */
  180. /* If the fault was caused by a kernel thread, or interrupt handler
  181. * we will kernel panic, so the system reboots.
  182. * If KGDB is enabled, don't set this for kernel breakpoints
  183. */
  184. /* TODO: check to see if we are in some sort of deferred HWERR
  185. * that we should be able to recover from, not kernel panic
  186. */
  187. if ((bfin_read_IPEND() & 0xFFC0) && (trapnr != VEC_STEP)
  188. #ifdef CONFIG_KGDB
  189. && (trapnr != VEC_EXCPT02)
  190. #endif
  191. ){
  192. console_verbose();
  193. oops_in_progress = 1;
  194. } else if (current) {
  195. if (current->mm == NULL) {
  196. console_verbose();
  197. oops_in_progress = 1;
  198. }
  199. }
  200. /* trap_c() will be called for exceptions. During exceptions
  201. * processing, the pc value should be set with retx value.
  202. * With this change we can cleanup some code in signal.c- TODO
  203. */
  204. fp->orig_pc = fp->retx;
  205. /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
  206. trapnr, fp->ipend, fp->pc, fp->retx); */
  207. /* send the appropriate signal to the user program */
  208. switch (trapnr) {
  209. /* This table works in conjuction with the one in ./mach-common/entry.S
  210. * Some exceptions are handled there (in assembly, in exception space)
  211. * Some are handled here, (in C, in interrupt space)
  212. * Some, like CPLB, are handled in both, where the normal path is
  213. * handled in assembly/exception space, and the error path is handled
  214. * here
  215. */
  216. /* 0x00 - Linux Syscall, getting here is an error */
  217. /* 0x01 - userspace gdb breakpoint, handled here */
  218. case VEC_EXCPT01:
  219. info.si_code = TRAP_ILLTRAP;
  220. sig = SIGTRAP;
  221. CHK_DEBUGGER_TRAP_MAYBE();
  222. /* Check if this is a breakpoint in kernel space */
  223. if (fp->ipend & 0xffc0)
  224. return;
  225. else
  226. break;
  227. #ifdef CONFIG_KGDB
  228. case VEC_EXCPT02 : /* gdb connection */
  229. info.si_code = TRAP_ILLTRAP;
  230. sig = SIGTRAP;
  231. CHK_DEBUGGER_TRAP();
  232. return;
  233. #else
  234. /* 0x02 - User Defined, Caught by default */
  235. #endif
  236. /* 0x03 - User Defined, userspace stack overflow */
  237. case VEC_EXCPT03:
  238. info.si_code = SEGV_STACKFLOW;
  239. sig = SIGSEGV;
  240. printk(KERN_NOTICE EXC_0x03(KERN_NOTICE));
  241. CHK_DEBUGGER_TRAP();
  242. break;
  243. /* 0x04 - User Defined, Caught by default */
  244. /* 0x05 - User Defined, Caught by default */
  245. /* 0x06 - User Defined, Caught by default */
  246. /* 0x07 - User Defined, Caught by default */
  247. /* 0x08 - User Defined, Caught by default */
  248. /* 0x09 - User Defined, Caught by default */
  249. /* 0x0A - User Defined, Caught by default */
  250. /* 0x0B - User Defined, Caught by default */
  251. /* 0x0C - User Defined, Caught by default */
  252. /* 0x0D - User Defined, Caught by default */
  253. /* 0x0E - User Defined, Caught by default */
  254. /* 0x0F - User Defined, Caught by default */
  255. /* 0x10 HW Single step, handled here */
  256. case VEC_STEP:
  257. info.si_code = TRAP_STEP;
  258. sig = SIGTRAP;
  259. CHK_DEBUGGER_TRAP_MAYBE();
  260. /* Check if this is a single step in kernel space */
  261. if (fp->ipend & 0xffc0)
  262. return;
  263. else
  264. break;
  265. /* 0x11 - Trace Buffer Full, handled here */
  266. case VEC_OVFLOW:
  267. info.si_code = TRAP_TRACEFLOW;
  268. sig = SIGTRAP;
  269. printk(KERN_NOTICE EXC_0x11(KERN_NOTICE));
  270. CHK_DEBUGGER_TRAP();
  271. break;
  272. /* 0x12 - Reserved, Caught by default */
  273. /* 0x13 - Reserved, Caught by default */
  274. /* 0x14 - Reserved, Caught by default */
  275. /* 0x15 - Reserved, Caught by default */
  276. /* 0x16 - Reserved, Caught by default */
  277. /* 0x17 - Reserved, Caught by default */
  278. /* 0x18 - Reserved, Caught by default */
  279. /* 0x19 - Reserved, Caught by default */
  280. /* 0x1A - Reserved, Caught by default */
  281. /* 0x1B - Reserved, Caught by default */
  282. /* 0x1C - Reserved, Caught by default */
  283. /* 0x1D - Reserved, Caught by default */
  284. /* 0x1E - Reserved, Caught by default */
  285. /* 0x1F - Reserved, Caught by default */
  286. /* 0x20 - Reserved, Caught by default */
  287. /* 0x21 - Undefined Instruction, handled here */
  288. case VEC_UNDEF_I:
  289. info.si_code = ILL_ILLOPC;
  290. sig = SIGILL;
  291. printk(KERN_NOTICE EXC_0x21(KERN_NOTICE));
  292. CHK_DEBUGGER_TRAP();
  293. break;
  294. /* 0x22 - Illegal Instruction Combination, handled here */
  295. case VEC_ILGAL_I:
  296. info.si_code = ILL_ILLPARAOP;
  297. sig = SIGILL;
  298. printk(KERN_NOTICE EXC_0x22(KERN_NOTICE));
  299. CHK_DEBUGGER_TRAP();
  300. break;
  301. /* 0x23 - Data CPLB protection violation, handled here */
  302. case VEC_CPLB_VL:
  303. info.si_code = ILL_CPLB_VI;
  304. sig = SIGBUS;
  305. printk(KERN_NOTICE EXC_0x23(KERN_NOTICE));
  306. CHK_DEBUGGER_TRAP();
  307. break;
  308. /* 0x24 - Data access misaligned, handled here */
  309. case VEC_MISALI_D:
  310. info.si_code = BUS_ADRALN;
  311. sig = SIGBUS;
  312. printk(KERN_NOTICE EXC_0x24(KERN_NOTICE));
  313. CHK_DEBUGGER_TRAP();
  314. break;
  315. /* 0x25 - Unrecoverable Event, handled here */
  316. case VEC_UNCOV:
  317. info.si_code = ILL_ILLEXCPT;
  318. sig = SIGILL;
  319. printk(KERN_NOTICE EXC_0x25(KERN_NOTICE));
  320. CHK_DEBUGGER_TRAP();
  321. break;
  322. /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
  323. error case is handled here */
  324. case VEC_CPLB_M:
  325. info.si_code = BUS_ADRALN;
  326. sig = SIGBUS;
  327. printk(KERN_NOTICE EXC_0x26(KERN_NOTICE));
  328. CHK_DEBUGGER_TRAP();
  329. break;
  330. /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
  331. case VEC_CPLB_MHIT:
  332. info.si_code = ILL_CPLB_MULHIT;
  333. sig = SIGSEGV;
  334. #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
  335. if (saved_dcplb_fault_addr < FIXED_CODE_START)
  336. printk(KERN_NOTICE "NULL pointer access\n");
  337. else
  338. #endif
  339. printk(KERN_NOTICE EXC_0x27(KERN_NOTICE));
  340. CHK_DEBUGGER_TRAP();
  341. break;
  342. /* 0x28 - Emulation Watchpoint, handled here */
  343. case VEC_WATCH:
  344. info.si_code = TRAP_WATCHPT;
  345. sig = SIGTRAP;
  346. pr_debug(EXC_0x28(KERN_DEBUG));
  347. CHK_DEBUGGER_TRAP_MAYBE();
  348. /* Check if this is a watchpoint in kernel space */
  349. if (fp->ipend & 0xffc0)
  350. return;
  351. else
  352. break;
  353. #ifdef CONFIG_BF535
  354. /* 0x29 - Instruction fetch access error (535 only) */
  355. case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
  356. info.si_code = BUS_OPFETCH;
  357. sig = SIGBUS;
  358. printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n");
  359. CHK_DEBUGGER_TRAP();
  360. break;
  361. #else
  362. /* 0x29 - Reserved, Caught by default */
  363. #endif
  364. /* 0x2A - Instruction fetch misaligned, handled here */
  365. case VEC_MISALI_I:
  366. info.si_code = BUS_ADRALN;
  367. sig = SIGBUS;
  368. printk(KERN_NOTICE EXC_0x2A(KERN_NOTICE));
  369. CHK_DEBUGGER_TRAP();
  370. break;
  371. /* 0x2B - Instruction CPLB protection violation, handled here */
  372. case VEC_CPLB_I_VL:
  373. info.si_code = ILL_CPLB_VI;
  374. sig = SIGBUS;
  375. printk(KERN_NOTICE EXC_0x2B(KERN_NOTICE));
  376. CHK_DEBUGGER_TRAP();
  377. break;
  378. /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
  379. case VEC_CPLB_I_M:
  380. info.si_code = ILL_CPLB_MISS;
  381. sig = SIGBUS;
  382. printk(KERN_NOTICE EXC_0x2C(KERN_NOTICE));
  383. CHK_DEBUGGER_TRAP();
  384. break;
  385. /* 0x2D - Instruction CPLB Multiple Hits, handled here */
  386. case VEC_CPLB_I_MHIT:
  387. info.si_code = ILL_CPLB_MULHIT;
  388. sig = SIGSEGV;
  389. #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
  390. if (saved_icplb_fault_addr < FIXED_CODE_START)
  391. printk(KERN_NOTICE "Jump to NULL address\n");
  392. else
  393. #endif
  394. printk(KERN_NOTICE EXC_0x2D(KERN_NOTICE));
  395. CHK_DEBUGGER_TRAP();
  396. break;
  397. /* 0x2E - Illegal use of Supervisor Resource, handled here */
  398. case VEC_ILL_RES:
  399. info.si_code = ILL_PRVOPC;
  400. sig = SIGILL;
  401. printk(KERN_NOTICE EXC_0x2E(KERN_NOTICE));
  402. CHK_DEBUGGER_TRAP();
  403. break;
  404. /* 0x2F - Reserved, Caught by default */
  405. /* 0x30 - Reserved, Caught by default */
  406. /* 0x31 - Reserved, Caught by default */
  407. /* 0x32 - Reserved, Caught by default */
  408. /* 0x33 - Reserved, Caught by default */
  409. /* 0x34 - Reserved, Caught by default */
  410. /* 0x35 - Reserved, Caught by default */
  411. /* 0x36 - Reserved, Caught by default */
  412. /* 0x37 - Reserved, Caught by default */
  413. /* 0x38 - Reserved, Caught by default */
  414. /* 0x39 - Reserved, Caught by default */
  415. /* 0x3A - Reserved, Caught by default */
  416. /* 0x3B - Reserved, Caught by default */
  417. /* 0x3C - Reserved, Caught by default */
  418. /* 0x3D - Reserved, Caught by default */
  419. /* 0x3E - Reserved, Caught by default */
  420. /* 0x3F - Reserved, Caught by default */
  421. case VEC_HWERR:
  422. info.si_code = BUS_ADRALN;
  423. sig = SIGBUS;
  424. switch (fp->seqstat & SEQSTAT_HWERRCAUSE) {
  425. /* System MMR Error */
  426. case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR):
  427. info.si_code = BUS_ADRALN;
  428. sig = SIGBUS;
  429. printk(KERN_NOTICE HWC_x2(KERN_NOTICE));
  430. break;
  431. /* External Memory Addressing Error */
  432. case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR):
  433. info.si_code = BUS_ADRERR;
  434. sig = SIGBUS;
  435. printk(KERN_NOTICE HWC_x3(KERN_NOTICE));
  436. break;
  437. /* Performance Monitor Overflow */
  438. case (SEQSTAT_HWERRCAUSE_PERF_FLOW):
  439. printk(KERN_NOTICE HWC_x12(KERN_NOTICE));
  440. break;
  441. /* RAISE 5 instruction */
  442. case (SEQSTAT_HWERRCAUSE_RAISE_5):
  443. printk(KERN_NOTICE HWC_x18(KERN_NOTICE));
  444. break;
  445. default: /* Reserved */
  446. printk(KERN_NOTICE HWC_default(KERN_NOTICE));
  447. break;
  448. }
  449. CHK_DEBUGGER_TRAP();
  450. break;
  451. default:
  452. info.si_code = TRAP_ILLTRAP;
  453. sig = SIGTRAP;
  454. printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
  455. (fp->seqstat & SEQSTAT_EXCAUSE));
  456. CHK_DEBUGGER_TRAP();
  457. break;
  458. }
  459. BUG_ON(sig == 0);
  460. if (sig != SIGTRAP) {
  461. unsigned long *stack;
  462. dump_bfin_process(fp);
  463. dump_bfin_mem(fp);
  464. show_regs(fp);
  465. /* Print out the trace buffer if it makes sense */
  466. #ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
  467. if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M)
  468. printk(KERN_NOTICE "No trace since you do not have "
  469. "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n"
  470. KERN_NOTICE "\n");
  471. else
  472. #endif
  473. dump_bfin_trace_buffer();
  474. if (oops_in_progress) {
  475. /* Dump the current kernel stack */
  476. printk(KERN_NOTICE "\n" KERN_NOTICE "Kernel Stack\n");
  477. show_stack(current, NULL);
  478. print_modules();
  479. #ifndef CONFIG_ACCESS_CHECK
  480. printk(KERN_EMERG "Please turn on "
  481. "CONFIG_ACCESS_CHECK\n");
  482. #endif
  483. panic("Kernel exception");
  484. } else {
  485. /* Dump the user space stack */
  486. stack = (unsigned long *)rdusp();
  487. printk(KERN_NOTICE "Userspace Stack\n");
  488. show_stack(NULL, stack);
  489. }
  490. }
  491. info.si_signo = sig;
  492. info.si_errno = 0;
  493. info.si_addr = (void __user *)fp->pc;
  494. force_sig_info(sig, &info, current);
  495. trace_buffer_restore(j);
  496. return;
  497. }
  498. /* Typical exception handling routines */
  499. #define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)
  500. /*
  501. * Similar to get_user, do some address checking, then dereference
  502. * Return true on sucess, false on bad address
  503. */
  504. bool get_instruction(unsigned short *val, unsigned short *address)
  505. {
  506. unsigned long addr;
  507. addr = (unsigned long)address;
  508. /* Check for odd addresses */
  509. if (addr & 0x1)
  510. return false;
  511. /* Check that things do not wrap around */
  512. if (addr > (addr + 2))
  513. return false;
  514. /*
  515. * Since we are in exception context, we need to do a little address checking
  516. * We need to make sure we are only accessing valid memory, and
  517. * we don't read something in the async space that can hang forever
  518. */
  519. if ((addr >= FIXED_CODE_START && (addr + 2) <= physical_mem_end) ||
  520. #if L2_LENGTH != 0
  521. (addr >= L2_START && (addr + 2) <= (L2_START + L2_LENGTH)) ||
  522. #endif
  523. (addr >= BOOT_ROM_START && (addr + 2) <= (BOOT_ROM_START + BOOT_ROM_LENGTH)) ||
  524. #if L1_DATA_A_LENGTH != 0
  525. (addr >= L1_DATA_A_START && (addr + 2) <= (L1_DATA_A_START + L1_DATA_A_LENGTH)) ||
  526. #endif
  527. #if L1_DATA_B_LENGTH != 0
  528. (addr >= L1_DATA_B_START && (addr + 2) <= (L1_DATA_B_START + L1_DATA_B_LENGTH)) ||
  529. #endif
  530. (addr >= L1_SCRATCH_START && (addr + 2) <= (L1_SCRATCH_START + L1_SCRATCH_LENGTH)) ||
  531. (!(bfin_read_EBIU_AMBCTL0() & B0RDYEN) &&
  532. addr >= ASYNC_BANK0_BASE && (addr + 2) <= (ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE)) ||
  533. (!(bfin_read_EBIU_AMBCTL0() & B1RDYEN) &&
  534. addr >= ASYNC_BANK1_BASE && (addr + 2) <= (ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE)) ||
  535. (!(bfin_read_EBIU_AMBCTL1() & B2RDYEN) &&
  536. addr >= ASYNC_BANK2_BASE && (addr + 2) <= (ASYNC_BANK2_BASE + ASYNC_BANK1_SIZE)) ||
  537. (!(bfin_read_EBIU_AMBCTL1() & B3RDYEN) &&
  538. addr >= ASYNC_BANK3_BASE && (addr + 2) <= (ASYNC_BANK3_BASE + ASYNC_BANK1_SIZE))) {
  539. *val = *address;
  540. return true;
  541. }
  542. #if L1_CODE_LENGTH != 0
  543. if (addr >= L1_CODE_START && (addr + 2) <= (L1_CODE_START + L1_CODE_LENGTH)) {
  544. dma_memcpy(val, address, 2);
  545. return true;
  546. }
  547. #endif
  548. return false;
  549. }
  550. /*
  551. * decode the instruction if we are printing out the trace, as it
  552. * makes things easier to follow, without running it through objdump
  553. * These are the normal instructions which cause change of flow, which
  554. * would be at the source of the trace buffer
  555. */
  556. void decode_instruction(unsigned short *address)
  557. {
  558. unsigned short opcode;
  559. if (get_instruction(&opcode, address)) {
  560. if (opcode == 0x0010)
  561. printk("RTS");
  562. else if (opcode == 0x0011)
  563. printk("RTI");
  564. else if (opcode == 0x0012)
  565. printk("RTX");
  566. else if (opcode >= 0x0050 && opcode <= 0x0057)
  567. printk("JUMP (P%i)", opcode & 7);
  568. else if (opcode >= 0x0060 && opcode <= 0x0067)
  569. printk("CALL (P%i)", opcode & 7);
  570. else if (opcode >= 0x0070 && opcode <= 0x0077)
  571. printk("CALL (PC+P%i)", opcode & 7);
  572. else if (opcode >= 0x0080 && opcode <= 0x0087)
  573. printk("JUMP (PC+P%i)", opcode & 7);
  574. else if ((opcode >= 0x1000 && opcode <= 0x13FF) || (opcode >= 0x1800 && opcode <= 0x1BFF))
  575. printk("IF !CC JUMP");
  576. else if ((opcode >= 0x1400 && opcode <= 0x17ff) || (opcode >= 0x1c00 && opcode <= 0x1fff))
  577. printk("IF CC JUMP");
  578. else if (opcode >= 0x2000 && opcode <= 0x2fff)
  579. printk("JUMP.S");
  580. else if (opcode >= 0xe080 && opcode <= 0xe0ff)
  581. printk("LSETUP");
  582. else if (opcode >= 0xe200 && opcode <= 0xe2ff)
  583. printk("JUMP.L");
  584. else if (opcode >= 0xe300 && opcode <= 0xe3ff)
  585. printk("CALL pcrel");
  586. else
  587. printk("0x%04x", opcode);
  588. }
  589. }
  590. void dump_bfin_trace_buffer(void)
  591. {
  592. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
  593. int tflags, i = 0;
  594. char buf[150];
  595. unsigned short *addr;
  596. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
  597. int j, index;
  598. #endif
  599. trace_buffer_save(tflags);
  600. printk(KERN_NOTICE "Hardware Trace:\n");
  601. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
  602. printk(KERN_NOTICE "WARNING: Expanded trace turned on - can not trace exceptions\n");
  603. #endif
  604. if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
  605. for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
  606. decode_address(buf, (unsigned long)bfin_read_TBUF());
  607. printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
  608. addr = (unsigned short *)bfin_read_TBUF();
  609. decode_address(buf, (unsigned long)addr);
  610. printk(KERN_NOTICE " Source : %s ", buf);
  611. decode_instruction(addr);
  612. printk("\n");
  613. }
  614. }
  615. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
  616. if (trace_buff_offset)
  617. index = trace_buff_offset / 4;
  618. else
  619. index = EXPAND_LEN;
  620. j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128;
  621. while (j) {
  622. decode_address(buf, software_trace_buff[index]);
  623. printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
  624. index -= 1;
  625. if (index < 0 )
  626. index = EXPAND_LEN;
  627. decode_address(buf, software_trace_buff[index]);
  628. printk(KERN_NOTICE " Source : %s ", buf);
  629. decode_instruction((unsigned short *)software_trace_buff[index]);
  630. printk("\n");
  631. index -= 1;
  632. if (index < 0)
  633. index = EXPAND_LEN;
  634. j--;
  635. i++;
  636. }
  637. #endif
  638. trace_buffer_restore(tflags);
  639. #endif
  640. }
  641. EXPORT_SYMBOL(dump_bfin_trace_buffer);
  642. /*
  643. * Checks to see if the address pointed to is either a
  644. * 16-bit CALL instruction, or a 32-bit CALL instruction
  645. */
  646. bool is_bfin_call(unsigned short *addr)
  647. {
  648. unsigned short opcode = 0, *ins_addr;
  649. ins_addr = (unsigned short *)addr;
  650. if (!get_instruction(&opcode, ins_addr))
  651. return false;
  652. if ((opcode >= 0x0060 && opcode <= 0x0067) ||
  653. (opcode >= 0x0070 && opcode <= 0x0077))
  654. return true;
  655. ins_addr--;
  656. if (!get_instruction(&opcode, ins_addr))
  657. return false;
  658. if (opcode >= 0xE300 && opcode <= 0xE3FF)
  659. return true;
  660. return false;
  661. }
  662. void show_stack(struct task_struct *task, unsigned long *stack)
  663. {
  664. unsigned int *addr, *endstack, *fp = 0, *frame;
  665. unsigned short *ins_addr;
  666. char buf[150];
  667. unsigned int i, j, ret_addr, frame_no = 0;
  668. /*
  669. * If we have been passed a specific stack, use that one otherwise
  670. * if we have been passed a task structure, use that, otherwise
  671. * use the stack of where the variable "stack" exists
  672. */
  673. if (stack == NULL) {
  674. if (task) {
  675. /* We know this is a kernel stack, so this is the start/end */
  676. stack = (unsigned long *)task->thread.ksp;
  677. endstack = (unsigned int *)(((unsigned int)(stack) & ~(THREAD_SIZE - 1)) + THREAD_SIZE);
  678. } else {
  679. /* print out the existing stack info */
  680. stack = (unsigned long *)&stack;
  681. endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack);
  682. }
  683. } else
  684. endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack);
  685. decode_address(buf, (unsigned int)stack);
  686. printk(KERN_NOTICE "Stack info:\n" KERN_NOTICE " SP: [0x%p] %s\n", stack, buf);
  687. addr = (unsigned int *)((unsigned int)stack & ~0x3F);
  688. /* First thing is to look for a frame pointer */
  689. for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0;
  690. addr < endstack; addr++, i++) {
  691. if (*addr & 0x1)
  692. continue;
  693. ins_addr = (unsigned short *)*addr;
  694. ins_addr--;
  695. if (is_bfin_call(ins_addr))
  696. fp = addr - 1;
  697. if (fp) {
  698. /* Let's check to see if it is a frame pointer */
  699. while (fp >= (addr - 1) && fp < endstack && fp)
  700. fp = (unsigned int *)*fp;
  701. if (fp == 0 || fp == endstack) {
  702. fp = addr - 1;
  703. break;
  704. }
  705. fp = 0;
  706. }
  707. }
  708. if (fp) {
  709. frame = fp;
  710. printk(" FP: (0x%p)\n", fp);
  711. } else
  712. frame = 0;
  713. /*
  714. * Now that we think we know where things are, we
  715. * walk the stack again, this time printing things out
  716. * incase there is no frame pointer, we still look for
  717. * valid return addresses
  718. */
  719. /* First time print out data, next time, print out symbols */
  720. for (j = 0; j <= 1; j++) {
  721. if (j)
  722. printk(KERN_NOTICE "Return addresses in stack:\n");
  723. else
  724. printk(KERN_NOTICE " Memory from 0x%08lx to %p", ((long unsigned int)stack & ~0xF), endstack);
  725. fp = frame;
  726. frame_no = 0;
  727. for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0;
  728. addr <= endstack; addr++, i++) {
  729. ret_addr = 0;
  730. if (!j && i % 8 == 0)
  731. printk("\n" KERN_NOTICE "%p:",addr);
  732. /* if it is an odd address, or zero, just skip it */
  733. if (*addr & 0x1 || !*addr)
  734. goto print;
  735. ins_addr = (unsigned short *)*addr;
  736. /* Go back one instruction, and see if it is a CALL */
  737. ins_addr--;
  738. ret_addr = is_bfin_call(ins_addr);
  739. print:
  740. if (!j && stack == (unsigned long *)addr)
  741. printk("[%08x]", *addr);
  742. else if (ret_addr)
  743. if (j) {
  744. decode_address(buf, (unsigned int)*addr);
  745. if (frame == addr) {
  746. printk(KERN_NOTICE " frame %2i : %s\n", frame_no, buf);
  747. continue;
  748. }
  749. printk(KERN_NOTICE " address : %s\n", buf);
  750. } else
  751. printk("<%08x>", *addr);
  752. else if (fp == addr) {
  753. if (j)
  754. frame = addr+1;
  755. else
  756. printk("(%08x)", *addr);
  757. fp = (unsigned int *)*addr;
  758. frame_no++;
  759. } else if (!j)
  760. printk(" %08x ", *addr);
  761. }
  762. if (!j)
  763. printk("\n");
  764. }
  765. }
  766. void dump_stack(void)
  767. {
  768. unsigned long stack;
  769. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
  770. int tflags;
  771. #endif
  772. trace_buffer_save(tflags);
  773. dump_bfin_trace_buffer();
  774. show_stack(current, &stack);
  775. trace_buffer_restore(tflags);
  776. }
  777. EXPORT_SYMBOL(dump_stack);
  778. void dump_bfin_process(struct pt_regs *fp)
  779. {
  780. /* We should be able to look at fp->ipend, but we don't push it on the
  781. * stack all the time, so do this until we fix that */
  782. unsigned int context = bfin_read_IPEND();
  783. if (oops_in_progress)
  784. printk(KERN_EMERG "Kernel OOPS in progress\n");
  785. if (context & 0x0020 && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR)
  786. printk(KERN_NOTICE "HW Error context\n");
  787. else if (context & 0x0020)
  788. printk(KERN_NOTICE "Deferred Exception context\n");
  789. else if (context & 0x3FC0)
  790. printk(KERN_NOTICE "Interrupt context\n");
  791. else if (context & 0x4000)
  792. printk(KERN_NOTICE "Deferred Interrupt context\n");
  793. else if (context & 0x8000)
  794. printk(KERN_NOTICE "Kernel process context\n");
  795. /* Because we are crashing, and pointers could be bad, we check things
  796. * pretty closely before we use them
  797. */
  798. if ((unsigned long)current >= FIXED_CODE_START &&
  799. !((unsigned long)current & 0x3) && current->pid) {
  800. printk(KERN_NOTICE "CURRENT PROCESS:\n");
  801. if (current->comm >= (char *)FIXED_CODE_START)
  802. printk(KERN_NOTICE "COMM=%s PID=%d\n",
  803. current->comm, current->pid);
  804. else
  805. printk(KERN_NOTICE "COMM= invalid\n");
  806. if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START)
  807. printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
  808. KERN_NOTICE " BSS = 0x%p-0x%p USER-STACK = 0x%p\n"
  809. KERN_NOTICE "\n",
  810. (void *)current->mm->start_code,
  811. (void *)current->mm->end_code,
  812. (void *)current->mm->start_data,
  813. (void *)current->mm->end_data,
  814. (void *)current->mm->end_data,
  815. (void *)current->mm->brk,
  816. (void *)current->mm->start_stack);
  817. else
  818. printk(KERN_NOTICE "invalid mm\n");
  819. } else
  820. printk(KERN_NOTICE "\n" KERN_NOTICE
  821. "No Valid process in current context\n");
  822. }
  823. void dump_bfin_mem(struct pt_regs *fp)
  824. {
  825. unsigned short *addr, *erraddr, val = 0, err = 0;
  826. char sti = 0, buf[6];
  827. erraddr = (void *)fp->pc;
  828. printk(KERN_NOTICE "return address: [0x%p]; contents of:", erraddr);
  829. for (addr = (unsigned short *)((unsigned long)erraddr & ~0xF) - 0x10;
  830. addr < (unsigned short *)((unsigned long)erraddr & ~0xF) + 0x10;
  831. addr++) {
  832. if (!((unsigned long)addr & 0xF))
  833. printk("\n" KERN_NOTICE "0x%p: ", addr);
  834. if (get_instruction(&val, addr)) {
  835. val = 0;
  836. sprintf(buf, "????");
  837. } else
  838. sprintf(buf, "%04x", val);
  839. if (addr == erraddr) {
  840. printk("[%s]", buf);
  841. err = val;
  842. } else
  843. printk(" %s ", buf);
  844. /* Do any previous instructions turn on interrupts? */
  845. if (addr <= erraddr && /* in the past */
  846. ((val >= 0x0040 && val <= 0x0047) || /* STI instruction */
  847. val == 0x017b)) /* [SP++] = RETI */
  848. sti = 1;
  849. }
  850. printk("\n");
  851. /* Hardware error interrupts can be deferred */
  852. if (unlikely(sti && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR &&
  853. oops_in_progress)){
  854. printk(KERN_NOTICE "Looks like this was a deferred error - sorry\n");
  855. #ifndef CONFIG_DEBUG_HWERR
  856. printk(KERN_NOTICE "The remaining message may be meaningless\n"
  857. KERN_NOTICE "You should enable CONFIG_DEBUG_HWERR to get a"
  858. " better idea where it came from\n");
  859. #else
  860. /* If we are handling only one peripheral interrupt
  861. * and current mm and pid are valid, and the last error
  862. * was in that user space process's text area
  863. * print it out - because that is where the problem exists
  864. */
  865. if ((!(((fp)->ipend & ~0x30) & (((fp)->ipend & ~0x30) - 1))) &&
  866. (current->pid && current->mm)) {
  867. /* And the last RETI points to the current userspace context */
  868. if ((fp + 1)->pc >= current->mm->start_code &&
  869. (fp + 1)->pc <= current->mm->end_code) {
  870. printk(KERN_NOTICE "It might be better to look around here : \n");
  871. printk(KERN_NOTICE "-------------------------------------------\n");
  872. show_regs(fp + 1);
  873. printk(KERN_NOTICE "-------------------------------------------\n");
  874. }
  875. }
  876. #endif
  877. }
  878. }
  879. void show_regs(struct pt_regs *fp)
  880. {
  881. char buf [150];
  882. struct irqaction *action;
  883. unsigned int i;
  884. unsigned long flags;
  885. printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted());
  886. printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n",
  887. (long)fp->seqstat, fp->ipend, fp->syscfg);
  888. printk(KERN_NOTICE " HWERRCAUSE: 0x%lx\n",
  889. (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14);
  890. printk(KERN_NOTICE " EXCAUSE : 0x%lx\n",
  891. fp->seqstat & SEQSTAT_EXCAUSE);
  892. for (i = 6; i <= 15 ; i++) {
  893. if (fp->ipend & (1 << i)) {
  894. decode_address(buf, bfin_read32(EVT0 + 4*i));
  895. printk(KERN_NOTICE " physical IVG%i asserted : %s\n", i, buf);
  896. }
  897. }
  898. /* if no interrupts are going off, don't print this out */
  899. if (fp->ipend & ~0x3F) {
  900. for (i = 0; i < (NR_IRQS - 1); i++) {
  901. spin_lock_irqsave(&irq_desc[i].lock, flags);
  902. action = irq_desc[i].action;
  903. if (!action)
  904. goto unlock;
  905. decode_address(buf, (unsigned int)action->handler);
  906. printk(KERN_NOTICE " logical irq %3d mapped : %s", i, buf);
  907. for (action = action->next; action; action = action->next) {
  908. decode_address(buf, (unsigned int)action->handler);
  909. printk(", %s", buf);
  910. }
  911. printk("\n");
  912. unlock:
  913. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  914. }
  915. }
  916. decode_address(buf, fp->rete);
  917. printk(KERN_NOTICE " RETE: %s\n", buf);
  918. decode_address(buf, fp->retn);
  919. printk(KERN_NOTICE " RETN: %s\n", buf);
  920. decode_address(buf, fp->retx);
  921. printk(KERN_NOTICE " RETX: %s\n", buf);
  922. decode_address(buf, fp->rets);
  923. printk(KERN_NOTICE " RETS: %s\n", buf);
  924. decode_address(buf, fp->pc);
  925. printk(KERN_NOTICE " PC : %s\n", buf);
  926. if (((long)fp->seqstat & SEQSTAT_EXCAUSE) &&
  927. (((long)fp->seqstat & SEQSTAT_EXCAUSE) != VEC_HWERR)) {
  928. decode_address(buf, saved_dcplb_fault_addr);
  929. printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf);
  930. decode_address(buf, saved_icplb_fault_addr);
  931. printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf);
  932. }
  933. printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n");
  934. printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n",
  935. fp->r0, fp->r1, fp->r2, fp->r3);
  936. printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n",
  937. fp->r4, fp->r5, fp->r6, fp->r7);
  938. printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n",
  939. fp->p0, fp->p1, fp->p2, fp->p3);
  940. printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n",
  941. fp->p4, fp->p5, fp->fp, (long)fp);
  942. printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n",
  943. fp->lb0, fp->lt0, fp->lc0);
  944. printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n",
  945. fp->lb1, fp->lt1, fp->lc1);
  946. printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n",
  947. fp->b0, fp->l0, fp->m0, fp->i0);
  948. printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n",
  949. fp->b1, fp->l1, fp->m1, fp->i1);
  950. printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n",
  951. fp->b2, fp->l2, fp->m2, fp->i2);
  952. printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n",
  953. fp->b3, fp->l3, fp->m3, fp->i3);
  954. printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
  955. fp->a0w, fp->a0x, fp->a1w, fp->a1x);
  956. printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n",
  957. rdusp(), fp->astat);
  958. printk(KERN_NOTICE "\n");
  959. }
  960. #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
  961. asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text));
  962. #endif
  963. asmlinkage int sys_bfin_spinlock(int *spinlock)
  964. {
  965. int ret = 0;
  966. int tmp = 0;
  967. local_irq_disable();
  968. ret = get_user(tmp, spinlock);
  969. if (ret == 0) {
  970. if (tmp)
  971. ret = 1;
  972. tmp = 1;
  973. put_user(tmp, spinlock);
  974. }
  975. local_irq_enable();
  976. return ret;
  977. }
  978. int bfin_request_exception(unsigned int exception, void (*handler)(void))
  979. {
  980. void (*curr_handler)(void);
  981. if (exception > 0x3F)
  982. return -EINVAL;
  983. curr_handler = ex_table[exception];
  984. if (curr_handler != ex_replaceable)
  985. return -EBUSY;
  986. ex_table[exception] = handler;
  987. return 0;
  988. }
  989. EXPORT_SYMBOL(bfin_request_exception);
  990. int bfin_free_exception(unsigned int exception, void (*handler)(void))
  991. {
  992. void (*curr_handler)(void);
  993. if (exception > 0x3F)
  994. return -EINVAL;
  995. curr_handler = ex_table[exception];
  996. if (curr_handler != handler)
  997. return -EBUSY;
  998. ex_table[exception] = ex_replaceable;
  999. return 0;
  1000. }
  1001. EXPORT_SYMBOL(bfin_free_exception);
  1002. void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
  1003. {
  1004. switch (cplb_panic) {
  1005. case CPLB_NO_UNLOCKED:
  1006. printk(KERN_EMERG "All CPLBs are locked\n");
  1007. break;
  1008. case CPLB_PROT_VIOL:
  1009. return;
  1010. case CPLB_NO_ADDR_MATCH:
  1011. return;
  1012. case CPLB_UNKNOWN_ERR:
  1013. printk(KERN_EMERG "Unknown CPLB Exception\n");
  1014. break;
  1015. }
  1016. oops_in_progress = 1;
  1017. dump_bfin_process(fp);
  1018. dump_bfin_mem(fp);
  1019. show_regs(fp);
  1020. dump_stack();
  1021. panic("Unrecoverable event\n");
  1022. }