traps.c 18 KB

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