FreeBSD/sys/sparc64/sparc64/bus_machdep.c
/*
 * Common function for DMA-safe memory allocation.  May be called
 * by bus-specific DMA memory allocation functions.
 */
Common function for DMA-safe memory allocation.  May be called
by bus-specific DMA memory allocation functions.
Common function for DMA - safe memory allocation . May be called by bus - specific DMA memory allocation functions .
static int
nexus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
    bus_dmamap_t *mapp)
{
	int mflags;
	if (flags & BUS_DMA_NOWAIT)
		mflags = M_NOWAIT;
	else
		mflags = M_WAITOK;
	if (flags & BUS_DMA_ZERO)
		mflags |= M_ZERO;
	if (dmat->dt_maxsize <= PAGE_SIZE &&
	    dmat->dt_alignment <= dmat->dt_maxsize)
		*vaddr = malloc(dmat->dt_maxsize, M_DEVBUF, mflags);
	else {
		*vaddr = contigmalloc(dmat->dt_maxsize, M_DEVBUF, mflags,
		    0ul, dmat->dt_lowaddr,
		    dmat->dt_alignment ? dmat->dt_alignment : 1UL,
		    dmat->dt_boundary);
	}
	if (*vaddr == NULL)
		return (ENOMEM);
	if (vtophys(*vaddr) % dmat->dt_alignment)
		printf("%s: failed to align memory properly.\n", __func__);
	return (0);
}
static int nexus_dmamem_alloc ( bus_dma_tag_t dmat , void * * vaddr , int flags , bus_dmamap_t * mapp ) { int mflags ; if ( flags & BUS_DMA_NOWAIT ) mflags = M_NOWAIT ; else mflags = M_WAITOK ; if ( flags & BUS_DMA_ZERO ) mflags |= M_ZERO ; if ( dmat -> dt_maxsize <= PAGE_SIZE && dmat -> dt_alignment <= dmat -> dt_maxsize ) * vaddr = malloc ( dmat -> dt_maxsize , M_DEVBUF , mflags ) ; else { * vaddr = contigmalloc ( dmat -> dt_maxsize , M_DEVBUF , mflags , 0ul , dmat -> dt_lowaddr , dmat -> dt_alignment ? dmat -> dt_alignment : 1UL , dmat -> dt_boundary ) ; } if ( * vaddr == NULL ) return ( ENOMEM ) ; if ( vtophys ( * vaddr ) % dmat -> dt_alignment ) printf ( " \n " , __func__ ) ; return ( 0 ) ; }
Common function for DMA-safe memory allocation.
Common function for DMA - safe memory allocation .
/*
	 * XXX:
	 * (dmat->dt_alignment <= dmat->dt_maxsize) is just a quick hack; the
	 * exact alignment guarantees of malloc need to be nailed down, and
	 * the code below should be rewritten to take that into account.
	 *
	 * In the meantime, we'll warn the user if malloc gets it wrong.
	 */ /*
		 * XXX use contigmalloc until it is merged into this
		 * facility and handles multi-seg allocations.  Nobody
		 * is doing multi-seg allocations yet though.
		 */