cinap_lenrek 2011-05-15 20:09:01 +00:00
commit d80cf1a4ba
1 changed files with 20 additions and 13 deletions

View File

@ -17,7 +17,6 @@ static int mpeisabus = -1;
extern int i8259elcr; /* mask of level-triggered interrupts */ extern int i8259elcr; /* mask of level-triggered interrupts */
static Apic mpapic[MaxAPICNO+1]; static Apic mpapic[MaxAPICNO+1];
static int machno2apicno[MaxAPICNO+1]; /* inverse map: machno -> APIC ID */ static int machno2apicno[MaxAPICNO+1]; /* inverse map: machno -> APIC ID */
static Ref mpvnoref; /* unique vector assignment */
static int mpmachno = 1; static int mpmachno = 1;
static Lock mpphysidlock; static Lock mpphysidlock;
static int mpphysid; static int mpphysid;
@ -705,6 +704,24 @@ mpintrcpu(void)
return mpapic[i].apicno; return mpapic[i].apicno;
} }
/* hardcoded VectorAPIC and stuff. bad. */
static int
allocvector(void)
{
static int round = 0, num = 1;
static Lock l;
int vno;
lock(&l);
if(num >= 24) {
if(++round >= 8) round = 0;
num = 1;
}
vno = 64 + num++ * 8 + round;
unlock(&l);
return vno;
}
static int static int
mpintrenablex(Vctl* v, int tbdf) mpintrenablex(Vctl* v, int tbdf)
{ {
@ -806,13 +823,7 @@ mpintrenablex(Vctl* v, int tbdf)
* vector regardless of whether the devices on that pin use * vector regardless of whether the devices on that pin use
* the same IRQ as devices on another pin. * the same IRQ as devices on another pin.
*/ */
vno = VectorAPIC + (incref(&mpvnoref)-1)*8; vno = allocvector();
//print("%s vector %d (imask)\n", v->name, vno);
if(vno > MaxVectorAPIC){
print("mpintrenable: vno %d, irq %d, tbdf %uX\n",
vno, v->irq, tbdf);
return -1;
}
hi = mpintrcpu()<<24; hi = mpintrcpu()<<24;
lo = mpintrinit(bus, aintr->intr, vno, v->irq); lo = mpintrinit(bus, aintr->intr, vno, v->irq);
//print("lo 0x%uX: busno %d intr %d vno %d irq %d elcr 0x%uX\n", //print("lo 0x%uX: busno %d intr %d vno %d irq %d elcr 0x%uX\n",
@ -869,11 +880,7 @@ msiintrenable(Vctl *v)
break; break;
} }
vno = VectorAPIC + (incref(&mpvnoref)-1)*8; vno = allocvector();
if(vno > MaxVectorAPIC) {
print("msiintrenable: vno %d\n", vno);
return -1;
}
cpu = mpintrcpu(); cpu = mpintrcpu();
pcicfgw32(pci, cap + MSIAddr, (0xFEE << 20) | (cpu << 12)); pcicfgw32(pci, cap + MSIAddr, (0xFEE << 20) | (cpu << 12));
pcicfgw32(pci, cap + MSIAddr + 4, 0); pcicfgw32(pci, cap + MSIAddr + 4, 0);