Browse Source

ACPI: further progress

This seems to find and correctly try to set up the IOAPIC entry on qemu.

It suicides on VMWARE, however, not sure why yet. It's dying in the ACPICA library.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 7 years ago
parent
commit
f172919462
4 changed files with 26 additions and 19 deletions
  1. 2 0
      lib/namespace
  2. 1 0
      sys/src/9/amd64/build.json
  3. 9 6
      sys/src/cmd/acpi/irq.c
  4. 14 13
      sys/src/libacpi/olsneracpi.c

+ 2 - 0
lib/namespace

@@ -15,6 +15,8 @@ bind -b #k /dev
 bind -a #κ /dev
 bind -a #u /dev
 bind -b #P /dev
+bind -b '#$' /dev
+bind -a 'α' /dev
 
 # mount points
 mount -a /srv/slashn /n

+ 1 - 0
sys/src/9/amd64/build.json

@@ -92,6 +92,7 @@
 				"fdisk": "/$ARCH/bin/disk/fdisk",
 				"fossil": "/$ARCH/bin/fossil/fossil",
 				"ipconfig": "/$ARCH/bin/ip/ipconfig",
+				"irq": "/$ARCH/bin/acpi/irq",
 				"ls": "/$ARCH/bin/ls",
 				"mount": "/$ARCH/bin/mount",
 				"nvram": "/util/nvram",

+ 9 - 6
sys/src/cmd/acpi/irq.c

@@ -87,20 +87,23 @@ main(int argc, char *argv[])
 
 	print("inited objects. Hi the any key to continue\n"); //getchar();
 	AcpiDbgLevel |= ACPI_LV_VERBOSITY1 | ACPI_LV_FUNCTIONS;
+	AcpiDbgLevel = 0;
 	status = AcpiInitializeDebugger();
 	if (ACPI_FAILURE(status)) {
 		sysfatal("Error %d\n", status);
 	}
 	ACPI_STATUS RouteIRQ(ACPI_PCI_ID* device, int pin, int* irq);
-	ACPI_PCI_ID id = {0, 0, 2, 0};
+	AcpiDbgLevel = 0;
+	ACPI_PCI_ID id = (ACPI_PCI_ID){0, 0, 2, 0};
 	int irq;
-	for(int i = 0; i < 4; i++) {
-		status = RouteIRQ(&id, i, &irq);
+	//for(int i = 0; i < 4; i++) {
+		status = RouteIRQ(&id, 0, &irq);
 		print("status %d, irq %d\n", status, irq);
-	}
+	//}
+//	}
 	AcpiDbgLevel = 0;
-	ACPI_STATUS PrintDevices(void);
-	status = PrintDevices();
+	//ACPI_STATUS PrintDevices(void);
+	//status = PrintDevices();
 	print("OK on init.\n");
 	exits(0);
 }

+ 14 - 13
sys/src/libacpi/olsneracpi.c

@@ -365,7 +365,7 @@ static ACPI_STATUS RouteIRQLinkDevice(ACPI_HANDLE Device, ACPI_PCI_ROUTING_TABLE
 	ResetBuffer(&buffer);
 	status = AcpiGetCurrentResources(LinkDevice, &buffer);
 	CHECK_STATUS("AcpiGetCurrentResources");
-	//printf("Got %lu bytes of current resources\n", buffer.Length);
+	printf("Got %lu bytes of current resources\n", buffer.Length);
 	ACPI_RESOURCE* resource = (ACPI_RESOURCE*)buffer.Pointer;
 	switch (resource->Type) {
 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
@@ -428,27 +428,28 @@ static ACPI_STATUS RouteIRQCallback(ACPI_HANDLE Device, UINT32 Depth, void *Cont
 	// multiple root pci bridges.
 	status = AcpiGetCurrentResources(Device, &buffer);
 	CHECK_STATUS("AcpiGetCurrentResources");
-	//printf("Got %lu bytes of current resources\n", buffer.Length);
-	//status = AcpiBufferToResource(buffer.Pointer, buffer.Length, &resource);
+	printf("Got %lu bytes of current resources\n", buffer.Length);
+	status = AcpiBufferToResource(buffer.Pointer, buffer.Length, &resource);
 	resource = (ACPI_RESOURCE*)buffer.Pointer;
-	//printf("Got resources %p (status %#x)\n", resource, status);
+	printf("Got resources %p (status %#x)\n", resource, status);
 	//CHECK_STATUS();
 	while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) {
-		//printf("Got resource type %d\n", resource->Type);
+		printf("Got resource type %d\n", resource->Type);
 		ACPI_RESOURCE_ADDRESS64 addr64;
 		ACPI_STATUS status = AcpiResourceToAddress64(resource, &addr64);
+		printf("Processed and got type\n",  addr64.ResourceType);
 		if (status == AE_OK && addr64.ResourceType == ACPI_BUS_NUMBER_RANGE)
 		{
 			printf("RouteIRQ: Root bridge bus range %#x..%#x\n",
-			       addr64.MinAddressFixed,
-					addr64.MaxAddressFixed);
-			if (data->pci.Bus < addr64.MinAddressFixed ||
-			    data->pci.Bus > addr64.MaxAddressFixed)
+			       addr64.Address.Minimum,
+					addr64.Address.Maximum);
+			if (data->pci.Bus < addr64.Address.Minimum ||
+			    data->pci.Bus > addr64.Address.Maximum)
 			{
 				// This is not the root bridge we're looking for...
 				goto failed;
 			}
-			rootBus = addr64.MinAddressFixed;
+			rootBus = addr64.Address.Minimum;
 			break;
 		}
 		resource = ACPI_NEXT_RESOURCE(resource);
@@ -472,10 +473,10 @@ static ACPI_STATUS RouteIRQCallback(ACPI_HANDLE Device, UINT32 Depth, void *Cont
 	ResetBuffer(&buffer);
 	status = AcpiGetIrqRoutingTable(Device, &buffer);
 	CHECK_STATUS("AcpiGetIrqRoutingTable");
-	//printf("Got %u bytes of IRQ routing table\n", buffer.Length);
+	printf("Got %u bytes of IRQ routing table\n", buffer.Length);
 	ACPI_PCI_ROUTING_TABLE* route = buffer.Pointer;
 	ACPI_PCI_ROUTING_TABLE* const end = buffer.Pointer + buffer.Length;
-	//printf("Routing table: %p..%p\n", route, end);
+	printf("Routing table: %p..%p\n", route, end);
 	UINT64 pciAddr = data->pci.Device;
 	while (route < end && route->Length) {
 		if ((route->Address >> 16) == pciAddr && route->Pin == data->pin) {
@@ -496,7 +497,7 @@ static ACPI_STATUS RouteIRQCallback(ACPI_HANDLE Device, UINT32 Depth, void *Cont
 
 	if (found->Source[0]) {
 		status = RouteIRQLinkDevice(Device, found, data);
-		//printf("status %#x irq %#x\n", status, data->gsi);
+		printf("status %#x irq %#x\n", status, data->gsi);
 		CHECK_STATUS("RouteIRQLinkDevice");
 	} else {
 		data->gsi = found->SourceIndex;