kernels/linux-2.4.0/arch/ia64/lib/swiotlb.c
/*
 * Map a set of buffers described by scatterlist in streaming mode for DMA.  This is the
 * scather-gather version of the above swiotlb_map_single interface.  Here the scatter
 * gather list elements are each tagged with the appropriate dma address and length.  They
 * are obtained via sg_dma_{address,length}(SG).
 *
 * NOTE: An implementation may be able to use a smaller number of
 *       DMA address/length pairs than there are SG table elements.
 *       (for example via virtual mapping capabilities)
 *       The routine returns the number of addr/length pairs actually
 *       used, at most nents.
 *
 * Device ownership issues as mentioned above for swiotlb_map_single are the same here.
 */
Map a set of buffers described by scatterlist in streaming mode for DMA.  This is the
scather-gather version of the above swiotlb_map_single interface.  Here the scatter
gather list elements are each tagged with the appropriate dma address and length.  They
are obtained via sg_dma_{address,length}(SG).

An implementation may be able to use a smaller number of
DMA address/length pairs than there are SG table elements.
(for example via virtual mapping capabilities)
The routine returns the number of addr/length pairs actually
used, at most nents.

Device ownership issues as mentioned above for swiotlb_map_single are the same here.
Map a set of buffers described by scatterlist in streaming mode for DMA . This is the scather - gather version of the above swiotlb_map_single interface . Here the scatter gather list elements are each tagged with the appropriate dma address and length . They are obtained via sg_dma_ { address length } ( SG ) . An implementation may be able to use a smaller number of DMA address / length pairs than there are SG table elements . ( for example via virtual mapping capabilities ) The routine returns the number of addr / length pairs actually used at most nents . Device ownership issues as mentioned above for swiotlb_map_single are the same here .
int
swiotlb_map_sg (struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction)
{
	int i;
	if (direction == PCI_DMA_NONE)
		BUG();
	for (i = 0; i < nelems; i++, sg++) {
		sg->orig_address = sg->address;
		if ((virt_to_phys(sg->address) & ~hwdev->dma_mask) != 0) {
			sg->address = map_single(hwdev, sg->address, sg->length, direction);
		}
	}
	return nelems;
}
int swiotlb_map_sg ( struct pci_dev * hwdev , struct scatterlist * sg , int nelems , int direction ) { int i ; if ( direction == PCI_DMA_NONE ) BUG ( ) ; for ( i = 0 ; i < nelems ; i ++ , sg ++ ) { sg -> orig_address = sg -> address ; if ( ( virt_to_phys ( sg -> address ) & ~ hwdev -> dma_mask ) != 0 ) { sg -> address = map_single ( hwdev , sg -> address , sg -> length , direction ) ; } } return nelems ; }
Map a set of buffers described by scatterlist in streaming mode for DMA.
Map a set of buffers described by scatterlist in streaming mode for DMA .