1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pm: fix weak-based default implementations

Instead of using `weak` function definitions, this PR handles
default implementations using `PROVIDES_x` defines, allowing
for cpus/pm realted modules to use their own implementations.
This commit is contained in:
Hauke Petersen 2017-10-12 16:20:15 +02:00
parent 508547d1bd
commit 5920d99752
18 changed files with 86 additions and 17 deletions

View File

@ -50,6 +50,14 @@ extern "C" {
*/
#define STACK_CANARY_WORD (0xE7FEE7FEu)
/**
* @brief All Cortex-m-based CPUs provide pm_set_lowest
*
* The pm_set_lowest is provided either by the pm_layered module if used, or
* alternatively as fallback by the cortexm's own implementation.
*/
#define PROVIDES_PM_SET_LOWEST
/**
* @brief Initialization of the CPU
*/

View File

@ -24,7 +24,7 @@
#include "cpu.h"
#include "periph/pm.h"
#ifndef FEATURE_PERIPH_PM
#if !defined(MODULE_PM_LAYERED) && !defined(PROVIDES_PM_SET_LOWEST_CORTEXM)
void pm_set_lowest(void)
{
cortexm_sleep(0);

View File

@ -21,7 +21,9 @@
#ifndef PERIPH_CPU_H
#define PERIPH_CPU_H
#include "cpu_conf.h"
#include "cpu.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -19,6 +19,7 @@
#ifndef PERIPH_CPU_H
#define PERIPH_CPU_H
#include "cpu.h"
#include "periph/dev_enums.h"
#ifdef __cplusplus

View File

@ -5,6 +5,7 @@ export APP_START=0x80000000
include $(RIOTMAKE)/arch/mips.inc.mk
export USEMODULE += periph
export USEMODULE += periph_common
export USEMODULE += newlib
ifeq ($(USE_UHI_SYSCALLS),1)

View File

@ -16,10 +16,23 @@
* or no peripherals
*/
#ifndef PERIPH_CPU_H
#define PERIPH_CPU_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Power management configuration
* @{
*/
#define PROVIDES_PM_SET_LOWEST
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CPU_H */
/** @} */

View File

@ -22,7 +22,6 @@
#include <mips/m32c0.h>
#include "periph/pm.h"
#ifndef FEATURES_PERIPH_PM
void pm_set_lowest(void)
{
/* Dont wait if interrupts are not enabled - we would never return!*/
@ -30,9 +29,3 @@ void pm_set_lowest(void)
__asm volatile ("wait");
}
}
#endif
void pm_off(void)
{
/* No Generic Power off Mechanism */
}

View File

@ -26,7 +26,14 @@
extern "C" {
#endif
/**
/**
* @name Power management configuration
* @{
*/
#define PROVIDES_PM_SET_LOWEST
/** @} */
/**
* @brief Length of the CPU_ID in bytes
*/
#define CPUID_LEN (4U)

View File

@ -8,6 +8,7 @@ export CFLAGS += -march=m4k -DSKIP_COPY_TO_RAM
export USEMODULE += mips_pic32_common
export USEMODULE += periph
export USEMODULE += periph_common
export USEMODULE += newlib
ifeq ($(USE_UHI_SYSCALLS),1)

View File

@ -9,6 +9,7 @@ export CFLAGS += -DMIPS_MICROMIPS
export USEMODULE += mips_pic32_common
export USEMODULE += periph
export USEMODULE += periph_common
export USEMODULE += newlib
ifeq ($(USE_UHI_SYSCALLS),1)

View File

@ -37,6 +37,13 @@ extern "C" {
*/
#define PERIPH_TIMER_PROVIDES_SET
/**
* @name Power management configuration
* @{
*/
#define PROVIDES_PM_OFF
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -25,6 +25,13 @@
extern "C" {
#endif
/**
* @name Power management configuration
* @{
*/
#define PROVIDES_PM_OFF
/** @} */
/**
* @brief Starting offset of CPU_ID
*/

View File

@ -50,6 +50,11 @@ extern "C" {
*/
#define CPUID_LEN (12U)
/**
* @brief We provide our own pm_off() function for all STM32-based CPUs
*/
#define PROVIDES_PM_LAYERED_OFF
/**
* @brief All STM timers have 4 capture-compare channels
*/

View File

@ -32,6 +32,13 @@
extern "C" {
#endif
/**
* @name Power management configuration
* @{
*/
#define PROVIDES_PM_OFF
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -27,8 +27,12 @@
#include "assert.h"
#include "periph_cpu.h"
#ifdef MODULE_PM_LAYERED
#include "pm_layered.h"
#endif
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
/**

View File

@ -24,10 +24,17 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
void __attribute__((weak)) pm_set_lowest(void) {}
void __attribute__((weak)) pm_off(void)
#ifndef PROVIDES_PM_OFF
void pm_off(void)
{
irq_disable();
while(1) {};
}
#endif
#ifndef PROVIDES_PM_SET_LOWEST
void pm_set_lowest(void)
{
/* don't do anything here */
}
#endif

View File

@ -35,11 +35,14 @@
#define PM_LAYERED_H
#include "assert.h"
#include "periph/pm.h"
#include "periph_cpu.h"
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#ifndef PROVIDES_PM_OFF
#define PROVIDES_PM_OFF
#endif
/**

View File

@ -87,9 +87,11 @@ void pm_unblock(unsigned mode)
irq_restore(state);
}
void __attribute__((weak)) pm_off(void)
#ifndef PROVIDES_PM_LAYERED_OFF
void pm_off(void)
{
pm_blocker.val_u32 = 0;
pm_set_lowest();
while(1);
}
#endif