1 #ifndef _ASM_IA64_HARDIRQ_H
2 #define _ASM_IA64_HARDIRQ_H
3 
4 /*
5  * Copyright (C) 1998-2001 Hewlett-Packard Co
6  * Copyright (C) 1998-2001 David Mosberger-Tang <davidm@hpl.hp.com>
7  */
8 
9 #include <linux/config.h>
10 
11 #include <linux/threads.h>
12 #include <linux/irq.h>
13 
14 #include <asm/processor.h>
15 
16 /*
17  * No irq_cpustat_t for IA-64.  The data is held in the per-CPU data structure.
18  */
19 #define softirq_pending(cpu)		(cpu_data(cpu)->softirq_pending)
20 #define ksoftirqd_task(cpu)		(cpu_data(cpu)->ksoftirqd)
21 #define irq_count(cpu)			(cpu_data(cpu)->irq_stat.f.irq_count)
22 #define bh_count(cpu)			(cpu_data(cpu)->irq_stat.f.bh_count)
23 #define syscall_count(cpu)		/* unused on IA-64 */
24 #define nmi_count(cpu)			0
25 
26 #define local_softirq_pending()		(local_cpu_data->softirq_pending)
27 #define local_ksoftirqd_task()		(local_cpu_data->ksoftirqd)
28 #define really_local_irq_count()	(local_cpu_data->irq_stat.f.irq_count)	/* XXX fix me */
29 #define really_local_bh_count()		(local_cpu_data->irq_stat.f.bh_count)	/* XXX fix me */
30 #define local_syscall_count()		/* unused on IA-64 */
31 #define local_nmi_count()		0
32 
33 /*
34  * Are we in an interrupt context? Either doing bottom half or hardware interrupt
35  * processing?
36  */
37 #define in_interrupt()			(local_cpu_data->irq_stat.irq_and_bh_counts != 0)
38 #define in_irq()			(local_cpu_data->irq_stat.f.irq_count != 0)
39 
40 #ifndef CONFIG_SMP
41 # define local_hardirq_trylock()	(really_local_irq_count() == 0)
42 # define local_hardirq_endlock()	do { } while (0)
43 
44 # define local_irq_enter(irq)		(really_local_irq_count()++)
45 # define local_irq_exit(irq)		(really_local_irq_count()--)
46 
47 # define synchronize_irq()		barrier()
48 #else
49 
50 #include <asm/atomic.h>
51 #include <asm/smp.h>
52 
53 extern unsigned int global_irq_holder;
54 extern volatile unsigned long global_irq_lock;
55 
56 static inline int
irqs_running(void)57 irqs_running (void)
58 {
59 	int i;
60 
61 	for (i = 0; i < smp_num_cpus; i++)
62 		if (irq_count(i))
63 			return 1;
64 	return 0;
65 }
66 
67 static inline void
release_irqlock(int cpu)68 release_irqlock (int cpu)
69 {
70 	/* if we didn't own the irq lock, just ignore.. */
71 	if (global_irq_holder == cpu) {
72 		global_irq_holder = NO_PROC_ID;
73 		smp_mb__before_clear_bit();	/* need barrier before releasing lock... */
74 		clear_bit(0,&global_irq_lock);
75         }
76 }
77 
78 static inline void
local_irq_enter(int irq)79 local_irq_enter (int irq)
80 {
81 	really_local_irq_count()++;
82 
83 	while (test_bit(0,&global_irq_lock)) {
84 		/* nothing */;
85 	}
86 }
87 
88 static inline void
local_irq_exit(int irq)89 local_irq_exit (int irq)
90 {
91 	really_local_irq_count()--;
92 }
93 
94 static inline int
local_hardirq_trylock(void)95 local_hardirq_trylock (void)
96 {
97 	return !really_local_irq_count() && !test_bit(0,&global_irq_lock);
98 }
99 
100 #define local_hardirq_endlock()		do { } while (0)
101 
102 extern void synchronize_irq (void);
103 
104 #endif /* CONFIG_SMP */
105 #endif /* _ASM_IA64_HARDIRQ_H */
106