FreeBSD/sys/dev/bhnd/bhndb/bhndb.c
/**
 * Attempt activation of a fixed register window mapping for @p child.
 * 
 * @param sc BHNDB device state.
 * @param region The static region definition capable of mapping @p r.
 * @param child A child requesting resource activation.
 * @param type Resource type.
 * @param rid Resource identifier.
 * @param r Resource to be activated.
 * 
 * @retval 0 if @p r was activated successfully
 * @retval ENOENT if no fixed register window was found.
 * @retval non-zero if @p r could not be activated.
 */
Attempt activation of a fixed register window mapping for @p child.

@param sc BHNDB device state.
@param region The static region definition capable of mapping @p r.
@param child A child requesting resource activation.
@param type Resource type.
@param rid Resource identifier.
@param r Resource to be activated.

@retval 0 if @p r was activated successfully
@retval ENOENT if no fixed register window was found.
@retval non-zero if @p r could not be activated.
Attempt activation of a fixed register window mapping for @p child . @param sc BHNDB device state . @param region The static region definition capable of mapping @p r . @param child A child requesting resource activation . @param type Resource type . @param rid Resource identifier . @param r Resource to be activated . @retval 0 if @p r was activated successfully @retval ENOENT if no fixed register window was found . @retval non - zero if @p r could not be activated .
static int
bhndb_activate_static_region(struct bhndb_softc *sc,
    struct bhndb_region *region, device_t child, int type, int rid,
    struct resource *r)
{
	struct resource			*bridge_res;
	const struct bhndb_regwin	*win;
	bhnd_size_t			 parent_offset;
	rman_res_t			 r_start, r_size;
	int				 error;
	win = region->static_regwin;
	KASSERT(win != NULL && BHNDB_REGWIN_T_IS_STATIC(win->win_type),
	    ("can't activate non-static region"));
	r_start = rman_get_start(r);
	r_size = rman_get_size(r);
	bridge_res = bhndb_find_regwin_resource(sc->bus_res, win);
	if (bridge_res == NULL)
		return (ENXIO);
	parent_offset = r_start - region->addr;
	parent_offset += win->win_offset;
	error = bhndb_init_child_resource(r, bridge_res, parent_offset, r_size);
	if (error)
		return (error);
	if ((error = rman_activate_resource(r)))
		return (error);
	return (0);
}
static int bhndb_activate_static_region ( struct bhndb_softc * sc , struct bhndb_region * region , device_t child , int type , int rid , struct resource * r ) { struct resource * bridge_res ; const struct bhndb_regwin * win ; bhnd_size_t parent_offset ; rman_res_t r_start , r_size ; int error ; win = region -> static_regwin ; KASSERT ( win != NULL && BHNDB_REGWIN_T_IS_STATIC ( win -> win_type ) , ( " " ) ) ; r_start = rman_get_start ( r ) ; r_size = rman_get_size ( r ) ; bridge_res = bhndb_find_regwin_resource ( sc -> bus_res , win ) ; if ( bridge_res == NULL ) return ( ENXIO ) ; parent_offset = r_start - region -> addr ; parent_offset += win -> win_offset ; error = bhndb_init_child_resource ( r , bridge_res , parent_offset , r_size ) ; if ( error ) return ( error ) ; if ( ( error = rman_activate_resource ( r ) ) ) return ( error ) ; return ( 0 ) ; }
Attempt activation of a fixed register window mapping for @p child.
Attempt activation of a fixed register window mapping for @p child .
/* Find the corresponding bridge resource */ /* Calculate subregion offset within the parent resource */ /* Configure resource with its real bus values. */ /* Mark active */