1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/arm7_common/irq_arch.c
Marian Buschsieweke fd559bcdb5
cpu/arm7_common: Cleaned up IRQ code
- Moved VIC.c to irq_arch.c for consistent naming scheme
- Removed unused functions IRQenabled, disableFIQ, restoreFIQ, enableFIQ
    - There is not header for those functions, so they *cannot* be used
    - These is obviously no user, as they *cannot* be used
    - There is absolutely no documentation what they would be used for
2019-07-25 10:31:41 +02:00

57 lines
1.2 KiB
C

/* 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.
*/
#include "VIC.h"
#include <stdbool.h>
#define IRQ_MASK 0x00000080
static inline unsigned __get_cpsr(void)
{
unsigned long retval;
__asm__ volatile(" mrs %0, cpsr" : "=r"(retval) : /* no inputs */ : "memory");
return retval;
}
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)
{
unsigned _cpsr;
_cpsr = __get_cpsr();
__set_cpsr(_cpsr | IRQ_MASK);
return _cpsr;
}
unsigned irq_restore(unsigned oldCPSR)
{
unsigned _cpsr;
_cpsr = __get_cpsr();
__set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
return _cpsr;
}
unsigned irq_enable(void)
{
unsigned _cpsr;
_cpsr = __get_cpsr();
__set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}