Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | 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;
333 giacomo 18
#ifdef NOTWORK
2 pj 19
        SYS_FLAGS f;
333 giacomo 20
#endif
2 pj 21
 
22
        /*      kstat.interrupts[irq]++;*/
23
        intr_count++;
24
 
25
#ifdef NOTWORK
26
        if ((handlers[irq].flags & SA_INTERRUPT) != 0) {
27
                        f = kern_fsave();
28
        }
29
#endif
30
 
31
        (*handlers[irq].func)(irq, handlers[irq].data, &regs);
32
 
33
#ifdef NOTWORK
34
        if ((handlers[irq].flags & SA_INTERRUPT) != 0) {
35
                        kern_frestore(f);
36
        }
37
#endif
38
/* cprintf("LinuxInt done\n"); */      
39
        intr_count--;
40
 
41
}
42
 
43
/*
44
 * Attach a handler to an IRQ.
45
 */
46
int request_irq(unsigned int irq, void (*handler)(int, void *dev_id, struct pt_regs *), unsigned long flags, const char *device, void *dev_id)
47
{
48
 
49
        if (handlers[irq].func) {
50
                return (-EBUSY);
51
        }
52
 
53
        handlers[irq].func = handler;
54
        handlers[irq].flags = flags;
55
        handlers[irq].data = dev_id;
56
 
57
        handler_set(irq, linux_intr, NIL);
58
        /*if (fdev_intr_alloc(irq, linux_intr, (void *)irq, 0)) {
59
                handlers[irq].func = 0;
60
                return (-EBUSY);
61
        }
62
        if (!handler) {
63
                handlers[irq].func = 0;
64
                fdev_intr_free(irq);
65
            return (-LINUX_EINVAL);
66
        }*/
67
        return 0;
68
}
69
 
70
/*
71
 * Deallocate an irq.
72
 */
73
void free_irq(unsigned int irq)
74
{
75
        handler_remove(irq);
76
        handlers[irq].func = 0;
77
}