voron

experimental ARM OS
git clone git://git.2f30.org/voron
Log | Files | Refs | README | LICENSE

irq.h (970B)


      1 #ifndef __IRQ_H
      2 #define __IRQ_H
      3 
      4 #include <kernel.h>
      5 
      6 typedef void (*irq_callback_func)(u32 irq_num, struct regs *regs);
      7 
      8 int irq_register(u32 irq_num, irq_callback_func func);
      9 int irq_trigger_sgi(u32 irq_num);
     10 
     11 /* board specific */
     12 #define HW_IRQ(x)	(x + 32)
     13 #define NR_IRQ		160
     14 
     15 static inline void
     16 irq_enable(void)
     17 {
     18 	asm volatile("cpsie if" : : : "memory");
     19 }
     20 
     21 static inline void
     22 irq_disable(void)
     23 {
     24 	asm volatile("cpsid if" : : : "memory");
     25 }
     26 
     27 #define CPSR_MASK_IRQ	(1<<7)
     28 #define CPSR_MASK_FIQ	(1<<6)
     29 
     30 static inline u32
     31 irq_get_flags()
     32 {
     33 	u32 val;
     34 	asm volatile("mrs %0, cpsr" : "=r" (val) : : "memory");
     35 	val &= CPSR_MASK_IRQ | CPSR_MASK_FIQ;
     36 	return val;
     37 }
     38 
     39 static inline void
     40 irq_set_flags(u32 flags)
     41 {
     42 	flags &= CPSR_MASK_IRQ | CPSR_MASK_FIQ;
     43 	asm volatile (
     44 		"mrs v1, cpsr		\n\t"
     45 		"bic v1, v1, %0		\n\t"
     46 		"orr v1, v1, %1		\n\t"
     47 		"msr cpsr_c, v1		\n\t"
     48 		:
     49 		: "r" (CPSR_MASK_IRQ | CPSR_MASK_FIQ), "r" (flags)
     50 		: "v1", "memory"
     51 	);
     52 }
     53 
     54 #endif	/* __IRQ_H */