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 #if defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_MIPS_MT_SMTC)
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 /* if defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_MIPS_MT_SMTC) */
124 extern void smtc_ipi_replay(void);
126 static inline void arch_local_irq_enable(void)
128 #ifdef CONFIG_MIPS_MT_SMTC
130 * SMTC kernel needs to do a software replay of queued
131 * IPIs, at the cost of call overhead on each local_irq_enable()
135 __asm__
__volatile__(
139 #ifdef CONFIG_MIPS_MT_SMTC
140 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
144 #elif defined(CONFIG_CPU_MIPSR2)
152 " " __stringify(__irq_enable_hazard
) " \n"
159 static inline unsigned long arch_local_save_flags(void)
166 #ifdef CONFIG_MIPS_MT_SMTC
167 " mfc0 %[flags], $2, 1 \n"
169 " mfc0 %[flags], $12 \n"
172 : [flags
] "=r" (flags
));
178 static inline int arch_irqs_disabled_flags(unsigned long flags
)
180 #ifdef CONFIG_MIPS_MT_SMTC
182 * SMTC model uses TCStatus.IXMT to disable interrupts for a thread/CPU
184 return flags
& 0x400;
190 #endif /* #ifndef __ASSEMBLY__ */
193 * Do the CPU's IRQ-state tracing from assembly code.
195 #ifdef CONFIG_TRACE_IRQFLAGS
196 /* Reload some registers clobbered by trace_hardirqs_on */
198 # define TRACE_IRQS_RELOAD_REGS \
199 LONG_L $11, PT_R11(sp); \
200 LONG_L $10, PT_R10(sp); \
201 LONG_L $9, PT_R9(sp); \
202 LONG_L $8, PT_R8(sp); \
203 LONG_L $7, PT_R7(sp); \
204 LONG_L $6, PT_R6(sp); \
205 LONG_L $5, PT_R5(sp); \
206 LONG_L $4, PT_R4(sp); \
209 # define TRACE_IRQS_RELOAD_REGS \
210 LONG_L $7, PT_R7(sp); \
211 LONG_L $6, PT_R6(sp); \
212 LONG_L $5, PT_R5(sp); \
213 LONG_L $4, PT_R4(sp); \
216 # define TRACE_IRQS_ON \
217 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
218 jal trace_hardirqs_on
219 # define TRACE_IRQS_ON_RELOAD \
221 TRACE_IRQS_RELOAD_REGS
222 # define TRACE_IRQS_OFF \
223 jal trace_hardirqs_off
225 # define TRACE_IRQS_ON
226 # define TRACE_IRQS_ON_RELOAD
227 # define TRACE_IRQS_OFF
230 #endif /* _ASM_IRQFLAGS_H */