Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
#include <kernel/kern.h>
2
#include <linux/compatib.h>
3
 
4
static struct {
5
        void (*func)(int, void *dev_id, struct pt_regs *);
6
        void *data;
7
        int flags;
8
} handlers[16];
9
 
10
unsigned long intr_count = 0;
11
 
12
/*
13
 * Generic Linux interrupt handler.
14
 */
15
static void linux_intr(int irq)
16
{
17
        struct pt_regs regs;
18
        //      SYS_FLAGS f;
19
 
20
 
21
        /*      kstat.interrupts[irq]++;*/
22
        intr_count++;
23
 
24
#ifdef NOTWORK
25
        if ((handlers[irq].flags & SA_INTERRUPT) != 0) {
26
                        f = kern_fsave();
27
        }
28
#endif
29
 
30
        (*handlers[irq].func)(irq, handlers[irq].data, &regs);
31
 
32
#ifdef NOTWORK
33
        if ((handlers[irq].flags & SA_INTERRUPT) != 0) {
34
                        kern_frestore(f);
35
        }
36
#endif
37
/* cprintf("LinuxInt done\n"); */      
38
        intr_count--;
39
 
40
}
41
 
42
/*
43
 * Attach a handler to an IRQ.
44
 */
45
int request_irq(unsigned int irq, void (*handler)(int, void *dev_id, struct pt_regs *), unsigned long flags, const char *device, void *dev_id)
46
{
47
 
48
        if (handlers[irq].func) {
49
                return (-EBUSY);
50
        }
51
 
52
        handlers[irq].func = handler;
53
        handlers[irq].flags = flags;
54
        handlers[irq].data = dev_id;
55
 
56
        handler_set(irq, linux_intr, NIL);
57
        /*if (fdev_intr_alloc(irq, linux_intr, (void *)irq, 0)) {
58
                handlers[irq].func = 0;
59
                return (-EBUSY);
60
        }
61
        if (!handler) {
62
                handlers[irq].func = 0;
63
                fdev_intr_free(irq);
64
            return (-LINUX_EINVAL);
65
        }*/
66
        return 0;
67
}
68
 
69
/*
70
 * Deallocate an irq.
71
 */
72
void free_irq(unsigned int irq, void *a)
73
{
74
        handler_set(irq, NULL, NIL);
75
        handlers[irq].func = 0;
76
}