head/sys/mips/mips/busdma_machdep.c
/*
 * Utility function to load a physical buffer.  segp contains
 * the starting segment on entrace, and the ending segment on exit.
 */
Utility function to load a physical buffer.  segp contains
the starting segment on entrace, and the ending segment on exit.
Utility function to load a physical buffer . segp contains the starting segment on entrace and the ending segment on exit .
int
_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
    vm_paddr_t buf, bus_size_t buflen, int flags, bus_dma_segment_t *segs,
    int *segp)
{
	bus_addr_t curaddr;
	bus_size_t sgsize;
	int error;
	if (segs == NULL)
		segs = dmat->segments;
	if ((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) {
		_bus_dmamap_count_phys(dmat, map, buf, buflen, flags);
		if (map->pagesneeded != 0) {
			error = _bus_dmamap_reserve_pages(dmat, map, flags);
			if (error)
				return (error);
		}
	}
	while (buflen > 0) {
		curaddr = buf;
		sgsize = MIN(buflen, dmat->maxsegsz);
		if (((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) &&
		    map->pagesneeded != 0 && run_filter(dmat, curaddr)) {
			sgsize = MIN(sgsize, PAGE_SIZE);
			curaddr = add_bounce_page(dmat, map, 0, curaddr,
			    sgsize);
		}
		sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs,
		    segp);
		if (sgsize == 0)
			break;
		buf += sgsize;
		buflen -= sgsize;
	}
	if (buflen != 0) {
		_bus_dmamap_unload(dmat, map);
		return (EFBIG); 
	}
	return (0);
}
int _bus_dmamap_load_phys ( bus_dma_tag_t dmat , bus_dmamap_t map , vm_paddr_t buf , bus_size_t buflen , int flags , bus_dma_segment_t * segs , int * segp ) { bus_addr_t curaddr ; bus_size_t sgsize ; int error ; if ( segs == NULL ) segs = dmat -> segments ; if ( ( dmat -> flags & BUS_DMA_COULD_BOUNCE ) != 0 ) { _bus_dmamap_count_phys ( dmat , map , buf , buflen , flags ) ; if ( map -> pagesneeded != 0 ) { error = _bus_dmamap_reserve_pages ( dmat , map , flags ) ; if ( error ) return ( error ) ; } } while ( buflen > 0 ) { curaddr = buf ; sgsize = MIN ( buflen , dmat -> maxsegsz ) ; if ( ( ( dmat -> flags & BUS_DMA_COULD_BOUNCE ) != 0 ) && map -> pagesneeded != 0 && run_filter ( dmat , curaddr ) ) { sgsize = MIN ( sgsize , PAGE_SIZE ) ; curaddr = add_bounce_page ( dmat , map , 0 , curaddr , sgsize ) ; } sgsize = _bus_dmamap_addseg ( dmat , map , curaddr , sgsize , segs , segp ) ; if ( sgsize == 0 ) break ; buf += sgsize ; buflen -= sgsize ; } if ( buflen != 0 ) { _bus_dmamap_unload ( dmat , map ) ; return ( EFBIG ) ; } return ( 0 ) ; }
Utility function to load a physical buffer.
Utility function to load a physical buffer .
/*
	 * Did we fit?
	 */ /* XXX better return value here? */