FreeBSD/sys/sparc64/sparc64/bus_machdep.c
/*
 * Allocate a device specific dma_tag.
 */
Allocate a device specific dma_tag.
Allocate a device specific dma_tag .
int
bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
    bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,
    bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize,
    int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc,
    void *lockfuncarg, bus_dma_tag_t *dmat)
{
	bus_dma_tag_t newtag;
	*dmat = NULL;
	if (parent == NULL)
		panic("%s: parent DMA tag NULL", __func__);
	newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF, M_NOWAIT);
	if (newtag == NULL)
		return (ENOMEM);
	newtag->dt_cookie = parent->dt_cookie;
	newtag->dt_mt = parent->dt_mt;
	newtag->dt_parent = parent;
	newtag->dt_alignment = alignment;
	newtag->dt_boundary = boundary;
	newtag->dt_lowaddr = trunc_page((vm_offset_t)lowaddr) + (PAGE_SIZE - 1);
	newtag->dt_highaddr = trunc_page((vm_offset_t)highaddr) +
	    (PAGE_SIZE - 1);
	newtag->dt_filter = filter;
	newtag->dt_filterarg = filterarg;
	newtag->dt_maxsize = maxsize;
	newtag->dt_nsegments = nsegments;
	newtag->dt_maxsegsz = maxsegsz;
	newtag->dt_flags = flags;
	newtag->dt_ref_count = 1; 
	newtag->dt_map_count = 0;
	if (lockfunc != NULL) {
		newtag->dt_lockfunc = lockfunc;
		newtag->dt_lockfuncarg = lockfuncarg;
	} else {
		newtag->dt_lockfunc = dflt_lock;
		newtag->dt_lockfuncarg = NULL;
	}
	newtag->dt_segments = NULL;
	newtag->dt_lowaddr = ulmin(parent->dt_lowaddr, newtag->dt_lowaddr);
	newtag->dt_highaddr = ulmax(parent->dt_highaddr, newtag->dt_highaddr);
	if (newtag->dt_boundary == 0)
		newtag->dt_boundary = parent->dt_boundary;
	else if (parent->dt_boundary != 0)
		newtag->dt_boundary = ulmin(parent->dt_boundary,
		    newtag->dt_boundary);
	atomic_add_int(&parent->dt_ref_count, 1);
	if (newtag->dt_boundary > 0)
		newtag->dt_maxsegsz = ulmin(newtag->dt_maxsegsz,
		    newtag->dt_boundary);
	*dmat = newtag;
	return (0);
}
int bus_dma_tag_create ( bus_dma_tag_t parent , bus_size_t alignment , bus_addr_t boundary , bus_addr_t lowaddr , bus_addr_t highaddr , bus_dma_filter_t * filter , void * filterarg , bus_size_t maxsize , int nsegments , bus_size_t maxsegsz , int flags , bus_dma_lock_t * lockfunc , void * lockfuncarg , bus_dma_tag_t * dmat ) { bus_dma_tag_t newtag ; * dmat = NULL ; if ( parent == NULL ) panic ( " " , __func__ ) ; newtag = ( bus_dma_tag_t ) malloc ( sizeof ( * newtag ) , M_DEVBUF , M_NOWAIT ) ; if ( newtag == NULL ) return ( ENOMEM ) ; newtag -> dt_cookie = parent -> dt_cookie ; newtag -> dt_mt = parent -> dt_mt ; newtag -> dt_parent = parent ; newtag -> dt_alignment = alignment ; newtag -> dt_boundary = boundary ; newtag -> dt_lowaddr = trunc_page ( ( vm_offset_t ) lowaddr ) + ( PAGE_SIZE - 1 ) ; newtag -> dt_highaddr = trunc_page ( ( vm_offset_t ) highaddr ) + ( PAGE_SIZE - 1 ) ; newtag -> dt_filter = filter ; newtag -> dt_filterarg = filterarg ; newtag -> dt_maxsize = maxsize ; newtag -> dt_nsegments = nsegments ; newtag -> dt_maxsegsz = maxsegsz ; newtag -> dt_flags = flags ; newtag -> dt_ref_count = 1 ; newtag -> dt_map_count = 0 ; if ( lockfunc != NULL ) { newtag -> dt_lockfunc = lockfunc ; newtag -> dt_lockfuncarg = lockfuncarg ; } else { newtag -> dt_lockfunc = dflt_lock ; newtag -> dt_lockfuncarg = NULL ; } newtag -> dt_segments = NULL ; newtag -> dt_lowaddr = ulmin ( parent -> dt_lowaddr , newtag -> dt_lowaddr ) ; newtag -> dt_highaddr = ulmax ( parent -> dt_highaddr , newtag -> dt_highaddr ) ; if ( newtag -> dt_boundary == 0 ) newtag -> dt_boundary = parent -> dt_boundary ; else if ( parent -> dt_boundary != 0 ) newtag -> dt_boundary = ulmin ( parent -> dt_boundary , newtag -> dt_boundary ) ; atomic_add_int ( & parent -> dt_ref_count , 1 ) ; if ( newtag -> dt_boundary > 0 ) newtag -> dt_maxsegsz = ulmin ( newtag -> dt_maxsegsz , newtag -> dt_boundary ) ; * dmat = newtag ; return ( 0 ) ; }
Allocate a device specific dma_tag.
Allocate a device specific dma_tag .
/* Return a NULL tag on failure */ /* Enforce the usage of BUS_GET_DMA_TAG(). */ /*
	 * The method table pointer and the cookie need to be taken over from
	 * the parent.
	 */ /* Count ourselves */ /* Take into account any restrictions imposed by our parent tag. */