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
)
87 static inline void __arch_local_irq_restore(unsigned long flags
)
93 #if defined(CONFIG_IRQ_MIPS_CPU)
95 * Slow, but doesn't suffer from a relatively unlikely race
96 * condition we're having since days 1.
98 " beqz %[flags], 1f \n"
104 * Fast, dangerous. Life is fun, life is good.
107 " ins $1, %[flags], 0, 1 \n"
110 " " __stringify(__irq_disable_hazard
) " \n"
112 : [flags
] "=r" (flags
)
117 /* Functions that require preempt_{dis,en}able() are in mips-atomic.c */
118 void arch_local_irq_disable(void);
119 unsigned long arch_local_irq_save(void);
120 void arch_local_irq_restore(unsigned long flags
);
121 void __arch_local_irq_restore(unsigned long flags
);
122 #endif /* CONFIG_CPU_MIPSR2 || CONFIG_CPU_MIPSR6 */
124 static inline void arch_local_irq_enable(void)
126 __asm__
__volatile__(
130 #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_CPU_MIPSR6)
138 " " __stringify(__irq_enable_hazard
) " \n"
145 static inline unsigned long arch_local_save_flags(void)
152 " mfc0 %[flags], $12 \n"
154 : [flags
] "=r" (flags
));
160 static inline int arch_irqs_disabled_flags(unsigned long flags
)
165 #endif /* #ifndef __ASSEMBLY__ */
168 * Do the CPU's IRQ-state tracing from assembly code.
170 #ifdef CONFIG_TRACE_IRQFLAGS
171 /* Reload some registers clobbered by trace_hardirqs_on */
173 # define TRACE_IRQS_RELOAD_REGS \
174 LONG_L $11, PT_R11(sp); \
175 LONG_L $10, PT_R10(sp); \
176 LONG_L $9, PT_R9(sp); \
177 LONG_L $8, PT_R8(sp); \
178 LONG_L $7, PT_R7(sp); \
179 LONG_L $6, PT_R6(sp); \
180 LONG_L $5, PT_R5(sp); \
181 LONG_L $4, PT_R4(sp); \
184 # define TRACE_IRQS_RELOAD_REGS \
185 LONG_L $7, PT_R7(sp); \
186 LONG_L $6, PT_R6(sp); \
187 LONG_L $5, PT_R5(sp); \
188 LONG_L $4, PT_R4(sp); \
191 # define TRACE_IRQS_ON \
192 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
193 jal trace_hardirqs_on
194 # define TRACE_IRQS_ON_RELOAD \
196 TRACE_IRQS_RELOAD_REGS
197 # define TRACE_IRQS_OFF \
198 jal trace_hardirqs_off
200 # define TRACE_IRQS_ON
201 # define TRACE_IRQS_ON_RELOAD
202 # define TRACE_IRQS_OFF
205 #endif /* _ASM_IRQFLAGS_H */