commit b45fc0f1a2f75f53f7f82ff64c313ee6c757a5d0
parent 8487ac8e7e7a793084b72ee82b206ee1fc3a4ae8
Author: oblique <psyberbits@gmail.com>
Date: Tue, 13 Nov 2012 07:05:42 +0200
add irq_get_flags() and irq_set_flags()
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/include/irq.h b/include/irq.h
@@ -24,4 +24,31 @@ irq_disable(void)
asm volatile("cpsid if" : : : "memory");
}
+#define CPSR_MASK_IRQ (1<<7)
+#define CPSR_MASK_FIQ (1<<6)
+
+static inline u32
+irq_get_flags()
+{
+ u32 val;
+ asm volatile("mrs %0, cpsr" : "=r" (val) : : "memory");
+ val &= CPSR_MASK_IRQ | CPSR_MASK_FIQ;
+ return val;
+}
+
+static inline void
+irq_set_flags(u32 flags)
+{
+ flags &= CPSR_MASK_IRQ | CPSR_MASK_FIQ;
+ asm volatile (
+ "mrs v1, cpsr \n\t"
+ "bic v1, v1, %0 \n\t"
+ "orr v1, v1, %1 \n\t"
+ "msr cpsr_c, v1 \n\t"
+ :
+ : "r" (CPSR_MASK_IRQ | CPSR_MASK_FIQ), "r" (flags)
+ : "v1", "memory"
+ );
+}
+
#endif /* __IRQ_H */