include/asm-i386/hardirq.h
10721 #ifndef __ASM_HARDIRQ_H
10722 #define __ASM_HARDIRQ_H
10723
10724 #include <linux/tasks.h>
10725
10726 extern unsigned int local_irq_count[NR_CPUS];
10727
10728 /* Are we in an interrupt context? Either doing bottom
10729 * half or hardware interrupt processing? */
10730 #define in_interrupt() \
10731 ({ int __cpu = smp_processor_id(); \
10732 (local_irq_count[__cpu] + local_bh_count[__cpu] != 0); })
10733
10734 #ifndef __SMP__
10735
10736 #define hardirq_trylock(cpu) (local_irq_count[cpu] == 0)
10737 #define hardirq_endlock(cpu) do { } while (0)
10738
10739 #define hardirq_enter(cpu) (local_irq_count[cpu]++)
10740 #define hardirq_exit(cpu) (local_irq_count[cpu]--)
10741
10742 #define synchronize_irq() barrier()
10743
10744 #else
10745
10746 #include <asm/atomic.h>
10747
10748 extern unsigned char global_irq_holder;
10749 extern unsigned volatile int global_irq_lock;
10750 extern atomic_t global_irq_count;
10751
10752 static inline void release_irqlock(int cpu)
10753 {
10754 /* if we didn't own the irq lock, just ignore.. */
10755 if (global_irq_holder == (unsigned char) cpu) {
10756 global_irq_holder = NO_PROC_ID;
10757 clear_bit(0,&global_irq_lock);
10758 }
10759 }
10760
10761 static inline void hardirq_enter(int cpu)
10762 {
10763 ++local_irq_count[cpu];
10764 atomic_inc(&global_irq_count);
10765 }
10766
10767 static inline void hardirq_exit(int cpu)
10768 {
10769 atomic_dec(&global_irq_count);
10770 --local_irq_count[cpu];
10771 }
10772
10773 static inline int hardirq_trylock(int cpu)
10774 {
10775 return !atomic_read(&global_irq_count) &&
10776 !test_bit(0,&global_irq_lock);
10777 }
10778
10779 #define hardirq_endlock(cpu) do { } while (0)
10780
10781 extern void synchronize_irq(void);
10782
10783 #endif /* __SMP__ */
10784
10785 #endif /* __ASM_HARDIRQ_H */
Сайт управляется системой
uCoz