blob: 19ccbf483a2403184b2eaaa9d21c809afd97bc4e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Arnd Bergmannaafe4db2009-05-13 22:56:33 +00002#ifndef __ASM_GENERIC_IRQFLAGS_H
3#define __ASM_GENERIC_IRQFLAGS_H
4
5/*
6 * All architectures should implement at least the first two functions,
7 * usually inline assembly will be the best way.
8 */
David Howellsdf9ee292010-10-07 14:08:55 +01009#ifndef ARCH_IRQ_DISABLED
10#define ARCH_IRQ_DISABLED 0
11#define ARCH_IRQ_ENABLED 1
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000012#endif
13
14/* read interrupt enabled status */
David Howellsdf9ee292010-10-07 14:08:55 +010015#ifndef arch_local_save_flags
16unsigned long arch_local_save_flags(void);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000017#endif
18
19/* set interrupt enabled status */
David Howellsdf9ee292010-10-07 14:08:55 +010020#ifndef arch_local_irq_restore
21void arch_local_irq_restore(unsigned long flags);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000022#endif
23
24/* get status and disable interrupts */
David Howellsdf9ee292010-10-07 14:08:55 +010025#ifndef arch_local_irq_save
26static inline unsigned long arch_local_irq_save(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000027{
28 unsigned long flags;
David Howellsdf9ee292010-10-07 14:08:55 +010029 flags = arch_local_save_flags();
30 arch_local_irq_restore(ARCH_IRQ_DISABLED);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000031 return flags;
32}
33#endif
34
35/* test flags */
David Howellsdf9ee292010-10-07 14:08:55 +010036#ifndef arch_irqs_disabled_flags
37static inline int arch_irqs_disabled_flags(unsigned long flags)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000038{
David Howellsdf9ee292010-10-07 14:08:55 +010039 return flags == ARCH_IRQ_DISABLED;
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000040}
41#endif
42
43/* unconditionally enable interrupts */
David Howellsdf9ee292010-10-07 14:08:55 +010044#ifndef arch_local_irq_enable
45static inline void arch_local_irq_enable(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000046{
David Howellsdf9ee292010-10-07 14:08:55 +010047 arch_local_irq_restore(ARCH_IRQ_ENABLED);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000048}
49#endif
50
51/* unconditionally disable interrupts */
David Howellsdf9ee292010-10-07 14:08:55 +010052#ifndef arch_local_irq_disable
53static inline void arch_local_irq_disable(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000054{
David Howellsdf9ee292010-10-07 14:08:55 +010055 arch_local_irq_restore(ARCH_IRQ_DISABLED);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000056}
57#endif
58
59/* test hardware interrupt enable bit */
David Howellsdf9ee292010-10-07 14:08:55 +010060#ifndef arch_irqs_disabled
61static inline int arch_irqs_disabled(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000062{
David Howellsdf9ee292010-10-07 14:08:55 +010063 return arch_irqs_disabled_flags(arch_local_save_flags());
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000064}
65#endif
66
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000067#endif /* __ASM_GENERIC_IRQFLAGS_H */