traps.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. static inline void spill_registers(void)
  21. {
  22. unsigned int a0, ps;
  23. __asm__ __volatile__ (
  24. "movi a14, " __stringify(PS_EXCM_BIT | LOCKLEVEL) "\n\t"
  25. "mov a12, a0\n\t"
  26. "rsr a13, sar\n\t"
  27. "xsr a14, ps\n\t"
  28. "movi a0, _spill_registers\n\t"
  29. "rsync\n\t"
  30. "callx0 a0\n\t"
  31. "mov a0, a12\n\t"
  32. "wsr a13, sar\n\t"
  33. "wsr a14, ps\n\t"
  34. : : "a" (&a0), "a" (&ps)
  35. #if defined(CONFIG_FRAME_POINTER)
  36. : "a2", "a3", "a4", "a11", "a12", "a13", "a14", "a15",
  37. #else
  38. : "a2", "a3", "a4", "a7", "a11", "a12", "a13", "a14", "a15",
  39. #endif
  40. "memory");
  41. }
  42. #endif /* _XTENSA_TRAPS_H */