blob: 359a7b50b158c4987edf6cc0582174a4cf678473 [file] [log] [blame]
Stefano Stabellini36a67ab2012-08-08 16:33:46 +00001#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
10#include <xen/interface/grant_table.h>
11
12#define pfn_to_mfn(pfn) (pfn)
Ian Campbellee7b5952012-10-17 09:39:17 +010013#define phys_to_machine_mapping_valid(pfn) (1)
Stefano Stabellini36a67ab2012-08-08 16:33:46 +000014#define mfn_to_pfn(mfn) (mfn)
15#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
16
17#define pte_mfn pte_pfn
18#define mfn_pte pfn_pte
19
20/* Xen machine address */
21typedef struct xmaddr {
22 phys_addr_t maddr;
23} xmaddr_t;
24
25/* Xen pseudo-physical address */
26typedef struct xpaddr {
27 phys_addr_t paddr;
28} xpaddr_t;
29
30#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
31#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
32
Ian Campbellee7b5952012-10-17 09:39:17 +010033#define INVALID_P2M_ENTRY (~0UL)
34
Stefano Stabellini36a67ab2012-08-08 16:33:46 +000035static inline xmaddr_t phys_to_machine(xpaddr_t phys)
36{
37 unsigned offset = phys.paddr & ~PAGE_MASK;
38 return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset);
39}
40
41static inline xpaddr_t machine_to_phys(xmaddr_t machine)
42{
43 unsigned offset = machine.maddr & ~PAGE_MASK;
44 return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset);
45}
46/* VIRT <-> MACHINE conversion */
47#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v))))
48#define virt_to_pfn(v) (PFN_DOWN(__pa(v)))
49#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v)))
50#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
51
52static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr)
53{
54 /* TODO: assuming it is mapped in the kernel 1:1 */
55 return virt_to_machine(vaddr);
56}
57
58/* TODO: this shouldn't be here but it is because the frontend drivers
59 * are using it (its rolled in headers) even though we won't hit the code path.
60 * So for right now just punt with this.
61 */
62static inline pte_t *lookup_address(unsigned long address, unsigned int *level)
63{
64 BUG();
65 return NULL;
66}
67
68static inline int m2p_add_override(unsigned long mfn, struct page *page,
69 struct gnttab_map_grant_ref *kmap_op)
70{
71 return 0;
72}
73
74static inline int m2p_remove_override(struct page *page, bool clear_pte)
75{
76 return 0;
77}
78
Ian Campbellee7b5952012-10-17 09:39:17 +010079static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
80{
81 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
82 return true;
83}
84
Stefano Stabellini36a67ab2012-08-08 16:33:46 +000085static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
86{
Ian Campbellee7b5952012-10-17 09:39:17 +010087 return __set_phys_to_machine(pfn, mfn);
Stefano Stabellini36a67ab2012-08-08 16:33:46 +000088}
Stefano Stabellini3216dce2013-02-19 13:59:19 +000089
Stefano Stabellinif0a8d592013-06-04 16:32:15 +000090#define xen_remap(cookie, size) ioremap_cached((cookie), (size));
Stefano Stabellini3216dce2013-02-19 13:59:19 +000091
Stefano Stabellini36a67ab2012-08-08 16:33:46 +000092#endif /* _ASM_ARM_XEN_PAGE_H */