1#ifndef _ALPHA_HARDIRQ_H 2#define _ALPHA_HARDIRQ_H 3 4#include <linux/config.h> 5#include <linux/threads.h> 6 7/* entry.S is sensitive to the offsets of these fields */ 8typedef struct { 9 unsigned long __softirq_pending; 10 unsigned int __local_irq_count; 11 unsigned int __local_bh_count; 12 unsigned int __syscall_count; 13 struct task_struct * __ksoftirqd_task; 14} ____cacheline_aligned irq_cpustat_t; 15 16#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ 17 18/* 19 * Are we in an interrupt context? Either doing bottom half 20 * or hardware interrupt processing? 21 */ 22 23#define in_interrupt() \ 24({ \ 25 int __cpu = smp_processor_id(); \ 26 (local_irq_count(__cpu) + local_bh_count(__cpu)) != 0; \ 27}) 28 29#define in_irq() (local_irq_count(smp_processor_id()) != 0) 30 31#ifndef CONFIG_SMP 32 33extern unsigned long __irq_attempt[]; 34#define irq_attempt(cpu, irq) ((void)(cpu), __irq_attempt[irq]) 35 36#define hardirq_trylock(cpu) (local_irq_count(cpu) == 0) 37#define hardirq_endlock(cpu) ((void) 0) 38 39#define irq_enter(cpu, irq) (local_irq_count(cpu)++) 40#define irq_exit(cpu, irq) (local_irq_count(cpu)--) 41 42#define synchronize_irq() barrier() 43 44#else 45 46#define irq_attempt(cpu, irq) (cpu_data[cpu].irq_attempt[irq]) 47 48#include <asm/atomic.h> 49#include <linux/spinlock.h> 50#include <asm/smp.h> 51 52extern int global_irq_holder; 53extern spinlock_t global_irq_lock; 54 55static inline int irqs_running (void) 56{ 57 int i; 58 59 for (i = 0; i < smp_num_cpus; i++) 60 if (local_irq_count(i)) 61 return 1; 62 return 0; 63} 64 65static inline void release_irqlock(int cpu) 66{ 67 /* if we didn't own the irq lock, just ignore.. */ 68 if (global_irq_holder == cpu) { 69 global_irq_holder = NO_PROC_ID; 70 spin_unlock(&global_irq_lock); 71 } 72} 73 74static inline void irq_enter(int cpu, int irq) 75{ 76 ++local_irq_count(cpu); 77 78 while (spin_is_locked(&global_irq_lock)) 79 barrier(); 80} 81 82static inline void irq_exit(int cpu, int irq) 83{ 84 --local_irq_count(cpu); 85} 86 87static inline int hardirq_trylock(int cpu) 88{ 89 return !local_irq_count(cpu) && !spin_is_locked(&global_irq_lock); 90} 91 92#define hardirq_endlock(cpu) do { } while (0) 93 94extern void synchronize_irq(void); 95 96#endif /* CONFIG_SMP */ 97#endif /* _ALPHA_HARDIRQ_H */ 98