panic_handler_asm.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "freertos/xtensa_rtos.h"
  2. #include "esp_private/panic_reason.h"
  3. #include "soc/soc.h"
  4. #include "sdkconfig.h"
  5. /*
  6. --------------------------------------------------------------------------------
  7. Panic handler.
  8. Should be reached by call0 (preferable) or jump only. If call0, a0 says where
  9. from. If on simulator, display panic message and abort, else loop indefinitely.
  10. --------------------------------------------------------------------------------
  11. */
  12. .section .iram1,"ax"
  13. .global panicHandler
  14. .global _xt_panic
  15. .type _xt_panic,@function
  16. .align 4
  17. .literal_position
  18. .align 4
  19. _xt_panic:
  20. /* Allocate exception frame and save minimal context. */
  21. mov a0, sp
  22. addi sp, sp, -XT_STK_FRMSZ
  23. s32i a0, sp, XT_STK_A1
  24. #if XCHAL_HAVE_WINDOWED
  25. s32e a0, sp, -12 /* for debug backtrace */
  26. #endif
  27. rsr a0, PS /* save interruptee's PS */
  28. s32i a0, sp, XT_STK_PS
  29. rsr a0, EPC_1 /* save interruptee's PC */
  30. s32i a0, sp, XT_STK_PC
  31. rsr a0, EXCSAVE_1 /* save interruptee's a0 */
  32. s32i a0, sp, XT_STK_A0
  33. #if XCHAL_HAVE_WINDOWED
  34. s32e a0, sp, -16 /* for debug backtrace */
  35. #endif
  36. s32i a12, sp, XT_STK_A12 /* _xt_context_save requires A12- */
  37. s32i a13, sp, XT_STK_A13 /* A13 to have already been saved */
  38. call0 _xt_context_save
  39. /* Save exc cause and vaddr into exception frame */
  40. rsr a0, EXCCAUSE
  41. s32i a0, sp, XT_STK_EXCCAUSE
  42. rsr a0, EXCVADDR
  43. s32i a0, sp, XT_STK_EXCVADDR
  44. /* Set up PS for C, disable all interrupts except NMI and debug, and clear EXCM. */
  45. movi a0, PS_INTLEVEL(XCHAL_DEBUGLEVEL - 2) | PS_UM | PS_WOE
  46. wsr a0, PS
  47. //Call panic handler
  48. mov a6,sp
  49. call4 panicHandler
  50. ret