2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-12-04 10:09:39 -05:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief CPU power management
|
|
|
|
*
|
|
|
|
* CPU power management routines.
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#define _ASMLANGUAGE
|
|
|
|
|
2016-11-08 10:36:50 -05:00
|
|
|
#include <kernel_structs.h>
|
|
|
|
#include <offsets_short.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
2015-05-28 10:56:47 -07:00
|
|
|
#include <arch/cpu.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-12-14 13:04:36 -05:00
|
|
|
GTEXT(k_cpu_idle)
|
|
|
|
GTEXT(k_cpu_atomic_idle)
|
|
|
|
GDATA(k_cpu_sleep_mode)
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2017-01-12 16:49:58 -05:00
|
|
|
.balign 4
|
2016-12-14 13:04:36 -05:00
|
|
|
SECTION_VAR(BSS, k_cpu_sleep_mode)
|
2015-04-10 16:44:37 -07:00
|
|
|
.word 0
|
|
|
|
|
|
|
|
/*
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Put the CPU in low-power mode
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
|
|
|
* This function always exits with interrupts unlocked.
|
|
|
|
*
|
|
|
|
* void nanCpuIdle(void)
|
|
|
|
*/
|
2015-06-09 16:46:29 -07:00
|
|
|
|
2016-12-14 13:04:36 -05:00
|
|
|
SECTION_FUNC(TEXT, k_cpu_idle)
|
2015-06-09 16:46:29 -07:00
|
|
|
|
2016-05-04 11:55:33 -05:00
|
|
|
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
|
|
push_s blink
|
|
|
|
jl _sys_k_event_logger_enter_sleep
|
|
|
|
pop_s blink
|
|
|
|
#endif
|
2015-06-09 16:46:29 -07:00
|
|
|
|
2016-12-14 13:04:36 -05:00
|
|
|
ld r1, [k_cpu_sleep_mode]
|
2015-04-10 16:44:37 -07:00
|
|
|
or r1, r1, (1 << 4) /* set IRQ-enabled bit */
|
|
|
|
sleep r1
|
2016-05-25 09:24:55 -07:00
|
|
|
j_s [blink]
|
2015-04-10 16:44:37 -07:00
|
|
|
nop
|
|
|
|
|
|
|
|
/*
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Put the CPU in low-power mode, entered with IRQs locked
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
|
|
|
* This function exits with interrupts restored to <key>.
|
|
|
|
*
|
2016-12-14 13:04:36 -05:00
|
|
|
* void k_cpu_atomic_idle(unsigned int key)
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
2016-12-14 13:04:36 -05:00
|
|
|
SECTION_FUNC(TEXT, k_cpu_atomic_idle)
|
2015-06-09 16:46:29 -07:00
|
|
|
|
2016-05-04 11:55:33 -05:00
|
|
|
#ifdef CONFIG_KERNEL_EVENT_LOGGER_SLEEP
|
|
|
|
push_s blink
|
|
|
|
jl _sys_k_event_logger_enter_sleep
|
|
|
|
pop_s blink
|
|
|
|
#endif
|
|
|
|
|
2016-12-14 13:04:36 -05:00
|
|
|
ld r1, [k_cpu_sleep_mode]
|
2015-04-10 16:44:37 -07:00
|
|
|
or r1, r1, (1 << 4) /* set IRQ-enabled bit */
|
|
|
|
sleep r1
|
|
|
|
j_s.d [blink]
|
|
|
|
seti r0
|