FreeBSD/sys/dev/bhnd/bhndb/bhndb_subr.c
/**
 * Attempt to set (or reset) the target address of @p dwa to map @p size bytes
 * at @p addr.
 * 
 * This will apply any necessary window alignment and verify that
 * the window is capable of mapping the requested range prior to modifying
 * therecord.
 * 
 * @param dev The device on which to issue the BHNDB_SET_WINDOW_ADDR() request.
 * @param br The resource state owning @p dwa.
 * @param dwa The allocation record to be configured.
 * @param addr The address to be mapped via @p dwa.
 * @param size The number of bytes to be mapped at @p addr.
 *
 * @retval 0 success
 * @retval non-zero no usable register window available.
 */
Attempt to set (or reset) the target address of @p dwa to map @p size bytes
at @p addr.

This will apply any necessary window alignment and verify that
the window is capable of mapping the requested range prior to modifying
therecord.

@param dev The device on which to issue the BHNDB_SET_WINDOW_ADDR() request.
@param br The resource state owning @p dwa.
@param dwa The allocation record to be configured.
@param addr The address to be mapped via @p dwa.
@param size The number of bytes to be mapped at @p addr.

@retval 0 success
@retval non-zero no usable register window available.
Attempt to set ( or reset ) the target address of @p dwa to map @p size bytes at @p addr . This will apply any necessary window alignment and verify that the window is capable of mapping the requested range prior to modifying therecord . @param dev The device on which to issue the BHNDB_SET_WINDOW_ADDR () request . @param br The resource state owning @p dwa . @param dwa The allocation record to be configured . @param addr The address to be mapped via @p dwa . @param size The number of bytes to be mapped at @p addr . @retval 0 success @retval non - zero no usable register window available .
int
bhndb_dw_set_addr(device_t dev, struct bhndb_resources *br,
    struct bhndb_dw_alloc *dwa, bus_addr_t addr, bus_size_t size)
{
	const struct bhndb_regwin	*rw;
	bus_addr_t			 offset;
	int				 error;
	rw = dwa->win;
	KASSERT(bhndb_dw_is_free(br, dwa),
	    ("attempting to set the target address on an in-use window"));
	offset = addr % rw->win_size;
	dwa->target = addr - offset;
	if (rw->win_size - offset < size)
		return (ENOMEM);
	error = BHNDB_SET_WINDOW_ADDR(dev, dwa->win, dwa->target);
	if (error) {
		dwa->target = 0x0;
		return (error);
	}
	return (0);
}
int bhndb_dw_set_addr ( device_t dev , struct bhndb_resources * br , struct bhndb_dw_alloc * dwa , bus_addr_t addr , bus_size_t size ) { const struct bhndb_regwin * rw ; bus_addr_t offset ; int error ; rw = dwa -> win ; KASSERT ( bhndb_dw_is_free ( br , dwa ) , ( " " ) ) ; offset = addr % rw -> win_size ; dwa -> target = addr - offset ; if ( rw -> win_size - offset < size ) return ( ENOMEM ) ; error = BHNDB_SET_WINDOW_ADDR ( dev , dwa -> win , dwa -> target ) ; if ( error ) { dwa -> target = 0x0 ; return ( error ) ; } return ( 0 ) ; }
Attempt to set (or reset) the target address of @p dwa to map @p size bytes
 at @p addr.
Attempt to set ( or reset ) the target address of @p dwa to map @p size bytes at @p addr .
/* Page-align the target address */ /* Verify that the window is large enough for the full target */ /* Update the window target */