src/sys/dev/bhnd/bhndb/bhndb_subr.c
/**
 * Find an existing dynamic window mapping @p size bytes
 * at @p addr. The window may or may not be free.
 * 
 * @param br The resource state to search.
 * @param addr The requested starting address.
 * @param size The requested size.
 * 
 * @retval bhndb_dw_alloc A window allocation that fully contains the requested
 * range.
 * @retval NULL If no mapping region can be found.
 */
Find an existing dynamic window mapping @p size bytes
at @p addr. The window may or may not be free.

@param br The resource state to search.
@param addr The requested starting address.
@param size The requested size.

@retval bhndb_dw_alloc A window allocation that fully contains the requested
range.
@retval NULL If no mapping region can be found.
Find an existing dynamic window mapping @p size bytes at @p addr . The window may or may not be free . @param br The resource state to search . @param addr The requested starting address . @param size The requested size . @retval bhndb_dw_alloc A window allocation that fully contains the requested range . @retval NULL If no mapping region can be found .
struct bhndb_dw_alloc *
bhndb_dw_find_mapping(struct bhndb_resources *br, bhnd_addr_t addr,
    bhnd_size_t size)
{
	struct bhndb_dw_alloc		*dwr;
	const struct bhndb_regwin	*win;
	for (size_t i = 0; i < br->dwa_count; i++) {
		dwr = &br->dw_alloc[i];
		win = dwr->win;
		if (addr < dwr->target)
			continue;
		if (addr + size > dwr->target + win->win_size)
			continue;
		return (dwr);
	}
	return (NULL);
}
struct bhndb_dw_alloc * bhndb_dw_find_mapping ( struct bhndb_resources * br , bhnd_addr_t addr , bhnd_size_t size ) { struct bhndb_dw_alloc * dwr ; const struct bhndb_regwin * win ; for ( size_t i = 0 ; i < br -> dwa_count ; i ++ ) { dwr = & br -> dw_alloc [ i ] ; win = dwr -> win ; if ( addr < dwr -> target ) continue ; if ( addr + size > dwr -> target + win -> win_size ) continue ; return ( dwr ) ; } return ( NULL ) ; }
Find an existing dynamic window mapping @p size bytes
 at @p addr.
Find an existing dynamic window mapping @p size bytes at @p addr .
/* Search for an existing dynamic mapping of this address range. */ /* Verify the range */ /* Found a usable mapping */ /* not found */