Subversion Repositories Kolibri OS

Rev

Rev 4568 | Rev 6588 | Go to most recent revision | 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-direction.h>
  9. #include <linux/scatterlist.h>
  10.  
  11. extern void *
  12. dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
  13.                    gfp_t flag);
  14. #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
  15.  
  16. #define DMA_MASK_NONE   0x0ULL
  17.  
  18. static inline int valid_dma_direction(int dma_direction)
  19. {
  20.         return ((dma_direction == DMA_BIDIRECTIONAL) ||
  21.                 (dma_direction == DMA_TO_DEVICE) ||
  22.                 (dma_direction == DMA_FROM_DEVICE));
  23. }
  24.  
  25. static inline int is_device_dma_capable(struct device *dev)
  26. {
  27.         return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
  28. }
  29. #ifndef dma_max_pfn
  30. static inline unsigned long dma_max_pfn(struct device *dev)
  31. {
  32.         return *dev->dma_mask >> PAGE_SHIFT;
  33. }
  34. #endif
  35.  
  36. static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
  37.                                         dma_addr_t *dma_handle, gfp_t flag)
  38. {
  39.         void *ret = dma_alloc_coherent(dev, size, dma_handle,
  40.                                        flag | __GFP_ZERO);
  41.         return ret;
  42. }
  43.  
  44. #endif
  45.