License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / s390 / include / asm / irqflags.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
1f194a4c 2/*
a53c8fab 3 * Copyright IBM Corp. 2006, 2010
428aecf6 4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
1f194a4c
HC
5 */
6
7#ifndef __ASM_IRQFLAGS_H
8#define __ASM_IRQFLAGS_H
9
428aecf6 10#include <linux/types.h>
1f194a4c 11
204ee2c5
CB
12#define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
13
df9ee292
DH
14/* store then OR system mask. */
15#define __arch_local_irq_stosm(__or) \
94c12cc7
MS
16({ \
17 unsigned long __mask; \
18 asm volatile( \
19 " stosm %0,%1" \
20 : "=Q" (__mask) : "i" (__or) : "memory"); \
21 __mask; \
22})
23
df9ee292
DH
24/* store then AND system mask. */
25#define __arch_local_irq_stnsm(__and) \
94c12cc7
MS
26({ \
27 unsigned long __mask; \
28 asm volatile( \
29 " stnsm %0,%1" \
30 : "=Q" (__mask) : "i" (__and) : "memory"); \
31 __mask; \
32})
33
34/* set system mask. */
f433c4ae 35static inline notrace void __arch_local_irq_ssm(unsigned long flags)
df9ee292
DH
36{
37 asm volatile("ssm %0" : : "Q" (flags) : "memory");
38}
94c12cc7 39
f433c4ae 40static inline notrace unsigned long arch_local_save_flags(void)
94c12cc7 41{
81fc77fb 42 return __arch_local_irq_stnsm(0xff);
94c12cc7 43}
63f4f9e1 44
f433c4ae 45static inline notrace unsigned long arch_local_irq_save(void)
94c12cc7 46{
df9ee292 47 return __arch_local_irq_stnsm(0xfc);
94c12cc7
MS
48}
49
f433c4ae 50static inline notrace void arch_local_irq_disable(void)
df9ee292
DH
51{
52 arch_local_irq_save();
53}
1f194a4c 54
f433c4ae 55static inline notrace void arch_local_irq_enable(void)
94c12cc7 56{
df9ee292 57 __arch_local_irq_stosm(0x03);
94c12cc7 58}
1f194a4c 59
204ee2c5 60/* This only restores external and I/O interrupt state */
f433c4ae 61static inline notrace void arch_local_irq_restore(unsigned long flags)
df9ee292 62{
204ee2c5
CB
63 /* only disabled->disabled and disabled->enabled is valid */
64 if (flags & ARCH_IRQ_ENABLED)
65 arch_local_irq_enable();
df9ee292
DH
66}
67
f433c4ae 68static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
1f194a4c 69{
204ee2c5 70 return !(flags & ARCH_IRQ_ENABLED);
1f194a4c
HC
71}
72
f433c4ae 73static inline notrace bool arch_irqs_disabled(void)
df9ee292
DH
74{
75 return arch_irqs_disabled_flags(arch_local_save_flags());
76}
1f194a4c 77
1f194a4c 78#endif /* __ASM_IRQFLAGS_H */