Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
armVIC.c
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $RCSfile$
4  * $Revision$
5  *
6  * This module provides the interface routines for setting up and
7  * controlling the various interrupt modes present on the ARM processor.
8  * Copyright 2004, R O SoftWare
9  * No guarantees, warrantees, or promises, implied or otherwise.
10  * May be used for hobby or commercial purposes provided copyright
11  * notice remains intact.
12  *
13  *****************************************************************************/
14 #include "types.h"
15 #include "armVIC.h"
16 
17 #define IRQ_MASK 0x00000080
18 #define FIQ_MASK 0x00000040
19 #define INT_MASK (IRQ_MASK | FIQ_MASK)
20 
21 static inline unsigned __get_cpsr(void)
22 {
23  unsigned long retval;
24  asm volatile(" mrs %0, cpsr" : "=r"(retval) : /* no inputs */);
25  return retval;
26 }
27 
28 static inline void __set_cpsr(unsigned val)
29 {
30  asm volatile(" msr cpsr, %0" : /* no outputs */ : "r"(val));
31 }
32 
33 unsigned disableIRQ(void)
34 {
35  unsigned _cpsr;
36 
37  _cpsr = __get_cpsr();
38  __set_cpsr(_cpsr | IRQ_MASK);
39  return _cpsr;
40 }
41 
42 unsigned restoreIRQ(unsigned oldCPSR)
43 {
44  unsigned _cpsr;
45 
46  _cpsr = __get_cpsr();
47  __set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
48  return _cpsr;
49 }
50 
51 unsigned enableIRQ(void)
52 {
53  unsigned _cpsr;
54 
55  _cpsr = __get_cpsr();
56  __set_cpsr(_cpsr & ~IRQ_MASK);
57  return _cpsr;
58 }
59 
60 unsigned disableFIQ(void)
61 {
62  unsigned _cpsr;
63 
64  _cpsr = __get_cpsr();
65  __set_cpsr(_cpsr | FIQ_MASK);
66  return _cpsr;
67 }
68 
69 unsigned restoreFIQ(unsigned oldCPSR)
70 {
71  unsigned _cpsr;
72 
73  _cpsr = __get_cpsr();
74  __set_cpsr((_cpsr & ~FIQ_MASK) | (oldCPSR & FIQ_MASK));
75  return _cpsr;
76 }
77 
78 unsigned enableFIQ(void)
79 {
80  unsigned _cpsr;
81 
82  _cpsr = __get_cpsr();
83  __set_cpsr(_cpsr & ~FIQ_MASK);
84  return _cpsr;
85 }
#define FIQ_MASK
Definition: armVIC.c:18
static void __set_cpsr(unsigned val)
Definition: armVIC.c:28
#define IRQ_MASK
Definition: armVIC.c:17
static unsigned __get_cpsr(void)
Definition: armVIC.c:21
unsigned restoreFIQ(unsigned oldCPSR)
Definition: armVIC.c:69
unsigned disableFIQ(void)
Definition: armVIC.c:60
unsigned enableIRQ(void)
Definition: armVIC.c:51
unsigned enableFIQ(void)
Definition: armVIC.c:78
uint16_t val[TCOUPLE_NB]
unsigned restoreIRQ(unsigned oldCPSR)
Definition: armVIC.c:42
unsigned disableIRQ(void)
Definition: armVIC.c:33