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

cpu/arm7_common: add inlined header only def for irq_%

This commit is contained in:
Benjamin Valentin 2020-05-15 11:18:52 +02:00
parent 477b29c80c
commit 8d0e902d38
2 changed files with 41 additions and 11 deletions

View File

@ -1,12 +1,31 @@
/* Copyright (C) 2005, 2006, 2007, 2008 by Thomas Hillebrandt and Heiko Will
/*
* Copyright (C) 2005, 2006, 2007, 2008 by Thomas Hillebrandt and Heiko Will
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_arm7_common
* @{
*
* @file
* @brief Implementation of the kernels irq interface
*
* @author Heiko Will <hwill@inf.fu-berlin.de>
*/
#ifndef IRQ_ARCH_H
#define IRQ_ARCH_H
#include "VIC.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define IRQ_MASK 0x00000080
static inline unsigned __get_cpsr(void)
@ -16,19 +35,19 @@ static inline unsigned __get_cpsr(void)
return retval;
}
int irq_is_in(void)
static inline void __set_cpsr(unsigned val)
{
__asm__ volatile(" msr cpsr, %0" : /* no outputs */ : "r"(val) : "memory");
}
static inline int irq_is_in(void)
{
int retval;
__asm__ volatile(" mrs %0, cpsr" : "=r"(retval) : /* no inputs */ : "memory");
return (retval & INTMode) == 18;
}
static inline void __set_cpsr(unsigned val)
{
__asm__ volatile(" msr cpsr, %0" : /* no outputs */ : "r"(val) : "memory");
}
unsigned irq_disable(void)
static inline __attribute__((always_inline)) unsigned irq_disable(void)
{
unsigned _cpsr;
@ -37,16 +56,15 @@ unsigned irq_disable(void)
return _cpsr;
}
unsigned irq_restore(unsigned oldCPSR)
static inline __attribute__((always_inline)) void irq_restore(unsigned oldCPSR)
{
unsigned _cpsr;
_cpsr = __get_cpsr();
__set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
return _cpsr;
}
unsigned irq_enable(void)
static inline __attribute__((always_inline)) unsigned irq_enable(void)
{
unsigned _cpsr;
@ -54,3 +72,10 @@ unsigned irq_enable(void)
__set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}
#ifdef __cplusplus
}
#endif
#endif /* IRQ_ARCH_H */
/** @} */

View File

@ -37,6 +37,11 @@ extern "C" {
#define __FILENAME_MAX__ 12
/** @} */
/**
* @brief This arch uses the inlined irq API.
*/
#define IRQ_API_INLINED (1)
/**
* @name Kernel configuration
* @{