blob: b0e77de9914866e19fb69ab28f9cd674d7e7f57d [file] [log] [blame]
Stefano Stabellini83862cc2013-10-10 13:40:44 +00001#include <linux/bootmem.h>
2#include <linux/gfp.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>
9
10#include <xen/xen.h>
11#include <xen/interface/memory.h>
12#include <xen/swiotlb-xen.h>
13
14#include <asm/cacheflush.h>
15#include <asm/xen/page.h>
16#include <asm/xen/hypercall.h>
17#include <asm/xen/interface.h>
18
Stefano Stabellini1b65c4e2013-10-10 13:41:10 +000019int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
Stefano Stabellini83862cc2013-10-10 13:40:44 +000020 unsigned int address_bits,
21 dma_addr_t *dma_handle)
22{
23 if (!xen_initial_domain())
24 return -EINVAL;
25
26 /* we assume that dom0 is mapped 1:1 for now */
Stefano Stabellini1b65c4e2013-10-10 13:41:10 +000027 *dma_handle = pstart;
Stefano Stabellini83862cc2013-10-10 13:40:44 +000028 return 0;
29}
30EXPORT_SYMBOL_GPL(xen_create_contiguous_region);
31
Stefano Stabellini1b65c4e2013-10-10 13:41:10 +000032void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
Stefano Stabellini83862cc2013-10-10 13:40:44 +000033{
34 return;
35}
36EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
37
38struct dma_map_ops *xen_dma_ops;
39EXPORT_SYMBOL_GPL(xen_dma_ops);
40
41static 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,
Stefano Stabellinieb1ddc02013-10-09 16:56:33 +000054 .set_dma_mask = xen_swiotlb_set_dma_mask,
Stefano Stabellini83862cc2013-10-10 13:40:44 +000055};
56
57int __init xen_mm_init(void)
58{
59 if (!xen_initial_domain())
60 return 0;
61 xen_swiotlb_init(1, false);
62 xen_dma_ops = &xen_swiotlb_dma_ops;
63 return 0;
64}
65arch_initcall(xen_mm_init);