arm/xen: Drop pte_mfn and mfn_pte
[firefly-linux-kernel-4.4.55.git] / arch / arm / include / asm / xen / page.h
1 #ifndef _ASM_ARM_XEN_PAGE_H
2 #define _ASM_ARM_XEN_PAGE_H
3
4 #include <asm/page.h>
5 #include <asm/pgtable.h>
6
7 #include <linux/pfn.h>
8 #include <linux/types.h>
9 #include <linux/dma-mapping.h>
10
11 #include <xen/xen.h>
12 #include <xen/interface/grant_table.h>
13
14 #define phys_to_machine_mapping_valid(pfn) (1)
15
16 /* Xen machine address */
17 typedef struct xmaddr {
18         phys_addr_t maddr;
19 } xmaddr_t;
20
21 /* Xen pseudo-physical address */
22 typedef struct xpaddr {
23         phys_addr_t paddr;
24 } xpaddr_t;
25
26 #define XMADDR(x)       ((xmaddr_t) { .maddr = (x) })
27 #define XPADDR(x)       ((xpaddr_t) { .paddr = (x) })
28
29 #define INVALID_P2M_ENTRY      (~0UL)
30
31 unsigned long __pfn_to_mfn(unsigned long pfn);
32 extern struct rb_root phys_to_mach;
33
34 /* Pseudo-physical <-> Guest conversion */
35 static inline unsigned long pfn_to_gfn(unsigned long pfn)
36 {
37         return pfn;
38 }
39
40 static inline unsigned long gfn_to_pfn(unsigned long gfn)
41 {
42         return gfn;
43 }
44
45 /* Pseudo-physical <-> BUS conversion */
46 static inline unsigned long pfn_to_bfn(unsigned long pfn)
47 {
48         unsigned long mfn;
49
50         if (phys_to_mach.rb_node != NULL) {
51                 mfn = __pfn_to_mfn(pfn);
52                 if (mfn != INVALID_P2M_ENTRY)
53                         return mfn;
54         }
55
56         return pfn;
57 }
58
59 static inline unsigned long bfn_to_pfn(unsigned long bfn)
60 {
61         return bfn;
62 }
63
64 #define bfn_to_local_pfn(bfn)   bfn_to_pfn(bfn)
65
66 /* VIRT <-> GUEST conversion */
67 #define virt_to_gfn(v)          (pfn_to_gfn(virt_to_pfn(v)))
68 #define gfn_to_virt(m)          (__va(gfn_to_pfn(m) << PAGE_SHIFT))
69
70 /* Only used in PV code. But ARM guests are always HVM. */
71 static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
72 {
73         BUG();
74 }
75
76 /* TODO: this shouldn't be here but it is because the frontend drivers
77  * are using it (its rolled in headers) even though we won't hit the code path.
78  * So for right now just punt with this.
79  */
80 static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
81 {
82         BUG();
83         return NULL;
84 }
85
86 extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
87                                    struct gnttab_map_grant_ref *kmap_ops,
88                                    struct page **pages, unsigned int count);
89
90 extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
91                                      struct gnttab_unmap_grant_ref *kunmap_ops,
92                                      struct page **pages, unsigned int count);
93
94 bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
95 bool __set_phys_to_machine_multi(unsigned long pfn, unsigned long mfn,
96                 unsigned long nr_pages);
97
98 static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
99 {
100         return __set_phys_to_machine(pfn, mfn);
101 }
102
103 #define xen_remap(cookie, size) ioremap_cache((cookie), (size))
104 #define xen_unmap(cookie) iounmap((cookie))
105
106 bool xen_arch_need_swiotlb(struct device *dev,
107                            unsigned long pfn,
108                            unsigned long bfn);
109 unsigned long xen_get_swiotlb_free_pages(unsigned int order);
110
111 #endif /* _ASM_ARM_XEN_PAGE_H */