blob: 1f40d0024cf381d5c380f2a1c19b5c5ce3ae24e1 [file] [log] [blame]
Arnd Bergmannaafe4db2009-05-13 22:56:33 +00001#ifndef __ASM_GENERIC_IRQFLAGS_H
2#define __ASM_GENERIC_IRQFLAGS_H
3
4/*
5 * All architectures should implement at least the first two functions,
6 * usually inline assembly will be the best way.
7 */
David Howellsdf9ee292010-10-07 14:08:55 +01008#ifndef ARCH_IRQ_DISABLED
9#define ARCH_IRQ_DISABLED 0
10#define ARCH_IRQ_ENABLED 1
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000011#endif
12
13/* read interrupt enabled status */
David Howellsdf9ee292010-10-07 14:08:55 +010014#ifndef arch_local_save_flags
15unsigned long arch_local_save_flags(void);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000016#endif
17
18/* set interrupt enabled status */
David Howellsdf9ee292010-10-07 14:08:55 +010019#ifndef arch_local_irq_restore
20void arch_local_irq_restore(unsigned long flags);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000021#endif
22
23/* get status and disable interrupts */
David Howellsdf9ee292010-10-07 14:08:55 +010024#ifndef arch_local_irq_save
25static inline unsigned long arch_local_irq_save(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000026{
27 unsigned long flags;
David Howellsdf9ee292010-10-07 14:08:55 +010028 flags = arch_local_save_flags();
29 arch_local_irq_restore(ARCH_IRQ_DISABLED);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000030 return flags;
31}
32#endif
33
34/* test flags */
David Howellsdf9ee292010-10-07 14:08:55 +010035#ifndef arch_irqs_disabled_flags
36static inline int arch_irqs_disabled_flags(unsigned long flags)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000037{
David Howellsdf9ee292010-10-07 14:08:55 +010038 return flags == ARCH_IRQ_DISABLED;
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000039}
40#endif
41
42/* unconditionally enable interrupts */
David Howellsdf9ee292010-10-07 14:08:55 +010043#ifndef arch_local_irq_enable
44static inline void arch_local_irq_enable(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000045{
David Howellsdf9ee292010-10-07 14:08:55 +010046 arch_local_irq_restore(ARCH_IRQ_ENABLED);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000047}
48#endif
49
50/* unconditionally disable interrupts */
David Howellsdf9ee292010-10-07 14:08:55 +010051#ifndef arch_local_irq_disable
52static inline void arch_local_irq_disable(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000053{
David Howellsdf9ee292010-10-07 14:08:55 +010054 arch_local_irq_restore(ARCH_IRQ_DISABLED);
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000055}
56#endif
57
58/* test hardware interrupt enable bit */
David Howellsdf9ee292010-10-07 14:08:55 +010059#ifndef arch_irqs_disabled
60static inline int arch_irqs_disabled(void)
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000061{
David Howellsdf9ee292010-10-07 14:08:55 +010062 return arch_irqs_disabled_flags(arch_local_save_flags());
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000063}
64#endif
65
Arnd Bergmannaafe4db2009-05-13 22:56:33 +000066#endif /* __ASM_GENERIC_IRQFLAGS_H */