git: 9front

Download patch

ref: f36586becb8de09cd5b0192e5c4b0a6dd198f59e
parent: 1c2c4b3bc0e0855eb81be73174ffcdb8cd3dba9b
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Apr 8 15:35:29 EDT 2014

process acpi interrupt source override entries in a 2nd pass over the madt (APIC) table (thanks erik)

according to erik, virtualbox puts the source overrides
before the ioapic entries so the addirq() call fails
as no ioapics have been declared yet. use a second pass
over the table after we processed the apic entries.

--- a/sys/src/9/pc/archacpi.c
+++ b/sys/src/9/pc/archacpi.c
@@ -461,7 +461,7 @@
 	Tbl *t;
 	Apic *a;
 	void *va;
-	uchar *p, *e;
+	uchar *s, *p, *e;
 	ulong lapicbase;
 	int machno, i, c;
 
@@ -497,9 +497,9 @@
 	return;
 
 Foundapic:
-	p = t->data;
-	e = p + tbldlen(t);
-	lapicbase = get32(p); p += 8;
+	s = t->data;
+	e = s + tbldlen(t);
+	lapicbase = get32(s); s += 8;
 	va = vmap(lapicbase, 1024);
 	print("LAPIC: %.8lux %#p\n", lapicbase, va);
 	if(va == nil)
@@ -506,7 +506,7 @@
 		panic("acpiinit: cannot map lapic %.8lux", lapicbase);
 
 	machno = 0;
-	for(; p < e; p += c){
+	for(p = s; p < e; p += c){
 		c = p[1];
 		if(c < 2 || (p+c) > e)
 			break;
@@ -555,6 +555,18 @@
 			mpioapic[a->apicno] = a;
 			ioapicinit(a, a->apicno);
 			break;
+		}
+	}
+
+	/*
+	 * need 2nd pass as vbox puts interrupt overrides
+	 * *before* the ioapic entries (!)
+	 */
+	for(p = s; p < e; p += c){
+		c = p[1];
+		if(c < 2 || (p+c) > e)
+			break;
+		switch(*p){
 		case 0x02:	/* Interrupt Source Override */
 			addirq(get32(p+4), BusISA, 0, p[3], get16(p+8));
 			break;
--