1 /* hardirq.h: 64-bit Sparc hard IRQ support.
2 *
3 * Copyright (C) 1997, 1998 David S. Miller (davem@caip.rutgers.edu)
4 */
5
6 #ifndef __SPARC64_HARDIRQ_H
7 #define __SPARC64_HARDIRQ_H
8
9 #include <linux/config.h>
10 #include <linux/threads.h>
11 #include <linux/brlock.h>
12 #include <linux/spinlock.h>
13
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 #ifndef CONFIG_SMP
19 unsigned int __local_irq_count;
20 #else
21 unsigned int __unused_on_SMP; /* DaveM says use brlock for SMP irq. KAO */
22 #endif
23 unsigned int __local_bh_count;
24 unsigned int __syscall_count;
25 } ____cacheline_aligned irq_cpustat_t;
26
27 #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
28 /* Note that local_irq_count() is replaced by sparc64 specific version for SMP */
29
30 #ifndef CONFIG_SMP
31 #define irq_enter(cpu, irq) ((void)(irq), local_irq_count(cpu)++)
32 #define irq_exit(cpu, irq) ((void)(irq), local_irq_count(cpu)--)
33 #else
34 #undef local_irq_count
35 #define local_irq_count(cpu) (__brlock_array[cpu][BR_GLOBALIRQ_LOCK])
36 #define irq_enter(cpu, irq) br_read_lock(BR_GLOBALIRQ_LOCK)
37 #define irq_exit(cpu, irq) br_read_unlock(BR_GLOBALIRQ_LOCK)
38 #endif
39
40 /*
41 * Are we in an interrupt context? Either doing bottom half
42 * or hardware interrupt processing?
43 */
44 #define in_interrupt() ((local_irq_count(smp_processor_id()) + \
45 local_bh_count(smp_processor_id())) != 0)
46
47 /* This tests only the local processors hw IRQ context disposition. */
48 #define in_irq() (local_irq_count(smp_processor_id()) != 0)
49
50 #ifndef CONFIG_SMP
51
52 #define hardirq_trylock(cpu) ((void)(cpu), local_irq_count(smp_processor_id()) == 0)
53 #define hardirq_endlock(cpu) do { (void)(cpu); } while(0)
54
55 #define synchronize_irq() barrier()
56
57 #else /* (CONFIG_SMP) */
58
59 static __inline__ int irqs_running(void)
60 {
61 int i;
62
63 for (i = 0; i < smp_num_cpus; i++)
64 if (local_irq_count(cpu_logical_map(i)))
65 return 1;
66 return 0;
67 }
68
69 extern unsigned char global_irq_holder;
70
71 static inline void release_irqlock(int cpu)
72 {
73 /* if we didn't own the irq lock, just ignore... */
74 if(global_irq_holder == (unsigned char) cpu) {
75 global_irq_holder = NO_PROC_ID;
76 br_write_unlock(BR_GLOBALIRQ_LOCK);
77 }
78 }
79
80 static inline int hardirq_trylock(int cpu)
81 {
82 spinlock_t *lock = &__br_write_locks[BR_GLOBALIRQ_LOCK].lock;
83
84 return (!local_irq_count(cpu) && !spin_is_locked(lock));
85 }
86
87 #define hardirq_endlock(cpu) do { (void)(cpu); } while (0)
88
89 extern void synchronize_irq(void);
90
91 #endif /* CONFIG_SMP */
92
93 #endif /* !(__SPARC64_HARDIRQ_H) */
94
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.