]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blob - arch/h8300/include/asm/irqflags.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-kernels.git] / arch / h8300 / include / asm / irqflags.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _H8300_IRQFLAGS_H
3 #define _H8300_IRQFLAGS_H
4
5 #ifdef CONFIG_CPU_H8300H
6 typedef unsigned char h8300flags;
7
8 static inline h8300flags arch_local_save_flags(void)
9 {
10 h8300flags flags;
11
12 __asm__ volatile ("stc ccr,%w0" : "=r" (flags));
13 return flags;
14 }
15
16 static inline void arch_local_irq_disable(void)
17 {
18 __asm__ volatile ("orc #0xc0,ccr");
19 }
20
21 static inline void arch_local_irq_enable(void)
22 {
23 __asm__ volatile ("andc #0x3f,ccr");
24 }
25
26 static inline h8300flags arch_local_irq_save(void)
27 {
28 h8300flags flags;
29
30 __asm__ volatile ("stc ccr,%w0\n\t"
31 "orc #0xc0,ccr" : "=r" (flags));
32 return flags;
33 }
34
35 static inline void arch_local_irq_restore(h8300flags flags)
36 {
37 __asm__ volatile ("ldc %w0,ccr" : : "r" (flags) : "cc");
38 }
39
40 static inline int arch_irqs_disabled_flags(unsigned long flags)
41 {
42 return (flags & 0xc0) == 0xc0;
43 }
44 #endif
45 #ifdef CONFIG_CPU_H8S
46 typedef unsigned short h8300flags;
47
48 static inline h8300flags arch_local_save_flags(void)
49 {
50 h8300flags flags;
51
52 __asm__ volatile ("stc ccr,%w0\n\tstc exr,%x0" : "=r" (flags));
53 return flags;
54 }
55
56 static inline void arch_local_irq_disable(void)
57 {
58 __asm__ volatile ("orc #0x80,ccr\n\t");
59 }
60
61 static inline void arch_local_irq_enable(void)
62 {
63 __asm__ volatile ("andc #0x7f,ccr\n\t"
64 "andc #0xf0,exr\n\t");
65 }
66
67 static inline h8300flags arch_local_irq_save(void)
68 {
69 h8300flags flags;
70
71 __asm__ volatile ("stc ccr,%w0\n\t"
72 "stc exr,%x0\n\t"
73 "orc #0x80,ccr\n\t"
74 : "=r" (flags));
75 return flags;
76 }
77
78 static inline void arch_local_irq_restore(h8300flags flags)
79 {
80 __asm__ volatile ("ldc %w0,ccr\n\t"
81 "ldc %x0,exr"
82 : : "r" (flags) : "cc");
83 }
84
85 static inline int arch_irqs_disabled_flags(h8300flags flags)
86 {
87 return (flags & 0x0080) == 0x0080;
88 }
89
90 #endif
91
92 static inline int arch_irqs_disabled(void)
93 {
94 return arch_irqs_disabled_flags(arch_local_save_flags());
95 }
96
97 #endif /* _H8300_IRQFLAGS_H */