1#ifndef _M68K_IRQFLAGS_H
2#define _M68K_IRQFLAGS_H
3
4#include <linux/types.h>
5#ifdef CONFIG_MMU
6#include <linux/preempt_mask.h>
7#endif
8#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	if (MACH_IS_ATARI) {
71		/* Ignore HSYNC = ipl 2 on Atari */
72		return (flags & ~(ALLOWINT | 0x200)) != 0;
73	}
74	return (flags & ~ALLOWINT) != 0;
75}
76
77static inline bool arch_irqs_disabled(void)
78{
79	return arch_irqs_disabled_flags(arch_local_save_flags());
80}
81
82#endif /* _M68K_IRQFLAGS_H */
83