dma-mapping.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_DMA_MAPPING_H
  3. #define _LINUX_DMA_MAPPING_H
  4. #ifdef CONFIG_HAS_DMA
  5. # error Virtio userspace code does not support CONFIG_HAS_DMA
  6. #endif
  7. enum dma_data_direction {
  8. DMA_BIDIRECTIONAL = 0,
  9. DMA_TO_DEVICE = 1,
  10. DMA_FROM_DEVICE = 2,
  11. DMA_NONE = 3,
  12. };
  13. #define dma_alloc_coherent(d, s, hp, f) ({ \
  14. void *__dma_alloc_coherent_p = kmalloc((s), (f)); \
  15. *(hp) = (unsigned long)__dma_alloc_coherent_p; \
  16. __dma_alloc_coherent_p; \
  17. })
  18. #define dma_free_coherent(d, s, p, h) kfree(p)
  19. #define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o))
  20. #define dma_map_page_attrs(d, p, o, s, dir, a) (page_to_phys(p) + (o))
  21. #define dma_map_single(d, p, s, dir) (virt_to_phys(p))
  22. #define dma_map_single_attrs(d, p, s, dir, a) (virt_to_phys(p))
  23. #define dma_mapping_error(...) (0)
  24. #define dma_unmap_single(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
  25. #define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
  26. #define dma_unmap_page_attrs(d, a, s, r, t) do { \
  27. (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
  28. } while (0)
  29. #define sg_dma_address(sg) (0)
  30. #define sg_dma_len(sg) (0)
  31. #define dma_need_sync(v, a) (0)
  32. #define dma_unmap_single_attrs(d, a, s, r, t) do { \
  33. (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
  34. } while (0)
  35. #define dma_sync_single_range_for_cpu(d, a, o, s, r) do { \
  36. (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \
  37. } while (0)
  38. #define dma_sync_single_range_for_device(d, a, o, s, r) do { \
  39. (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \
  40. } while (0)
  41. #define dma_max_mapping_size(...) SIZE_MAX
  42. /*
  43. * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
  44. * be given to a device to use as a DMA source or target. It is specific to a
  45. * given device and there may be a translation between the CPU physical address
  46. * space and the bus address space.
  47. *
  48. * DMA_MAPPING_ERROR is the magic error code if a mapping failed. It should not
  49. * be used directly in drivers, but checked for using dma_mapping_error()
  50. * instead.
  51. */
  52. #define DMA_MAPPING_ERROR (~(dma_addr_t)0)
  53. #endif