FreeBSD/sys/dev/bhnd/bhndb/bhndb.c
/**
 * Default bhndb(4) implementation of BHND_BUS_ACTIVATE_RESOURCE().
 *
 * For BHNDB_ADDRSPACE_NATIVE children, all resources may be assumed to
 * be activated by the bridge.
 * 
 * For BHNDB_ADDRSPACE_BRIDGED children, attempts to activate a static register
 * window, a dynamic register window, or configures @p r as an indirect
 * resource -- in that order.
 */
Default bhndb(4) implementation of BHND_BUS_ACTIVATE_RESOURCE().
For BHNDB_ADDRSPACE_NATIVE children, all resources may be assumed to
be activated by the bridge.

For BHNDB_ADDRSPACE_BRIDGED children, attempts to activate a static register
window, a dynamic register window, or configures @p r as an indirect
resource -- in that order.
Default bhndb ( 4 ) implementation of BHND_BUS_ACTIVATE_RESOURCE () . For BHNDB_ADDRSPACE_NATIVE children all resources may be assumed to be activated by the bridge . For BHNDB_ADDRSPACE_BRIDGED children attempts to activate a static register window a dynamic register window or configures @p r as an indirect resource -- in that order .
static int
bhndb_activate_bhnd_resource(device_t dev, device_t child,
    int type, int rid, struct bhnd_resource *r)
{
	struct bhndb_softc	*sc;
	struct bhndb_region	*region;
	rman_res_t		 r_start, r_size;
	int 			 error;
	bool			 indirect;
	KASSERT(!r->direct,
	    ("direct flag set on inactive resource"));
	KASSERT(!(rman_get_flags(r->res) & RF_ACTIVE),
	    ("RF_ACTIVE set on inactive resource"));
	sc = device_get_softc(dev);
	r_start = rman_get_start(r->res);
	r_size = rman_get_size(r->res);
	if (bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_BRIDGED) {
		bhndb_priority_t r_prio;
		region = bhndb_find_resource_region(sc->bus_res, r_start,
		    r_size);
		if (region != NULL)
			r_prio = region->priority;
		else
			r_prio = BHNDB_PRIORITY_NONE;
		if (r_prio < sc->bus_res->min_prio)
			return (0);
	}
	error = bhndb_try_activate_resource(sc, child, type, rid, r->res,
	    &indirect);
	if (!error) {
		r->direct = true;
	} else if (indirect) {
		error = 0;
		r->direct = false;
	}
	if (BHNDB_DEBUG(PRIO) &&
	    bhndb_get_addrspace(sc, child) == BHNDB_ADDRSPACE_BRIDGED)
	{
		device_printf(child, "activated 0x%llx-0x%llx as %s "
		    "resource\n",
		    (unsigned long long) r_start, 
		    (unsigned long long) r_start + r_size - 1,
		    r->direct ? "direct" : "indirect");
	}
	return (error);
}
static int bhndb_activate_bhnd_resource ( device_t dev , device_t child , int type , int rid , struct bhnd_resource * r ) { struct bhndb_softc * sc ; struct bhndb_region * region ; rman_res_t r_start , r_size ; int error ; bool indirect ; KASSERT ( ! r -> direct , ( " " ) ) ; KASSERT ( ! ( rman_get_flags ( r -> res ) & RF_ACTIVE ) , ( " " ) ) ; sc = device_get_softc ( dev ) ; r_start = rman_get_start ( r -> res ) ; r_size = rman_get_size ( r -> res ) ; if ( bhndb_get_addrspace ( sc , child ) == BHNDB_ADDRSPACE_BRIDGED ) { bhndb_priority_t r_prio ; region = bhndb_find_resource_region ( sc -> bus_res , r_start , r_size ) ; if ( region != NULL ) r_prio = region -> priority ; else r_prio = BHNDB_PRIORITY_NONE ; if ( r_prio < sc -> bus_res -> min_prio ) return ( 0 ) ; } error = bhndb_try_activate_resource ( sc , child , type , rid , r -> res , & indirect ) ; if ( ! error ) { r -> direct = true ; } else if ( indirect ) { error = 0 ; r -> direct = false ; } if ( BHNDB_DEBUG ( PRIO ) && bhndb_get_addrspace ( sc , child ) == BHNDB_ADDRSPACE_BRIDGED ) { device_printf ( child , " " " \n " , ( unsigned long long ) r_start , ( unsigned long long ) r_start + r_size - 1 , r -> direct ? " " : " " ) ; } return ( error ) ; }
Default bhndb(4) implementation of BHND_BUS_ACTIVATE_RESOURCE().
Default bhndb ( 4 ) implementation of BHND_BUS_ACTIVATE_RESOURCE () .
/* Verify bridged address range's resource priority, and skip direct
	 * allocation if the priority is too low. */ /* If less than the minimum dynamic window priority, this
		 * resource should always be indirect. */ /* Attempt direct activation */ /* The request was valid, but no viable register window is
		 * available; indirection must be employed. */