ref: 3d5a7ea1b46dcc1581debed24840ee24a00f502f
parent: 5716207e61a5fbb95b29c368316c4cff20262168
parent: f5a1a6abb7bce70b12d5d4c6174745d9444cc611
author: cinap_lenrek <cinap_lenrek@localhost>
date: Sun May 15 16:09:01 EDT 2011
merge
--- a/sys/src/9/pc/mp.c
+++ b/sys/src/9/pc/mp.c
@@ -17,7 +17,6 @@
extern int i8259elcr; /* mask of level-triggered interrupts */
static Apic mpapic[MaxAPICNO+1];
static int machno2apicno[MaxAPICNO+1]; /* inverse map: machno -> APIC ID */
-static Ref mpvnoref; /* unique vector assignment */
static int mpmachno = 1;
static Lock mpphysidlock;
static int mpphysid;
@@ -705,7 +704,25 @@
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
mpintrenablex(Vctl* v, int tbdf)
{Bus *bus;
@@ -806,13 +823,7 @@
* vector regardless of whether the devices on that pin use
* the same IRQ as devices on another pin.
*/
- vno = VectorAPIC + (incref(&mpvnoref)-1)*8;
-//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;
- }
+ vno = allocvector();
hi = mpintrcpu()<<24;
lo = mpintrinit(bus, aintr->intr, vno, v->irq);
//print("lo 0x%uX: busno %d intr %d vno %d irq %d elcr 0x%uX\n",@@ -869,11 +880,7 @@
break;
}
- vno = VectorAPIC + (incref(&mpvnoref)-1)*8;
- if(vno > MaxVectorAPIC) {- print("msiintrenable: vno %d\n", vno);- return -1;
- }
+ vno = allocvector();
cpu = mpintrcpu();
pcicfgw32(pci, cap + MSIAddr, (0xFEE << 20) | (cpu << 12));
pcicfgw32(pci, cap + MSIAddr + 4, 0);
--
⑨