2016-04-22 05:47:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-04-22 05:47:09 +08:00
|
|
|
*/
|
|
|
|
|
2016-12-23 21:35:34 +08:00
|
|
|
#include <kernel.h>
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <kernel_structs.h>
|
2016-04-22 05:47:09 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Power save idle routine
|
|
|
|
*
|
2016-12-18 22:42:55 +08:00
|
|
|
* This function will be called by the kernel idle loop or possibly within
|
2017-04-09 23:50:18 +08:00
|
|
|
* an implementation of _sys_power_save_idle in the kernel when the
|
2016-04-22 05:47:09 +08:00
|
|
|
* '_sys_power_save_flag' variable is non-zero.
|
|
|
|
*
|
|
|
|
* @return N/A
|
|
|
|
*/
|
2016-12-15 02:04:36 +08:00
|
|
|
void k_cpu_idle(void)
|
2016-04-22 05:47:09 +08:00
|
|
|
{
|
2016-06-30 05:58:49 +08:00
|
|
|
/* Do nothing but unconditionally unlock interrupts and return to the
|
|
|
|
* caller. This CPU does not have any kind of power saving instruction.
|
2016-06-08 01:26:57 +08:00
|
|
|
*/
|
2016-06-30 05:58:49 +08:00
|
|
|
irq_unlock(NIOS2_STATUS_PIE_MSK);
|
2016-04-22 05:47:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Atomically re-enable interrupts and enter low power mode
|
|
|
|
*
|
|
|
|
* INTERNAL
|
2016-12-15 02:04:36 +08:00
|
|
|
* The requirements for k_cpu_atomic_idle() are as follows:
|
2016-04-22 05:47:09 +08:00
|
|
|
* 1) The enablement of interrupts and entering a low-power mode needs to be
|
|
|
|
* atomic, i.e. there should be no period of time where interrupts are
|
|
|
|
* enabled before the processor enters a low-power mode. See the comments
|
2016-12-18 22:42:55 +08:00
|
|
|
* in k_lifo_get(), for example, of the race condition that
|
2016-04-22 05:47:09 +08:00
|
|
|
* occurs if this requirement is not met.
|
|
|
|
*
|
|
|
|
* 2) After waking up from the low-power mode, the interrupt lockout state
|
2018-09-26 05:54:25 +08:00
|
|
|
* must be restored as indicated in the 'key' input parameter.
|
2016-04-22 05:47:09 +08:00
|
|
|
*
|
|
|
|
* @return N/A
|
|
|
|
*/
|
2016-12-15 02:04:36 +08:00
|
|
|
void k_cpu_atomic_idle(unsigned int key)
|
2016-04-22 05:47:09 +08:00
|
|
|
{
|
2016-06-08 01:26:57 +08:00
|
|
|
/* Do nothing but restore IRQ state. This CPU does not have any
|
|
|
|
* kind of power saving instruction.
|
|
|
|
*/
|
|
|
|
irq_unlock(key);
|
2016-04-22 05:47:09 +08:00
|
|
|
}
|
|
|
|
|