Linux 5.7.6
[linux/fpc-iii.git] / arch / sparc / include / asm / irqflags_64.h
blobc29ed571ae49e92c6424da7f4d89f1ab10254f94
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * include/asm/irqflags.h
5 * IRQ flags handling
7 * This file gets included from lowlevel asm headers too, to provide
8 * wrapped versions of the local_irq_*() APIs, based on the
9 * arch_local_irq_*() functions from the lowlevel headers.
11 #ifndef _ASM_IRQFLAGS_H
12 #define _ASM_IRQFLAGS_H
14 #include <asm/pil.h>
16 #ifndef __ASSEMBLY__
18 static inline notrace unsigned long arch_local_save_flags(void)
20 unsigned long flags;
22 __asm__ __volatile__(
23 "rdpr %%pil, %0"
24 : "=r" (flags)
27 return flags;
30 static inline notrace void arch_local_irq_restore(unsigned long flags)
32 __asm__ __volatile__(
33 "wrpr %0, %%pil"
34 : /* no output */
35 : "r" (flags)
36 : "memory"
40 static inline notrace void arch_local_irq_disable(void)
42 __asm__ __volatile__(
43 "wrpr %0, %%pil"
44 : /* no outputs */
45 : "i" (PIL_NORMAL_MAX)
46 : "memory"
50 static inline notrace void arch_local_irq_enable(void)
52 __asm__ __volatile__(
53 "wrpr 0, %%pil"
54 : /* no outputs */
55 : /* no inputs */
56 : "memory"
60 static inline notrace int arch_irqs_disabled_flags(unsigned long flags)
62 return (flags > 0);
65 static inline notrace int arch_irqs_disabled(void)
67 return arch_irqs_disabled_flags(arch_local_save_flags());
70 static inline notrace unsigned long arch_local_irq_save(void)
72 unsigned long flags, tmp;
74 /* Disable interrupts to PIL_NORMAL_MAX unless we already
75 * are using PIL_NMI, in which case PIL_NMI is retained.
77 * The only values we ever program into the %pil are 0,
78 * PIL_NORMAL_MAX and PIL_NMI.
80 * Since PIL_NMI is the largest %pil value and all bits are
81 * set in it (0xf), it doesn't matter what PIL_NORMAL_MAX
82 * actually is.
84 __asm__ __volatile__(
85 "rdpr %%pil, %0\n\t"
86 "or %0, %2, %1\n\t"
87 "wrpr %1, 0x0, %%pil"
88 : "=r" (flags), "=r" (tmp)
89 : "i" (PIL_NORMAL_MAX)
90 : "memory"
93 return flags;
96 #endif /* (__ASSEMBLY__) */
98 #endif /* !(_ASM_IRQFLAGS_H) */