traps.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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_unaligned(void);
  45. asmlinkage void fast_second_level_miss(void);
  46. asmlinkage void fast_store_prohibited(void);
  47. asmlinkage void fast_coprocessor(void);
  48. asmlinkage void kernel_exception(void);
  49. asmlinkage void user_exception(void);
  50. asmlinkage void system_call(struct pt_regs *regs);
  51. void do_IRQ(int hwirq, struct pt_regs *regs);
  52. void do_page_fault(struct pt_regs *regs);
  53. void do_unhandled(struct pt_regs *regs);
  54. /* Initialize minimal exc_table structure sufficient for basic paging */
  55. static inline void __init early_trap_init(void)
  56. {
  57. static struct exc_table init_exc_table __initdata = {
  58. .fast_kernel_handler[EXCCAUSE_DTLB_MISS] =
  59. fast_second_level_miss,
  60. };
  61. xtensa_set_sr(&init_exc_table, excsave1);
  62. }
  63. void secondary_trap_init(void);
  64. static inline void spill_registers(void)
  65. {
  66. #if defined(__XTENSA_WINDOWED_ABI__)
  67. #if XCHAL_NUM_AREGS > 16
  68. __asm__ __volatile__ (
  69. " call8 1f\n"
  70. " _j 2f\n"
  71. " retw\n"
  72. " .align 4\n"
  73. "1:\n"
  74. #if XCHAL_NUM_AREGS == 32
  75. " _entry a1, 32\n"
  76. " addi a8, a0, 3\n"
  77. " _entry a1, 16\n"
  78. " mov a12, a12\n"
  79. " retw\n"
  80. #else
  81. " _entry a1, 48\n"
  82. " call12 1f\n"
  83. " retw\n"
  84. " .align 4\n"
  85. "1:\n"
  86. " .rept (" __stringify(XCHAL_NUM_AREGS) " - 16) / 12\n"
  87. " _entry a1, 48\n"
  88. " mov a12, a0\n"
  89. " .endr\n"
  90. " _entry a1, 16\n"
  91. #if XCHAL_NUM_AREGS % 12 == 0
  92. " mov a12, a12\n"
  93. #elif XCHAL_NUM_AREGS % 12 == 4
  94. " mov a4, a4\n"
  95. #elif XCHAL_NUM_AREGS % 12 == 8
  96. " mov a8, a8\n"
  97. #endif
  98. " retw\n"
  99. #endif
  100. "2:\n"
  101. : : : "a8", "a9", "memory");
  102. #else
  103. __asm__ __volatile__ (
  104. " mov a12, a12\n"
  105. : : : "memory");
  106. #endif
  107. #endif
  108. }
  109. struct debug_table {
  110. /* Pointer to debug exception handler */
  111. void (*debug_exception)(void);
  112. /* Temporary register save area */
  113. unsigned long debug_save[1];
  114. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  115. /* Save area for DBREAKC registers */
  116. unsigned long dbreakc_save[XCHAL_NUM_DBREAK];
  117. /* Saved ICOUNT register */
  118. unsigned long icount_save;
  119. /* Saved ICOUNTLEVEL register */
  120. unsigned long icount_level_save;
  121. #endif
  122. };
  123. void debug_exception(void);
  124. #endif /* _XTENSA_TRAPS_H */