Michal Simek | 4dbdc9a | 2009-03-27 14:25:35 +0100 | [diff] [blame] | 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 | |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 12 | #include <linux/types.h> |
Michal Simek | a3cd613 | 2009-10-30 12:26:53 +0100 | [diff] [blame] | 13 | #include <asm/registers.h> |
Michal Simek | 4dbdc9a | 2009-03-27 14:25:35 +0100 | [diff] [blame] | 14 | |
Michal Simek | 12dfc73 | 2011-02-07 13:32:55 +0100 | [diff] [blame] | 15 | #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR |
Michal Simek | 4dbdc9a | 2009-03-27 14:25:35 +0100 | [diff] [blame] | 16 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 17 | static inline notrace unsigned long arch_local_irq_save(void) |
Michal Simek | 4dbdc9a | 2009-03-27 14:25:35 +0100 | [diff] [blame] | 18 | { |
| 19 | unsigned long flags; |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 20 | asm volatile(" msrclr %0, %1 \n" |
| 21 | " nop \n" |
| 22 | : "=r"(flags) |
| 23 | : "i"(MSR_IE) |
| 24 | : "memory"); |
Michal Simek | a3cd613 | 2009-10-30 12:26:53 +0100 | [diff] [blame] | 25 | return flags; |
Michal Simek | 4dbdc9a | 2009-03-27 14:25:35 +0100 | [diff] [blame] | 26 | } |
| 27 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 28 | static inline notrace void arch_local_irq_disable(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 29 | { |
| 30 | /* this uses r0 without declaring it - is that correct? */ |
| 31 | asm volatile(" msrclr r0, %0 \n" |
| 32 | " nop \n" |
| 33 | : |
| 34 | : "i"(MSR_IE) |
| 35 | : "memory"); |
| 36 | } |
| 37 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 38 | static inline notrace void arch_local_irq_enable(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 39 | { |
| 40 | /* this uses r0 without declaring it - is that correct? */ |
| 41 | asm volatile(" msrset r0, %0 \n" |
| 42 | " nop \n" |
| 43 | : |
| 44 | : "i"(MSR_IE) |
| 45 | : "memory"); |
| 46 | } |
| 47 | |
| 48 | #else /* !CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ |
| 49 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 50 | static inline notrace unsigned long arch_local_irq_save(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 51 | { |
| 52 | unsigned long flags, tmp; |
| 53 | asm volatile (" mfs %0, rmsr \n" |
| 54 | " nop \n" |
| 55 | " andi %1, %0, %2 \n" |
| 56 | " mts rmsr, %1 \n" |
| 57 | " nop \n" |
| 58 | : "=r"(flags), "=r"(tmp) |
| 59 | : "i"(~MSR_IE) |
| 60 | : "memory"); |
| 61 | return flags; |
| 62 | } |
| 63 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 64 | static inline notrace void arch_local_irq_disable(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 65 | { |
| 66 | unsigned long tmp; |
| 67 | asm volatile(" mfs %0, rmsr \n" |
| 68 | " nop \n" |
| 69 | " andi %0, %0, %1 \n" |
| 70 | " mts rmsr, %0 \n" |
| 71 | " nop \n" |
| 72 | : "=r"(tmp) |
| 73 | : "i"(~MSR_IE) |
| 74 | : "memory"); |
| 75 | } |
| 76 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 77 | static inline notrace void arch_local_irq_enable(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 78 | { |
| 79 | unsigned long tmp; |
| 80 | asm volatile(" mfs %0, rmsr \n" |
| 81 | " nop \n" |
| 82 | " ori %0, %0, %1 \n" |
| 83 | " mts rmsr, %0 \n" |
| 84 | " nop \n" |
| 85 | : "=r"(tmp) |
| 86 | : "i"(MSR_IE) |
| 87 | : "memory"); |
| 88 | } |
| 89 | |
| 90 | #endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */ |
| 91 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 92 | static inline notrace unsigned long arch_local_save_flags(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 93 | { |
| 94 | unsigned long flags; |
| 95 | asm volatile(" mfs %0, rmsr \n" |
| 96 | " nop \n" |
| 97 | : "=r"(flags) |
| 98 | : |
| 99 | : "memory"); |
| 100 | return flags; |
| 101 | } |
| 102 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 103 | static inline notrace void arch_local_irq_restore(unsigned long flags) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 104 | { |
| 105 | asm volatile(" mts rmsr, %0 \n" |
| 106 | " nop \n" |
| 107 | : |
| 108 | : "r"(flags) |
| 109 | : "memory"); |
| 110 | } |
| 111 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 112 | static inline notrace bool arch_irqs_disabled_flags(unsigned long flags) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 113 | { |
| 114 | return (flags & MSR_IE) == 0; |
| 115 | } |
| 116 | |
Steven Rostedt | a2f5269 | 2011-07-01 23:04:40 -0400 | [diff] [blame] | 117 | static inline notrace bool arch_irqs_disabled(void) |
David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 118 | { |
| 119 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
| 120 | } |
Michal Simek | 4dbdc9a | 2009-03-27 14:25:35 +0100 | [diff] [blame] | 121 | |
| 122 | #endif /* _ASM_MICROBLAZE_IRQFLAGS_H */ |