Loading...
Searching...
No Matches
irq_arch.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2005, 2006, 2007, 2008 by Thomas Hillebrandt and Heiko Will
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
19#ifndef IRQ_ARCH_H
20#define IRQ_ARCH_H
21
22#include "VIC.h"
23#include <stdbool.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define IRQ_MASK 0x00000080
30
31static inline unsigned __get_cpsr(void)
32{
33 unsigned long retval;
34 __asm__ volatile(" mrs %0, cpsr" : "=r"(retval) : /* no inputs */ : "memory");
35 return retval;
36}
37
38static inline void __set_cpsr(unsigned val)
39{
40 __asm__ volatile(" msr cpsr, %0" : /* no outputs */ : "r"(val) : "memory");
41}
42
43static inline bool irq_is_in(void)
44{
45 int retval;
46 __asm__ volatile(" mrs %0, cpsr" : "=r"(retval) : /* no inputs */ : "memory");
47 return (retval & INTMode) == 18;
48}
49
50static inline __attribute__((always_inline)) unsigned irq_disable(void)
51{
52 unsigned _cpsr;
53
54 _cpsr = __get_cpsr();
55 __set_cpsr(_cpsr | IRQ_MASK);
56 return _cpsr;
57}
58
59static inline __attribute__((always_inline)) void irq_restore(unsigned oldCPSR)
60{
61 __set_cpsr(oldCPSR);
62}
63
64static inline __attribute__((always_inline)) unsigned irq_enable(void)
65{
66 unsigned _cpsr;
67
68 _cpsr = __get_cpsr();
69 __set_cpsr(_cpsr & ~IRQ_MASK);
70 return _cpsr;
71}
72
73static inline __attribute__((always_inline)) bool irq_is_enabled(void)
74{
75 return !(__get_cpsr() & IRQ_MASK);
76}
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif /* IRQ_ARCH_H */
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_enabled(void)
Test if IRQs are currently enabled.
MAYBE_INLINE unsigned irq_enable(void)
This function clears the IRQ disable bit in the status register.
MAYBE_INLINE bool irq_is_in(void)
Check whether called from interrupt service routine.