Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Jul 2006 23:34:35 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 101251 for review
Message-ID:  <200607102334.k6ANYZdv098588@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=101251

Change 101251 by imp@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
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607102334.k6ANYZdv098588>