2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003 by Ralf Baechle
7 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics
9 * Copyright (C) 2000 MIPS Technologies, Inc.
11 #ifndef _ASM_IRQFLAGS_H
12 #define _ASM_IRQFLAGS_H
16 #include <linux/compiler.h>
17 #include <linux/stringify.h>
18 #include <asm/hazards.h>
20 #ifdef CONFIG_CPU_MIPSR2
22 static inline void arch_local_irq_disable(void)
28 " " __stringify(__irq_disable_hazard) " \n"
35 static inline unsigned long arch_local_irq_save(void)
44 " andi %[flags], 1 \n"
45 " " __stringify(__irq_disable_hazard) " \n"
47 : [flags] "=r" (flags)
54 static inline void arch_local_irq_restore(unsigned long flags)
62 #if defined(CONFIG_IRQ_CPU)
64 * Slow, but doesn't suffer from a relatively unlikely race
65 * condition we're having since days 1.
67 " beqz %[flags], 1f \n"
73 * Fast, dangerous. Life is fun, life is good.
76 " ins $1, %[flags], 0, 1 \n"
79 " " __stringify(__irq_disable_hazard) " \n"
81 : [flags] "=r" (__tmp1)
86 static inline void __arch_local_irq_restore(unsigned long flags)
92 #if defined(CONFIG_IRQ_CPU)
94 * Slow, but doesn't suffer from a relatively unlikely race
95 * condition we're having since days 1.
97 " beqz %[flags], 1f \n"
103 * Fast, dangerous. Life is fun, life is good.
106 " ins $1, %[flags], 0, 1 \n"
109 " " __stringify(__irq_disable_hazard) " \n"
111 : [flags] "=r" (flags)
116 /* Functions that require preempt_{dis,en}able() are in mips-atomic.c */
117 void arch_local_irq_disable(void);
118 unsigned long arch_local_irq_save(void);
119 void arch_local_irq_restore(unsigned long flags);
120 void __arch_local_irq_restore(unsigned long flags);
121 #endif /* CONFIG_CPU_MIPSR2 */
123 static inline void arch_local_irq_enable(void)
125 __asm__ __volatile__(
129 #if defined(CONFIG_CPU_MIPSR2)
137 " " __stringify(__irq_enable_hazard) " \n"
144 static inline unsigned long arch_local_save_flags(void)
151 " mfc0 %[flags], $12 \n"
153 : [flags] "=r" (flags));
159 static inline int arch_irqs_disabled_flags(unsigned long flags)
164 #endif /* #ifndef __ASSEMBLY__ */
167 * Do the CPU's IRQ-state tracing from assembly code.
169 #ifdef CONFIG_TRACE_IRQFLAGS
170 /* Reload some registers clobbered by trace_hardirqs_on */
172 # define TRACE_IRQS_RELOAD_REGS \
173 LONG_L $11, PT_R11(sp); \
174 LONG_L $10, PT_R10(sp); \
175 LONG_L $9, PT_R9(sp); \
176 LONG_L $8, PT_R8(sp); \
177 LONG_L $7, PT_R7(sp); \
178 LONG_L $6, PT_R6(sp); \
179 LONG_L $5, PT_R5(sp); \
180 LONG_L $4, PT_R4(sp); \
183 # define TRACE_IRQS_RELOAD_REGS \
184 LONG_L $7, PT_R7(sp); \
185 LONG_L $6, PT_R6(sp); \
186 LONG_L $5, PT_R5(sp); \
187 LONG_L $4, PT_R4(sp); \
190 # define TRACE_IRQS_ON \
191 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
192 jal trace_hardirqs_on
193 # define TRACE_IRQS_ON_RELOAD \
195 TRACE_IRQS_RELOAD_REGS
196 # define TRACE_IRQS_OFF \
197 jal trace_hardirqs_off
199 # define TRACE_IRQS_ON
200 # define TRACE_IRQS_ON_RELOAD
201 # define TRACE_IRQS_OFF
204 #endif /* _ASM_IRQFLAGS_H */