blob: 7ef4115b8c4a59f0248df2273184ab5e2ed8f053 [file] [log] [blame]
David Howellsdf9ee292010-10-07 14:08:55 +01001#ifndef _M68K_IRQFLAGS_H
2#define _M68K_IRQFLAGS_H
3
4#include <linux/types.h>
Philippe De Muytered35f652010-10-28 14:42:58 +02005#ifdef CONFIG_MMU
David Howellsdf9ee292010-10-07 14:08:55 +01006#include <linux/hardirq.h>
Philippe De Muytered35f652010-10-28 14:42:58 +02007#endif
David Howellsdf9ee292010-10-07 14:08:55 +01008#include <linux/preempt.h>
9#include <asm/thread_info.h>
10#include <asm/entry.h>
11
12static inline unsigned long arch_local_save_flags(void)
13{
14 unsigned long flags;
15 asm volatile ("movew %%sr,%0" : "=d" (flags) : : "memory");
16 return flags;
17}
18
19static inline void arch_local_irq_disable(void)
20{
21#ifdef CONFIG_COLDFIRE
22 asm volatile (
23 "move %/sr,%%d0 \n\t"
24 "ori.l #0x0700,%%d0 \n\t"
25 "move %%d0,%/sr \n"
26 : /* no outputs */
27 :
28 : "cc", "%d0", "memory");
29#else
30 asm volatile ("oriw #0x0700,%%sr" : : : "memory");
31#endif
32}
33
34static inline void arch_local_irq_enable(void)
35{
36#if defined(CONFIG_COLDFIRE)
37 asm volatile (
38 "move %/sr,%%d0 \n\t"
39 "andi.l #0xf8ff,%%d0 \n\t"
40 "move %%d0,%/sr \n"
41 : /* no outputs */
42 :
43 : "cc", "%d0", "memory");
44#else
45# if defined(CONFIG_MMU)
46 if (MACH_IS_Q40 || !hardirq_count())
47# endif
48 asm volatile (
49 "andiw %0,%%sr"
50 :
51 : "i" (ALLOWINT)
52 : "memory");
53#endif
54}
55
56static inline unsigned long arch_local_irq_save(void)
57{
58 unsigned long flags = arch_local_save_flags();
59 arch_local_irq_disable();
60 return flags;
61}
62
63static inline void arch_local_irq_restore(unsigned long flags)
64{
65 asm volatile ("movew %0,%%sr" : : "d" (flags) : "memory");
66}
67
68static inline bool arch_irqs_disabled_flags(unsigned long flags)
69{
70 return (flags & ~ALLOWINT) != 0;
71}
72
73static inline bool arch_irqs_disabled(void)
74{
75 return arch_irqs_disabled_flags(arch_local_save_flags());
76}
77
78#endif /* _M68K_IRQFLAGS_H */