1*4baa9922SRussell King #ifndef __ASM_ARM_IRQFLAGS_H 2*4baa9922SRussell King #define __ASM_ARM_IRQFLAGS_H 3*4baa9922SRussell King 4*4baa9922SRussell King #ifdef __KERNEL__ 5*4baa9922SRussell King 6*4baa9922SRussell King #include <asm/ptrace.h> 7*4baa9922SRussell King 8*4baa9922SRussell King /* 9*4baa9922SRussell King * CPU interrupt mask handling. 10*4baa9922SRussell King */ 11*4baa9922SRussell King #if __LINUX_ARM_ARCH__ >= 6 12*4baa9922SRussell King 13*4baa9922SRussell King #define raw_local_irq_save(x) \ 14*4baa9922SRussell King ({ \ 15*4baa9922SRussell King __asm__ __volatile__( \ 16*4baa9922SRussell King "mrs %0, cpsr @ local_irq_save\n" \ 17*4baa9922SRussell King "cpsid i" \ 18*4baa9922SRussell King : "=r" (x) : : "memory", "cc"); \ 19*4baa9922SRussell King }) 20*4baa9922SRussell King 21*4baa9922SRussell King #define raw_local_irq_enable() __asm__("cpsie i @ __sti" : : : "memory", "cc") 22*4baa9922SRussell King #define raw_local_irq_disable() __asm__("cpsid i @ __cli" : : : "memory", "cc") 23*4baa9922SRussell King #define local_fiq_enable() __asm__("cpsie f @ __stf" : : : "memory", "cc") 24*4baa9922SRussell King #define local_fiq_disable() __asm__("cpsid f @ __clf" : : : "memory", "cc") 25*4baa9922SRussell King 26*4baa9922SRussell King #else 27*4baa9922SRussell King 28*4baa9922SRussell King /* 29*4baa9922SRussell King * Save the current interrupt enable state & disable IRQs 30*4baa9922SRussell King */ 31*4baa9922SRussell King #define raw_local_irq_save(x) \ 32*4baa9922SRussell King ({ \ 33*4baa9922SRussell King unsigned long temp; \ 34*4baa9922SRussell King (void) (&temp == &x); \ 35*4baa9922SRussell King __asm__ __volatile__( \ 36*4baa9922SRussell King "mrs %0, cpsr @ local_irq_save\n" \ 37*4baa9922SRussell King " orr %1, %0, #128\n" \ 38*4baa9922SRussell King " msr cpsr_c, %1" \ 39*4baa9922SRussell King : "=r" (x), "=r" (temp) \ 40*4baa9922SRussell King : \ 41*4baa9922SRussell King : "memory", "cc"); \ 42*4baa9922SRussell King }) 43*4baa9922SRussell King 44*4baa9922SRussell King /* 45*4baa9922SRussell King * Enable IRQs 46*4baa9922SRussell King */ 47*4baa9922SRussell King #define raw_local_irq_enable() \ 48*4baa9922SRussell King ({ \ 49*4baa9922SRussell King unsigned long temp; \ 50*4baa9922SRussell King __asm__ __volatile__( \ 51*4baa9922SRussell King "mrs %0, cpsr @ local_irq_enable\n" \ 52*4baa9922SRussell King " bic %0, %0, #128\n" \ 53*4baa9922SRussell King " msr cpsr_c, %0" \ 54*4baa9922SRussell King : "=r" (temp) \ 55*4baa9922SRussell King : \ 56*4baa9922SRussell King : "memory", "cc"); \ 57*4baa9922SRussell King }) 58*4baa9922SRussell King 59*4baa9922SRussell King /* 60*4baa9922SRussell King * Disable IRQs 61*4baa9922SRussell King */ 62*4baa9922SRussell King #define raw_local_irq_disable() \ 63*4baa9922SRussell King ({ \ 64*4baa9922SRussell King unsigned long temp; \ 65*4baa9922SRussell King __asm__ __volatile__( \ 66*4baa9922SRussell King "mrs %0, cpsr @ local_irq_disable\n" \ 67*4baa9922SRussell King " orr %0, %0, #128\n" \ 68*4baa9922SRussell King " msr cpsr_c, %0" \ 69*4baa9922SRussell King : "=r" (temp) \ 70*4baa9922SRussell King : \ 71*4baa9922SRussell King : "memory", "cc"); \ 72*4baa9922SRussell King }) 73*4baa9922SRussell King 74*4baa9922SRussell King /* 75*4baa9922SRussell King * Enable FIQs 76*4baa9922SRussell King */ 77*4baa9922SRussell King #define local_fiq_enable() \ 78*4baa9922SRussell King ({ \ 79*4baa9922SRussell King unsigned long temp; \ 80*4baa9922SRussell King __asm__ __volatile__( \ 81*4baa9922SRussell King "mrs %0, cpsr @ stf\n" \ 82*4baa9922SRussell King " bic %0, %0, #64\n" \ 83*4baa9922SRussell King " msr cpsr_c, %0" \ 84*4baa9922SRussell King : "=r" (temp) \ 85*4baa9922SRussell King : \ 86*4baa9922SRussell King : "memory", "cc"); \ 87*4baa9922SRussell King }) 88*4baa9922SRussell King 89*4baa9922SRussell King /* 90*4baa9922SRussell King * Disable FIQs 91*4baa9922SRussell King */ 92*4baa9922SRussell King #define local_fiq_disable() \ 93*4baa9922SRussell King ({ \ 94*4baa9922SRussell King unsigned long temp; \ 95*4baa9922SRussell King __asm__ __volatile__( \ 96*4baa9922SRussell King "mrs %0, cpsr @ clf\n" \ 97*4baa9922SRussell King " orr %0, %0, #64\n" \ 98*4baa9922SRussell King " msr cpsr_c, %0" \ 99*4baa9922SRussell King : "=r" (temp) \ 100*4baa9922SRussell King : \ 101*4baa9922SRussell King : "memory", "cc"); \ 102*4baa9922SRussell King }) 103*4baa9922SRussell King 104*4baa9922SRussell King #endif 105*4baa9922SRussell King 106*4baa9922SRussell King /* 107*4baa9922SRussell King * Save the current interrupt enable state. 108*4baa9922SRussell King */ 109*4baa9922SRussell King #define raw_local_save_flags(x) \ 110*4baa9922SRussell King ({ \ 111*4baa9922SRussell King __asm__ __volatile__( \ 112*4baa9922SRussell King "mrs %0, cpsr @ local_save_flags" \ 113*4baa9922SRussell King : "=r" (x) : : "memory", "cc"); \ 114*4baa9922SRussell King }) 115*4baa9922SRussell King 116*4baa9922SRussell King /* 117*4baa9922SRussell King * restore saved IRQ & FIQ state 118*4baa9922SRussell King */ 119*4baa9922SRussell King #define raw_local_irq_restore(x) \ 120*4baa9922SRussell King __asm__ __volatile__( \ 121*4baa9922SRussell King "msr cpsr_c, %0 @ local_irq_restore\n" \ 122*4baa9922SRussell King : \ 123*4baa9922SRussell King : "r" (x) \ 124*4baa9922SRussell King : "memory", "cc") 125*4baa9922SRussell King 126*4baa9922SRussell King #define raw_irqs_disabled_flags(flags) \ 127*4baa9922SRussell King ({ \ 128*4baa9922SRussell King (int)((flags) & PSR_I_BIT); \ 129*4baa9922SRussell King }) 130*4baa9922SRussell King 131*4baa9922SRussell King #endif 132*4baa9922SRussell King #endif 133