memoryDefinitionWaterRelatedData.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Main exception handling logic.
  3. *
  4. * Copyright 2004-2010 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later
  7. */
  8. #include <linux/bug.h>
  9. #include <linux/uaccess.h>
  10. #include <linux/module.h>
  11. #include <asm/traps.h>
  12. #include <asm/cplb.h>
  13. #include <asm/blackfin.h>
  14. #include <asm/irq_handler.h>
  15. #include <linux/irq.h>
  16. #include <asm/trace.h>
  17. #include <asm/fixed_code.h>
  18. #include <asm/pseudo_instructions.h>
  19. #include <asm/pda.h>
  20. #ifdef CONFIG_KGDB
  21. # include <linux/kgdb.h>
  22. # define CHK_DEBUGGER_TRAP() \
  23. do { \
  24. kgdb_handle_exception(trapnr, sig, info.si_code, fp); \
  25. } while (0)
  26. # define CHK_DEBUGGER_TRAP_MAYBE() \
  27. do { \
  28. if (kgdb_connected) \
  29. CHK_DEBUGGER_TRAP(); \
  30. } while (0)
  31. #else
  32. # define CHK_DEBUGGER_TRAP() do { } while (0)
  33. # define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0)
  34. #endif
  35. #ifdef CONFIG_DEBUG_VERBOSE
  36. #define verbose_printk(fmt, arg...) \
  37. printk(fmt, ##arg)
  38. #else
  39. #define verbose_printk(fmt, arg...) \
  40. ({ if (0) printk(fmt, ##arg); 0; })
  41. #endif
  42. #if defined(CONFIG_DEBUG_MMRS) || defined(CONFIG_DEBUG_MMRS_MODULE)
  43. u32 last_seqstat;
  44. #ifdef CONFIG_DEBUG_MMRS_MODULE
  45. EXPORT_SYMBOL(last_seqstat);
  46. #endif
  47. #endif
  48. /* Initiate the event table handler */
  49. void __init trap_init(void)
  50. {
  51. CSYNC();
  52. bfin_write_EVT3(trap);
  53. CSYNC();
  54. }
  55. static int kernel_mode_regs(struct pt_regs *regs)
  56. {
  57. return regs->ipend & 0xffc0;
  58. }
  59. asmlinkage notrace void trap_c(struct pt_regs *fp)
  60. {
  61. #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
  62. int j;
  63. #endif
  64. #ifdef CONFIG_BFIN_PSEUDODBG_INSNS
  65. int opcode;
  66. #endif
  67. unsigned int cpu = raw_smp_processor_id();
  68. const char *strerror = NULL;
  69. int sig = 0;
  70. siginfo_t info;
  71. unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE;
  72. trace_buffer_save(j);
  73. #if defined(CONFIG_DEBUG_MMRS) || defined(CONFIG_DEBUG_MMRS_MODULE)
  74. last_seqstat = (u32)fp->seqstat;
  75. #endif
  76. /* Important - be very careful dereferncing pointers - will lead to
  77. * double faults if the stack has become corrupt
  78. */
  79. /* trap_c() will be called for exceptions. During exceptions
  80. * processing, the pc value should be set with retx value.
  81. * With this change we can cleanup some code in signal.c- TODO
  82. */
  83. fp->orig_pc = fp->retx;
  84. /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n",
  85. trapnr, fp->ipend, fp->pc, fp->retx); */
  86. /* send the appropriate signal to the user program */
  87. switch (trapnr) {
  88. /* This table works in conjunction with the one in ./mach-common/entry.S
  89. * Some exceptions are handled there (in assembly, in exception space)
  90. * Some are handled here, (in C, in interrupt space)
  91. * Some, like CPLB, are handled in both, where the normal path is
  92. * handled in assembly/exception space, and the error path is handled
  93. * here
  94. */
  95. /* 0x00 - Linux Syscall, getting here is an error */
  96. /* 0x01 - userspace gdb breakpoint, handled here */
  97. case VEC_EXCPT01:
  98. info.si_code = TRAP_ILLTRAP;
  99. sig = SIGTRAP;
  100. CHK_DEBUGGER_TRAP_MAYBE();
  101. /* Check if this is a breakpoint in kernel space */
  102. if (kernel_mode_regs(fp))
  103. goto traps_done;
  104. else
  105. break;
  106. /* 0x03 - User Defined, userspace stack overflow */
  107. case VEC_EXCPT03:
  108. info.si_code = SEGV_STACKFLOW;
  109. sig = SIGSEGV;
  110. strerror = KERN_NOTICE EXC_0x03(KERN_NOTICE);
  111. CHK_DEBUGGER_TRAP_MAYBE();
  112. break;
  113. /* 0x02 - KGDB initial connection and break signal trap */
  114. case VEC_EXCPT02:
  115. #ifdef CONFIG_KGDB
  116. info.si_code = TRAP_ILLTRAP;
  117. sig = SIGTRAP;
  118. CHK_DEBUGGER_TRAP();
  119. goto traps_done;
  120. #endif
  121. /* 0x04 - User Defined */