irqflags.h 1.5 KB
Newer Older
1
/*
2
 *    Copyright IBM Corp. 2006, 2010
3
 *    Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
4 5 6 7 8
 */

#ifndef __ASM_IRQFLAGS_H
#define __ASM_IRQFLAGS_H

9
#include <linux/types.h>
10

D
David Howells 已提交
11 12
/* store then OR system mask. */
#define __arch_local_irq_stosm(__or)					\
13 14 15 16 17 18 19 20
({									\
	unsigned long __mask;						\
	asm volatile(							\
		"	stosm	%0,%1"					\
		: "=Q" (__mask) : "i" (__or) : "memory");		\
	__mask;								\
})

D
David Howells 已提交
21 22
/* store then AND system mask. */
#define __arch_local_irq_stnsm(__and)					\
23 24 25 26 27 28 29 30 31
({									\
	unsigned long __mask;						\
	asm volatile(							\
		"	stnsm	%0,%1"					\
		: "=Q" (__mask) : "i" (__and) : "memory");		\
	__mask;								\
})

/* set system mask. */
32
static inline notrace void __arch_local_irq_ssm(unsigned long flags)
D
David Howells 已提交
33 34 35
{
	asm volatile("ssm   %0" : : "Q" (flags) : "memory");
}
36

37
static inline notrace unsigned long arch_local_save_flags(void)
38
{
39
	return __arch_local_irq_stnsm(0xff);
40
}
41

42
static inline notrace unsigned long arch_local_irq_save(void)
43
{
D
David Howells 已提交
44
	return __arch_local_irq_stnsm(0xfc);
45 46
}

47
static inline notrace void arch_local_irq_disable(void)
D
David Howells 已提交
48 49 50
{
	arch_local_irq_save();
}
51

52
static inline notrace void arch_local_irq_enable(void)
53
{
D
David Howells 已提交
54
	__arch_local_irq_stosm(0x03);
55
}
56

57
static inline notrace void arch_local_irq_restore(unsigned long flags)
D
David Howells 已提交
58 59 60 61
{
	__arch_local_irq_ssm(flags);
}

62
static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
63
{
64
	return !(flags & (3UL << (BITS_PER_LONG - 8)));
65 66
}

67
static inline notrace bool arch_irqs_disabled(void)
D
David Howells 已提交
68 69 70
{
	return arch_irqs_disabled_flags(arch_local_save_flags());
}
71 72

#endif /* __ASM_IRQFLAGS_H */