- Andries Brouwer: final isofs pieces.
[davej-history.git] / include / asm-ia64 / hardirq.h
blob1dabc1bdfeab8735a883392b3da5357a32f02c13
1 #ifndef _ASM_IA64_HARDIRQ_H
2 #define _ASM_IA64_HARDIRQ_H
4 /*
5 * Copyright (C) 1998-2000 Hewlett-Packard Co
6 * Copyright (C) 1998-2000 David Mosberger-Tang <davidm@hpl.hp.com>
7 */
9 #include <linux/config.h>
11 #include <linux/threads.h>
12 #include <linux/irq.h>
14 /* entry.S is sensitive to the offsets of these fields */
15 typedef struct {
16 unsigned int __softirq_active;
17 unsigned int __softirq_mask;
18 unsigned int __local_irq_count;
19 unsigned int __local_bh_count;
20 unsigned int __syscall_count;
21 unsigned int __nmi_count; /* arch dependent */
22 } ____cacheline_aligned irq_cpustat_t;
24 #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
27 * Are we in an interrupt context? Either doing bottom half
28 * or hardware interrupt processing?
30 #define in_interrupt() \
31 ({ \
32 int __cpu = smp_processor_id(); \
33 (local_irq_count(__cpu) + local_bh_count(__cpu)) != 0; \
36 #define in_irq() (local_irq_count(smp_processor_id()) != 0)
38 #ifndef CONFIG_SMP
39 # define hardirq_trylock(cpu) (local_irq_count(cpu) == 0)
40 # define hardirq_endlock(cpu) do { } while (0)
42 # define irq_enter(cpu, irq) (local_irq_count(cpu)++)
43 # define irq_exit(cpu, irq) (local_irq_count(cpu)--)
45 # define synchronize_irq() barrier()
46 #else
48 #include <asm/atomic.h>
49 #include <asm/smp.h>
51 extern unsigned int global_irq_holder;
52 extern volatile unsigned long global_irq_lock;
54 static inline int irqs_running (void)
56 int i;
58 for (i = 0; i < smp_num_cpus; i++)
59 if (local_irq_count(i))
60 return 1;
61 return 0;
64 static inline void release_irqlock(int cpu)
66 /* if we didn't own the irq lock, just ignore.. */
67 if (global_irq_holder == cpu) {
68 global_irq_holder = NO_PROC_ID;
69 clear_bit(0,&global_irq_lock);
73 static inline void irq_enter(int cpu, int irq)
75 local_irq_count(cpu)++;
77 while (test_bit(0,&global_irq_lock)) {
78 /* nothing */;
82 static inline void irq_exit(int cpu, int irq)
84 local_irq_count(cpu)--;
87 static inline int hardirq_trylock(int cpu)
89 return !local_irq_count(cpu) && !test_bit(0,&global_irq_lock);
92 #define hardirq_endlock(cpu) do { } while (0)
94 extern void synchronize_irq(void);
96 #endif /* CONFIG_SMP */
97 #endif /* _ASM_IA64_HARDIRQ_H */