From owner-p4-projects@FreeBSD.ORG Sat Jul 8 16:37:20 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 A63D716A4E5; Sat, 8 Jul 2006 16:37:20 +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 8099516A4DA for ; Sat, 8 Jul 2006 16:37:20 +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 43DC443D67 for ; Sat, 8 Jul 2006 16:37:13 +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 k68GbDbh055820 for ; Sat, 8 Jul 2006 16:37:13 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k68GbCni055815 for perforce@freebsd.org; Sat, 8 Jul 2006 16:37:12 GMT (envelope-from imp@freebsd.org) Date: Sat, 8 Jul 2006 16:37:12 GMT Message-Id: <200607081637.k68GbCni055815@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 101031 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: Sat, 08 Jul 2006 16:37:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=101031 Change 101031 by imp@imp_lighthouse on 2006/07/08 16:36:41 First steps towards making the hinted device enumeration stuff more generic. Affected files ... .. //depot/projects/arm/src/sys/kern/bus_if.m#2 edit .. //depot/projects/arm/src/sys/kern/subr_bus.c#9 edit .. //depot/projects/arm/src/sys/sys/bus.h#5 edit Differences ... ==== //depot/projects/arm/src/sys/kern/bus_if.m#2 (text+ko) ==== @@ -507,3 +507,25 @@ enum intr_trigger _trig; enum intr_polarity _pol; } DEFAULT bus_generic_config_intr; + +/** + * @brief Notify a (bus) driver about a child that the hints mechanism + * believes it has discovered. + * + * The bus is responsible for then adding the child in the right order + * and discovering other things about the child. The bus driver is + * free to ignore this hint, to do special things, etc. It is all up + * to the bus driver to interpret. + * + * This method is only called in response to the parent bus asking for + * hinted devices to be enumerated. + * + * @param _dev the bus device + * @param _dname the name of the device w/o unit numbers + * @param _dunit the unit number of the device + */ +METHOD void hinted_child { + device_t _dev; + const char * _dname; + int _dunit; +}; ==== //depot/projects/arm/src/sys/kern/subr_bus.c#9 (text+ko) ==== @@ -3799,6 +3799,40 @@ return (error); } +/** + * @brief Enumerate all hinted devices for this bus. + * + * Walks throught he hints for this bus and calls the bus_hinted_child + * routine for each one it fines. It searches first for the specific + * bus that's being probed for hinted children (eg isa0), and then for + * generic children (eg isa). + * + * @param dev bus device to enumerate + */ +void +bus_enumerate_hinted_children(device_t bus) +{ + int i; + const char *dname, *busname; + int dunit; + + /* + * enumerate all devices on the specific bus + */ + busname = device_get_nameunit(bus); + i = 0; + while (resource_find_match(&i, &dname, &dunit, "at", busname) == 0) + BUS_HINTED_CHILD(bus, dname, dunit); + + /* + * and all the generic ones. + */ + busname = device_get_name(bus); + i = 0; + while (resource_find_match(&i, &dname, &dunit, "at", busname) == 0) + BUS_HINTED_CHILD(bus, dname, dunit); +} + #ifdef BUS_DEBUG /* the _short versions avoid iteration by not calling anything that prints ==== //depot/projects/arm/src/sys/sys/bus.h#5 (text+ko) ==== @@ -322,6 +322,7 @@ int bus_child_present(device_t child); int bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen); int bus_child_location_str(device_t child, char *buf, size_t buflen); +void bus_enumerate_hinted_children(device_t bus); static __inline struct resource * bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)