1 /* 2 * Copyright (C) 2006 Atmark Techno, Inc. 3 * 4 * This file is subject to the terms and conditions of the GNU General Public 5 * License. See the file "COPYING" in the main directory of this archive 6 * for more details. 7 */ 8 9 #ifndef _ASM_MICROBLAZE_IRQFLAGS_H 10 #define _ASM_MICROBLAZE_IRQFLAGS_H 11 12 #include <linux/irqflags.h> 13 14 # if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR 15 16 # define local_irq_save(flags) \ 17 do { \ 18 asm volatile ("# local_irq_save \n\t" \ 19 "msrclr %0, %1 \n\t" \ 20 "nop \n\t" \ 21 : "=r"(flags) \ 22 : "i"(MSR_IE) \ 23 : "memory"); \ 24 } while (0) 25 26 # define local_irq_disable() \ 27 do { \ 28 asm volatile ("# local_irq_disable \n\t" \ 29 "msrclr r0, %0 \n\t" \ 30 "nop \n\t" \ 31 : \ 32 : "i"(MSR_IE) \ 33 : "memory"); \ 34 } while (0) 35 36 # define local_irq_enable() \ 37 do { \ 38 asm volatile ("# local_irq_enable \n\t" \ 39 "msrset r0, %0 \n\t" \ 40 "nop \n\t" \ 41 : \ 42 : "i"(MSR_IE) \ 43 : "memory"); \ 44 } while (0) 45 46 # else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */ 47 48 # define local_irq_save(flags) \ 49 do { \ 50 register unsigned tmp; \ 51 asm volatile ("# local_irq_save \n\t" \ 52 "mfs %0, rmsr \n\t" \ 53 "nop \n\t" \ 54 "andi %1, %0, %2 \n\t" \ 55 "mts rmsr, %1 \n\t" \ 56 "nop \n\t" \ 57 : "=r"(flags), "=r" (tmp) \ 58 : "i"(~MSR_IE) \ 59 : "memory"); \ 60 } while (0) 61 62 # define local_irq_disable() \ 63 do { \ 64 register unsigned tmp; \ 65 asm volatile ("# local_irq_disable \n\t" \ 66 "mfs %0, rmsr \n\t" \ 67 "nop \n\t" \ 68 "andi %0, %0, %1 \n\t" \ 69 "mts rmsr, %0 \n\t" \ 70 "nop \n\t" \ 71 : "=r"(tmp) \ 72 : "i"(~MSR_IE) \ 73 : "memory"); \ 74 } while (0) 75 76 # define local_irq_enable() \ 77 do { \ 78 register unsigned tmp; \ 79 asm volatile ("# local_irq_enable \n\t" \ 80 "mfs %0, rmsr \n\t" \ 81 "nop \n\t" \ 82 "ori %0, %0, %1 \n\t" \ 83 "mts rmsr, %0 \n\t" \ 84 "nop \n\t" \ 85 : "=r"(tmp) \ 86 : "i"(MSR_IE) \ 87 : "memory"); \ 88 } while (0) 89 90 # endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ 91 92 #define local_save_flags(flags) \ 93 do { \ 94 asm volatile ("# local_save_flags \n\t" \ 95 "mfs %0, rmsr \n\t" \ 96 "nop \n\t" \ 97 : "=r"(flags) \ 98 : \ 99 : "memory"); \ 100 } while (0) 101 102 #define local_irq_restore(flags) \ 103 do { \ 104 asm volatile ("# local_irq_restore \n\t"\ 105 "mts rmsr, %0 \n\t" \ 106 "nop \n\t" \ 107 : \ 108 : "r"(flags) \ 109 : "memory"); \ 110 } while (0) 111 112 static inline int irqs_disabled(void) 113 { 114 unsigned long flags; 115 116 local_save_flags(flags); 117 return ((flags & MSR_IE) == 0); 118 } 119 120 #define raw_irqs_disabled irqs_disabled 121 #define raw_irqs_disabled_flags(flags) ((flags) == 0) 122 123 #endif /* _ASM_MICROBLAZE_IRQFLAGS_H */ 124