1 #ifndef _ASM_ARM_XEN_PAGE_H 2 #define _ASM_ARM_XEN_PAGE_H 3 4 #include <asm/mach/map.h> 5 #include <asm/page.h> 6 #include <asm/pgtable.h> 7 8 #include <linux/pfn.h> 9 #include <linux/types.h> 10 11 #include <xen/interface/grant_table.h> 12 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)) 17 18 #define pte_mfn pte_pfn 19 #define mfn_pte pfn_pte 20 21 /* Xen machine address */ 22 typedef struct xmaddr { 23 phys_addr_t maddr; 24 } xmaddr_t; 25 26 /* Xen pseudo-physical address */ 27 typedef struct xpaddr { 28 phys_addr_t paddr; 29 } xpaddr_t; 30 31 #define XMADDR(x) ((xmaddr_t) { .maddr = (x) }) 32 #define XPADDR(x) ((xpaddr_t) { .paddr = (x) }) 33 34 #define INVALID_P2M_ENTRY (~0UL) 35 36 static inline xmaddr_t phys_to_machine(xpaddr_t phys) 37 { 38 unsigned offset = phys.paddr & ~PAGE_MASK; 39 return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset); 40 } 41 42 static inline xpaddr_t machine_to_phys(xmaddr_t machine) 43 { 44 unsigned offset = machine.maddr & ~PAGE_MASK; 45 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); 46 } 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)) 52 53 static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr) 54 { 55 /* TODO: assuming it is mapped in the kernel 1:1 */ 56 return virt_to_machine(vaddr); 57 } 58 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. 62 */ 63 static inline pte_t *lookup_address(unsigned long address, unsigned int *level) 64 { 65 BUG(); 66 return NULL; 67 } 68 69 static inline int m2p_add_override(unsigned long mfn, struct page *page, 70 struct gnttab_map_grant_ref *kmap_op) 71 { 72 return 0; 73 } 74 75 static inline int m2p_remove_override(struct page *page, bool clear_pte) 76 { 77 return 0; 78 } 79 80 static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) 81 { 82 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); 83 return true; 84 } 85 86 static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn) 87 { 88 return __set_phys_to_machine(pfn, mfn); 89 } 90 91 #define xen_remap(cookie, size) __arm_ioremap((cookie), (size), MT_MEMORY); 92 93 #endif /* _ASM_ARM_XEN_PAGE_H */ 94