generic: add common struct for dma map operations
[linux-2.6.git] / arch / ia64 / dig / dig_vtd_iommu.c
1 #include <linux/types.h>
2 #include <linux/kernel.h>
3 #include <linux/module.h>
4 #include <linux/dma-mapping.h>
5 #include <linux/intel-iommu.h>
6
7 void *
8 vtd_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
9                  gfp_t flags)
10 {
11         return intel_alloc_coherent(dev, size, dma_handle, flags);
12 }
13 EXPORT_SYMBOL_GPL(vtd_alloc_coherent);
14
15 void
16 vtd_free_coherent(struct device *dev, size_t size, void *vaddr,
17                  dma_addr_t dma_handle)
18 {
19         intel_free_coherent(dev, size, vaddr, dma_handle);
20 }
21 EXPORT_SYMBOL_GPL(vtd_free_coherent);
22
23 dma_addr_t
24 vtd_map_single_attrs(struct device *dev, void *addr, size_t size,
25                      int dir, struct dma_attrs *attrs)
26 {
27         return intel_map_single(dev, (phys_addr_t)addr, size, dir);
28 }
29 EXPORT_SYMBOL_GPL(vtd_map_single_attrs);
30
31 void
32 vtd_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size,
33                        int dir, struct dma_attrs *attrs)
34 {
35         intel_unmap_single(dev, iova, size, dir);
36 }
37 EXPORT_SYMBOL_GPL(vtd_unmap_single_attrs);
38
39 int
40 vtd_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents,
41                  int dir, struct dma_attrs *attrs)
42 {
43         return intel_map_sg(dev, sglist, nents, dir);
44 }
45 EXPORT_SYMBOL_GPL(vtd_map_sg_attrs);
46
47 void
48 vtd_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist,
49                    int nents, int dir, struct dma_attrs *attrs)
50 {
51         intel_unmap_sg(dev, sglist, nents, dir);
52 }
53 EXPORT_SYMBOL_GPL(vtd_unmap_sg_attrs);
54
55 int
56 vtd_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
57 {
58         return 0;
59 }
60 EXPORT_SYMBOL_GPL(vtd_dma_mapping_error);
61
62 extern int iommu_dma_supported(struct device *dev, u64 mask);
63
64 struct dma_mapping_ops vtd_dma_ops = {
65         .alloc_coherent         = vtd_alloc_coherent,
66         .free_coherent          = vtd_free_coherent,
67         .map_single_attrs       = vtd_map_single_attrs,
68         .unmap_single_attrs     = vtd_unmap_single_attrs,
69         .map_sg_attrs           = vtd_map_sg_attrs,
70         .unmap_sg_attrs         = vtd_unmap_sg_attrs,
71         .sync_single_for_cpu    = machvec_dma_sync_single,
72         .sync_sg_for_cpu        = machvec_dma_sync_sg,
73         .sync_single_for_device = machvec_dma_sync_single,
74         .sync_sg_for_device     = machvec_dma_sync_sg,
75         .dma_supported_op       = iommu_dma_supported,
76         .mapping_error          = vtd_dma_mapping_error,
77 };