2 * Copyright (C) 2004-2006 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #ifndef __ASM_AVR32_IRQFLAGS_H
9 #define __ASM_AVR32_IRQFLAGS_H
11 #include <linux/types.h>
12 #include <asm/sysreg.h>
14 static inline unsigned long arch_local_save_flags(void)
16 return sysreg_read(SR);
20 * This will restore ALL status register flags, not only the interrupt
23 * The empty asm statement informs the compiler of this fact while
24 * also serving as a barrier.
26 static inline void arch_local_irq_restore(unsigned long flags)
28 sysreg_write(SR, flags);
29 asm volatile("" : : : "memory", "cc");
32 static inline void arch_local_irq_disable(void)
34 asm volatile("ssrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
37 static inline void arch_local_irq_enable(void)
39 asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
42 static inline bool arch_irqs_disabled_flags(unsigned long flags)
44 return (flags & SYSREG_BIT(GM)) != 0;
47 static inline bool arch_irqs_disabled(void)
49 return arch_irqs_disabled_flags(arch_local_save_flags());
52 static inline unsigned long arch_local_irq_save(void)
54 unsigned long flags = arch_local_save_flags();
56 arch_local_irq_disable();
61 #endif /* __ASM_AVR32_IRQFLAGS_H */