traps.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. " call12 1f\n"
  26. " _j 2f\n"
  27. " retw\n"
  28. " .align 4\n"
  29. "1:\n"
  30. " _entry a1, 48\n"
  31. " addi a12, a0, 3\n"
  32. #if XCHAL_NUM_AREGS > 32
  33. " .rept (" __stringify(XCHAL_NUM_AREGS) " - 32) / 12\n"
  34. " _entry a1, 48\n"
  35. " mov a12, a0\n"
  36. " .endr\n"
  37. #endif
  38. " _entry a1, 48\n"
  39. #if XCHAL_NUM_AREGS % 12 == 0
  40. " mov a8, a8\n"
  41. #elif XCHAL_NUM_AREGS % 12 == 4
  42. " mov a12, a12\n"
  43. #elif XCHAL_NUM_AREGS % 12 == 8
  44. " mov a4, a4\n"
  45. #endif
  46. " retw\n"
  47. "2:\n"
  48. : : : "a12", "a13", "memory");
  49. #else
  50. __asm__ __volatile__ (
  51. " mov a12, a12\n"
  52. : : : "memory");
  53. #endif
  54. }
  55. #endif /* _XTENSA_TRAPS_H */