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 <linux/config.h>
15 #include <asm/hazards.h>
18 " .macro local_irq_enable \n"
22 #ifdef CONFIG_MIPS_MT_SMTC
23 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
27 #elif defined(CONFIG_CPU_MIPSR2)
35 " irq_enable_hazard \n"
39 static inline void local_irq_enable(void)
49 * For cli() we have to insert nops to make sure that the new value
50 * has actually arrived in the status register before the end of this
52 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
56 * For TX49, operating only IE bit is not enough.
58 * If mfc0 $12 follows store and the mfc0 is last instruction of a
59 * page and fetching the next instruction causes TLB miss, the result
60 * of the mfc0 might wrongly contain EXL bit.
62 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
64 * Workaround: mask EXL bit of the result or place a nop before mfc0.
67 " .macro local_irq_disable\n"
70 #ifdef CONFIG_MIPS_MT_SMTC
75 #elif defined(CONFIG_CPU_MIPSR2)
84 " irq_disable_hazard \n"
88 static inline void local_irq_disable(void)
98 " .macro local_save_flags flags \n"
101 #ifdef CONFIG_MIPS_MT_SMTC
102 " mfc0 \\flags, $2, 1 \n"
104 " mfc0 \\flags, $12 \n"
109 #define local_save_flags(x) \
110 __asm__ __volatile__( \
111 "local_save_flags %0" \
115 " .macro local_irq_save result \n"
119 #ifdef CONFIG_MIPS_MT_SMTC
120 " mfc0 \\result, $2, 1 \n"
121 " ori $1, \\result, 0x400 \n"
124 " andi \\result, \\result, 0x400 \n"
125 #elif defined(CONFIG_CPU_MIPSR2)
127 " andi \\result, 1 \n"
129 " mfc0 \\result, $12 \n"
130 " ori $1, \\result, 0x1f \n"
135 " irq_disable_hazard \n"
139 #define local_irq_save(x) \
140 __asm__ __volatile__( \
141 "local_irq_save\t%0" \
147 " .macro local_irq_restore flags \n"
151 #ifdef CONFIG_MIPS_MT_SMTC
153 "andi \\flags, 0x400 \n"
157 "mtc0 \\flags, $2, 1 \n"
158 #elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
160 * Slow, but doesn't suffer from a relativly unlikely race
161 * condition we're having since days 1.
163 " beqz \\flags, 1f \n"
167 #elif defined(CONFIG_CPU_MIPSR2)
169 * Fast, dangerous. Life is fun, life is good.
172 " ins $1, \\flags, 0, 1 \n"
176 " andi \\flags, 1 \n"
180 " mtc0 \\flags, $12 \n"
182 " irq_disable_hazard \n"
186 #define local_irq_restore(flags) \
188 unsigned long __tmp1; \
190 __asm__ __volatile__( \
191 "local_irq_restore\t%0" \
197 static inline int irqs_disabled(void)
199 #ifdef CONFIG_MIPS_MT_SMTC
201 * SMTC model uses TCStatus.IXMT to disable interrupts for a thread/CPU
203 unsigned long __result
;
205 __asm__
__volatile__(
216 local_save_flags(flags
);
222 #endif /* _ASM_INTERRUPT_H */