| plan 9 kernel history: overview | file list | diff list |
1998/0910/pc/i8259.c (diff list | history)
| 1998/0320/sys/src/9/pc/i8259.c:27,46 – 1998/0910/sys/src/9/pc/i8259.c:27,47 (short | long | prev | next) | ||
|
XXX bug fix?: add i8259lock. Change Vector* to Irq*.
rsc Fri Mar 4 12:44:25 2005 | ||
| 1997/0327 | static int int0mask; /* interrupts enabled for first 8259 */ static int int1mask; /* interrupts enabled for second 8259 */ | |
| 1998/0910 | static int elcr; /* mask of level-triggered interrupts */ static Lock i8259lock; | |
| 1997/0327 |
| |
| 1998/0910 | ilock(&i8259lock); | |
| 1997/0327 | int0mask = 0xFF; int1mask = 0xFF; /* * Set up the first 8259 interrupt processor. | |
| 1998/0910 | * Make 8259 interrupts start at CPU vector VectorPIC. | |
| 1997/0327 | * Set the 8259 as master with edge triggered * input with fully nested interrupts. */ | |
| 1998/0320/sys/src/9/pc/i8259.c:91,149 – 1998/0910/sys/src/9/pc/i8259.c:92,158 | ||
| 1997/0327 | elcr = (inb(Elcr2)<<8)|elcr1; } outb(Elcr1, elcr1); | |
| 1998/0910 | iunlock(&i8259lock); | |
| 1997/0521 | // if(elcr) // print("ELCR: %4.4uX\n", elcr); | |
| 1997/0327 | } int | |
| 1998/0910 | i8259isr(int vno) | |
| 1997/0327 | { int isr; | |
| 1998/0910 | if(vno < VectorPIC || vno > VectorPIC+MaxIrqPIC) return 0; | |
| 1997/0327 | /* * tell the 8259 that we're done with the * highest level interrupt (interrupts are still * off at this point) */ | |
| 1998/0910 | ilock(&i8259lock); isr = inb(Int0ctl); outb(Int0ctl, EOI); if(vno >= VectorPIC+8){ isr |= inb(Int1ctl)<<8; outb(Int1ctl, EOI); | |
| 1997/0327 | } | |
| 1998/0910 | iunlock(&i8259lock); | |
| 1997/0327 |
| |
| 1998/0910 | return isr & (1<<(vno-VectorPIC)); | |
| 1997/0327 | } int | |
| 1998/0910 | i8259enable(Vctl* v) | |
| 1997/0327 | { | |
| 1998/0320 |
| |
| 1997/0327 |
| |
| 1998/0910 | int irq; | |
| 1997/0327 | /* | |
| 1998/0910 | * Given an IRQ, enable the corresponding interrupt in the i8259 * and return the vector to be used. The i8259 is set to use a fixed * range of vectors starting at VectorPIC. | |
| 1997/0327 | */ | |
| 1998/0910 | irq = v->irq; if(irq < 0 || irq > MaxIrqPIC){ print("i8259enable: irq %d out of range\n", irq); return -1; } ilock(&i8259lock); if(irq < 8){ int0mask &= ~(1<<irq); | |
| 1997/0327 | outb(Int0aux, int0mask); } else{ | |
| 1998/0910 | int1mask &= ~(1<<(irq-8)); | |
| 1997/0327 | outb(Int1aux, int1mask); } | |
| 1998/0910 | if(elcr & (1<<irq)) v->eoi = i8259isr; | |
| 1997/0327 | else | |
| 1998/0910 | v->isr = i8259isr; iunlock(&i8259lock); | |
| 1997/0327 |
| |
| 1998/0910 | return VectorPIC+irq; | |
| 1997/0327 | } | |