blob: 15b3ac253898d8029e886c192f5d887bf1b3948f [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
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020011/* store then or system mask. */
12#define __raw_local_irq_stosm(__or) \
13({ \
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
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020021/* store then and system mask. */
22#define __raw_local_irq_stnsm(__and) \
23({ \
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. */
32#define __raw_local_irq_ssm(__mask) \
33({ \
34 asm volatile("ssm %0" : : "Q" (__mask) : "memory"); \
35})
36
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020037/* interrupt control.. */
38static inline unsigned long raw_local_irq_enable(void)
39{
40 return __raw_local_irq_stosm(0x03);
41}
42
43static inline unsigned long raw_local_irq_disable(void)
44{
45 return __raw_local_irq_stnsm(0xfc);
46}
47
48#define raw_local_save_flags(x) \
49do { \
50 typecheck(unsigned long, x); \
51 (x) = __raw_local_irq_stosm(0x00); \
52} while (0)
53
54static inline void raw_local_irq_restore(unsigned long flags)
55{
56 __raw_local_irq_ssm(flags);
57}
58
Heiko Carstens1f194a42006-07-03 00:24:46 -070059static inline int raw_irqs_disabled_flags(unsigned long flags)
60{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020061 return !(flags & (3UL << (BITS_PER_LONG - 8)));
Heiko Carstens1f194a42006-07-03 00:24:46 -070062}
63
64/* For spinlocks etc */
65#define raw_local_irq_save(x) ((x) = raw_local_irq_disable())
66
Heiko Carstens1f194a42006-07-03 00:24:46 -070067#endif /* __ASM_IRQFLAGS_H */