vserver 1.9.3
[linux-2.6.git] / include / asm-mips / hardirq.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1997, 1998, 1999, 2000, 2001 by Ralf Baechle
7  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8  * Copyright (C) 2001 MIPS Technologies, Inc.
9  */
10 #ifndef _ASM_HARDIRQ_H
11 #define _ASM_HARDIRQ_H
12
13 #include <linux/config.h>
14 #include <linux/threads.h>
15 #include <linux/irq.h>
16
17 typedef struct {
18         unsigned int __softirq_pending;
19 } ____cacheline_aligned irq_cpustat_t;
20
21 #include <linux/irq_cpustat.h>  /* Standard mappings for irq_cpustat_t above */
22
23 /*
24  * We put the hardirq and softirq counter into the preemption
25  * counter. The bitmask has the following meaning:
26  *
27  * - bits 0-7 are the preemption count (max preemption depth: 256)
28  * - bits 8-15 are the softirq count (max # of softirqs: 256)
29  * - bits 16-23 are the hardirq count (max # of hardirqs: 256)
30  *
31  * - ( bit 26 is the PREEMPT_ACTIVE flag. )
32  *
33  * PREEMPT_MASK: 0x000000ff
34  * SOFTIRQ_MASK: 0x0000ff00
35  * HARDIRQ_MASK: 0x00ff0000
36  */
37
38 #define PREEMPT_BITS    8
39 #define SOFTIRQ_BITS    8
40 #define HARDIRQ_BITS    8
41
42 #define PREEMPT_SHIFT   0
43 #define SOFTIRQ_SHIFT   (PREEMPT_SHIFT + PREEMPT_BITS)
44 #define HARDIRQ_SHIFT   (SOFTIRQ_SHIFT + SOFTIRQ_BITS)
45
46 /*
47  * The hardirq mask has to be large enough to have
48  * space for potentially all IRQ sources in the system
49  * nesting on a single CPU:
50  */
51 #if (1 << HARDIRQ_BITS) < NR_IRQS
52 # error HARDIRQ_BITS is too low!
53 #endif
54
55 #define irq_enter()             (preempt_count() += HARDIRQ_OFFSET)
56 #define irq_exit()                                                     \
57 do {                                                                   \
58         preempt_count() -= IRQ_EXIT_OFFSET;                     \
59         if (!in_interrupt() && softirq_pending(smp_processor_id())) \
60                 do_softirq();                                   \
61         preempt_enable_no_resched();                            \
62 } while (0)
63
64 #endif /* _ASM_HARDIRQ_H */