traps.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. /*
  14. * Per-CPU exception handling data structure.
  15. * EXCSAVE1 points to it.
  16. */
  17. struct exc_table {
  18. /* Kernel Stack */
  19. void *kstk;
  20. /* Double exception save area for a0 */
  21. unsigned long double_save;
  22. /* Fixup handler */
  23. void *fixup;
  24. /* For passing a parameter to fixup */
  25. void *fixup_param;
  26. /* For fast syscall handler */
  27. unsigned long syscall_save;
  28. /* Fast user exception handlers */
  29. void *fast_user_handler[EXCCAUSE_N];
  30. /* Fast kernel exception handlers */
  31. void *fast_kernel_handler[EXCCAUSE_N];
  32. /* Default C-Handlers */
  33. void *default_handler[EXCCAUSE_N];
  34. };
  35. /*
  36. * handler must be either of the following:
  37. * void (*)(struct pt_regs *regs);
  38. * void (*)(struct pt_regs *regs, unsigned long exccause);
  39. */
  40. extern void * __init trap_set_handler(int cause, void *handler);
  41. extern void do_unhandled(struct pt_regs *regs, unsigned long exccause);
  42. void fast_second_level_miss(void);
  43. /* Initialize minimal exc_table structure sufficient for basic paging */
  44. static inline void __init early_trap_init(void)
  45. {
  46. static struct exc_table exc_table __initdata = {
  47. .fast_kernel_handler[EXCCAUSE_DTLB_MISS] =
  48. fast_second_level_miss,
  49. };
  50. __asm__ __volatile__("wsr %0, excsave1\n" : : "a" (&exc_table));
  51. }
  52. void secondary_trap_init(void);
  53. static inline void spill_registers(void)
  54. {
  55. #if XCHAL_NUM_AREGS > 16
  56. __asm__ __volatile__ (
  57. " call8 1f\n"
  58. " _j 2f\n"
  59. " retw\n"
  60. " .align 4\n"
  61. "1:\n"
  62. #if XCHAL_NUM_AREGS == 32
  63. " _entry a1, 32\n"
  64. " addi a8, a0, 3\n"
  65. " _entry a1, 16\n"
  66. " mov a12, a12\n"
  67. " retw\n"
  68. #else
  69. " _entry a1, 48\n"
  70. " call12 1f\n"
  71. " retw\n"
  72. " .align 4\n"
  73. "1:\n"
  74. " .rept (" __stringify(XCHAL_NUM_AREGS) " - 16) / 12\n"
  75. " _entry a1, 48\n"
  76. " mov a12, a0\n"
  77. " .endr\n"
  78. " _entry a1, 16\n"
  79. #if XCHAL_NUM_AREGS % 12 == 0
  80. " mov a12, a12\n"
  81. #elif XCHAL_NUM_AREGS % 12 == 4
  82. " mov a4, a4\n"
  83. #elif XCHAL_NUM_AREGS % 12 == 8
  84. " mov a8, a8\n"
  85. #endif
  86. " retw\n"
  87. #endif
  88. "2:\n"
  89. : : : "a8", "a9", "memory");
  90. #else
  91. __asm__ __volatile__ (
  92. " mov a12, a12\n"
  93. : : : "memory");
  94. #endif
  95. }
  96. struct debug_table {
  97. /* Pointer to debug exception handler */
  98. void (*debug_exception)(void);
  99. /* Temporary register save area */
  100. unsigned long debug_save[1];
  101. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  102. /* Save area for DBREAKC registers */
  103. unsigned long dbreakc_save[XCHAL_NUM_DBREAK];
  104. /* Saved ICOUNT register */
  105. unsigned long icount_save;
  106. /* Saved ICOUNTLEVEL register */
  107. unsigned long icount_level_save;
  108. #endif
  109. };
  110. void debug_exception(void);
  111. #endif /* _XTENSA_TRAPS_H */