File tree Expand file tree Collapse file tree 8 files changed +49
-2
lines changed Expand file tree Collapse file tree 8 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -273,6 +273,16 @@ FORCE_INLINE_ATTR void esp_cpu_intr_set_mtvt_addr(const void *mtvt_addr)
273273}
274274#endif //#if SOC_INT_CLIC_SUPPORTED
275275
276+ #if SOC_CPU_SUPPORT_WFE
277+ /**
278+ * @brief Disable the WFE (wait for event) feature for CPU.
279+ */
280+ FORCE_INLINE_ATTR void rv_utils_disable_wfe_mode (void )
281+ {
282+ rv_utils_wfe_mode_enable (false);
283+ }
284+ #endif
285+
276286#if SOC_CPU_HAS_FLEXIBLE_INTC
277287/**
278288 * @brief Set the interrupt type of a particular interrupt
Original file line number Diff line number Diff line change @@ -211,7 +211,9 @@ void IRAM_ATTR call_start_cpu1(void)
211211 */
212212 esp_cpu_intr_set_mtvt_addr (& _mtvt_table );
213213#endif
214-
214+ #if SOC_CPU_SUPPORT_WFE
215+ rv_utils_disable_wfe_mode ();
216+ #endif
215217 ets_set_appcpu_boot_addr (0 );
216218
217219 bootloader_init_mem ();
@@ -412,6 +414,9 @@ void IRAM_ATTR call_start_cpu0(void)
412414 */
413415 esp_cpu_intr_set_mtvt_addr (& _mtvt_table );
414416#endif
417+ #if SOC_CPU_SUPPORT_WFE
418+ rv_utils_disable_wfe_mode ();
419+ #endif
415420
416421 /* NOTE: When ESP-TEE is enabled, this sets up the callback function
417422 * which redirects all the interrupt management for the REE (user app)
Original file line number Diff line number Diff line change 11/*
2- * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -148,6 +148,20 @@ FORCE_INLINE_ATTR void rv_utils_set_mtvt(uint32_t mtvt_val)
148148 RV_WRITE_CSR (MTVT_CSR , mtvt_val );
149149}
150150
151+ #if SOC_CPU_SUPPORT_WFE
152+ /**
153+ * @brief Set the MEXSTATUS_WFFEN value, used to enable/disable wait for event mode.
154+ */
155+ FORCE_INLINE_ATTR void rv_utils_wfe_mode_enable (bool en )
156+ {
157+ if (en ) {
158+ RV_SET_CSR (MEXSTATUS , MEXSTATUS_WFFEN );
159+ } else {
160+ RV_CLEAR_CSR (MEXSTATUS , MEXSTATUS_WFFEN );
161+ }
162+ }
163+ #endif
164+
151165/**
152166 * @brief Get the current CPU raw interrupt level
153167 */
Original file line number Diff line number Diff line change 5353#define MSTATUS_SXL 0x0000000C00000000
5454#define MSTATUS64_SD 0x8000000000000000
5555
56+ #define MEXSTATUS_SOFT_RST 0x00000003
57+ #define MEXSTATUS_LPMD 0x0000000C
58+ #define MEXSTATUS_WFFEN 0x00000010
59+ #define MEXSTATUS_EXPT_VLD 0x00000020
60+ #define MEXSTATUS_LOCKUP 0x00000040
61+ #define MEXSTATUS_NMISTS 0x00000080
62+ #define MEXSTATUS_BUSEER 0x00000100
63+
5664#define SSTATUS_UIE 0x00000001
5765#define SSTATUS_SIE 0x00000002
5866#define SSTATUS_UPIE 0x00000010
Original file line number Diff line number Diff line change @@ -403,6 +403,10 @@ config SOC_CPU_HAS_FLEXIBLE_INTC
403403 bool
404404 default y
405405
406+ config SOC_CPU_SUPPORT_WFE
407+ bool
408+ default y
409+
406410config SOC_INT_CLIC_SUPPORTED
407411 bool
408412 default y
Original file line number Diff line number Diff line change 156156#define SOC_CPU_CORES_NUM (1U)
157157#define SOC_CPU_INTR_NUM 32
158158#define SOC_CPU_HAS_FLEXIBLE_INTC 1
159+ #define SOC_CPU_SUPPORT_WFE 1
159160#define SOC_INT_CLIC_SUPPORTED 1
160161#define SOC_INT_HW_NESTED_SUPPORTED 1 // Support for hardware interrupts nesting
161162#define SOC_BRANCH_PREDICTOR_SUPPORTED 1
Original file line number Diff line number Diff line change @@ -303,6 +303,10 @@ config SOC_CPU_HAS_FLEXIBLE_INTC
303303 bool
304304 default y
305305
306+ config SOC_CPU_SUPPORT_WFE
307+ bool
308+ default y
309+
306310config SOC_INT_PLIC_SUPPORTED
307311 bool
308312 default n
Original file line number Diff line number Diff line change 126126#define SOC_CPU_CORES_NUM (1U)
127127#define SOC_CPU_INTR_NUM 32
128128#define SOC_CPU_HAS_FLEXIBLE_INTC 1
129+ #define SOC_CPU_SUPPORT_WFE 1
129130#define SOC_INT_PLIC_SUPPORTED 0 //riscv platform-level interrupt controller
130131#define SOC_INT_CLIC_SUPPORTED 1
131132#define SOC_INT_HW_NESTED_SUPPORTED 1 // Support for hardware interrupts nesting
You can’t perform that action at this time.
0 commit comments