2017-10-03 22:31:55 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011-2015 Wind River Systems, Inc.
|
|
|
|
* Copyright (c) 2017 Oticon A/S
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @file CPU power management code for POSIX
|
|
|
|
*
|
2018-09-30 20:00:21 +08:00
|
|
|
* This module provides:
|
|
|
|
*
|
|
|
|
* An implementation of the architecture-specific
|
2019-11-08 04:43:29 +08:00
|
|
|
* arch_cpu_idle() primitive required by the kernel idle loop component.
|
2017-10-03 22:31:55 +08:00
|
|
|
* It can be called within an implementation of _sys_power_save_idle(),
|
|
|
|
* which is provided for the kernel by the platform.
|
|
|
|
*
|
2019-11-08 04:43:29 +08:00
|
|
|
* An implementation of arch_cpu_atomic_idle(), which
|
2017-10-03 22:31:55 +08:00
|
|
|
* atomically re-enables interrupts and enters low power mode.
|
|
|
|
*
|
2018-09-30 20:00:21 +08:00
|
|
|
* A weak stub for sys_arch_reboot(), which does nothing
|
2017-10-03 22:31:55 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "posix_core.h"
|
2019-10-24 23:08:21 +08:00
|
|
|
#include <arch/posix/posix_soc_if.h>
|
2020-02-06 22:14:51 +08:00
|
|
|
#include <tracing/tracing.h>
|
2017-10-03 22:31:55 +08:00
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
void arch_cpu_idle(void)
|
2017-10-03 22:31:55 +08:00
|
|
|
{
|
2019-09-19 15:25:19 +08:00
|
|
|
sys_trace_idle();
|
2017-10-03 22:31:55 +08:00
|
|
|
posix_irq_full_unlock();
|
|
|
|
posix_halt_cpu();
|
|
|
|
}
|
|
|
|
|
2019-11-08 04:43:29 +08:00
|
|
|
void arch_cpu_atomic_idle(unsigned int key)
|
2017-10-03 22:31:55 +08:00
|
|
|
{
|
2019-09-19 15:25:19 +08:00
|
|
|
sys_trace_idle();
|
2018-09-26 05:54:25 +08:00
|
|
|
posix_atomic_halt_cpu(key);
|
2017-10-03 22:31:55 +08:00
|
|
|
}
|
2018-09-30 20:00:21 +08:00
|
|
|
|
|
|
|
#if defined(CONFIG_REBOOT)
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Stub for sys_arch_reboot
|
|
|
|
*
|
|
|
|
* Does nothing
|
|
|
|
*
|
|
|
|
* @return N/A
|
|
|
|
*/
|
|
|
|
void __weak sys_arch_reboot(int type)
|
|
|
|
{
|
|
|
|
ARG_UNUSED(type);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_REBOOT */
|