Annotation of funnyos/kern/kern_irq.c, Revision 1.1
1.1 ! init 1: /*
! 2: * $Id$
! 3: */
! 4: #include <sys/types.h>
! 5: #include <sys/device.h>
! 6: #include <sys/mem.h>
! 7:
! 8: #include <sys/kern_irq.h>
! 9: #include <libkern/printf.h>
! 10:
! 11: /*
! 12: * System interrupt vectors to be used by (some) interrupt controller unit.
! 13: */
! 14:
! 15: struct intr_vector *irqtable = NULL;
! 16:
! 17:
! 18: void
! 19: intr_establish(uint8_t intrno, struct device *device, void (*intrfunc)(struct device *))
! 20: {
! 21: /*
! 22: * Add interrupt vector to irqtable.
! 23: */
! 24: struct intr_vector *ivp;
! 25:
! 26: ivp = irqtable;
! 27:
! 28: if (ivp == NULL) {
! 29: /* first element in list */
! 30:
! 31: /* allocate space for this (first) vector */
! 32: ivp = kmalloc(sizeof(struct intr_vector));
! 33:
! 34: if (ivp == NULL)
! 35: panic("failed to allocate initial space for interrupt table\n");
! 36:
! 37: ivp->iv_intrno = intrno;
! 38: ivp->iv_device = device;
! 39: ivp->iv_intrfunc = intrfunc;
! 40: ivp->iv_next = NULL;
! 41: }
! 42: else {
! 43: /* walk through the list */
! 44: do {
! 45: /* check if this interrupt line already binded */
! 46: if (ivp->iv_intrno == intrno)
! 47: panic("failed to establish interrupt (intrno %d already set by other device)\n", intrno);
! 48:
! 49: /* become next element */
! 50: ivp = ivp->iv_next;
! 51: } while(ivp != NULL);
! 52:
! 53: /* allocate space */
! 54: ivp = kmalloc(sizeof(struct intr_vector));
! 55:
! 56: if (ivp == NULL)
! 57: panic("failed to allocate space for interrupt vector\n");
! 58:
! 59: ivp->iv_intrno = intrno;
! 60: ivp->iv_device = device;
! 61: ivp->iv_intrfunc = intrfunc;
! 62: ivp->iv_next = NULL;
! 63: }
! 64:
! 65: }
! 66:
! 67:
! 68: void
! 69: intr_disestablish(uint8_t intrno)
! 70: {
! 71: /*
! 72: * Delete interrupt vector from vectors irqtable.
! 73: */
! 74: /* TODO when kfree() will be implemented */
! 75: }
! 76:
! 77:
! 78: void
! 79: intr_execute(uint8_t intrno)
! 80: {
! 81: /*
! 82: * Find intrno in irqtable and call interrupt handler of driver associated with this line.
! 83: * Pass struct device * into that handler to disguise between driver instances.
! 84: */
! 85: struct intr_vector *ivp;
! 86:
! 87: ivp = irqtable;
! 88:
! 89: if (ivp == NULL)
! 90: /* none vectors are configured yet */
! 91: panic("failed to execute intr handler (irqtable is not configured yet)\n");
! 92:
! 93: /* look for our handler */
! 94: while(ivp != NULL) {
! 95: if (ivp->iv_intrno == intrno) {
! 96: /* jump off */
! 97: ivp->iv_intrfunc(ivp->iv_device);
! 98: return;
! 99: }
! 100:
! 101: ivp = ivp->iv_next;
! 102: }
! 103: /*
! 104: * Search stopped on NULL.
! 105: */
! 106: /* XXX really panic here? */
! 107: panic("failed to execute intr handler for intr %d (irqtable record not found)\n", intrno);
! 108:
! 109: }
! 110:
CVSweb