USB: serial: option: reimplement interface masking
[linux/fpc-iii.git] / arch / score / include / asm / irqflags.h
blob354c1979ea8dd463448d5bf57a90867de088d2f6
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_SCORE_IRQFLAGS_H
3 #define _ASM_SCORE_IRQFLAGS_H
5 #ifndef __ASSEMBLY__
7 #include <linux/types.h>
9 static inline unsigned long arch_local_save_flags(void)
11 unsigned long flags;
13 asm volatile(
14 " mfcr r8, cr0 \n"
15 " nop \n"
16 " nop \n"
17 " mv %0, r8 \n"
18 " nop \n"
19 " nop \n"
20 " nop \n"
21 " nop \n"
22 " nop \n"
23 " ldi r9, 0x1 \n"
24 " and %0, %0, r9 \n"
25 : "=r" (flags)
27 : "r8", "r9");
28 return flags;
31 static inline unsigned long arch_local_irq_save(void)
33 unsigned long flags;
35 asm volatile(
36 " mfcr r8, cr0 \n"
37 " li r9, 0xfffffffe \n"
38 " nop \n"
39 " mv %0, r8 \n"
40 " and r8, r8, r9 \n"
41 " mtcr r8, cr0 \n"
42 " nop \n"
43 " nop \n"
44 " nop \n"
45 " nop \n"
46 " nop \n"
47 : "=r" (flags)
49 : "r8", "r9", "memory");
51 return flags;
54 static inline void arch_local_irq_restore(unsigned long flags)
56 asm volatile(
57 " mfcr r8, cr0 \n"
58 " ldi r9, 0x1 \n"
59 " and %0, %0, r9 \n"
60 " or r8, r8, %0 \n"
61 " mtcr r8, cr0 \n"
62 " nop \n"
63 " nop \n"
64 " nop \n"
65 " nop \n"
66 " nop \n"
68 : "r"(flags)
69 : "r8", "r9", "memory");
72 static inline void arch_local_irq_enable(void)
74 asm volatile(
75 " mfcr r8,cr0 \n"
76 " nop \n"
77 " nop \n"
78 " ori r8,0x1 \n"
79 " mtcr r8,cr0 \n"
80 " nop \n"
81 " nop \n"
82 " nop \n"
83 " nop \n"
84 " nop \n"
87 : "r8", "memory");
90 static inline void arch_local_irq_disable(void)
92 asm volatile(
93 " mfcr r8,cr0 \n"
94 " nop \n"
95 " nop \n"
96 " srli r8,r8,1 \n"
97 " slli r8,r8,1 \n"
98 " mtcr r8,cr0 \n"
99 " nop \n"
100 " nop \n"
101 " nop \n"
102 " nop \n"
103 " nop \n"
106 : "r8", "memory");
109 static inline bool arch_irqs_disabled_flags(unsigned long flags)
111 return !(flags & 1);
114 static inline bool arch_irqs_disabled(void)
116 return arch_irqs_disabled_flags(arch_local_save_flags());
119 #endif /* __ASSEMBLY__ */
121 #endif /* _ASM_SCORE_IRQFLAGS_H */