traps.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * handler must be either of the following:
  15. * void (*)(struct pt_regs *regs);
  16. * void (*)(struct pt_regs *regs, unsigned long exccause);
  17. */
  18. extern void * __init trap_set_handler(int cause, void *handler);
  19. extern void do_unhandled(struct pt_regs *regs, unsigned long exccause);
  20. void secondary_trap_init(void);
  21. static inline void spill_registers(void)
  22. {
  23. #if XCHAL_NUM_AREGS > 16
  24. __asm__ __volatile__ (
  25. " call8 1f\n"
  26. " _j 2f\n"
  27. " retw\n"
  28. " .align 4\n"
  29. "1:\n"
  30. #if XCHAL_NUM_AREGS == 32
  31. " _entry a1, 32\n"
  32. " addi a8, a0, 3\n"
  33. " _entry a1, 16\n"
  34. " mov a12, a12\n"
  35. " retw\n"
  36. #else
  37. " _entry a1, 48\n"
  38. " call12 1f\n"
  39. " retw\n"
  40. " .align 4\n"
  41. "1:\n"
  42. " .rept (" __stringify(XCHAL_NUM_AREGS) " - 16) / 12\n"
  43. " _entry a1, 48\n"
  44. " mov a12, a0\n"
  45. " .endr\n"
  46. " _entry a1, 16\n"
  47. #if XCHAL_NUM_AREGS % 12 == 0
  48. " mov a12, a12\n"
  49. #elif XCHAL_NUM_AREGS % 12 == 4
  50. " mov a4, a4\n"
  51. #elif XCHAL_NUM_AREGS % 12 == 8
  52. " mov a8, a8\n"
  53. #endif
  54. " retw\n"
  55. #endif
  56. "2:\n"
  57. : : : "a8", "a9", "memory");
  58. #else
  59. __asm__ __volatile__ (
  60. " mov a12, a12\n"
  61. : : : "memory");
  62. #endif
  63. }
  64. struct debug_table {
  65. /* Pointer to debug exception handler */
  66. void (*debug_exception)(void);
  67. /* Temporary register save area */
  68. unsigned long debug_save[1];
  69. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  70. /* Save area for DBREAKC registers */
  71. unsigned long dbreakc_save[XCHAL_NUM_DBREAK];
  72. /* Saved ICOUNT register */
  73. unsigned long icount_save;
  74. /* Saved ICOUNTLEVEL register */
  75. unsigned long icount_level_save;
  76. #endif
  77. };
  78. void debug_exception(void);
  79. #endif /* _XTENSA_TRAPS_H */