Browse Source

ACPI: first use of ACPI to set apicbase!

we're on our way. If you have ACPI, and you boot with -a,
the apicbase is now set from the MADT, not the _MP_.

We're going to drag this kernel into the 3rd millenium.

I'm doing this set of changes in a very incremental manner
to make bisection easy. Please do not squash this series.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 3 years ago
parent
commit
e09d60550d
2 changed files with 9 additions and 1 deletions
  1. 1 1
      sys/src/9/amd64/apic.c
  2. 8 0
      sys/src/9/amd64/devacpi.c

+ 1 - 1
sys/src/9/amd64/apic.c

@@ -79,7 +79,7 @@ enum {						/* Tdc */
 	DivX1		= 0x0000000b,		/* Divide by 1 */
 };
 
-static uint8_t* apicbase;
+uint8_t* apicbase;
 static int apmachno = 1;
 
 Apic	xlapic[Napic];

+ 8 - 0
sys/src/9/amd64/devacpi.c

@@ -247,12 +247,20 @@ acpiinit(void)
 		panic("Can't Initialize ACPI objects");
 
 	for(apiccnt = 1; ;apiccnt++) {
+		extern uint8_t *apicbase;
 		ACPI_TABLE_MADT *m;
 		status = AcpiGetTable(ACPI_SIG_MADT, apiccnt, &h);
 		if (ACPI_FAILURE(status))
 			break;
 		m = (ACPI_TABLE_MADT *)h;
 		print("APIC %d: %p 0x%x\n", apiccnt, (void *)(uint64_t)m->Address, m->Flags);
+		if(apicbase == nil){
+			if((apicbase = vmap((uintptr_t)m->Address, 1024)) == nil){
+				panic("%s: can't map apicbase\n", __func__);
+			}
+			print("%s: apicbase %#p -> %#p\n", __func__, (void *)(uint64_t)m->Address, apicbase);
+		}
+
 	}
 	if ((apiccnt == 1) && ACPI_FAILURE(status))
 			panic("Can't find a MADT");