FreeBSD/sys/dev/bhnd/bhndb/bhndb.c
/**
 * Default bhndb(4) implementation of BHNDB_INIT_FULL_CONFIG().
 * 
 * This function provides the default bhndb implementation of
 * BHNDB_INIT_FULL_CONFIG(), and must be called by any subclass driver
 * overriding BHNDB_INIT_FULL_CONFIG().
 * 
 * As documented by BHNDB_INIT_FULL_CONFIG, this function performs final
 * bridge configuration based on the hardware information enumerated by the
 * child bus, and will reset all resource allocation state on the bridge.
 * 
 * When calling this method:
 * - Any bus resources previously allocated by @p child must be deallocated.
 * - The @p child bus must have performed initial enumeration -- but not
 *   probe or attachment -- of its children.
 */
Default bhndb(4) implementation of BHNDB_INIT_FULL_CONFIG().

This function provides the default bhndb implementation of
BHNDB_INIT_FULL_CONFIG(), and must be called by any subclass driver
overriding BHNDB_INIT_FULL_CONFIG().

As documented by BHNDB_INIT_FULL_CONFIG, this function performs final
bridge configuration based on the hardware information enumerated by the
child bus, and will reset all resource allocation state on the bridge.

When calling this method:
- Any bus resources previously allocated by @p child must be deallocated.
Default bhndb ( 4 ) implementation of BHNDB_INIT_FULL_CONFIG () . This function provides the default bhndb implementation of BHNDB_INIT_FULL_CONFIG () and must be called by any subclass driver overriding BHNDB_INIT_FULL_CONFIG () . As documented by BHNDB_INIT_FULL_CONFIG this function performs final bridge configuration based on the hardware information enumerated by the child bus and will reset all resource allocation state on the bridge . When calling this method : - Any bus resources previously allocated by @p child must be deallocated .
int
bhndb_generic_init_full_config(device_t dev, device_t child,
    const struct bhndb_hw_priority *hw_prio_table)
{
	struct bhndb_softc		*sc;
	const struct bhndb_hw		*hw;
	struct bhndb_resources		*r;
	device_t			*devs;
	device_t			 hostb;
	int				 ndevs;
	int				 error;
	sc = device_get_softc(dev);
	hostb = NULL;
	if ((error = device_get_children(sc->bus_dev, &devs, &ndevs))) {
		device_printf(sc->dev, "unable to get children\n");
		return (error);
	}
	hostb = BHNDB_FIND_HOSTB_DEVICE(dev, child);
	if (hostb == NULL) {
		device_printf(sc->dev, "no host bridge core found\n");
		error = ENODEV;
		goto cleanup;
	}
	if ((error = bhndb_find_hwspec(sc, devs, ndevs, &hw))) {
		device_printf(sc->dev, "unable to identify device, "
			" using generic bridge resource definitions\n");
		error = 0;
		goto cleanup;
	}
	if (bootverbose || BHNDB_DEBUG(PRIO))
		device_printf(sc->dev, "%s resource configuration\n", hw->name);
	BHNDB_LOCK(sc);
	bhndb_free_resources(sc->bus_res);
	sc->bus_res = NULL;
	BHNDB_UNLOCK(sc);
	r = bhndb_alloc_resources(dev, sc->parent_dev, hw->cfg);
	if (r == NULL) {
		error = ENXIO;
		goto cleanup;
	}
	error = bhndb_initialize_region_cfg(sc, devs, ndevs, hw_prio_table, r);
	if (error) {
		bhndb_free_resources(r);
		goto cleanup;
	}
	BHNDB_LOCK(sc);
	sc->bus_res = r;
	sc->hostb_dev = hostb;
	BHNDB_UNLOCK(sc);
cleanup:
	free(devs, M_TEMP);
	return (error);
}
int bhndb_generic_init_full_config ( device_t dev , device_t child , const struct bhndb_hw_priority * hw_prio_table ) { struct bhndb_softc * sc ; const struct bhndb_hw * hw ; struct bhndb_resources * r ; device_t * devs ; device_t hostb ; int ndevs ; int error ; sc = device_get_softc ( dev ) ; hostb = NULL ; if ( ( error = device_get_children ( sc -> bus_dev , & devs , & ndevs ) ) ) { device_printf ( sc -> dev , " \n " ) ; return ( error ) ; } hostb = BHNDB_FIND_HOSTB_DEVICE ( dev , child ) ; if ( hostb == NULL ) { device_printf ( sc -> dev , " \n " ) ; error = ENODEV ; goto cleanup ; } if ( ( error = bhndb_find_hwspec ( sc , devs , ndevs , & hw ) ) ) { device_printf ( sc -> dev , " " " \n " ) ; error = 0 ; goto cleanup ; } if ( bootverbose || BHNDB_DEBUG ( PRIO ) ) device_printf ( sc -> dev , " \n " , hw -> name ) ; BHNDB_LOCK ( sc ) ; bhndb_free_resources ( sc -> bus_res ) ; sc -> bus_res = NULL ; BHNDB_UNLOCK ( sc ) ; r = bhndb_alloc_resources ( dev , sc -> parent_dev , hw -> cfg ) ; if ( r == NULL ) { error = ENXIO ; goto cleanup ; } error = bhndb_initialize_region_cfg ( sc , devs , ndevs , hw_prio_table , r ) ; if ( error ) { bhndb_free_resources ( r ) ; goto cleanup ; } BHNDB_LOCK ( sc ) ; sc -> bus_res = r ; sc -> hostb_dev = hostb ; BHNDB_UNLOCK ( sc ) ; cleanup : free ( devs , M_TEMP ) ; return ( error ) ; }
Default bhndb(4) implementation of BHNDB_INIT_FULL_CONFIG().
Default bhndb ( 4 ) implementation of BHNDB_INIT_FULL_CONFIG () .
/* Fetch the full set of bhnd-attached cores */ /* Find our host bridge device */ /* Find our full register window configuration */ /* Release existing resource state */ /* Allocate new resource state */ /* Initialize our resource priority configuration */ /* Update our bridge state */