blob: 37b9091ab8c010c88a22bb2851f0133b10c6f032 [file] [log] [blame]
Heiko Carstens1f194a42006-07-03 00:24:46 -07001/*
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02002 * Copyright IBM Corp. 2006, 2010
Heiko Carstens428aecf2010-01-27 10:12:36 +01003 * 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. */
Steven Rostedtf433c4a2011-07-24 10:47:58 +020032static inline notrace 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
Steven Rostedtf433c4a2011-07-24 10:47:58 +020037static inline notrace 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
Steven Rostedtf433c4a2011-07-24 10:47:58 +020042static inline notrace 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
Steven Rostedtf433c4a2011-07-24 10:47:58 +020047static inline notrace void arch_local_irq_disable(void)
David Howellsdf9ee292010-10-07 14:08:55 +010048{
49 arch_local_irq_save();
50}
51
Steven Rostedtf433c4a2011-07-24 10:47:58 +020052static inline notrace void arch_local_irq_enable(void)
David Howellsdf9ee292010-10-07 14:08:55 +010053{
54 __arch_local_irq_stosm(0x03);
55}
56
Steven Rostedtf433c4a2011-07-24 10:47:58 +020057static inline notrace void arch_local_irq_restore(unsigned long flags)
David Howellsdf9ee292010-10-07 14:08:55 +010058{
59 __arch_local_irq_ssm(flags);
60}
61
Steven Rostedtf433c4a2011-07-24 10:47:58 +020062static inline notrace 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
Steven Rostedtf433c4a2011-07-24 10:47:58 +020067static inline notrace bool arch_irqs_disabled(void)
David Howellsdf9ee292010-10-07 14:08:55 +010068{
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 */