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_INTERRUPT_H
12 #define _ASM_INTERRUPT_H
14 #include <asm/hazards.h>
17 " .macro local_irq_enable \n"
21 #ifdef CONFIG_MIPS_MT_SMTC
22 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
26 #elif defined(CONFIG_CPU_MIPSR2)
34 " irq_enable_hazard \n"
38 static inline void local_irq_enable(void)
48 * For cli() we have to insert nops to make sure that the new value
49 * has actually arrived in the status register before the end of this
51 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
55 * For TX49, operating only IE bit is not enough.
57 * If mfc0 $12 follows store and the mfc0 is last instruction of a
58 * page and fetching the next instruction causes TLB miss, the result
59 * of the mfc0 might wrongly contain EXL bit.
61 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
63 * Workaround: mask EXL bit of the result or place a nop before mfc0.
66 " .macro local_irq_disable\n"
69 #ifdef CONFIG_MIPS_MT_SMTC
74 #elif defined(CONFIG_CPU_MIPSR2)
83 " irq_disable_hazard \n"
87 static inline void local_irq_disable(void)
97 " .macro local_save_flags flags \n"
100 #ifdef CONFIG_MIPS_MT_SMTC
101 " mfc0 \\flags, $2, 1 \n"
103 " mfc0 \\flags, $12 \n"
108 #define local_save_flags(x) \
109 __asm__ __volatile__( \
110 "local_save_flags %0" \
114 " .macro local_irq_save result \n"
118 #ifdef CONFIG_MIPS_MT_SMTC
119 " mfc0 \\result, $2, 1 \n"
120 " ori $1, \\result, 0x400 \n"
123 " andi \\result, \\result, 0x400 \n"
124 #elif defined(CONFIG_CPU_MIPSR2)
126 " andi \\result, 1 \n"
128 " mfc0 \\result, $12 \n"
129 " ori $1, \\result, 0x1f \n"
134 " irq_disable_hazard \n"
138 #define local_irq_save(x) \
139 __asm__ __volatile__( \
140 "local_irq_save\t%0" \
146 " .macro local_irq_restore flags \n"
150 #ifdef CONFIG_MIPS_MT_SMTC
152 "andi \\flags, 0x400 \n"
156 "mtc0 \\flags, $2, 1 \n"
157 #elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
159 * Slow, but doesn't suffer from a relativly unlikely race
160 * condition we're having since days 1.
162 " beqz \\flags, 1f \n"
166 #elif defined(CONFIG_CPU_MIPSR2)
168 * Fast, dangerous. Life is fun, life is good.
171 " ins $1, \\flags, 0, 1 \n"
175 " andi \\flags, 1 \n"
179 " mtc0 \\flags, $12 \n"
181 " irq_disable_hazard \n"
185 #define local_irq_restore(flags) \
187 unsigned long __tmp1; \
189 __asm__ __volatile__( \
190 "local_irq_restore\t%0" \
196 static inline int irqs_disabled(void)
198 #ifdef CONFIG_MIPS_MT_SMTC
200 * SMTC model uses TCStatus.IXMT to disable interrupts for a thread/CPU
202 unsigned long __result
;
204 __asm__
__volatile__(
215 local_save_flags(flags
);
221 #endif /* _ASM_INTERRUPT_H */