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 <asm/hazards.h>
20 " .macro raw_local_irq_enable \n"
24 #ifdef CONFIG_MIPS_MT_SMTC
25 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
29 #elif defined(CONFIG_CPU_MIPSR2)
37 " irq_enable_hazard \n"
41 extern void smtc_ipi_replay(void);
43 static inline void raw_local_irq_enable(void)
45 #ifdef CONFIG_MIPS_MT_SMTC
47 * SMTC kernel needs to do a software replay of queued
48 * IPIs, at the cost of call overhead on each local_irq_enable()
53 "raw_local_irq_enable"
61 * For cli() we have to insert nops to make sure that the new value
62 * has actually arrived in the status register before the end of this
64 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
68 * For TX49, operating only IE bit is not enough.
70 * If mfc0 $12 follows store and the mfc0 is last instruction of a
71 * page and fetching the next instruction causes TLB miss, the result
72 * of the mfc0 might wrongly contain EXL bit.
74 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
76 * Workaround: mask EXL bit of the result or place a nop before mfc0.
79 " .macro raw_local_irq_disable\n"
82 #ifdef CONFIG_MIPS_MT_SMTC
87 #elif defined(CONFIG_CPU_MIPSR2)
96 " irq_disable_hazard \n"
100 static inline void raw_local_irq_disable(void)
102 __asm__
__volatile__(
103 "raw_local_irq_disable"
110 " .macro raw_local_save_flags flags \n"
113 #ifdef CONFIG_MIPS_MT_SMTC
114 " mfc0 \\flags, $2, 1 \n"
116 " mfc0 \\flags, $12 \n"
121 #define raw_local_save_flags(x) \
122 __asm__ __volatile__( \
123 "raw_local_save_flags %0" \
127 " .macro raw_local_irq_save result \n"
131 #ifdef CONFIG_MIPS_MT_SMTC
132 " mfc0 \\result, $2, 1 \n"
133 " ori $1, \\result, 0x400 \n"
136 " andi \\result, \\result, 0x400 \n"
137 #elif defined(CONFIG_CPU_MIPSR2)
139 " andi \\result, 1 \n"
141 " mfc0 \\result, $12 \n"
142 " ori $1, \\result, 0x1f \n"
147 " irq_disable_hazard \n"
151 #define raw_local_irq_save(x) \
152 __asm__ __volatile__( \
153 "raw_local_irq_save\t%0" \
159 " .macro raw_local_irq_restore flags \n"
163 #ifdef CONFIG_MIPS_MT_SMTC
165 "andi \\flags, 0x400 \n"
169 "mtc0 \\flags, $2, 1 \n"
170 #elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
172 * Slow, but doesn't suffer from a relativly unlikely race
173 * condition we're having since days 1.
175 " beqz \\flags, 1f \n"
179 #elif defined(CONFIG_CPU_MIPSR2)
181 * Fast, dangerous. Life is fun, life is good.
184 " ins $1, \\flags, 0, 1 \n"
188 " andi \\flags, 1 \n"
192 " mtc0 \\flags, $12 \n"
194 " irq_disable_hazard \n"
199 static inline void raw_local_irq_restore(unsigned long flags
)
201 unsigned long __tmp1
;
203 #ifdef CONFIG_MIPS_MT_SMTC
205 * SMTC kernel needs to do a software replay of queued
206 * IPIs, at the cost of branch and call overhead on each
207 * local_irq_restore()
209 if (unlikely(!(flags
& 0x0400)))
213 __asm__
__volatile__(
214 "raw_local_irq_restore\t%0"
220 static inline void __raw_local_irq_restore(unsigned long flags
)
222 unsigned long __tmp1
;
224 __asm__
__volatile__(
225 "raw_local_irq_restore\t%0"
231 static inline int raw_irqs_disabled_flags(unsigned long flags
)
233 #ifdef CONFIG_MIPS_MT_SMTC
235 * SMTC model uses TCStatus.IXMT to disable interrupts for a thread/CPU
237 return flags
& 0x400;
246 * Do the CPU's IRQ-state tracing from assembly code.
248 #ifdef CONFIG_TRACE_IRQFLAGS
249 /* Reload some registers clobbered by trace_hardirqs_on */
251 # define TRACE_IRQS_RELOAD_REGS \
252 LONG_L $11, PT_R11(sp); \
253 LONG_L $10, PT_R10(sp); \
254 LONG_L $9, PT_R9(sp); \
255 LONG_L $8, PT_R8(sp); \
256 LONG_L $7, PT_R7(sp); \
257 LONG_L $6, PT_R6(sp); \
258 LONG_L $5, PT_R5(sp); \
259 LONG_L $4, PT_R4(sp); \
262 # define TRACE_IRQS_RELOAD_REGS \
263 LONG_L $7, PT_R7(sp); \
264 LONG_L $6, PT_R6(sp); \
265 LONG_L $5, PT_R5(sp); \
266 LONG_L $4, PT_R4(sp); \
269 # define TRACE_IRQS_ON \
270 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
271 jal trace_hardirqs_on
272 # define TRACE_IRQS_ON_RELOAD \
274 TRACE_IRQS_RELOAD_REGS
275 # define TRACE_IRQS_OFF \
276 jal trace_hardirqs_off
278 # define TRACE_IRQS_ON
279 # define TRACE_IRQS_ON_RELOAD
280 # define TRACE_IRQS_OFF
283 #endif /* _ASM_IRQFLAGS_H */