1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5 #ifndef _ASM_IRQFLAGS_H
6 #define _ASM_IRQFLAGS_H
10 #include <linux/compiler.h>
11 #include <linux/stringify.h>
12 #include <asm/loongarch.h>
14 static inline void arch_local_irq_enable(void)
16 u32 flags
= CSR_CRMD_IE
;
18 "csrxchg %[val], %[mask], %[reg]\n\t"
20 : [mask
] "r" (CSR_CRMD_IE
), [reg
] "i" (LOONGARCH_CSR_CRMD
)
24 static inline void arch_local_irq_disable(void)
28 "csrxchg %[val], %[mask], %[reg]\n\t"
30 : [mask
] "r" (CSR_CRMD_IE
), [reg
] "i" (LOONGARCH_CSR_CRMD
)
34 static inline unsigned long arch_local_irq_save(void)
38 "csrxchg %[val], %[mask], %[reg]\n\t"
40 : [mask
] "r" (CSR_CRMD_IE
), [reg
] "i" (LOONGARCH_CSR_CRMD
)
45 static inline void arch_local_irq_restore(unsigned long flags
)
48 "csrxchg %[val], %[mask], %[reg]\n\t"
50 : [mask
] "r" (CSR_CRMD_IE
), [reg
] "i" (LOONGARCH_CSR_CRMD
)
54 static inline unsigned long arch_local_save_flags(void)
58 "csrrd %[val], %[reg]\n\t"
60 : [reg
] "i" (LOONGARCH_CSR_CRMD
)
65 static inline int arch_irqs_disabled_flags(unsigned long flags
)
67 return !(flags
& CSR_CRMD_IE
);
70 static inline int arch_irqs_disabled(void)
72 return arch_irqs_disabled_flags(arch_local_save_flags());
75 #endif /* #ifndef __ASSEMBLY__ */
77 #endif /* _ASM_IRQFLAGS_H */