From aec3d8022ae0aa2f7209970df0399c1242af20c9 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 8 Apr 2014 19:35:29 +0200 Subject: [PATCH] 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. --- sys/src/9/pc/archacpi.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/src/9/pc/archacpi.c b/sys/src/9/pc/archacpi.c index 3a5cc3506..0b6e7ea48 100644 --- a/sys/src/9/pc/archacpi.c +++ b/sys/src/9/pc/archacpi.c @@ -461,7 +461,7 @@ acpiinit(void) Tbl *t; Apic *a; void *va; - uchar *p, *e; + uchar *s, *p, *e; ulong lapicbase; int machno, i, c; @@ -497,16 +497,16 @@ acpiinit(void) 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) 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 @@ Foundapic: 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;