1 #ifndef _LINUX_DMA_MAPPING_H
2 #define _LINUX_DMA_MAPPING_H
4 #include <linux/string.h>
5 #include <linux/device.h>
53 #ifdef ARCH_HAS_DMA_GET_REQUIRED_MASK
59 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
61 #define DMA_MASK_NONE 0x0ULL
63 static inline int valid_dma_direction(
int dma_direction)
70 static inline int is_device_dma_capable(
struct device *
dev)
76 #include <asm/dma-mapping.h>
88 #ifdef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
102 static inline unsigned int dma_get_max_seg_size(
struct device *dev)
107 static inline unsigned int dma_set_max_seg_size(
struct device *dev,
117 static inline unsigned long dma_get_seg_boundary(
struct device *dev)
120 dev->
dma_parms->segment_boundary_mask : 0xffffffff;
123 static inline int dma_set_seg_boundary(
struct device *dev,
unsigned long mask)
132 static inline void *dma_zalloc_coherent(
struct device *dev,
size_t size,
141 #ifdef CONFIG_HAS_DMA
144 #ifdef ARCH_DMA_MINALIGN
152 #define DMA_MEMORY_MAP 0x01
153 #define DMA_MEMORY_IO 0x02
154 #define DMA_MEMORY_INCLUDES_CHILDREN 0x04
155 #define DMA_MEMORY_EXCLUSIVE 0x08
157 #ifndef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
174 return ERR_PTR(-
EBUSY);
189 #ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
190 extern int dmam_declare_coherent_memory(
struct device *dev,
dma_addr_t bus_addr,
193 extern void dmam_release_declared_memory(
struct device *dev);
195 static inline int dmam_declare_coherent_memory(
struct device *dev,
197 size_t size,
gfp_t gfp)
202 static inline void dmam_release_declared_memory(
struct device *dev)
207 #ifndef CONFIG_HAVE_DMA_ATTRS
210 #define dma_map_single_attrs(dev, cpu_addr, size, dir, attrs) \
211 dma_map_single(dev, cpu_addr, size, dir)
213 #define dma_unmap_single_attrs(dev, dma_addr, size, dir, attrs) \
214 dma_unmap_single(dev, dma_addr, size, dir)
216 #define dma_map_sg_attrs(dev, sgl, nents, dir, attrs) \
217 dma_map_sg(dev, sgl, nents, dir)
219 #define dma_unmap_sg_attrs(dev, sgl, nents, dir, attrs) \
220 dma_unmap_sg(dev, sgl, nents, dir)
224 #ifdef CONFIG_NEED_DMA_MAP_STATE
225 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME
226 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME
227 #define dma_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
228 #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
229 #define dma_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
230 #define dma_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
232 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
233 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
234 #define dma_unmap_addr(PTR, ADDR_NAME) (0)
235 #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
236 #define dma_unmap_len(PTR, LEN_NAME) (0)
237 #define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)