traps.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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 <asm/uaccess.h>
  30. #include <asm/traps.h>
  31. #include <asm/cacheflush.h>
  32. #include <asm/blackfin.h>
  33. #include <asm/uaccess.h>
  34. #include <asm/irq_handler.h>
  35. #include <linux/interrupt.h>
  36. #include <linux/module.h>
  37. #include <linux/kallsyms.h>
  38. #ifdef CONFIG_KGDB
  39. # include <linux/debugger.h>
  40. # include <linux/kgdb.h>
  41. #endif
  42. /* Initiate the event table handler */
  43. void __init trap_init(void)
  44. {
  45. CSYNC();
  46. bfin_write_EVT3(trap);
  47. CSYNC();
  48. }
  49. asmlinkage void trap_c(struct pt_regs *fp);
  50. int kstack_depth_to_print = 48;
  51. static int printk_address(unsigned long address)
  52. {
  53. struct vm_list_struct *vml;
  54. struct task_struct *p;
  55. struct mm_struct *mm;
  56. #ifdef CONFIG_KALLSYMS
  57. unsigned long offset = 0, symsize;
  58. const char *symname;
  59. char *modname;
  60. char *delim = ":";
  61. char namebuf[128];
  62. /* look up the address and see if we are in kernel space */
  63. symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf);
  64. if (symname) {
  65. /* yeah! kernel space! */
  66. if (!modname)
  67. modname = delim = "";
  68. return printk("<0x%p> { %s%s%s%s + 0x%lx }",
  69. (void*)address, delim, modname, delim, symname,
  70. (unsigned long)offset);
  71. }
  72. #endif
  73. /* looks like we're off in user-land, so let's walk all the
  74. * mappings of all our processes and see if we can't be a whee
  75. * bit more specific
  76. */
  77. write_lock_irq(&tasklist_lock);
  78. for_each_process(p) {
  79. mm = get_task_mm(p);
  80. if (!mm)
  81. continue;
  82. vml = mm->context.vmlist;
  83. while (vml) {
  84. struct vm_area_struct *vma = vml->vma;
  85. if (address >= vma->vm_start && address < vma->vm_end) {
  86. char *name = p->comm;
  87. struct file *file = vma->vm_file;
  88. if (file) {
  89. char _tmpbuf[256];
  90. name = d_path(file->f_dentry,
  91. file->f_vfsmnt,
  92. _tmpbuf,
  93. sizeof(_tmpbuf));
  94. }
  95. write_unlock_irq(&tasklist_lock);
  96. return printk("<0x%p> [ %s + 0x%lx ]",
  97. (void*)address, name,
  98. (unsigned long)
  99. ((address - vma->vm_start) +
  100. (vma->vm_pgoff << PAGE_SHIFT)));
  101. }
  102. vml = vml->next;
  103. }
  104. }
  105. write_unlock_irq(&tasklist_lock);
  106. /* we were unable to find this address anywhere */
  107. return printk("[<0x%p>]", (void*)address);
  108. }
  109. #define trace_buffer_save(x) \
  110. do { \
  111. (x) = bfin_read_TBUFCTL(); \
  112. bfin_write_TBUFCTL((x) & ~TBUFEN); \
  113. } while (0)
  114. #define trace_buffer_restore(x) \
  115. do { \
  116. bfin_write_TBUFCTL((x)); \
  117. } while (0)
  118. asmlinkage void trap_c(struct pt_regs *fp)
  119. {
  120. int j, sig = 0;
  121. siginfo_t info;
  122. unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
  123. #ifdef CONFIG_KGDB
  124. # define CHK_DEBUGGER_TRAP() do { CHK_DEBUGGER(trapnr, sig, info.si_code, fp,); } while (0)
  125. # define CHK_DEBUGGER_TRAP_MAYBE() do { if (kgdb_connected) CHK_DEBUGGER_TRAP(); } while (0)
  126. #else
  127. # define CHK_DEBUGGER_TRAP() do { } while (0)
  128. # define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
  129. #endif
  130. trace_buffer_save(j);
  131. /* trap_c() will be called for exceptions. During exceptions
  132. * processing, the pc value should be set with retx value.
  133. * With this change we can cleanup some code in signal.c- TODO
  134. */
  135. fp->orig_pc = fp->retx;
  136. /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
  137. trapnr, fp->ipend, fp->pc, fp->retx); */
  138. /* send the appropriate signal to the user program */
  139. switch (trapnr) {
  140. /* This table works in conjuction with the one in ./mach-common/entry.S
  141. * Some exceptions are handled there (in assembly, in exception space)
  142. * Some are handled here, (in C, in interrupt space)
  143. * Some, like CPLB, are handled in both, where the normal path is
  144. * handled in assembly/exception space, and the error path is handled
  145. * here
  146. */
  147. /* 0x00 - Linux Syscall, getting here is an error */
  148. /* 0x01 - userspace gdb breakpoint, handled here */
  149. case VEC_EXCPT01:
  150. info.si_code = TRAP_ILLTRAP;
  151. sig = SIGTRAP;
  152. CHK_DEBUGGER_TRAP_MAYBE();
  153. /* Check if this is a breakpoint in kernel space */
  154. if (fp->ipend & 0xffc0)
  155. return;
  156. else
  157. break;
  158. #ifdef CONFIG_KGDB
  159. case VEC_EXCPT02 : /* gdb connection */
  160. info.si_code = TRAP_ILLTRAP;
  161. sig = SIGTRAP;
  162. CHK_DEBUGGER_TRAP();
  163. return;
  164. #else
  165. /* 0x02 - User Defined, Caught by default */
  166. #endif
  167. /* 0x03 - Atomic test and set */
  168. case VEC_EXCPT03:
  169. info.si_code = SEGV_STACKFLOW;
  170. sig = SIGSEGV;
  171. printk(KERN_EMERG EXC_0x03);
  172. CHK_DEBUGGER_TRAP();
  173. break;
  174. /* 0x04 - spinlock - handled by _ex_spinlock,
  175. getting here is an error */
  176. /* 0x05 - User Defined, Caught by default */
  177. /* 0x06 - User Defined, Caught by default */
  178. /* 0x07 - User Defined, Caught by default */
  179. /* 0x08 - User Defined, Caught by default */
  180. /* 0x09 - User Defined, Caught by default */
  181. /* 0x0A - User Defined, Caught by default */
  182. /* 0x0B - User Defined, Caught by default */
  183. /* 0x0C - User Defined, Caught by default */
  184. /* 0x0D - User Defined, Caught by default */
  185. /* 0x0E - User Defined, Caught by default */
  186. /* 0x0F - User Defined, Caught by default */
  187. /* 0x10 HW Single step, handled here */
  188. case VEC_STEP:
  189. info.si_code = TRAP_STEP;
  190. sig = SIGTRAP;
  191. CHK_DEBUGGER_TRAP_MAYBE();
  192. /* Check if this is a single step in kernel space */
  193. if (fp->ipend & 0xffc0)
  194. return;
  195. else
  196. break;
  197. /* 0x11 - Trace Buffer Full, handled here */
  198. case VEC_OVFLOW:
  199. info.si_code = TRAP_TRACEFLOW;
  200. sig = SIGTRAP;
  201. printk(KERN_EMERG EXC_0x11);
  202. CHK_DEBUGGER_TRAP();
  203. break;
  204. /* 0x12 - Reserved, Caught by default */
  205. /* 0x13 - Reserved, Caught by default */
  206. /* 0x14 - Reserved, Caught by default */
  207. /* 0x15 - Reserved, Caught by default */
  208. /* 0x16 - Reserved, Caught by default */
  209. /* 0x17 - Reserved, Caught by default */
  210. /* 0x18 - Reserved, Caught by default */
  211. /* 0x19 - Reserved, Caught by default */
  212. /* 0x1A - Reserved, Caught by default */
  213. /* 0x1B - Reserved, Caught by default */
  214. /* 0x1C - Reserved, Caught by default */
  215. /* 0x1D - Reserved, Caught by default */
  216. /* 0x1E - Reserved, Caught by default */
  217. /* 0x1F - Reserved, Caught by default */
  218. /* 0x20 - Reserved, Caught by default */
  219. /* 0x21 - Undefined Instruction, handled here */
  220. case VEC_UNDEF_I:
  221. info.si_code = ILL_ILLOPC;
  222. sig = SIGILL;
  223. printk(KERN_EMERG EXC_0x21);
  224. CHK_DEBUGGER_TRAP();
  225. break;
  226. /* 0x22 - Illegal Instruction Combination, handled here */
  227. case VEC_ILGAL_I:
  228. info.si_code = ILL_ILLPARAOP;
  229. sig = SIGILL;
  230. printk(KERN_EMERG EXC_0x22);
  231. CHK_DEBUGGER_TRAP();
  232. break;
  233. /* 0x23 - Data CPLB Protection Violation,
  234. normal case is handled in _cplb_hdr */
  235. case VEC_CPLB_VL:
  236. info.si_code = ILL_CPLB_VI;
  237. sig = SIGILL;
  238. printk(KERN_EMERG EXC_0x23);
  239. CHK_DEBUGGER_TRAP();
  240. break;
  241. /* 0x24 - Data access misaligned, handled here */
  242. case VEC_MISALI_D:
  243. info.si_code = BUS_ADRALN;
  244. sig = SIGBUS;
  245. printk(KERN_EMERG EXC_0x24);
  246. CHK_DEBUGGER_TRAP();
  247. break;
  248. /* 0x25 - Unrecoverable Event, handled here */
  249. case VEC_UNCOV:
  250. info.si_code = ILL_ILLEXCPT;
  251. sig = SIGILL;
  252. printk(KERN_EMERG EXC_0x25);
  253. CHK_DEBUGGER_TRAP();
  254. break;
  255. /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr,
  256. error case is handled here */
  257. case VEC_CPLB_M:
  258. info.si_code = BUS_ADRALN;
  259. sig = SIGBUS;
  260. printk(KERN_EMERG EXC_0x26);
  261. CHK_DEBUGGER_TRAP();
  262. break;
  263. /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */
  264. case VEC_CPLB_MHIT:
  265. info.si_code = ILL_CPLB_MULHIT;
  266. #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
  267. sig = SIGSEGV;
  268. printk(KERN_EMERG "\n\nNULL pointer access (probably)\n");
  269. #else
  270. sig = SIGILL;
  271. printk(KERN_EMERG EXC_0x27);
  272. #endif
  273. CHK_DEBUGGER_TRAP();
  274. break;
  275. /* 0x28 - Emulation Watchpoint, handled here */
  276. case VEC_WATCH:
  277. info.si_code = TRAP_WATCHPT;
  278. sig = SIGTRAP;
  279. pr_debug(EXC_0x28);
  280. CHK_DEBUGGER_TRAP_MAYBE();
  281. /* Check if this is a watchpoint in kernel space */
  282. if (fp->ipend & 0xffc0)
  283. return;
  284. else
  285. break;
  286. #ifdef CONFIG_BF535
  287. /* 0x29 - Instruction fetch access error (535 only) */
  288. case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */
  289. info.si_code = BUS_OPFETCH;
  290. sig = SIGBUS;
  291. printk(KERN_EMERG "BF535: VEC_ISTRU_VL\n");
  292. CHK_DEBUGGER_TRAP();
  293. break;
  294. #else
  295. /* 0x29 - Reserved, Caught by default */
  296. #endif
  297. /* 0x2A - Instruction fetch misaligned, handled here */
  298. case VEC_MISALI_I:
  299. info.si_code = BUS_ADRALN;
  300. sig = SIGBUS;
  301. printk(KERN_EMERG EXC_0x2A);
  302. CHK_DEBUGGER_TRAP();
  303. break;
  304. /* 0x2B - Instruction CPLB protection Violation,
  305. handled in _cplb_hdr */
  306. case VEC_CPLB_I_VL:
  307. info.si_code = ILL_CPLB_VI;
  308. sig = SIGILL;
  309. printk(KERN_EMERG EXC_0x2B);
  310. CHK_DEBUGGER_TRAP();
  311. break;
  312. /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */
  313. case VEC_CPLB_I_M:
  314. info.si_code = ILL_CPLB_MISS;
  315. sig = SIGBUS;
  316. printk(KERN_EMERG EXC_0x2C);
  317. CHK_DEBUGGER_TRAP();
  318. break;
  319. /* 0x2D - Instruction CPLB Multiple Hits, handled here */
  320. case VEC_CPLB_I_MHIT:
  321. info.si_code = ILL_CPLB_MULHIT;
  322. #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO
  323. sig = SIGSEGV;
  324. printk(KERN_EMERG "\n\nJump to address 0 - 0x0fff\n");
  325. #else
  326. sig = SIGILL;
  327. printk(KERN_EMERG EXC_0x2D);
  328. #endif
  329. CHK_DEBUGGER_TRAP();
  330. break;
  331. /* 0x2E - Illegal use of Supervisor Resource, handled here */
  332. case VEC_ILL_RES:
  333. info.si_code = ILL_PRVOPC;
  334. sig = SIGILL;
  335. printk(KERN_EMERG EXC_0x2E);
  336. CHK_DEBUGGER_TRAP();
  337. break;
  338. /* 0x2F - Reserved, Caught by default */
  339. /* 0x30 - Reserved, Caught by default */
  340. /* 0x31 - Reserved, Caught by default */
  341. /* 0x32 - Reserved, Caught by default */
  342. /* 0x33 - Reserved, Caught by default */
  343. /* 0x34 - Reserved, Caught by default */
  344. /* 0x35 - Reserved, Caught by default */
  345. /* 0x36 - Reserved, Caught by default */
  346. /* 0x37 - Reserved, Caught by default */
  347. /* 0x38 - Reserved, Caught by default */
  348. /* 0x39 - Reserved, Caught by default */
  349. /* 0x3A - Reserved, Caught by default */
  350. /* 0x3B - Reserved, Caught by default */
  351. /* 0x3C - Reserved, Caught by default */
  352. /* 0x3D - Reserved, Caught by default */
  353. /* 0x3E - Reserved, Caught by default */
  354. /* 0x3F - Reserved, Caught by default */
  355. default:
  356. info.si_code = TRAP_ILLTRAP;
  357. sig = SIGTRAP;
  358. printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n",
  359. (fp->seqstat & SEQSTAT_EXCAUSE));
  360. CHK_DEBUGGER_TRAP();
  361. break;
  362. }
  363. info.si_signo = sig;
  364. info.si_errno = 0;
  365. info.si_addr = (void *)fp->pc;
  366. force_sig_info(sig, &info, current);
  367. if (sig != 0 && sig != SIGTRAP) {
  368. unsigned long stack;
  369. dump_bfin_regs(fp, (void *)fp->retx);
  370. dump_bfin_trace_buffer();
  371. show_stack(current, &stack);
  372. if (current->mm == NULL)
  373. panic("Kernel exception");
  374. }
  375. /* if the address that we are about to return to is not valid, set it
  376. * to a valid address, if we have a current application or panic
  377. */
  378. if (!(fp->pc <= physical_mem_end
  379. #if L1_CODE_LENGTH != 0
  380. || (fp->pc >= L1_CODE_START &&
  381. fp->pc <= (L1_CODE_START + L1_CODE_LENGTH))
  382. #endif
  383. )) {
  384. if (current->mm) {
  385. fp->pc = current->mm->start_code;
  386. } else {
  387. printk(KERN_EMERG "I can't return to memory that doesn't exist - bad things happen\n");
  388. panic("Help - I've fallen and can't get up\n");
  389. }
  390. }
  391. trace_buffer_restore(j);
  392. return;
  393. }
  394. /* Typical exception handling routines */
  395. void dump_bfin_trace_buffer(void)
  396. {
  397. int tflags;
  398. trace_buffer_save(tflags);
  399. if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
  400. int i;
  401. printk(KERN_EMERG "Hardware Trace:\n");
  402. for (i = 0; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
  403. printk(KERN_EMERG "%2i Target : ", i);
  404. printk_address((unsigned long)bfin_read_TBUF());
  405. printk("\n" KERN_EMERG " Source : ");
  406. printk_address((unsigned long)bfin_read_TBUF());
  407. printk("\n");
  408. }
  409. }
  410. trace_buffer_restore(tflags);
  411. }
  412. EXPORT_SYMBOL(dump_bfin_trace_buffer);
  413. static void show_trace(struct task_struct *tsk, unsigned long *sp)
  414. {
  415. unsigned long addr;
  416. printk("\nCall Trace:");
  417. #ifdef CONFIG_KALLSYMS
  418. printk("\n");
  419. #endif
  420. while (!kstack_end(sp)) {
  421. addr = *sp++;
  422. /*
  423. * If the address is either in the text segment of the
  424. * kernel, or in the region which contains vmalloc'ed
  425. * memory, it *may* be the address of a calling
  426. * routine; if so, print it so that someone tracing
  427. * down the cause of the crash will be able to figure
  428. * out the call path that was taken.
  429. */
  430. if (kernel_text_address(addr))
  431. print_ip_sym(addr);
  432. }
  433. printk("\n");
  434. }
  435. void show_stack(struct task_struct *task, unsigned long *stack)
  436. {
  437. unsigned long *endstack, addr;
  438. int i;
  439. /* Cannot call dump_bfin_trace_buffer() here as show_stack() is
  440. * called externally in some places in the kernel.
  441. */
  442. if (!stack) {
  443. if (task)
  444. stack = (unsigned long *)task->thread.ksp;
  445. else
  446. stack = (unsigned long *)&stack;
  447. }
  448. addr = (unsigned long)stack;
  449. endstack = (unsigned long *)PAGE_ALIGN(addr);
  450. printk(KERN_EMERG "Stack from %08lx:", (unsigned long)stack);
  451. for (i = 0; i < kstack_depth_to_print; i++) {
  452. if (stack + 1 > endstack)
  453. break;
  454. if (i % 8 == 0)
  455. printk("\n" KERN_EMERG " ");
  456. printk(" %08lx", *stack++);
  457. }
  458. show_trace(task, stack);
  459. }
  460. void dump_stack(void)
  461. {
  462. unsigned long stack;
  463. int tflags;
  464. trace_buffer_save(tflags);
  465. dump_bfin_trace_buffer();
  466. show_stack(current, &stack);
  467. trace_buffer_restore(tflags);
  468. }
  469. EXPORT_SYMBOL(dump_stack);
  470. void dump_bfin_regs(struct pt_regs *fp, void *retaddr)
  471. {
  472. if (current->pid) {
  473. printk("\nCURRENT PROCESS:\n\n");
  474. printk("COMM=%s PID=%d\n", current->comm, current->pid);
  475. } else {
  476. printk
  477. ("\nNo Valid pid - Either things are really messed up, or you are in the kernel\n");
  478. }
  479. if (current->mm) {
  480. printk("TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n"
  481. "BSS = 0x%p-0x%p USER-STACK = 0x%p\n\n",
  482. (void*)current->mm->start_code,
  483. (void*)current->mm->end_code,
  484. (void*)current->mm->start_data,
  485. (void*)current->mm->end_data,
  486. (void*)current->mm->end_data,
  487. (void*)current->mm->brk,
  488. (void*)current->mm->start_stack);
  489. }
  490. printk("return address: 0x%p; contents of [PC-16...PC+8]:\n", retaddr);
  491. if (retaddr != 0 && retaddr <= (void*)physical_mem_end
  492. #if L1_CODE_LENGTH != 0
  493. /* FIXME: Copy the code out of L1 Instruction SRAM through dma
  494. memcpy. */
  495. && !(retaddr >= (void*)L1_CODE_START
  496. && retaddr < (void*)(L1_CODE_START + L1_CODE_LENGTH))
  497. #endif
  498. ) {
  499. int i = 0;
  500. unsigned short x = 0;
  501. for (i = -16; i < 8; i++) {
  502. if (get_user(x, (unsigned short *)retaddr + i))
  503. break;
  504. #ifndef CONFIG_DEBUG_HWERR
  505. /* If one of the last few instructions was a STI
  506. * it is likily that the error occured awhile ago
  507. * and we just noticed
  508. */
  509. if (x >= 0x0040 && x <= 0x0047 && i <= 0)
  510. panic("\n\nWARNING : You should reconfigure the kernel to turn on\n"
  511. " 'Hardware error interrupt debugging'\n"
  512. " The rest of this error is meanless\n");
  513. #endif
  514. if (i == -8)
  515. printk("\n");
  516. if (i == 0)
  517. printk("X\n");
  518. printk("%04x ", x);
  519. }
  520. } else
  521. printk("Cannot look at the [PC] for it is in unreadable L1 SRAM - sorry\n");
  522. printk("\n\n");
  523. printk("RETE: %08lx RETN: %08lx RETX: %08lx RETS: %08lx\n",
  524. fp->rete, fp->retn, fp->retx, fp->rets);
  525. printk("IPEND: %04lx SYSCFG: %04lx\n", fp->ipend, fp->syscfg);
  526. printk("SEQSTAT: %08lx SP: %08lx\n", (long)fp->seqstat, (long)fp);
  527. printk("R0: %08lx R1: %08lx R2: %08lx R3: %08lx\n",
  528. fp->r0, fp->r1, fp->r2, fp->r3);
  529. printk("R4: %08lx R5: %08lx R6: %08lx R7: %08lx\n",
  530. fp->r4, fp->r5, fp->r6, fp->r7);
  531. printk("P0: %08lx P1: %08lx P2: %08lx P3: %08lx\n",
  532. fp->p0, fp->p1, fp->p2, fp->p3);
  533. printk("P4: %08lx P5: %08lx FP: %08lx\n", fp->p4, fp->p5, fp->fp);
  534. printk("A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n",
  535. fp->a0w, fp->a0x, fp->a1w, fp->a1x);
  536. printk("LB0: %08lx LT0: %08lx LC0: %08lx\n", fp->lb0, fp->lt0,
  537. fp->lc0);
  538. printk("LB1: %08lx LT1: %08lx LC1: %08lx\n", fp->lb1, fp->lt1,
  539. fp->lc1);
  540. printk("B0: %08lx L0: %08lx M0: %08lx I0: %08lx\n", fp->b0, fp->l0,
  541. fp->m0, fp->i0);
  542. printk("B1: %08lx L1: %08lx M1: %08lx I1: %08lx\n", fp->b1, fp->l1,
  543. fp->m1, fp->i1);
  544. printk("B2: %08lx L2: %08lx M2: %08lx I2: %08lx\n", fp->b2, fp->l2,
  545. fp->m2, fp->i2);
  546. printk("B3: %08lx L3: %08lx M3: %08lx I3: %08lx\n", fp->b3, fp->l3,
  547. fp->m3, fp->i3);
  548. printk("\nUSP: %08lx ASTAT: %08lx\n", rdusp(), fp->astat);
  549. if ((long)fp->seqstat & SEQSTAT_EXCAUSE) {
  550. printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
  551. printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
  552. }
  553. printk("\n\n");
  554. }
  555. #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1
  556. asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text));
  557. #endif
  558. asmlinkage int sys_bfin_spinlock(int *spinlock)
  559. {
  560. int ret = 0;
  561. int tmp = 0;
  562. local_irq_disable();
  563. ret = get_user(tmp, spinlock);
  564. if (ret == 0) {
  565. if (tmp)
  566. ret = 1;
  567. tmp = 1;
  568. put_user(tmp, spinlock);
  569. }
  570. local_irq_enable();
  571. return ret;
  572. }
  573. void panic_cplb_error(int cplb_panic, struct pt_regs *fp)
  574. {
  575. switch (cplb_panic) {
  576. case CPLB_NO_UNLOCKED:
  577. printk(KERN_EMERG "All CPLBs are locked\n");
  578. break;
  579. case CPLB_PROT_VIOL:
  580. return;
  581. case CPLB_NO_ADDR_MATCH:
  582. return;
  583. case CPLB_UNKNOWN_ERR:
  584. printk(KERN_EMERG "Unknown CPLB Exception\n");
  585. break;
  586. }
  587. printk(KERN_EMERG "DCPLB_FAULT_ADDR=%p\n", (void*)bfin_read_DCPLB_FAULT_ADDR());
  588. printk(KERN_EMERG "ICPLB_FAULT_ADDR=%p\n", (void*)bfin_read_ICPLB_FAULT_ADDR());
  589. dump_bfin_regs(fp, (void *)fp->retx);
  590. dump_stack();
  591. panic("Unrecoverable event\n");
  592. }