3 #include "../port/lib.h"
8 #include "../port/error.h"
16 void (*f)(Ureg *, void *);
51 /* disable all irqs and clear any pending interrupts */
52 for(i = 0; i < NINTR/32; i++){
53 mpcore[ICDISR + i] = -1;
54 mpcore[ICDICER + i] = -1;
55 mpcore[ICDICPR + i] = -1;
56 mpcore[ICDABR + i] = 0;
61 intrenable(int irq, void (*f)(Ureg *, void *), void *arg, int type, char *name)
67 panic("intrenable: f == nil");
68 if(irq < 0 || irq >= NINTR)
69 panic("intrenable: invalid irq %d", irq);
70 if(type != LEVEL && type != EDGE)
71 panic("intrenable: invalid type %d", type);
72 if(irqs[irq].f != nil && irqs[irq].f != f)
73 panic("intrenable: handler already assigned");
75 e = &mpcore[ICDIPTR + (irq >> 2)];
77 *e = *e & ~(3 << s) | 1 << s;
78 e = &mpcore[ICDICFR + (irq >> 4)];
79 s = irq << 1 & 30 | 1;
80 *e = *e & ~(1 << s) | type << s;
82 ((uchar*)&mpcore[ICDIPRI])[irq] = 0;
87 mpcore[ICDISER + (irq >> 5)] = 1 << (irq & 31);
88 mpcore[ICDABR + (irq >> 5)] |= 1 << (irq & 31);
107 print("irq without handler %d\n", irq);