PERFORCE change 101251 for review

Warner Losh imp at FreeBSD.org
Mon Jul 10 23:34:36 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=101251

Change 101251 by imp at imp_lighthouse on 2006/07/10 23:33:46

	Implement bus_hint_device_unit for ACPI too, to kill the dreaded
	sio1 binding to COMA problem.  Untested, but with the default
	device.hints, we should now do the right (== bind sio by port
	addresses) thing.
	
	This could also be extended to allow binding to acpi locations
	as well, but this is supposed to just be PoC.

Affected files ...

.. //depot/projects/arm/src/sys/dev/acpica/acpi.c#11 edit

Differences ...

==== //depot/projects/arm/src/sys/dev/acpica/acpi.c#11 (text+ko) ====

@@ -149,9 +149,10 @@
 static int	acpi_sleep_state_sysctl(SYSCTL_HANDLER_ARGS);
 static int	acpi_pm_func(u_long cmd, void *arg, ...);
 static int	acpi_child_location_str_method(device_t acdev, device_t child,
-					       char *buf, size_t buflen);
+		    char *buf, size_t buflen);
 static int	acpi_child_pnpinfo_str_method(device_t acdev, device_t child,
-					      char *buf, size_t buflen);
+		    char *buf, size_t buflen);
+static void	acpi_hint_device_unit(device_t bus, device_t child, int *unit);
 
 static device_method_t acpi_methods[] = {
     /* Device interface */
@@ -182,6 +183,7 @@
     DEVMETHOD(bus_deactivate_resource,	bus_generic_deactivate_resource),
     DEVMETHOD(bus_setup_intr,		bus_generic_setup_intr),
     DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+    DEVMETHOD(bus_hint_device_unit,	acpi_hint_device_unit),
 
     /* ACPI bus */
     DEVMETHOD(acpi_id_probe,		acpi_device_id_probe),
@@ -811,6 +813,29 @@
     return (0);
 }
 
+static void
+acpi_hint_device_unit(device_t bus, device_t child, int *unit)
+{
+    int i;
+    char buf[10];
+    char *kind = NULL;
+    u_long start, len;
+
+    if (bus_get_resource(child, SYS_RES_IOPORT, 0, &start, &len) == 0)
+	kind = "port";
+    else if (bus_get_resource(child, SYS_RES_MEMORY, 0, &start, &len) == 0)
+	kind = "maddr";
+    if (kind == NULL)
+	return;
+    snprintf(buf, sizeof(buf), "0x%lx", start);
+    i = 0;
+    resource_find_dev(&i, device_get_name(child), unit, kind, buf);
+    // NOTE: We eat units on ANY bus, not just acpi because acpi
+    // should be a specialization of isa, but isn't atm.
+    return;
+}
+
+
 /*
  * Handle per-device ivars
  */


More information about the p4-projects mailing list