2015-04-11 07:44:37 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
|
|
|
|
2015-12-04 23:09:39 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief CPU power management
|
|
|
|
*
|
|
|
|
* CPU power management routines.
|
2015-07-02 05:22:39 +08:00
|
|
|
*/
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <kernel_structs.h>
|
|
|
|
#include <offsets_short.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
#include <toolchain.h>
|
2017-06-17 23:30:47 +08:00
|
|
|
#include <linker/sections.h>
|
2015-05-29 01:56:47 +08:00
|
|
|
#include <arch/cpu.h>
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2016-12-15 02:04:36 +08:00
|
|
|
GTEXT(k_cpu_idle)
|
|
|
|
GTEXT(k_cpu_atomic_idle)
|
|
|
|
GDATA(k_cpu_sleep_mode)
|
2015-04-11 07:44:37 +08:00
|
|
|
|
2016-12-15 02:04:36 +08:00
|
|
|
SECTION_VAR(BSS, k_cpu_sleep_mode)
|
2017-06-13 07:07:07 +08:00
|
|
|
.balign 4
|
2015-04-11 07:44:37 +08:00
|
|
|
.word 0
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Put the CPU in low-power mode
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* This function always exits with interrupts unlocked.
|
|
|
|
*
|
|
|
|
* void nanCpuIdle(void)
|
|
|
|
*/
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2016-12-15 02:04:36 +08:00
|
|
|
SECTION_FUNC(TEXT, k_cpu_idle)
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2016-05-05 00:55:33 +08:00
|
|
|
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
|
|
push_s blink
|
|
|
|
jl _sys_k_event_logger_enter_sleep
|
|
|
|
pop_s blink
|
|
|
|
#endif
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2016-12-15 02:04:36 +08:00
|
|
|
ld r1, [k_cpu_sleep_mode]
|
2015-04-11 07:44:37 +08:00
|
|
|
or r1, r1, (1 << 4) /* set IRQ-enabled bit */
|
|
|
|
sleep r1
|
2016-05-26 00:24:55 +08:00
|
|
|
j_s [blink]
|
2015-04-11 07:44:37 +08:00
|
|
|
nop
|
|
|
|
|
|
|
|
/*
|
2015-07-02 05:51:40 +08:00
|
|
|
* @brief Put the CPU in low-power mode, entered with IRQs locked
|
2015-04-11 07:44:37 +08:00
|
|
|
*
|
|
|
|
* This function exits with interrupts restored to <key>.
|
|
|
|
*
|
2016-12-15 02:04:36 +08:00
|
|
|
* void k_cpu_atomic_idle(unsigned int key)
|
2015-04-11 07:44:37 +08:00
|
|
|
*/
|
2016-12-15 02:04:36 +08:00
|
|
|
SECTION_FUNC(TEXT, k_cpu_atomic_idle)
|
2015-06-10 07:46:29 +08:00
|
|
|
|
2016-05-05 00:55:33 +08:00
|
|
|
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
|
|
push_s blink
|
|
|
|
jl _sys_k_event_logger_enter_sleep
|
|
|
|
pop_s blink
|
|
|
|
#endif
|
|
|
|
|
2016-12-15 02:04:36 +08:00
|
|
|
ld r1, [k_cpu_sleep_mode]
|
2015-04-11 07:44:37 +08:00
|
|
|
or r1, r1, (1 << 4) /* set IRQ-enabled bit */
|
|
|
|
sleep r1
|
|
|
|
j_s.d [blink]
|
|
|
|
seti r0
|