shithub: riscv

Download patch

ref: aec3d8022ae0aa2f7209970df0399c1242af20c9
parent: ae3afb12a05aca507b313c2ff61c27f015688e6e
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;