Subversion Repositories shark

Rev

Rev 333 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include <kernel/kern.h>
#include <linux/compatib.h>

static struct {
        void (*func)(int, void *dev_id, struct pt_regs *);
        void *data;
        int flags;
} handlers[16];

unsigned long intr_count = 0;

/*
 * Generic Linux interrupt handler.
 */

static void linux_intr(int irq)
{
        struct pt_regs regs;
#ifdef NOTWORK
        SYS_FLAGS f;
#endif

        /*      kstat.interrupts[irq]++;*/
        intr_count++;

#ifdef NOTWORK
        if ((handlers[irq].flags & SA_INTERRUPT) != 0) {
                        f = kern_fsave();
        }
#endif

        (*handlers[irq].func)(irq, handlers[irq].data, &regs);

#ifdef NOTWORK
        if ((handlers[irq].flags & SA_INTERRUPT) != 0) {
                        kern_frestore(f);
        }
#endif
/* cprintf("LinuxInt done\n"); */      
        intr_count--;

}

/*
 * Attach a handler to an IRQ.
 */

int request_irq(unsigned int irq, void (*handler)(int, void *dev_id, struct pt_regs *), unsigned long flags, const char *device, void *dev_id)
{
       
        if (handlers[irq].func) {
                return (-EBUSY);
        }
       
        handlers[irq].func = handler;
        handlers[irq].flags = flags;
        handlers[irq].data = dev_id;

        handler_set(irq, linux_intr, NIL, TRUE);
        /*if (fdev_intr_alloc(irq, linux_intr, (void *)irq, 0)) {
                handlers[irq].func = 0;
                return (-EBUSY);
        }
        if (!handler) {
                handlers[irq].func = 0;
                fdev_intr_free(irq);
            return (-LINUX_EINVAL);
        }*/

        return 0;
}

/*
 * Deallocate an irq.
 */

void free_irq(unsigned int irq)
{
        handler_remove(irq);
        handlers[irq].func = 0;
}