vserver 1.9.3
[linux-2.6.git] / include / asm-ppc / hardirq.h
1 #ifdef __KERNEL__
2 #ifndef __ASM_HARDIRQ_H
3 #define __ASM_HARDIRQ_H
4
5 #include <linux/config.h>
6 #include <linux/cache.h>
7 #include <linux/smp_lock.h>
8 #include <asm/irq.h>
9
10 /* The __last_jiffy_stamp field is needed to ensure that no decrementer
11  * interrupt is lost on SMP machines. Since on most CPUs it is in the same
12  * cache line as local_irq_count, it is cheap to access and is also used on UP
13  * for uniformity.
14  */
15 typedef struct {
16         unsigned long __softirq_pending;        /* set_bit is used on this */
17         unsigned int __last_jiffy_stamp;
18 } ____cacheline_aligned irq_cpustat_t;
19
20 #include <linux/irq_cpustat.h>  /* Standard mappings for irq_cpustat_t above */
21
22 #define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp)
23
24 /*
25  * We put the hardirq and softirq counter into the preemption
26  * counter. The bitmask has the following meaning:
27  *
28  * - bits 0-7 are the preemption count (max preemption depth: 256)
29  * - bits 8-15 are the softirq count (max # of softirqs: 256)
30  * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
31  *
32  * - ( bit 26 is the PREEMPT_ACTIVE flag. )
33  *
34  * PREEMPT_MASK: 0x000000ff
35  * SOFTIRQ_MASK: 0x0000ff00
36  * HARDIRQ_MASK: 0x00ff0000
37  */
38
39 #define PREEMPT_BITS    8
40 #define SOFTIRQ_BITS    8
41 #define HARDIRQ_BITS    8
42
43 #define PREEMPT_SHIFT   0
44 #define SOFTIRQ_SHIFT   (PREEMPT_SHIFT + PREEMPT_BITS)
45 #define HARDIRQ_SHIFT   (SOFTIRQ_SHIFT + SOFTIRQ_BITS)
46
47 /*
48  * The hardirq mask has to be large enough to have
49  * space for potentially all IRQ sources in the system
50  * nesting on a single CPU:
51  */
52 #if (1 << HARDIRQ_BITS) < NR_IRQS
53 # error HARDIRQ_BITS is too low!
54 #endif
55
56 #define irq_enter()             (preempt_count() += HARDIRQ_OFFSET)
57 #define irq_exit()                                                      \
58 do {                                                                    \
59         preempt_count() -= IRQ_EXIT_OFFSET;                             \
60         if (!in_interrupt() && softirq_pending(smp_processor_id()))     \
61                 do_softirq();                                           \
62         preempt_enable_no_resched();                                    \
63 } while (0)
64
65 #endif /* __ASM_HARDIRQ_H */
66 #endif /* __KERNEL__ */