dma-mapping_32.h 3.3 KB

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