1 /*
2  * Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <toolchain.h>
8 #include <irq.h>
9 #include <arch/cpu.h>
10 
11 /**
12  *
13  * @brief Power save idle routine
14  *
15  * This function will be called by the kernel idle loop or possibly within
16  * an implementation of _pm_save_idle in the kernel when the
17  * '_pm_save_flag' variable is non-zero.
18  *
19  * @return N/A
20  */
arch_cpu_idle(void)21 void arch_cpu_idle(void)
22 {
23 	/* curiously it arives here with the interrupts masked
24 	 * so umask it before wait for an event
25 	 */
26 	arch_irq_unlock(MSTATUS_IEN);
27 
28 	/* Wait for interrupt */
29 	__asm__ volatile("wfi");
30 }
31