diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-x86_64/dma-mapping.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-x86_64/dma-mapping.h')
-rw-r--r-- | include/asm-x86_64/dma-mapping.h | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/include/asm-x86_64/dma-mapping.h b/include/asm-x86_64/dma-mapping.h new file mode 100644 index 000000000000..a416dc31634a --- /dev/null +++ b/include/asm-x86_64/dma-mapping.h | |||
@@ -0,0 +1,138 @@ | |||
1 | #ifndef _X8664_DMA_MAPPING_H | ||
2 | #define _X8664_DMA_MAPPING_H 1 | ||
3 | |||
4 | /* | ||
5 | * IOMMU interface. See Documentation/DMA-mapping.txt and DMA-API.txt for | ||
6 | * documentation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/config.h> | ||
10 | |||
11 | #include <asm/scatterlist.h> | ||
12 | #include <asm/io.h> | ||
13 | #include <asm/swiotlb.h> | ||
14 | |||
15 | extern dma_addr_t bad_dma_address; | ||
16 | #define dma_mapping_error(x) \ | ||
17 | (swiotlb ? swiotlb_dma_mapping_error(x) : ((x) == bad_dma_address)) | ||
18 | |||
19 | void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
20 | unsigned gfp); | ||
21 | void dma_free_coherent(struct device *dev, size_t size, void *vaddr, | ||
22 | dma_addr_t dma_handle); | ||
23 | |||
24 | #ifdef CONFIG_GART_IOMMU | ||
25 | |||
26 | extern dma_addr_t dma_map_single(struct device *hwdev, void *ptr, size_t size, | ||
27 | int direction); | ||
28 | extern void dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size, | ||
29 | int direction); | ||
30 | |||
31 | #else | ||
32 | |||
33 | /* No IOMMU */ | ||
34 | |||
35 | static inline dma_addr_t dma_map_single(struct device *hwdev, void *ptr, | ||
36 | size_t size, int direction) | ||
37 | { | ||
38 | dma_addr_t addr; | ||
39 | |||
40 | if (direction == DMA_NONE) | ||
41 | out_of_line_bug(); | ||
42 | addr = virt_to_bus(ptr); | ||
43 | |||
44 | if ((addr+size) & ~*hwdev->dma_mask) | ||
45 | out_of_line_bug(); | ||
46 | return addr; | ||
47 | } | ||
48 | |||
49 | static inline void dma_unmap_single(struct device *hwdev, dma_addr_t dma_addr, | ||
50 | size_t size, int direction) | ||
51 | { | ||
52 | if (direction == DMA_NONE) | ||
53 | out_of_line_bug(); | ||
54 | /* Nothing to do */ | ||
55 | } | ||
56 | |||
57 | #endif | ||
58 | |||
59 | #define dma_map_page(dev,page,offset,size,dir) \ | ||
60 | dma_map_single((dev), page_address(page)+(offset), (size), (dir)) | ||
61 | |||
62 | static inline void dma_sync_single_for_cpu(struct device *hwdev, | ||
63 | dma_addr_t dma_handle, | ||
64 | size_t size, int direction) | ||
65 | { | ||
66 | if (direction == DMA_NONE) | ||
67 | out_of_line_bug(); | ||
68 | |||
69 | if (swiotlb) | ||
70 | return swiotlb_sync_single_for_cpu(hwdev,dma_handle,size,direction); | ||
71 | |||
72 | flush_write_buffers(); | ||
73 | } | ||
74 | |||
75 | static inline void dma_sync_single_for_device(struct device *hwdev, | ||
76 | dma_addr_t dma_handle, | ||
77 | size_t size, int direction) | ||
78 | { | ||
79 | if (direction == DMA_NONE) | ||
80 | out_of_line_bug(); | ||
81 | |||
82 | if (swiotlb) | ||
83 | return swiotlb_sync_single_for_device(hwdev,dma_handle,size,direction); | ||
84 | |||
85 | flush_write_buffers(); | ||
86 | } | ||
87 | |||
88 | static inline void dma_sync_sg_for_cpu(struct device *hwdev, | ||
89 | struct scatterlist *sg, | ||
90 | int nelems, int direction) | ||
91 | { | ||
92 | if (direction == DMA_NONE) | ||
93 | out_of_line_bug(); | ||
94 | |||
95 | if (swiotlb) | ||
96 | return swiotlb_sync_sg_for_cpu(hwdev,sg,nelems,direction); | ||
97 | |||
98 | flush_write_buffers(); | ||
99 | } | ||
100 | |||
101 | static inline void dma_sync_sg_for_device(struct device *hwdev, | ||
102 | struct scatterlist *sg, | ||
103 | int nelems, int direction) | ||
104 | { | ||
105 | if (direction == DMA_NONE) | ||
106 | out_of_line_bug(); | ||
107 | |||
108 | if (swiotlb) | ||
109 | return swiotlb_sync_sg_for_device(hwdev,sg,nelems,direction); | ||
110 | |||
111 | flush_write_buffers(); | ||
112 | } | ||
113 | |||
114 | extern int dma_map_sg(struct device *hwdev, struct scatterlist *sg, | ||
115 | int nents, int direction); | ||
116 | extern void dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, | ||
117 | int nents, int direction); | ||
118 | |||
119 | #define dma_unmap_page dma_unmap_single | ||
120 | |||
121 | extern int dma_supported(struct device *hwdev, u64 mask); | ||
122 | extern int dma_get_cache_alignment(void); | ||
123 | #define dma_is_consistent(h) 1 | ||
124 | |||
125 | static inline int dma_set_mask(struct device *dev, u64 mask) | ||
126 | { | ||
127 | if (!dev->dma_mask || !dma_supported(dev, mask)) | ||
128 | return -EIO; | ||
129 | *dev->dma_mask = mask; | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | static inline void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir) | ||
134 | { | ||
135 | flush_write_buffers(); | ||
136 | } | ||
137 | |||
138 | #endif | ||