aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/virtio/linux/dma-mapping.h
blob: 822ecaa8e4df26f3e5881ee31d68cc7d12218f1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_DMA_MAPPING_H
#define _LINUX_DMA_MAPPING_H

#ifdef CONFIG_HAS_DMA
# error Virtio userspace code does not support CONFIG_HAS_DMA
#endif

enum dma_data_direction {
	DMA_BIDIRECTIONAL = 0,
	DMA_TO_DEVICE = 1,
	DMA_FROM_DEVICE = 2,
	DMA_NONE = 3,
};

#define dma_alloc_coherent(d, s, hp, f) ({ \
	void *__dma_alloc_coherent_p = kmalloc((s), (f)); \
	*(hp) = (unsigned long)__dma_alloc_coherent_p; \
	__dma_alloc_coherent_p; \
})

#define dma_free_coherent(d, s, p, h) kfree(p)

#define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o))

#define dma_map_single(d, p, s, dir) (virt_to_phys(p))
#define dma_map_single_attrs(d, p, s, dir, a) (virt_to_phys(p))
#define dma_mapping_error(...) (0)

#define dma_unmap_single(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
#define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)

#define sg_dma_address(sg) (0)
#define dma_need_sync(v, a) (0)
#define dma_unmap_single_attrs(d, a, s, r, t) do { \
	(void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
} while (0)
#define dma_sync_single_range_for_cpu(d, a, o, s, r) do { \
	(void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \
} while (0)
#define dma_sync_single_range_for_device(d, a, o, s, r) do { \
	(void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \
} while (0)
#define dma_max_mapping_size(...) SIZE_MAX

#endif