Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *    Copyright IBM Corp. 2006, 2010
0004  *    Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
0005  */
0006 
0007 #ifndef __ASM_IRQFLAGS_H
0008 #define __ASM_IRQFLAGS_H
0009 
0010 #include <linux/types.h>
0011 
0012 #define ARCH_IRQ_ENABLED    (3UL << (BITS_PER_LONG - 8))
0013 
0014 /* store then OR system mask. */
0015 #define __arch_local_irq_stosm(__or)                    \
0016 ({                                  \
0017     unsigned long __mask;                       \
0018     asm volatile(                           \
0019         "   stosm   %0,%1"                  \
0020         : "=Q" (__mask) : "i" (__or) : "memory");       \
0021     __mask;                             \
0022 })
0023 
0024 /* store then AND system mask. */
0025 #define __arch_local_irq_stnsm(__and)                   \
0026 ({                                  \
0027     unsigned long __mask;                       \
0028     asm volatile(                           \
0029         "   stnsm   %0,%1"                  \
0030         : "=Q" (__mask) : "i" (__and) : "memory");      \
0031     __mask;                             \
0032 })
0033 
0034 /* set system mask. */
0035 static __always_inline void __arch_local_irq_ssm(unsigned long flags)
0036 {
0037     asm volatile("ssm   %0" : : "Q" (flags) : "memory");
0038 }
0039 
0040 static __always_inline unsigned long arch_local_save_flags(void)
0041 {
0042     return __arch_local_irq_stnsm(0xff);
0043 }
0044 
0045 static __always_inline unsigned long arch_local_irq_save(void)
0046 {
0047     return __arch_local_irq_stnsm(0xfc);
0048 }
0049 
0050 static __always_inline void arch_local_irq_disable(void)
0051 {
0052     arch_local_irq_save();
0053 }
0054 
0055 static __always_inline void arch_local_irq_enable(void)
0056 {
0057     __arch_local_irq_stosm(0x03);
0058 }
0059 
0060 /* This only restores external and I/O interrupt state */
0061 static __always_inline void arch_local_irq_restore(unsigned long flags)
0062 {
0063     /* only disabled->disabled and disabled->enabled is valid */
0064     if (flags & ARCH_IRQ_ENABLED)
0065         arch_local_irq_enable();
0066 }
0067 
0068 static __always_inline bool arch_irqs_disabled_flags(unsigned long flags)
0069 {
0070     return !(flags & ARCH_IRQ_ENABLED);
0071 }
0072 
0073 static __always_inline bool arch_irqs_disabled(void)
0074 {
0075     return arch_irqs_disabled_flags(arch_local_save_flags());
0076 }
0077 
0078 #endif /* __ASM_IRQFLAGS_H */