FreeBSD/sys/kern/subr_bus_dma.c
/*
 * Load up data starting at offset within a region specified by a
 * list of virtual address ranges until either length or the region
 * are exhausted.
 */
Load up data starting at offset within a region specified by a
list of virtual address ranges until either length or the region
are exhausted.
Load up data starting at offset within a region specified by a list of virtual address ranges until either length or the region are exhausted .
static int
_bus_dmamap_load_vlist(bus_dma_tag_t dmat, bus_dmamap_t map,
    bus_dma_segment_t *list, int sglist_cnt, struct pmap *pmap, int *nsegs,
    int flags, size_t offset, size_t length)
{
	int error;
	error = 0;
	for (; sglist_cnt > 0 && length != 0; sglist_cnt--, list++) {
		char *addr;
		size_t ds_len;
		KASSERT((offset < list->ds_len),
		    ("Invalid mid-segment offset"));
		addr = (char *)(uintptr_t)list->ds_addr + offset;
		ds_len = list->ds_len - offset;
		offset = 0;
		if (ds_len > length)
			ds_len = length;
		length -= ds_len;
		KASSERT((ds_len != 0), ("Segment length is zero"));
		error = _bus_dmamap_load_buffer(dmat, map, addr, ds_len, pmap,
		    flags, NULL, nsegs);
		if (error)
			break;
	}
	return (error);
}
static int _bus_dmamap_load_vlist ( bus_dma_tag_t dmat , bus_dmamap_t map , bus_dma_segment_t * list , int sglist_cnt , struct pmap * pmap , int * nsegs , int flags , size_t offset , size_t length ) { int error ; error = 0 ; for ( ; sglist_cnt > 0 && length != 0 ; sglist_cnt -- , list ++ ) { char * addr ; size_t ds_len ; KASSERT ( ( offset < list -> ds_len ) , ( " " ) ) ; addr = ( char * ) ( uintptr_t ) list -> ds_addr + offset ; ds_len = list -> ds_len - offset ; offset = 0 ; if ( ds_len > length ) ds_len = length ; length -= ds_len ; KASSERT ( ( ds_len != 0 ) , ( " " ) ) ; error = _bus_dmamap_load_buffer ( dmat , map , addr , ds_len , pmap , flags , NULL , nsegs ) ; if ( error ) break ; } return ( error ) ; }
Load up data starting at offset within a region specified by a
 list of virtual address ranges until either length or the region
 are exhausted.
Load up data starting at offset within a region specified by a list of virtual address ranges until either length or the region are exhausted .