xtensa_vector_defaults.S 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "xtensa_rtos.h"
  7. #include "esp_private/panic_reason.h"
  8. #include "sdkconfig.h"
  9. #include "soc/soc.h"
  10. /*
  11. This file contains the default handlers for the high interrupt levels as well as some specialized exceptions.
  12. The default behaviour is to just exit the interrupt or call the panic handler on the exceptions
  13. */
  14. #if XCHAL_HAVE_DEBUG
  15. .global xt_debugexception
  16. .weak xt_debugexception
  17. .set xt_debugexception, _xt_debugexception
  18. .section .iram1,"ax"
  19. .type _xt_debugexception,@function
  20. .align 4
  21. _xt_debugexception:
  22. #if (CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
  23. #define XT_DEBUGCAUSE_DI (5)
  24. getcoreid a0
  25. #if (CONFIG_BTDM_CTRL_PINNED_TO_CORE == PRO_CPU_NUM)
  26. beqz a0, 1f
  27. #else
  28. bnez a0, 1f
  29. #endif
  30. rsr a0, DEBUGCAUSE
  31. extui a0, a0, XT_DEBUGCAUSE_DI, 1
  32. bnez a0, _xt_debug_di_exc
  33. 1:
  34. #endif //(CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
  35. movi a0,PANIC_RSN_DEBUGEXCEPTION
  36. wsr a0,EXCCAUSE
  37. /* _xt_panic assumes a level 1 exception. As we're
  38. crashing anyhow, copy EPC & EXCSAVE from DEBUGLEVEL
  39. to level 1. */
  40. rsr a0,(EPC + XCHAL_DEBUGLEVEL)
  41. wsr a0,EPC_1
  42. rsr a0,(EXCSAVE + XCHAL_DEBUGLEVEL)
  43. wsr a0,EXCSAVE_1
  44. call0 _xt_panic /* does not return */
  45. rfi XCHAL_DEBUGLEVEL
  46. #if (CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
  47. .align 4
  48. _xt_debug_di_exc:
  49. /*
  50. The delay time can be calculated by the following formula:
  51. T = ceil(0.25 + max(t1, t2)) us
  52. t1 = 80 / f1, t2 = (1 + 14/N) * 20 / f2
  53. f1: PSRAM access frequency, unit: MHz.
  54. f2: Flash access frequency, unit: MHz.
  55. When flash is slow/fast read, N = 1.
  56. When flash is DOUT/DIO read, N = 2.
  57. When flash is QOUT/QIO read, N = 4.
  58. And after testing, when CPU frequency is 240 MHz, it will take 1us to loop 27 times.
  59. */
  60. #if defined(CONFIG_ESPTOOLPY_FLASHMODE_QIO) || defined(CONFIG_ESPTOOLPY_FLASHMODE_QOUT)
  61. # if defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_80M)
  62. movi a0, 54
  63. # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_40M)
  64. movi a0, 81
  65. # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_40M) && defined(CONFIG_SPIRAM_SPEED_40M)
  66. movi a0, 81
  67. # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_26M) && defined(CONFIG_SPIRAM_SPEED_40M)
  68. movi a0, 108
  69. # else
  70. movi a0, 135
  71. # endif
  72. #elif defined(CONFIG_ESPTOOLPY_FLASHMODE_DIO) || defined(CONFIG_ESPTOOLPY_FLASHMODE_DOUT)
  73. # if defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_80M)
  74. movi a0, 81
  75. # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_40M)
  76. movi a0, 81
  77. # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_40M) && defined(CONFIG_SPIRAM_SPEED_40M)
  78. movi a0, 135
  79. # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_26M) && defined(CONFIG_SPIRAM_SPEED_40M)
  80. movi a0, 189
  81. # else
  82. movi a0, 243
  83. # endif
  84. #else
  85. movi a0, 243
  86. #endif
  87. 1: addi a0, a0, -1 /* delay_us(N) */
  88. .rept 4
  89. nop
  90. .endr
  91. bnez a0, 1b
  92. rsr a0, EXCSAVE+XCHAL_DEBUGLEVEL
  93. rfi XCHAL_DEBUGLEVEL
  94. #endif //(CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
  95. #endif /* Debug exception */
  96. #if XCHAL_NUM_INTLEVELS >=2 && XCHAL_EXCM_LEVEL <2 && XCHAL_DEBUGLEVEL !=2
  97. .global xt_highint2
  98. .weak xt_highint2
  99. .set xt_highint2, _xt_highint2
  100. .section .iram1,"ax"
  101. .type _xt_highint2,@function
  102. .align 4
  103. _xt_highint2:
  104. /* Default handler does nothing; just returns */
  105. .align 4
  106. .L_xt_highint2_exit:
  107. rsr a0, EXCSAVE_2 /* restore a0 */
  108. rfi 2
  109. #endif /* Level 2 */
  110. #if XCHAL_NUM_INTLEVELS >=3 && XCHAL_EXCM_LEVEL <3 && XCHAL_DEBUGLEVEL !=3
  111. .global xt_highint3
  112. .weak xt_highint3
  113. .set xt_highint3, _xt_highint3
  114. .section .iram1,"ax"
  115. .type _xt_highint3,@function
  116. .align 4
  117. _xt_highint3:
  118. /* Default handler does nothing; just returns */
  119. .align 4
  120. .L_xt_highint3_exit:
  121. rsr a0, EXCSAVE_3 /* restore a0 */
  122. rfi 3
  123. #endif /* Level 3 */
  124. #if XCHAL_NUM_INTLEVELS >=4 && XCHAL_EXCM_LEVEL <4 && XCHAL_DEBUGLEVEL !=4
  125. .global xt_highint4
  126. .weak xt_highint4
  127. .set xt_highint4, _xt_highint4
  128. .section .iram1,"ax"
  129. .type _xt_highint4,@function
  130. .align 4
  131. _xt_highint4:
  132. /* Default handler does nothing; just returns */
  133. .align 4
  134. .L_xt_highint4_exit:
  135. rsr a0, EXCSAVE_4 /* restore a0 */
  136. rfi 4
  137. #endif /* Level 4 */
  138. #if XCHAL_NUM_INTLEVELS >=5 && XCHAL_EXCM_LEVEL <5 && XCHAL_DEBUGLEVEL !=5
  139. .global xt_highint5
  140. .weak xt_highint5
  141. .set xt_highint5, _xt_highint5
  142. .section .iram1,"ax"
  143. .type _xt_highint5,@function
  144. .align 4
  145. _xt_highint5:
  146. /* Default handler does nothing; just returns */
  147. .align 4
  148. .L_xt_highint5_exit:
  149. rsr a0, EXCSAVE_5 /* restore a0 */
  150. rfi 5
  151. #endif /* Level 5 */
  152. #if XCHAL_NUM_INTLEVELS >=6 && XCHAL_EXCM_LEVEL <6 && XCHAL_DEBUGLEVEL !=6
  153. .global _xt_highint6
  154. .global xt_highint6
  155. .weak xt_highint6
  156. .set xt_highint6, _xt_highint6
  157. .section .iram1,"ax"
  158. .type _xt_highint6,@function
  159. .align 4
  160. _xt_highint6:
  161. /* Default handler does nothing; just returns */
  162. .align 4
  163. .L_xt_highint6_exit:
  164. rsr a0, EXCSAVE_6 /* restore a0 */
  165. rfi 6
  166. #endif /* Level 6 */
  167. #if XCHAL_HAVE_NMI
  168. .global _xt_nmi
  169. .global xt_nmi
  170. .weak xt_nmi
  171. .set xt_nmi, _xt_nmi
  172. .section .iram1,"ax"
  173. .type _xt_nmi,@function
  174. .align 4
  175. _xt_nmi:
  176. /* Default handler does nothing; just returns */
  177. .align 4
  178. .L_xt_nmi_exit:
  179. rsr a0, EXCSAVE + XCHAL_NMILEVEL /* restore a0 */
  180. rfi XCHAL_NMILEVEL
  181. #endif /* NMI */