FreeBSD/sys/kern/subr_bus_dma.c
/*
 * Map the buffer buf into bus space using the dmamap map.
 */
Map the buffer buf into bus space using the dmamap map.
Map the buffer buf into bus space using the dmamap map .
int
bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
    bus_size_t buflen, bus_dmamap_callback_t *callback,
    void *callback_arg, int flags)
{
	bus_dma_segment_t *segs;
	struct memdesc mem;
	int error;
	int nsegs;
	if ((flags & BUS_DMA_NOWAIT) == 0) {
		mem = memdesc_vaddr(buf, buflen);
		_bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg);
	}
	nsegs = -1;
	error = _bus_dmamap_load_buffer(dmat, map, buf, buflen, kernel_pmap,
	    flags, NULL, &nsegs);
	nsegs++;
	CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d",
	    __func__, dmat, flags, error, nsegs);
	if (error == EINPROGRESS)
		return (error);
	segs = _bus_dmamap_complete(dmat, map, NULL, nsegs, error);
	if (error)
		(*callback)(callback_arg, segs, 0, error);
	else
		(*callback)(callback_arg, segs, nsegs, 0);
	if (error == ENOMEM)
		return (error);
	return (0);
}
int bus_dmamap_load ( bus_dma_tag_t dmat , bus_dmamap_t map , void * buf , bus_size_t buflen , bus_dmamap_callback_t * callback , void * callback_arg , int flags ) { bus_dma_segment_t * segs ; struct memdesc mem ; int error ; int nsegs ; if ( ( flags & BUS_DMA_NOWAIT ) == 0 ) { mem = memdesc_vaddr ( buf , buflen ) ; _bus_dmamap_waitok ( dmat , map , & mem , callback , callback_arg ) ; } nsegs = -1 ; error = _bus_dmamap_load_buffer ( dmat , map , buf , buflen , kernel_pmap , flags , NULL , & nsegs ) ; nsegs ++ ; CTR5 ( KTR_BUSDMA , " " , __func__ , dmat , flags , error , nsegs ) ; if ( error == EINPROGRESS ) return ( error ) ; segs = _bus_dmamap_complete ( dmat , map , NULL , nsegs , error ) ; if ( error ) ( * callback ) ( callback_arg , segs , 0 , error ) ; else ( * callback ) ( callback_arg , segs , nsegs , 0 ) ; if ( error == ENOMEM ) return ( error ) ; return ( 0 ) ; }
Map the buffer buf into bus space using the dmamap map.
Map the buffer buf into bus space using the dmamap map .
/*
	 * Return ENOMEM to the caller so that it can pass it up the stack.
	 * This error only happens when NOWAIT is set, so deferral is disabled.
	 */