Subversion Repositories Kolibri OS

Rev

Rev 6588 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef _LINUX_DMA_MAPPING_H
  2. #define _LINUX_DMA_MAPPING_H
  3.  
  4. #include <linux/sizes.h>
  5. #include <linux/string.h>
  6. #include <linux/device.h>
  7. #include <linux/err.h>
  8. #include <linux/dma-attrs.h>
  9. #include <linux/dma-direction.h>
  10. #include <linux/scatterlist.h>
  11. #include <linux/bug.h>
  12.  
  13. extern void *
  14. dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
  15.                    gfp_t flag);
  16. #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
  17.  
  18. #define DMA_MASK_NONE   0x0ULL
  19.  
  20. static inline int valid_dma_direction(int dma_direction)
  21. {
  22.         return ((dma_direction == DMA_BIDIRECTIONAL) ||
  23.                 (dma_direction == DMA_TO_DEVICE) ||
  24.                 (dma_direction == DMA_FROM_DEVICE));
  25. }
  26.  
  27. static inline int is_device_dma_capable(struct device *dev)
  28. {
  29.         return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
  30. }
  31.  
  32. #ifdef CONFIG_HAS_DMA
  33. #include <asm/dma-mapping.h>
  34. #else
  35. #include <asm-generic/dma-mapping-broken.h>
  36. #endif
  37. #ifndef dma_max_pfn
  38. static inline unsigned long dma_max_pfn(struct device *dev)
  39. {
  40.         return *dev->dma_mask >> PAGE_SHIFT;
  41. }
  42. #endif
  43.  
  44. static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
  45.                                         dma_addr_t *dma_handle, gfp_t flag)
  46. {
  47.         void *ret = dma_alloc_coherent(dev, size, dma_handle,
  48.                                        flag | __GFP_ZERO);
  49.         return ret;
  50. }
  51.  
  52. #endif
  53.