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/compiler.h>
19 #include <asm/hazards.h>
21 #if defined(CONFIG_CPU_MIPSR2) || defined (CONFIG_CPU_MIPSR6)
23 static inline void arch_local_irq_disable(void)
29 " " __stringify(__irq_disable_hazard) " \n"
36 static inline unsigned long arch_local_irq_save(void)
45 " andi %[flags], 1 \n"
46 " " __stringify(__irq_disable_hazard) " \n"
48 : [flags] "=r" (flags)
55 static inline void arch_local_irq_restore(unsigned long flags)
63 #if defined(CONFIG_IRQ_MIPS_CPU)
65 * Slow, but doesn't suffer from a relatively unlikely race
66 * condition we're having since days 1.
68 " beqz %[flags], 1f \n"
74 * Fast, dangerous. Life is fun, life is good.
77 " ins $1, %[flags], 0, 1 \n"
80 " " __stringify(__irq_disable_hazard) " \n"
82 : [flags] "=r" (__tmp1)
88 /* Functions that require preempt_{dis,en}able() are in mips-atomic.c */
89 void arch_local_irq_disable(void);
90 unsigned long arch_local_irq_save(void);
91 void arch_local_irq_restore(unsigned long flags);
92 #endif /* CONFIG_CPU_MIPSR2 || CONFIG_CPU_MIPSR6 */
94 static inline void arch_local_irq_enable(void)
100 #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6)
108 " " __stringify(__irq_enable_hazard) " \n"
115 static inline unsigned long arch_local_save_flags(void)
122 " mfc0 %[flags], $12 \n"
124 : [flags] "=r" (flags));
130 static inline int arch_irqs_disabled_flags(unsigned long flags)
135 #endif /* #ifndef __ASSEMBLY__ */
138 * Do the CPU's IRQ-state tracing from assembly code.
140 #ifdef CONFIG_TRACE_IRQFLAGS
141 /* Reload some registers clobbered by trace_hardirqs_on */
143 # define TRACE_IRQS_RELOAD_REGS \
144 LONG_L $11, PT_R11(sp); \
145 LONG_L $10, PT_R10(sp); \
146 LONG_L $9, PT_R9(sp); \
147 LONG_L $8, PT_R8(sp); \
148 LONG_L $7, PT_R7(sp); \
149 LONG_L $6, PT_R6(sp); \
150 LONG_L $5, PT_R5(sp); \
151 LONG_L $4, PT_R4(sp); \
154 # define TRACE_IRQS_RELOAD_REGS \
155 LONG_L $7, PT_R7(sp); \
156 LONG_L $6, PT_R6(sp); \
157 LONG_L $5, PT_R5(sp); \
158 LONG_L $4, PT_R4(sp); \
161 # define TRACE_IRQS_ON \
162 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
163 jal trace_hardirqs_on
164 # define TRACE_IRQS_ON_RELOAD \
166 TRACE_IRQS_RELOAD_REGS
167 # define TRACE_IRQS_OFF \
168 jal trace_hardirqs_off
170 # define TRACE_IRQS_ON
171 # define TRACE_IRQS_ON_RELOAD
172 # define TRACE_IRQS_OFF
175 #endif /* _ASM_IRQFLAGS_H */