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
26 extern "C" {
27 #endif
28 
29 #define IRQ_MASK 0x00000080
30 
31 static 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 
38 static inline void __set_cpsr(unsigned val)
39 {
40  __asm__ volatile(" msr cpsr, %0" : /* no outputs */ : "r"(val) : "memory");
41 }
42 
43 static inline int 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 
50 static 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 
59 static inline __attribute__((always_inline)) void irq_restore(unsigned oldCPSR)
60 {
61  __set_cpsr(oldCPSR);
62 }
63 
64 static 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 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif /* IRQ_ARCH_H */
78 
irq_enable
MAYBE_INLINE unsigned irq_enable(void)
This function clears the IRQ disable bit in the status register.
irq_disable
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
irq_is_in
MAYBE_INLINE int irq_is_in(void)
Check whether called from interrupt service routine.
irq_restore
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...