FreeBSD/sys/mips/mips/busdma_machdep.c
/*
 * Add a single contiguous physical range to the segment list.
 */
Add a single contiguous physical range to the segment list.
Add a single contiguous physical range to the segment list .
static int
_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
    bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
{
	bus_addr_t baddr, bmask;
	int seg;
	bmask = ~(dmat->boundary - 1);
	if (dmat->boundary > 0) {
		baddr = (curaddr + dmat->boundary) & bmask;
		if (sgsize > (baddr - curaddr))
			sgsize = (baddr - curaddr);
	}
	seg = *segp;
	if (seg >= 0 &&
	    curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
	    (segs[seg].ds_len + sgsize) <= dmat->maxsegsz &&
	    (dmat->boundary == 0 ||
	     (segs[seg].ds_addr & bmask) == (curaddr & bmask))) {
		segs[seg].ds_len += sgsize;
	} else {
		if (++seg >= dmat->nsegments)
			return (0);
		segs[seg].ds_addr = curaddr;
		segs[seg].ds_len = sgsize;
	}
	*segp = seg;
	return (sgsize);
}
static int _bus_dmamap_addseg ( bus_dma_tag_t dmat , bus_dmamap_t map , bus_addr_t curaddr , bus_size_t sgsize , bus_dma_segment_t * segs , int * segp ) { bus_addr_t baddr , bmask ; int seg ; bmask = ~ ( dmat -> boundary - 1 ) ; if ( dmat -> boundary > 0 ) { baddr = ( curaddr + dmat -> boundary ) & bmask ; if ( sgsize > ( baddr - curaddr ) ) sgsize = ( baddr - curaddr ) ; } seg = * segp ; if ( seg >= 0 && curaddr == segs [ seg ] . ds_addr + segs [ seg ] . ds_len && ( segs [ seg ] . ds_len + sgsize ) <= dmat -> maxsegsz && ( dmat -> boundary == 0 || ( segs [ seg ] . ds_addr & bmask ) == ( curaddr & bmask ) ) ) { segs [ seg ] . ds_len += sgsize ; } else { if ( ++ seg >= dmat -> nsegments ) return ( 0 ) ; segs [ seg ] . ds_addr = curaddr ; segs [ seg ] . ds_len = sgsize ; } * segp = seg ; return ( sgsize ) ; }
Add a single contiguous physical range to the segment list.
Add a single contiguous physical range to the segment list .
/*
	 * Make sure we don't cross any boundaries.
	 */ /*
	 * Insert chunk into a segment, coalescing with
	 * the previous segment if possible.
	 */