2015-11-07 03:37:10 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011-2015 Wind River Systems, Inc.
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-11-07 03:37:10 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr.h>
|
2019-06-26 00:25:12 +08:00
|
|
|
#include <debug/tracing.h>
|
2015-11-07 03:37:10 +08:00
|
|
|
#include <arch/cpu.h>
|
|
|
|
|
2019-09-22 07:17:23 +08:00
|
|
|
void z_arch_cpu_idle(void)
|
2015-11-07 03:37:10 +08:00
|
|
|
{
|
2019-09-19 15:25:19 +08:00
|
|
|
sys_trace_idle();
|
2015-11-07 03:37:10 +08:00
|
|
|
__asm__ volatile (
|
|
|
|
"sti\n\t"
|
|
|
|
"hlt\n\t");
|
|
|
|
}
|
|
|
|
|
2019-09-22 07:17:23 +08:00
|
|
|
void z_arch_cpu_atomic_idle(unsigned int key)
|
2015-11-07 03:37:10 +08:00
|
|
|
{
|
2019-09-19 15:25:19 +08:00
|
|
|
sys_trace_idle();
|
2015-11-07 03:37:10 +08:00
|
|
|
|
|
|
|
__asm__ volatile (
|
|
|
|
"sti\n\t"
|
|
|
|
/*
|
|
|
|
* The following statement appears in "Intel 64 and IA-32
|
|
|
|
* Architectures Software Developer's Manual", regarding the 'sti'
|
|
|
|
* instruction:
|
|
|
|
*
|
|
|
|
* "After the IF flag is set, the processor begins responding to
|
|
|
|
* external, maskable interrupts after the next instruction is
|
|
|
|
* executed."
|
|
|
|
*
|
2019-09-22 07:17:23 +08:00
|
|
|
* Thus the IA-32 implementation of z_arch_cpu_atomic_idle() will
|
2015-11-07 03:37:10 +08:00
|
|
|
* atomically re-enable interrupts and enter a low-power mode.
|
|
|
|
*/
|
|
|
|
"hlt\n\t");
|
|
|
|
|
|
|
|
/* restore interrupt lockout state before returning to caller */
|
2019-03-27 09:57:45 +08:00
|
|
|
if ((key & 0x200U) == 0U) {
|
2015-11-07 03:37:10 +08:00
|
|
|
__asm__ volatile("cli");
|
|
|
|
}
|
|
|
|
}
|