traps.c 19 KB

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