Subversion Repositories shark

Rev

Rev 514 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include <linuxcomp.h>

#include <asm/ptrace.h>
#include <asm-generic/errno-base.h>
#include <linux/kernel.h>

#define NIL -1

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;

        //printk("linux_intr %d\n", irq);

        intr_count++;

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

        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;

        shark_handler_set(irq, linux_intr, NIL, TRUE);

        return 0;
}

/*
 * Deallocate an irq.
 */

void free_irq(unsigned int irq, void *a)
{
        shark_handler_remove(irq);
        handlers[irq].func = 0;
}