From owner-p4-projects@FreeBSD.ORG Mon Jul 10 23:34:36 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7D7D216A4E1; Mon, 10 Jul 2006 23:34:36 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5A93A16A4DE for ; Mon, 10 Jul 2006 23:34:36 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id ECCFA43D53 for ; Mon, 10 Jul 2006 23:34:35 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6ANYZAu098591 for ; Mon, 10 Jul 2006 23:34:35 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6ANYZdv098588 for perforce@freebsd.org; Mon, 10 Jul 2006 23:34:35 GMT (envelope-from imp@freebsd.org) Date: Mon, 10 Jul 2006 23:34:35 GMT Message-Id: <200607102334.k6ANYZdv098588@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 101251 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jul 2006 23:34:36 -0000 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 */