2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
4 * SPDX-License-Identifier: Apache-2.0
7 #include "xtensa_rtos.h"
8 #include "esp_idf_version.h"
9 #if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0))
10 #include "esp_panic.h"
12 #include "esp_private/panic_reason.h"
13 #endif /* ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 2, 0) */
14 #include "sdkconfig.h"
18 This file contains the default handlers for the high interrupt levels as well as some specialized exceptions.
19 The default behaviour is to just exit the interrupt or call the panic handler on the exceptions
24 .global xt_debugexception
25 .weak xt_debugexception
26 .set xt_debugexception, _xt_debugexception
28 .type _xt_debugexception,@function
32 #if (CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
33 #define XT_DEBUGCAUSE_DI (5)
35 #if (CONFIG_BTDM_CTRL_PINNED_TO_CORE == PRO_CPU_NUM)
42 extui a0, a0, XT_DEBUGCAUSE_DI, 1
43 bnez a0, _xt_debug_di_exc
45 #endif //(CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
47 movi a0,PANIC_RSN_DEBUGEXCEPTION
49 /* _xt_panic assumes a level 1 exception. As we're
50 crashing anyhow, copy EPC & EXCSAVE from DEBUGLEVEL
52 rsr a0,(EPC + XCHAL_DEBUGLEVEL)
54 rsr a0,(EXCSAVE + XCHAL_DEBUGLEVEL)
56 call0 _xt_panic /* does not return */
59 #if (CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
64 The delay time can be calculated by the following formula:
65 T = ceil(0.25 + max(t1, t2)) us
67 t1 = 80 / f1, t2 = (1 + 14/N) * 20 / f2
69 f1: PSRAM access frequency, unit: MHz.
70 f2: Flash access frequency, unit: MHz.
72 When flash is slow/fast read, N = 1.
73 When flash is DOUT/DIO read, N = 2.
74 When flash is QOUT/QIO read, N = 4.
76 And after testing, when CPU frequency is 240 MHz, it will take 1us to loop 27 times.
78 #if defined(CONFIG_ESPTOOLPY_FLASHMODE_QIO) || defined(CONFIG_ESPTOOLPY_FLASHMODE_QOUT)
80 # if defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_80M)
82 # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_40M)
84 # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_40M) && defined(CONFIG_SPIRAM_SPEED_40M)
86 # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_26M) && defined(CONFIG_SPIRAM_SPEED_40M)
92 #elif defined(CONFIG_ESPTOOLPY_FLASHMODE_DIO) || defined(CONFIG_ESPTOOLPY_FLASHMODE_DOUT)
94 # if defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_80M)
96 # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_80M) && defined(CONFIG_SPIRAM_SPEED_40M)
98 # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_40M) && defined(CONFIG_SPIRAM_SPEED_40M)
100 # elif defined(CONFIG_ESPTOOLPY_FLASHFREQ_26M) && defined(CONFIG_SPIRAM_SPEED_40M)
110 1: addi a0, a0, -1 /* delay_us(N) */
116 rsr a0, EXCSAVE+XCHAL_DEBUGLEVEL
118 #endif //(CONFIG_ESP32_ECO3_CACHE_LOCK_FIX && CONFIG_BTDM_CTRL_HLI)
119 #endif /* Debug exception */
122 #if XCHAL_NUM_INTLEVELS >=2 && XCHAL_EXCM_LEVEL <2 && XCHAL_DEBUGLEVEL !=2
125 .set xt_highint2, _xt_highint2
127 .type _xt_highint2,@function
131 /* Default handler does nothing; just returns */
134 rsr a0, EXCSAVE_2 /* restore a0 */
139 #if XCHAL_NUM_INTLEVELS >=3 && XCHAL_EXCM_LEVEL <3 && XCHAL_DEBUGLEVEL !=3
143 .set xt_highint3, _xt_highint3
145 .type _xt_highint3,@function
149 /* Default handler does nothing; just returns */
153 rsr a0, EXCSAVE_3 /* restore a0 */
158 #if XCHAL_NUM_INTLEVELS >=4 && XCHAL_EXCM_LEVEL <4 && XCHAL_DEBUGLEVEL !=4
162 .set xt_highint4, _xt_highint4
164 .type _xt_highint4,@function
168 /* Default handler does nothing; just returns */
172 rsr a0, EXCSAVE_4 /* restore a0 */
177 #if XCHAL_NUM_INTLEVELS >=5 && XCHAL_EXCM_LEVEL <5 && XCHAL_DEBUGLEVEL !=5
181 .set xt_highint5, _xt_highint5
183 .type _xt_highint5,@function
187 /* Default handler does nothing; just returns */
191 rsr a0, EXCSAVE_5 /* restore a0 */
197 #if XCHAL_NUM_INTLEVELS >=6 && XCHAL_EXCM_LEVEL <6 && XCHAL_DEBUGLEVEL !=6
202 .set xt_highint6, _xt_highint6
204 .type _xt_highint6,@function
208 /* Default handler does nothing; just returns */
212 rsr a0, EXCSAVE_6 /* restore a0 */
224 .type _xt_nmi,@function
228 /* Default handler does nothing; just returns */
232 rsr a0, EXCSAVE + XCHAL_NMILEVEL /* restore a0 */