1 #ifndef _ASM_ARM_XEN_PAGE_H
2 #define _ASM_ARM_XEN_PAGE_H
4 #include <asm/mach/map.h>
6 #include <asm/pgtable.h>
9 #include <linux/types.h>
11 #include <xen/interface/grant_table.h>
13 #define pfn_to_mfn(pfn) (pfn)
14 #define phys_to_machine_mapping_valid(pfn) (1)
15 #define mfn_to_pfn(mfn) (mfn)
16 #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
18 #define pte_mfn pte_pfn
19 #define mfn_pte pfn_pte
21 /* Xen machine address */
22 typedef struct xmaddr {
26 /* Xen pseudo-physical address */
27 typedef struct xpaddr {
31 #define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
32 #define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
34 #define INVALID_P2M_ENTRY (~0UL)
36 static inline xmaddr_t phys_to_machine(xpaddr_t phys)
38 unsigned offset = phys.paddr & ~PAGE_MASK;
39 return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
42 static inline xpaddr_t machine_to_phys(xmaddr_t machine)
44 unsigned offset = machine.maddr & ~PAGE_MASK;
45 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
47 /* VIRT <-> MACHINE conversion */
48 #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
49 #define virt_to_pfn(v) (PFN_DOWN(__pa(v)))
50 #define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
51 #define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
53 static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
55 /* TODO: assuming it is mapped in the kernel 1:1 */
56 return virt_to_machine(vaddr);
59 /* TODO: this shouldn't be here but it is because the frontend drivers
60 * are using it (its rolled in headers) even though we won't hit the code path.
61 * So for right now just punt with this.
63 static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
69 static inline int m2p_add_override(unsigned long mfn, struct page *page,
70 struct gnttab_map_grant_ref *kmap_op)
75 static inline int m2p_remove_override(struct page *page, bool clear_pte)
80 static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
82 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
86 static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
88 return __set_phys_to_machine(pfn, mfn);
91 #define xen_remap(cookie, size) __arm_ioremap((cookie), (size), MT_MEMORY);
93 #endif /* _ASM_ARM_XEN_PAGE_H */