]> err.no Git - linux-2.6/blob - include/asm-x86/dma-mapping_32.h
x86: move dma_unmap_sg to common header
[linux-2.6] / include / asm-x86 / dma-mapping_32.h
1 #ifndef _ASM_I386_DMA_MAPPING_H
2 #define _ASM_I386_DMA_MAPPING_H
3
4 #include <linux/mm.h>
5 #include <linux/scatterlist.h>
6
7 #include <asm/cache.h>
8 #include <asm/io.h>
9 #include <asm/bug.h>
10
11 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
12 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
13
14 void *dma_alloc_coherent(struct device *dev, size_t size,
15                            dma_addr_t *dma_handle, gfp_t flag);
16
17 void dma_free_coherent(struct device *dev, size_t size,
18                          void *vaddr, dma_addr_t dma_handle);
19
20 static inline dma_addr_t
21 dma_map_page(struct device *dev, struct page *page, unsigned long offset,
22              size_t size, enum dma_data_direction direction)
23 {
24         BUG_ON(!valid_dma_direction(direction));
25         return page_to_phys(page) + offset;
26 }
27
28 static inline void
29 dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
30                enum dma_data_direction direction)
31 {
32         BUG_ON(!valid_dma_direction(direction));
33 }
34
35 static inline void
36 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
37                         enum dma_data_direction direction)
38 {
39 }
40
41 static inline void
42 dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
43                         enum dma_data_direction direction)
44 {
45         flush_write_buffers();
46 }
47
48 static inline void
49 dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
50                               unsigned long offset, size_t size,
51                               enum dma_data_direction direction)
52 {
53 }
54
55 static inline void
56 dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
57                                  unsigned long offset, size_t size,
58                                  enum dma_data_direction direction)
59 {
60         flush_write_buffers();
61 }
62
63 static inline void
64 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
65                     enum dma_data_direction direction)
66 {
67 }
68
69 static inline void
70 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
71                     enum dma_data_direction direction)
72 {
73         flush_write_buffers();
74 }
75
76 static inline int
77 dma_mapping_error(dma_addr_t dma_addr)
78 {
79         return 0;
80 }
81
82 extern int forbid_dac;
83
84 static inline int
85 dma_supported(struct device *dev, u64 mask)
86 {
87         /*
88          * we fall back to GFP_DMA when the mask isn't all 1s,
89          * so we can't guarantee allocations that must be
90          * within a tighter range than GFP_DMA..
91          */
92         if(mask < 0x00ffffff)
93                 return 0;
94
95         /* Work around chipset bugs */
96         if (forbid_dac > 0 && mask > 0xffffffffULL)
97                 return 0;
98
99         return 1;
100 }
101
102 static inline int
103 dma_set_mask(struct device *dev, u64 mask)
104 {
105         if(!dev->dma_mask || !dma_supported(dev, mask))
106                 return -EIO;
107
108         *dev->dma_mask = mask;
109
110         return 0;
111 }
112
113 static inline int
114 dma_get_cache_alignment(void)
115 {
116         /* no easy way to get cache size on all x86, so return the
117          * maximum possible, to be safe */
118         return (1 << INTERNODE_CACHE_SHIFT);
119 }
120
121 #define dma_is_consistent(d, h) (1)
122
123 static inline void
124 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
125                enum dma_data_direction direction)
126 {
127         flush_write_buffers();
128 }
129
130 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
131 extern int
132 dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
133                             dma_addr_t device_addr, size_t size, int flags);
134
135 extern void
136 dma_release_declared_memory(struct device *dev);
137
138 extern void *
139 dma_mark_declared_memory_occupied(struct device *dev,
140                                   dma_addr_t device_addr, size_t size);
141
142 #endif