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_HAS_DIEI)
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)
44 #if defined(CONFIG_CPU_LOONGSON64) || defined(CONFIG_CPU_LOONGSON32)
45 " mfc0 %[flags], $12 \n"
50 " andi %[flags], 1 \n"
51 " " __stringify(__irq_disable_hazard
) " \n"
53 : [flags
] "=r" (flags
)
60 static inline void arch_local_irq_restore(unsigned long flags
)
68 #if defined(CONFIG_IRQ_MIPS_CPU)
70 * Slow, but doesn't suffer from a relatively unlikely race
71 * condition we're having since days 1.
73 " beqz %[flags], 1f \n"
79 * Fast, dangerous. Life is fun, life is good.
82 " ins $1, %[flags], 0, 1 \n"
85 " " __stringify(__irq_disable_hazard
) " \n"
87 : [flags
] "=r" (__tmp1
)
93 /* Functions that require preempt_{dis,en}able() are in mips-atomic.c */
94 void arch_local_irq_disable(void);
95 unsigned long arch_local_irq_save(void);
96 void arch_local_irq_restore(unsigned long flags
);
97 #endif /* CONFIG_CPU_HAS_DIEI */
99 static inline void arch_local_irq_enable(void)
101 __asm__
__volatile__(
105 #if defined(CONFIG_CPU_HAS_DIEI)
113 " " __stringify(__irq_enable_hazard
) " \n"
120 static inline unsigned long arch_local_save_flags(void)
127 " mfc0 %[flags], $12 \n"
129 : [flags
] "=r" (flags
));
135 static inline int arch_irqs_disabled_flags(unsigned long flags
)
140 #endif /* #ifndef __ASSEMBLY__ */
143 * Do the CPU's IRQ-state tracing from assembly code.
145 #ifdef CONFIG_TRACE_IRQFLAGS
146 /* Reload some registers clobbered by trace_hardirqs_on */
148 # define TRACE_IRQS_RELOAD_REGS \
149 LONG_L $11, PT_R11(sp); \
150 LONG_L $10, PT_R10(sp); \
151 LONG_L $9, PT_R9(sp); \
152 LONG_L $8, PT_R8(sp); \
153 LONG_L $7, PT_R7(sp); \
154 LONG_L $6, PT_R6(sp); \
155 LONG_L $5, PT_R5(sp); \
156 LONG_L $4, PT_R4(sp); \
159 # define TRACE_IRQS_RELOAD_REGS \
160 LONG_L $7, PT_R7(sp); \
161 LONG_L $6, PT_R6(sp); \
162 LONG_L $5, PT_R5(sp); \
163 LONG_L $4, PT_R4(sp); \
166 # define TRACE_IRQS_ON \
167 CLI; /* make sure trace_hardirqs_on() is called in kernel level */ \
168 jal trace_hardirqs_on
169 # define TRACE_IRQS_ON_RELOAD \
171 TRACE_IRQS_RELOAD_REGS
172 # define TRACE_IRQS_OFF \
173 jal trace_hardirqs_off
175 # define TRACE_IRQS_ON
176 # define TRACE_IRQS_ON_RELOAD
177 # define TRACE_IRQS_OFF
180 #endif /* _ASM_IRQFLAGS_H */