David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 1 | #ifndef _H8300_IRQFLAGS_H |
| 2 | #define _H8300_IRQFLAGS_H |
| 3 | |
| 4 | static inline unsigned long arch_local_save_flags(void) |
| 5 | { |
| 6 | unsigned long flags; |
| 7 | asm volatile ("stc ccr,%w0" : "=r" (flags)); |
| 8 | return flags; |
| 9 | } |
| 10 | |
| 11 | static inline void arch_local_irq_disable(void) |
| 12 | { |
| 13 | asm volatile ("orc #0x80,ccr" : : : "memory"); |
| 14 | } |
| 15 | |
| 16 | static inline void arch_local_irq_enable(void) |
| 17 | { |
| 18 | asm volatile ("andc #0x7f,ccr" : : : "memory"); |
| 19 | } |
| 20 | |
| 21 | static inline unsigned long arch_local_irq_save(void) |
| 22 | { |
| 23 | unsigned long flags = arch_local_save_flags(); |
| 24 | arch_local_irq_disable(); |
| 25 | return flags; |
| 26 | } |
| 27 | |
| 28 | static inline void arch_local_irq_restore(unsigned long flags) |
| 29 | { |
| 30 | asm volatile ("ldc %w0,ccr" : : "r" (flags) : "memory"); |
| 31 | } |
| 32 | |
| 33 | static inline bool arch_irqs_disabled_flags(unsigned long flags) |
| 34 | { |
| 35 | return (flags & 0x80) == 0x80; |
| 36 | } |
| 37 | |
| 38 | static inline bool arch_irqs_disabled(void) |
| 39 | { |
| 40 | return arch_irqs_disabled_flags(arch_local_save_flags()); |
| 41 | } |
| 42 | |
| 43 | #endif /* _H8300_IRQFLAGS_H */ |