Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
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.
7 */
8#ifndef __ASM_AVR32_IRQFLAGS_H
9#define __ASM_AVR32_IRQFLAGS_H
10
11#include <linux/types.h>
12#include <asm/sysreg.h>
13
14static inline unsigned long arch_local_save_flags(void)
15{
16 return sysreg_read(SR);
17}
18
19/*
20 * This will restore ALL status register flags, not only the interrupt
21 * mask flag.
22 *
23 * The empty asm statement informs the compiler of this fact while
24 * also serving as a barrier.
25 */
26static inline void arch_local_irq_restore(unsigned long flags)
27{
28 sysreg_write(SR, flags);
29 asm volatile("" : : : "memory", "cc");
30}
31
32static inline void arch_local_irq_disable(void)
33{
34 asm volatile("ssrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
35}
36
37static inline void arch_local_irq_enable(void)
38{
39 asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
40}
41
42static inline bool arch_irqs_disabled_flags(unsigned long flags)
43{
44 return (flags & SYSREG_BIT(GM)) != 0;
45}
46
47static inline bool arch_irqs_disabled(void)
48{
49 return arch_irqs_disabled_flags(arch_local_save_flags());
50}
51
52static inline unsigned long arch_local_irq_save(void)
53{
54 unsigned long flags = arch_local_save_flags();
55
56 arch_local_irq_disable();
57
58 return flags;
59}
60
61#endif /* __ASM_AVR32_IRQFLAGS_H */