traps.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * arch/xtensa/include/asm/traps.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2012 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_TRAPS_H
  11. #define _XTENSA_TRAPS_H
  12. #include <asm/ptrace.h>
  13. typedef void xtensa_exception_handler(struct pt_regs *regs);
  14. /*
  15. * Per-CPU exception handling data structure.
  16. * EXCSAVE1 points to it.
  17. */
  18. struct exc_table {
  19. /* Kernel Stack */
  20. void *kstk;
  21. /* Double exception save area for a0 */
  22. unsigned long double_save;
  23. /* Fixup handler */
  24. void *fixup;
  25. /* For passing a parameter to fixup */
  26. void *fixup_param;
  27. #if XTENSA_HAVE_COPROCESSORS
  28. /* Pointers to owner struct thread_info */
  29. struct thread_info *coprocessor_owner[XCHAL_CP_MAX];
  30. #endif
  31. /* Fast user exception handlers */
  32. void *fast_user_handler[EXCCAUSE_N];
  33. /* Fast kernel exception handlers */
  34. void *fast_kernel_handler[EXCCAUSE_N];
  35. /* Default C-Handlers */
  36. xtensa_exception_handler *default_handler[EXCCAUSE_N];
  37. };
  38. DECLARE_PER_CPU(struct exc_table, exc_table);
  39. xtensa_exception_handler *
  40. __init trap_set_handler(int cause, xtensa_exception_handler *handler);
  41. asmlinkage void fast_illegal_instruction_user(void);
  42. asmlinkage void fast_syscall_user(void);
  43. asmlinkage void fast_alloca(void);
  44. asmlinkage void fast_load_store(void);
  45. asmlinkage void fast_unaligned(void);
  46. asmlinkage void fast_second_level_miss(void);
  47. asmlinkage void fast_store_prohibited(void);
  48. asmlinkage void fast_coprocessor(void);
  49. asmlinkage void kernel_exception(void);
  50. asmlinkage void user_exception(void);
  51. asmlinkage void system_call(struct pt_regs *regs);
  52. void do_IRQ(int hwirq, struct pt_regs *regs);
  53. void do_page_fault(struct pt_regs *regs);
  54. void do_unhandled(struct pt_regs *regs);
  55. /* Initialize minimal exc_table structure sufficient for basic paging */
  56. static inline void __init early_trap_init(void)
  57. {
  58. static struct exc_table init_exc_table __initdata = {
  59. #ifdef CONFIG_XTENSA_LOAD_STORE
  60. .fast_kernel_handler[EXCCAUSE_LOAD_STORE_ERROR] =
  61. fast_load_store,
  62. #endif
  63. #ifdef CONFIG_MMU
  64. .fast_kernel_handler[EXCCAUSE_DTLB_MISS] =
  65. fast_second_level_miss,
  66. #endif
  67. };
  68. xtensa_set_sr(&init_exc_table, excsave1);
  69. }
  70. void secondary_trap_init(void);
  71. static inline void spill_registers(void)
  72. {
  73. #if defined(__XTENSA_WINDOWED_ABI__)
  74. #if XCHAL_NUM_AREGS > 16
  75. __asm__ __volatile__ (
  76. " call8 1f\n"
  77. " _j 2f\n"
  78. " retw\n"
  79. " .align 4\n"
  80. "1:\n"
  81. #if XCHAL_NUM_AREGS == 32
  82. " _entry a1, 32\n"
  83. " addi a8, a0, 3\n"
  84. " _entry a1, 16\n"
  85. " mov a12, a12\n"
  86. " retw\n"
  87. #else
  88. " _entry a1, 48\n"
  89. " call12 1f\n"
  90. " retw\n"
  91. " .align 4\n"
  92. "1:\n"
  93. " .rept (" __stringify(XCHAL_NUM_AREGS) " - 16) / 12\n"
  94. " _entry a1, 48\n"
  95. " mov a12, a0\n"
  96. " .endr\n"
  97. " _entry a1, 16\n"
  98. #if XCHAL_NUM_AREGS % 12 == 0
  99. " mov a12, a12\n"
  100. #elif XCHAL_NUM_AREGS % 12 == 4
  101. " mov a4, a4\n"
  102. #elif XCHAL_NUM_AREGS % 12 == 8
  103. " mov a8, a8\n"
  104. #endif
  105. " retw\n"
  106. #endif
  107. "2:\n"
  108. : : : "a8", "a9", "memory");
  109. #else
  110. __asm__ __volatile__ (
  111. " mov a12, a12\n"
  112. : : : "memory");
  113. #endif
  114. #endif
  115. }
  116. struct debug_table {
  117. /* Pointer to debug exception handler */
  118. void (*debug_exception)(void);
  119. /* Temporary register save area */
  120. unsigned long debug_save[1];
  121. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  122. /* Save area for DBREAKC registers */
  123. unsigned long dbreakc_save[XCHAL_NUM_DBREAK];
  124. /* Saved ICOUNT register */
  125. unsigned long icount_save;
  126. /* Saved ICOUNTLEVEL register */
  127. unsigned long icount_level_save;
  128. #endif
  129. };
  130. void debug_exception(void);
  131. #endif /* _XTENSA_TRAPS_H */