blob: 865d6d891ace56f0b45d7d50aeca02f7daf46a23 [file] [log] [blame]
Heiko Carstens1f194a42006-07-03 00:24:46 -07001/*
Heiko Carstens428aecf2010-01-27 10:12:36 +01002 * Copyright IBM Corp. 2006,2010
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
Heiko Carstens1f194a42006-07-03 00:24:46 -07004 */
5
6#ifndef __ASM_IRQFLAGS_H
7#define __ASM_IRQFLAGS_H
8
Heiko Carstens428aecf2010-01-27 10:12:36 +01009#include <linux/types.h>
Heiko Carstens1f194a42006-07-03 00:24:46 -070010
David Howellsdf9ee292010-10-07 14:08:55 +010011/* store then OR system mask. */
12#define __arch_local_irq_stosm(__or) \
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020013({ \
14 unsigned long __mask; \
15 asm volatile( \
16 " stosm %0,%1" \
17 : "=Q" (__mask) : "i" (__or) : "memory"); \
18 __mask; \
Heiko Carstens1f194a42006-07-03 00:24:46 -070019})
20
David Howellsdf9ee292010-10-07 14:08:55 +010021/* store then AND system mask. */
22#define __arch_local_irq_stnsm(__and) \
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020023({ \
24 unsigned long __mask; \
25 asm volatile( \
26 " stnsm %0,%1" \
27 : "=Q" (__mask) : "i" (__and) : "memory"); \
28 __mask; \
29})
30
31/* set system mask. */
David Howellsdf9ee292010-10-07 14:08:55 +010032static inline void __arch_local_irq_ssm(unsigned long flags)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020033{
David Howellsdf9ee292010-10-07 14:08:55 +010034 asm volatile("ssm %0" : : "Q" (flags) : "memory");
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020035}
36
David Howellsdf9ee292010-10-07 14:08:55 +010037static inline unsigned long arch_local_save_flags(void)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020038{
David Howellsdf9ee292010-10-07 14:08:55 +010039 return __arch_local_irq_stosm(0x00);
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020040}
41
David Howellsdf9ee292010-10-07 14:08:55 +010042static inline unsigned long arch_local_irq_save(void)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020043{
David Howellsdf9ee292010-10-07 14:08:55 +010044 return __arch_local_irq_stnsm(0xfc);
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020045}
46
David Howellsdf9ee292010-10-07 14:08:55 +010047static inline void arch_local_irq_disable(void)
48{
49 arch_local_irq_save();
50}
51
52static inline void arch_local_irq_enable(void)
53{
54 __arch_local_irq_stosm(0x03);
55}
56
57static inline void arch_local_irq_restore(unsigned long flags)
58{
59 __arch_local_irq_ssm(flags);
60}
61
62static inline bool arch_irqs_disabled_flags(unsigned long flags)
Heiko Carstens1f194a42006-07-03 00:24:46 -070063{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020064 return !(flags & (3UL << (BITS_PER_LONG - 8)));
Heiko Carstens1f194a42006-07-03 00:24:46 -070065}
66
David Howellsdf9ee292010-10-07 14:08:55 +010067static inline bool arch_irqs_disabled(void)
68{
69 return arch_irqs_disabled_flags(arch_local_save_flags());
70}
Heiko Carstens1f194a42006-07-03 00:24:46 -070071
Heiko Carstens1f194a42006-07-03 00:24:46 -070072#endif /* __ASM_IRQFLAGS_H */