Subversion Repositories shark

Rev

Rev 34 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
#include<asm/bitops.h>
2
#include<kernel/kern.h>
34 pj 3
#include <time.h>
2 pj 4
 
5
struct device *irq2dev_map[16] = {0, 0, /* ... zeroed */};
6
 
7
static DWORD handled;           /* The irq lines we have a handler on. */
8
static volatile int irq_number = 0;                     /* The latest irq number we actually found. */
9
 
10
static void autoirq_probe(int irq)
11
{
12
        irq_number = irq;
13
        cprintf("Autoirq: %d\n", irq);
14
 
15
        return;
16
}
17
 
18
int autoirq_setup(int waittime)
19
{
20
        int i;
34 pj 21
        struct timespec delay;
2 pj 22
 
23
        handled = 0;
24
 
25
        for (i = 0; i < 16; i++) {
496 giacomo 26
                if (handler_set(i, autoirq_probe, NIL, TRUE) == 1) {
2 pj 27
                                set_bit(i, (void *)&handled);
28
                }
29
        }
30
 
31
        /* Hang out at least <waittime> jiffies waiting for bogus IRQ hits. */
34 pj 32
        delay.tv_sec = waittime/1000000;
33
        delay.tv_nsec = (waittime%1000000)*1000;
34
        nanosleep(&delay, NULL);
2 pj 35
 
36
        return handled;
37
}
38
 
39
int autoirq_report(int waittime)
40
{
34 pj 41
    struct timespec delay;
2 pj 42
        int i;
34 pj 43
 
2 pj 44
        /* Hang out at least <waittime> jiffies waiting for the IRQ. */
34 pj 45
    delay.tv_sec=waittime/1000000;
46
        delay.tv_nsec=(waittime%1000000)*1000;
47
        nanosleep(&delay, NULL);
2 pj 48
 
49
        /* Retract the irq handlers that we installed. */
50
        for (i = 0; i < 16; i++) {
51
                if (test_bit(i, (void *)&handled))
52
                        handler_remove(i);
53
        }
54
        return irq_number;
55
}
56
 
57
/*
58
 * Local variables:
59
 *  compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c auto_irq.c"
60
 *  version-control: t
61
 *  kept-new-versions: 5
62
 *  c-indent-level: 4
63
 *  tab-width: 4
64
 * End:
65
 */