traps.c 32 KB

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