FreeBSD/sys/sparc64/sparc64/bus_machdep.c
/*
 * Utility function to load a linear buffer.  segp contains
 * the starting segment on entrace, and the ending segment on exit.
 */
Utility function to load a linear buffer.  segp contains
the starting segment on entrace, and the ending segment on exit.
Utility function to load a linear buffer . segp contains the starting segment on entrace and the ending segment on exit .
static int
nexus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
    bus_size_t buflen, pmap_t pmap, int flags, bus_dma_segment_t *segs,
    int *segp)
{
	bus_size_t sgsize;
	bus_addr_t curaddr;
	vm_offset_t vaddr = (vm_offset_t)buf;
	if (segs == NULL)
		segs = dmat->dt_segments;
	while (buflen > 0) {
		if (pmap == kernel_pmap)
			curaddr = pmap_kextract(vaddr);
		else
			curaddr = pmap_extract(pmap, vaddr);
		sgsize = PAGE_SIZE - ((u_long)curaddr & PAGE_MASK);
		if (sgsize > dmat->dt_maxsegsz)
			sgsize = dmat->dt_maxsegsz;
		if (buflen < sgsize)
			sgsize = buflen;
		sgsize = nexus_dmamap_addseg(dmat, map, curaddr, sgsize, segs,
		    segp);
		if (sgsize == 0)
			break;
		vaddr += sgsize;
		buflen -= sgsize;
	}
	return (buflen != 0 ? EFBIG : 0); 
}
static int nexus_dmamap_load_buffer ( bus_dma_tag_t dmat , bus_dmamap_t map , void * buf , bus_size_t buflen , pmap_t pmap , int flags , bus_dma_segment_t * segs , int * segp ) { bus_size_t sgsize ; bus_addr_t curaddr ; vm_offset_t vaddr = ( vm_offset_t ) buf ; if ( segs == NULL ) segs = dmat -> dt_segments ; while ( buflen > 0 ) { if ( pmap == kernel_pmap ) curaddr = pmap_kextract ( vaddr ) ; else curaddr = pmap_extract ( pmap , vaddr ) ; sgsize = PAGE_SIZE - ( ( u_long ) curaddr & PAGE_MASK ) ; if ( sgsize > dmat -> dt_maxsegsz ) sgsize = dmat -> dt_maxsegsz ; if ( buflen < sgsize ) sgsize = buflen ; sgsize = nexus_dmamap_addseg ( dmat , map , curaddr , sgsize , segs , segp ) ; if ( sgsize == 0 ) break ; vaddr += sgsize ; buflen -= sgsize ; } return ( buflen != 0 ? EFBIG : 0 ) ; }
Utility function to load a linear buffer.
Utility function to load a linear buffer .
/*
		 * Get the physical address for this segment.
		 */ /*
		 * Compute the segment size, and adjust counts.
		 */ /*
	 * Did we fit?
	 */ /* XXX better return value here? */