patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / asm-h8300 / hardirq.h
1 #ifndef __H8300_HARDIRQ_H
2 #define __H8300_HARDIRQ_H
3
4 #include <linux/kernel.h>
5 #include <linux/config.h>
6 #include <linux/threads.h>
7 #include <linux/interrupt.h>
8 #include <linux/irq.h>
9
10 typedef struct {
11         unsigned int __softirq_pending;
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  * We put the hardirq and softirq counter into the preemption
20  * counter. The bitmask has the following meaning:
21  *
22  * - bits 0-7 are the preemption count (max preemption depth: 256)
23  * - bits 8-15 are the softirq count (max # of softirqs: 256)
24  * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
25  *
26  * - ( bit 26 is the PREEMPT_ACTIVE flag. )
27  *
28  * PREEMPT_MASK: 0x000000ff
29  * HARDIRQ_MASK: 0x0000ff00
30  * SOFTIRQ_MASK: 0x00ff0000
31  */
32
33 #define PREEMPT_BITS    8
34 #define SOFTIRQ_BITS    8
35 #define HARDIRQ_BITS    8
36
37 #define PREEMPT_SHIFT   0
38 #define SOFTIRQ_SHIFT   (PREEMPT_SHIFT + PREEMPT_BITS)
39 #define HARDIRQ_SHIFT   (SOFTIRQ_SHIFT + SOFTIRQ_BITS)
40
41 #define __MASK(x)       ((1UL << (x))-1)
42
43 #define PREEMPT_MASK    (__MASK(PREEMPT_BITS) << PREEMPT_SHIFT)
44 #define HARDIRQ_MASK    (__MASK(HARDIRQ_BITS) << HARDIRQ_SHIFT)
45 #define SOFTIRQ_MASK    (__MASK(SOFTIRQ_BITS) << SOFTIRQ_SHIFT)
46
47 #define hardirq_count() (preempt_count() & HARDIRQ_MASK)
48 #define softirq_count() (preempt_count() & SOFTIRQ_MASK)
49 #define irq_count()     (preempt_count() & (HARDIRQ_MASK | SOFTIRQ_MASK))
50
51 #define PREEMPT_OFFSET  (1UL << PREEMPT_SHIFT)
52 #define SOFTIRQ_OFFSET  (1UL << SOFTIRQ_SHIFT)
53 #define HARDIRQ_OFFSET  (1UL << HARDIRQ_SHIFT)
54
55 /*
56  * The hardirq mask has to be large enough to have
57  * space for potentially all IRQ sources in the system
58  * nesting on a single CPU:
59  */
60 #if (1 << HARDIRQ_BITS) < NR_IRQS
61 # error HARDIRQ_BITS is too low!
62 #endif
63
64 /*
65  * Are we doing bottom half or hardware interrupt processing?
66  * Are we in a softirq context? Interrupt context?
67  */
68 #define in_irq()                (hardirq_count())
69 #define in_softirq()            (softirq_count())
70 #define in_interrupt()          (irq_count())
71
72 #define hardirq_trylock()       (!in_interrupt())
73 #define hardirq_endlock()       do { } while (0)
74
75 #define irq_enter()             (preempt_count() += HARDIRQ_OFFSET)
76
77 #ifdef CONFIG_PREEMPT
78 # define in_atomic()    ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
79 # define IRQ_EXIT_OFFSET (HARDIRQ_OFFSET-1)
80 #else
81 # define in_atomic()    (preempt_count() != 0)
82 # define IRQ_EXIT_OFFSET HARDIRQ_OFFSET
83 #endif
84
85 #define irq_exit()                                                      \
86 do {                                                                    \
87                 preempt_count() -= IRQ_EXIT_OFFSET;                     \
88                 if (!in_interrupt() && softirq_pending(smp_processor_id())) \
89                         do_softirq();                                   \
90                 preempt_enable_no_resched();                            \
91 } while (0)
92
93 #ifndef CONFIG_SMP
94 # define synchronize_irq(irq)   barrier()
95 #else
96 # error h8300 SMP is not available
97 #endif /* CONFIG_SMP */
98
99 #endif