1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _H8300_IRQFLAGS_H
3 #define _H8300_IRQFLAGS_H
5 #ifdef CONFIG_CPU_H8300H
6 typedef unsigned char h8300flags;
8 static inline h8300flags arch_local_save_flags(void)
12 __asm__ volatile ("stc ccr,%w0" : "=r" (flags));
16 static inline void arch_local_irq_disable(void)
18 __asm__ volatile ("orc #0xc0,ccr");
21 static inline void arch_local_irq_enable(void)
23 __asm__ volatile ("andc #0x3f,ccr");
26 static inline h8300flags arch_local_irq_save(void)
30 __asm__ volatile ("stc ccr,%w0\n\t"
31 "orc #0xc0,ccr" : "=r" (flags));
35 static inline void arch_local_irq_restore(h8300flags flags)
37 __asm__ volatile ("ldc %w0,ccr" : : "r" (flags) : "cc");
40 static inline int arch_irqs_disabled_flags(unsigned long flags)
42 return (flags & 0xc0) == 0xc0;
46 typedef unsigned short h8300flags;
48 static inline h8300flags arch_local_save_flags(void)
52 __asm__ volatile ("stc ccr,%w0\n\tstc exr,%x0" : "=r" (flags));
56 static inline void arch_local_irq_disable(void)
58 __asm__ volatile ("orc #0x80,ccr\n\t");
61 static inline void arch_local_irq_enable(void)
63 __asm__ volatile ("andc #0x7f,ccr\n\t"
64 "andc #0xf0,exr\n\t");
67 static inline h8300flags arch_local_irq_save(void)
71 __asm__ volatile ("stc ccr,%w0\n\t"
78 static inline void arch_local_irq_restore(h8300flags flags)
80 __asm__ volatile ("ldc %w0,ccr\n\t"
82 : : "r" (flags) : "cc");
85 static inline int arch_irqs_disabled_flags(h8300flags flags)
87 return (flags & 0x0080) == 0x0080;
92 static inline int arch_irqs_disabled(void)
94 return arch_irqs_disabled_flags(arch_local_save_flags());
97 #endif /* _H8300_IRQFLAGS_H */