FreeBSD/sys/dev/bhnd/bhndb/bhndb.c
/**
 * Default bhndb(4) implementation of BHND_BUS_FIND_HOSTB_DEVICE().
 * 
 * This function uses a heuristic valid on all known PCI/PCIe/PCMCIA-bridged
 * bhnd(4) devices to determine the hostb core:
 * 
 * - The core must have a Broadcom vendor ID.
 * - The core devclass must match the bridge type.
 * - The core must be the first device on the bus with the bridged device
 *   class.
 * 
 * @param dev The bhndb device
 * @param child The requesting bhnd bus.
 */
Default bhndb(4) implementation of BHND_BUS_FIND_HOSTB_DEVICE().

This function uses a heuristic valid on all known PCI/PCIe/PCMCIA-bridged
bhnd(4) devices to determine the hostb core.

- The core must have a Broadcom vendor ID.
- The core devclass must match the bridge type.
- The core must be the first device on the bus with the bridged device
class.

@param dev The bhndb device
@param child The requesting bhnd bus.
Default bhndb ( 4 ) implementation of BHND_BUS_FIND_HOSTB_DEVICE () . This function uses a heuristic valid on all known PCI / PCIe / PCMCIA - bridged bhnd ( 4 ) devices to determine the hostb core . - The core must have a Broadcom vendor ID . - The core devclass must match the bridge type . - The core must be the first device on the bus with the bridged device class . @param dev The bhndb device @param child The requesting bhnd bus .
static device_t
bhndb_find_hostb_device(device_t dev, device_t child)
{
	struct bhndb_softc		*sc;
	struct bhnd_device_match	 md;
	device_t			 hostb_dev, *devlist;
	int				 devcnt, error;
	sc = device_get_softc(dev);
	md = (struct bhnd_device_match) {
		BHND_MATCH_CORE_CLASS(sc->bridge_class),
		BHND_MATCH_CORE_UNIT(0)
	};
	if ((error = device_get_children(child, &devlist, &devcnt)))
		return (false);
	qsort(devlist, devcnt, sizeof(*devlist), compare_core_index);
	hostb_dev = NULL;
	for (int i = 0; i < devcnt; i++) {
		if (bhnd_device_matches(devlist[i], &md)) {
			hostb_dev = devlist[i];
			break;
		}
	}
	free(devlist, M_TEMP);
	return (hostb_dev);
}
static device_t bhndb_find_hostb_device ( device_t dev , device_t child ) { struct bhndb_softc * sc ; struct bhnd_device_match md ; device_t hostb_dev , * devlist ; int devcnt , error ; sc = device_get_softc ( dev ) ; md = ( struct bhnd_device_match ) { BHND_MATCH_CORE_CLASS ( sc -> bridge_class ) , BHND_MATCH_CORE_UNIT ( 0 ) } ; if ( ( error = device_get_children ( child , & devlist , & devcnt ) ) ) return ( false ) ; qsort ( devlist , devcnt , sizeof ( * devlist ) , compare_core_index ) ; hostb_dev = NULL ; for ( int i = 0 ; i < devcnt ; i ++ ) { if ( bhnd_device_matches ( devlist [ i ] , & md ) ) { hostb_dev = devlist [ i ] ; break ; } } free ( devlist , M_TEMP ) ; return ( hostb_dev ) ; }
Default bhndb(4) implementation of BHND_BUS_FIND_HOSTB_DEVICE().
Default bhndb ( 4 ) implementation of BHND_BUS_FIND_HOSTB_DEVICE () .
/* Set up a match descriptor for the required device class. */ /* Must be the absolute first matching device on the bus. */ /* Sort by core index value, ascending */ /* Find the hostb device */ /* Clean up */