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