aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/dma.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/dma.h')
-rw-r--r--drivers/ieee1394/dma.h90
1 files changed, 56 insertions, 34 deletions
diff --git a/drivers/ieee1394/dma.h b/drivers/ieee1394/dma.h
index 061550a6fb99..a1682aba71c7 100644
--- a/drivers/ieee1394/dma.h
+++ b/drivers/ieee1394/dma.h
@@ -10,69 +10,91 @@
10#ifndef IEEE1394_DMA_H 10#ifndef IEEE1394_DMA_H
11#define IEEE1394_DMA_H 11#define IEEE1394_DMA_H
12 12
13#include <linux/pci.h> 13#include <asm/types.h>
14#include <asm/scatterlist.h> 14
15 15struct pci_dev;
16/* struct dma_prog_region 16struct scatterlist;
17 17struct vm_area_struct;
18 a small, physically-contiguous DMA buffer with random-access, 18
19 synchronous usage characteristics 19/**
20*/ 20 * struct dma_prog_region - small contiguous DMA buffer
21 21 * @kvirt: kernel virtual address
22 * @dev: PCI device
23 * @n_pages: number of kernel pages
24 * @bus_addr: base bus address
25 *
26 * a small, physically contiguous DMA buffer with random-access, synchronous
27 * usage characteristics
28 */
22struct dma_prog_region { 29struct dma_prog_region {
23 unsigned char *kvirt; /* kernel virtual address */ 30 unsigned char *kvirt;
24 struct pci_dev *dev; /* PCI device */ 31 struct pci_dev *dev;
25 unsigned int n_pages; /* # of kernel pages */ 32 unsigned int n_pages;
26 dma_addr_t bus_addr; /* base bus address */ 33 dma_addr_t bus_addr;
27}; 34};
28 35
29/* clear out all fields but do not allocate any memory */ 36/* clear out all fields but do not allocate any memory */
30void dma_prog_region_init(struct dma_prog_region *prog); 37void dma_prog_region_init(struct dma_prog_region *prog);
31int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, struct pci_dev *dev); 38int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes,
39 struct pci_dev *dev);
32void dma_prog_region_free(struct dma_prog_region *prog); 40void dma_prog_region_free(struct dma_prog_region *prog);
33 41
34static inline dma_addr_t dma_prog_region_offset_to_bus(struct dma_prog_region *prog, unsigned long offset) 42static inline dma_addr_t dma_prog_region_offset_to_bus(
43 struct dma_prog_region *prog, unsigned long offset)
35{ 44{
36 return prog->bus_addr + offset; 45 return prog->bus_addr + offset;
37} 46}
38 47
39/* struct dma_region 48/**
40 49 * struct dma_region - large non-contiguous DMA buffer
41 a large, non-physically-contiguous DMA buffer with streaming, 50 * @virt: kernel virtual address
42 asynchronous usage characteristics 51 * @dev: PCI device
43*/ 52 * @n_pages: number of kernel pages
44 53 * @n_dma_pages: number of IOMMU pages
54 * @sglist: IOMMU mapping
55 * @direction: PCI_DMA_TODEVICE, etc.
56 *
57 * a large, non-physically-contiguous DMA buffer with streaming, asynchronous
58 * usage characteristics
59 */
45struct dma_region { 60struct dma_region {
46 unsigned char *kvirt; /* kernel virtual address */ 61 unsigned char *kvirt;
47 struct pci_dev *dev; /* PCI device */ 62 struct pci_dev *dev;
48 unsigned int n_pages; /* # of kernel pages */ 63 unsigned int n_pages;
49 unsigned int n_dma_pages; /* # of IOMMU pages */ 64 unsigned int n_dma_pages;
50 struct scatterlist *sglist; /* IOMMU mapping */ 65 struct scatterlist *sglist;
51 int direction; /* PCI_DMA_TODEVICE, etc */ 66 int direction;
52}; 67};
53 68
54/* clear out all fields but do not allocate anything */ 69/* clear out all fields but do not allocate anything */
55void dma_region_init(struct dma_region *dma); 70void dma_region_init(struct dma_region *dma);
56 71
57/* allocate the buffer and map it to the IOMMU */ 72/* allocate the buffer and map it to the IOMMU */
58int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_dev *dev, int direction); 73int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes,
74 struct pci_dev *dev, int direction);
59 75
60/* unmap and free the buffer */ 76/* unmap and free the buffer */
61void dma_region_free(struct dma_region *dma); 77void dma_region_free(struct dma_region *dma);
62 78
63/* sync the CPU's view of the buffer */ 79/* sync the CPU's view of the buffer */
64void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsigned long len); 80void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset,
81 unsigned long len);
82
65/* sync the IO bus' view of the buffer */ 83/* sync the IO bus' view of the buffer */
66void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len); 84void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset,
85 unsigned long len);
67 86
68/* map the buffer into a user space process */ 87/* map the buffer into a user space process */
69int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma); 88int dma_region_mmap(struct dma_region *dma, struct file *file,
89 struct vm_area_struct *vma);
70 90
71/* macro to index into a DMA region (or dma_prog_region) */ 91/* macro to index into a DMA region (or dma_prog_region) */
72#define dma_region_i(_dma, _type, _index) ( ((_type*) ((_dma)->kvirt)) + (_index) ) 92#define dma_region_i(_dma, _type, _index) \
93 ( ((_type*) ((_dma)->kvirt)) + (_index) )
73 94
74/* return the DMA bus address of the byte with the given offset 95/* return the DMA bus address of the byte with the given offset
75 relative to the beginning of the dma_region */ 96 * relative to the beginning of the dma_region */
76dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset); 97dma_addr_t dma_region_offset_to_bus(struct dma_region *dma,
98 unsigned long offset);
77 99
78#endif /* IEEE1394_DMA_H */ 100#endif /* IEEE1394_DMA_H */