blob: 595a275c36f87d5ea4fa58d0a580eb36c601ef34 [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
Christian Borntraeger204ee2c2016-01-11 09:17:18 +010011#define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
12
David Howellsdf9ee292010-10-07 14:08:55 +010013/* store then OR system mask. */
14#define __arch_local_irq_stosm(__or) \
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020015({ \
16 unsigned long __mask; \
17 asm volatile( \
18 " stosm %0,%1" \
19 : "=Q" (__mask) : "i" (__or) : "memory"); \
20 __mask; \
Heiko Carstens1f194a42006-07-03 00:24:46 -070021})
22
David Howellsdf9ee292010-10-07 14:08:55 +010023/* store then AND system mask. */
24#define __arch_local_irq_stnsm(__and) \
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020025({ \
26 unsigned long __mask; \
27 asm volatile( \
28 " stnsm %0,%1" \
29 : "=Q" (__mask) : "i" (__and) : "memory"); \
30 __mask; \
31})
32
33/* set system mask. */
Steven Rostedtf433c4a2011-07-24 10:47:58 +020034static inline notrace void __arch_local_irq_ssm(unsigned long flags)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020035{
David Howellsdf9ee292010-10-07 14:08:55 +010036 asm volatile("ssm %0" : : "Q" (flags) : "memory");
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020037}
38
Steven Rostedtf433c4a2011-07-24 10:47:58 +020039static inline notrace unsigned long arch_local_save_flags(void)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020040{
Christian Borntraeger81fc77f2014-12-16 10:25:37 +010041 return __arch_local_irq_stnsm(0xff);
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020042}
43
Steven Rostedtf433c4a2011-07-24 10:47:58 +020044static inline notrace unsigned long arch_local_irq_save(void)
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020045{
David Howellsdf9ee292010-10-07 14:08:55 +010046 return __arch_local_irq_stnsm(0xfc);
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020047}
48
Steven Rostedtf433c4a2011-07-24 10:47:58 +020049static inline notrace void arch_local_irq_disable(void)
David Howellsdf9ee292010-10-07 14:08:55 +010050{
51 arch_local_irq_save();
52}
53
Steven Rostedtf433c4a2011-07-24 10:47:58 +020054static inline notrace void arch_local_irq_enable(void)
David Howellsdf9ee292010-10-07 14:08:55 +010055{
56 __arch_local_irq_stosm(0x03);
57}
58
Christian Borntraeger204ee2c2016-01-11 09:17:18 +010059/* This only restores external and I/O interrupt state */
Steven Rostedtf433c4a2011-07-24 10:47:58 +020060static inline notrace void arch_local_irq_restore(unsigned long flags)
David Howellsdf9ee292010-10-07 14:08:55 +010061{
Christian Borntraeger204ee2c2016-01-11 09:17:18 +010062 /* only disabled->disabled and disabled->enabled is valid */
63 if (flags & ARCH_IRQ_ENABLED)
64 arch_local_irq_enable();
David Howellsdf9ee292010-10-07 14:08:55 +010065}
66
Steven Rostedtf433c4a2011-07-24 10:47:58 +020067static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
Heiko Carstens1f194a42006-07-03 00:24:46 -070068{
Christian Borntraeger204ee2c2016-01-11 09:17:18 +010069 return !(flags & ARCH_IRQ_ENABLED);
Heiko Carstens1f194a42006-07-03 00:24:46 -070070}
71
Steven Rostedtf433c4a2011-07-24 10:47:58 +020072static inline notrace bool arch_irqs_disabled(void)
David Howellsdf9ee292010-10-07 14:08:55 +010073{
74 return arch_irqs_disabled_flags(arch_local_save_flags());
75}
Heiko Carstens1f194a42006-07-03 00:24:46 -070076
Heiko Carstens1f194a42006-07-03 00:24:46 -070077#endif /* __ASM_IRQFLAGS_H */