1 #include <linux/bootmem.h>
3 #include <linux/export.h>
4 #include <linux/slab.h>
5 #include <linux/types.h>
6 #include <linux/dma-mapping.h>
7 #include <linux/vmalloc.h>
8 #include <linux/swiotlb.h>
11 #include <xen/interface/memory.h>
12 #include <xen/swiotlb-xen.h>
14 #include <asm/cacheflush.h>
15 #include <asm/xen/page.h>
16 #include <asm/xen/hypercall.h>
17 #include <asm/xen/interface.h>
19 int xen_create_contiguous_region(phys_addr_t pstart
, unsigned int order
,
20 unsigned int address_bits
,
21 dma_addr_t
*dma_handle
)
23 if (!xen_initial_domain())
26 /* we assume that dom0 is mapped 1:1 for now */
30 EXPORT_SYMBOL_GPL(xen_create_contiguous_region
);
32 void xen_destroy_contiguous_region(phys_addr_t pstart
, unsigned int order
)
36 EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region
);
38 struct dma_map_ops
*xen_dma_ops
;
39 EXPORT_SYMBOL_GPL(xen_dma_ops
);
41 static struct dma_map_ops xen_swiotlb_dma_ops
= {
42 .mapping_error
= xen_swiotlb_dma_mapping_error
,
43 .alloc
= xen_swiotlb_alloc_coherent
,
44 .free
= xen_swiotlb_free_coherent
,
45 .sync_single_for_cpu
= xen_swiotlb_sync_single_for_cpu
,
46 .sync_single_for_device
= xen_swiotlb_sync_single_for_device
,
47 .sync_sg_for_cpu
= xen_swiotlb_sync_sg_for_cpu
,
48 .sync_sg_for_device
= xen_swiotlb_sync_sg_for_device
,
49 .map_sg
= xen_swiotlb_map_sg_attrs
,
50 .unmap_sg
= xen_swiotlb_unmap_sg_attrs
,
51 .map_page
= xen_swiotlb_map_page
,
52 .unmap_page
= xen_swiotlb_unmap_page
,
53 .dma_supported
= xen_swiotlb_dma_supported
,
54 .set_dma_mask
= xen_swiotlb_set_dma_mask
,
57 int __init
xen_mm_init(void)
59 if (!xen_initial_domain())
61 xen_swiotlb_init(1, false);
62 xen_dma_ops
= &xen_swiotlb_dma_ops
;
65 arch_initcall(xen_mm_init
);