OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-ppc/] [hardirq.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
#ifdef __KERNEL__
2
#ifndef __ASM_HARDIRQ_H
3
#define __ASM_HARDIRQ_H
4
 
5
#include <linux/config.h>
6
#include <asm/smp.h>
7
 
8
/* entry.S is sensitive to the offsets of these fields */
9
/* The __last_jiffy_stamp field is needed to ensure that no decrementer
10
 * interrupt is lost on SMP machines. Since on most CPUs it is in the same
11
 * cache line as local_irq_count, it is cheap to access and is also used on UP
12
 * for uniformity.
13
 */
14
typedef struct {
15
        unsigned long __softirq_pending;        /* set_bit is used on this */
16
        unsigned int __local_irq_count;
17
        unsigned int __local_bh_count;
18
        unsigned int __syscall_count;
19
        struct task_struct * __ksoftirqd_task;
20
        unsigned int __last_jiffy_stamp;
21
        unsigned int __heartbeat_count;
22
        unsigned int __heartbeat_reset;
23
} ____cacheline_aligned irq_cpustat_t;
24
 
25
#include <linux/irq_cpustat.h>  /* Standard mappings for irq_cpustat_t above */
26
 
27
#define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp)
28
#define heartbeat_count(cpu) __IRQ_STAT((cpu), __heartbeat_count)
29
#define heartbeat_reset(cpu) __IRQ_STAT((cpu), __heartbeat_reset)
30
/*
31
 * Are we in an interrupt context? Either doing bottom half
32
 * or hardware interrupt processing?
33
 */
34
#define in_interrupt() ({ int __cpu = smp_processor_id(); \
35
        (local_irq_count(__cpu) + local_bh_count(__cpu) != 0); })
36
 
37
#define in_irq() (local_irq_count(smp_processor_id()) != 0)
38
 
39
#ifndef CONFIG_SMP
40
 
41
#define hardirq_trylock(cpu)    (local_irq_count(cpu) == 0)
42
#define hardirq_endlock(cpu)    do { } while (0)
43
 
44
#define hardirq_enter(cpu)      (local_irq_count(cpu)++)
45
#define hardirq_exit(cpu)       (local_irq_count(cpu)--)
46
 
47
#define synchronize_irq()       do { } while (0)
48
 
49
#else /* CONFIG_SMP */
50
 
51
#include <asm/atomic.h>
52
 
53
extern unsigned char global_irq_holder;
54
extern unsigned volatile long global_irq_lock;
55
extern atomic_t global_irq_count;
56
 
57
static inline void release_irqlock(int cpu)
58
{
59
        /* if we didn't own the irq lock, just ignore.. */
60
        if (global_irq_holder == (unsigned char) cpu) {
61
                global_irq_holder = NO_PROC_ID;
62
                clear_bit(0,&global_irq_lock);
63
        }
64
}
65
 
66
static inline void hardirq_enter(int cpu)
67
{
68
        unsigned int loops = 10000000;
69
 
70
        ++local_irq_count(cpu);
71
        atomic_inc(&global_irq_count);
72
        while (test_bit(0,&global_irq_lock)) {
73
                if (cpu == global_irq_holder) {
74
                        printk("uh oh, interrupt while we hold global irq lock! (CPU %d)\n", cpu);
75
#ifdef CONFIG_XMON
76
                        xmon(0);
77
#endif
78
                        break;
79
                }
80
                if (loops-- == 0) {
81
                        printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder);
82
#ifdef CONFIG_XMON
83
                        xmon(0);
84
#endif
85
                }
86
        }
87
}
88
 
89
static inline void hardirq_exit(int cpu)
90
{
91
        atomic_dec(&global_irq_count);
92
        --local_irq_count(cpu);
93
}
94
 
95
static inline int hardirq_trylock(int cpu)
96
{
97
        return !atomic_read(&global_irq_count) && !test_bit(0,&global_irq_lock);
98
}
99
 
100
#define hardirq_endlock(cpu)    do { } while (0)
101
 
102
extern void synchronize_irq(void);
103
 
104
#endif /* CONFIG_SMP */
105
 
106
#endif /* __ASM_HARDIRQ_H */
107
#endif /* __KERNEL__ */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.