1 #ifndef _ASM_IA64_MADDR_H
2 #define _ASM_IA64_MADDR_H
4 #include <linux/kernel.h>
5 #include <asm/hypervisor.h>
6 #include <xen/features.h>
7 #include <xen/interface/xen.h>
11 #define INVALID_P2M_ENTRY (~0UL)
13 /* XXX xen page size != page size */
14 static inline unsigned long
15 pfn_to_mfn_for_dma(unsigned long pfn)
18 mfn = HYPERVISOR_phystomach(pfn);
19 BUG_ON(mfn == 0); // XXX
20 BUG_ON(mfn == INVALID_P2M_ENTRY); // XXX
21 BUG_ON(mfn == INVALID_MFN);
25 static inline unsigned long
26 phys_to_machine_for_dma(unsigned long phys)
28 unsigned long machine =
29 pfn_to_mfn_for_dma(phys >> PAGE_SHIFT) << PAGE_SHIFT;
30 machine |= (phys & ~PAGE_MASK);
34 static inline unsigned long
35 mfn_to_pfn_for_dma(unsigned long mfn)
38 pfn = HYPERVISOR_machtophys(mfn);
40 //BUG_ON(pfn == INVALID_M2P_ENTRY);
44 static inline unsigned long
45 machine_to_phys_for_dma(unsigned long machine)
48 mfn_to_pfn_for_dma(machine >> PAGE_SHIFT) << PAGE_SHIFT;
49 phys |= (machine & ~PAGE_MASK);
53 static inline unsigned long
54 mfn_to_local_pfn(unsigned long mfn)
56 extern unsigned long max_mapnr;
57 unsigned long pfn = mfn_to_pfn_for_dma(mfn);
59 return INVALID_P2M_ENTRY;
63 #else /* !CONFIG_XEN */
65 #define pfn_to_mfn_for_dma(pfn) (pfn)
66 #define mfn_to_pfn_for_dma(mfn) (mfn)
67 #define phys_to_machine_for_dma(phys) (phys)
68 #define machine_to_phys_for_dma(machine) (machine)
69 #define mfn_to_local_pfn(mfn) (mfn)
71 #endif /* !CONFIG_XEN */
73 /* XXX to compile set_phys_to_machine(vaddr, FOREIGN_FRAME(m)) */
74 #define FOREIGN_FRAME(m) (INVALID_P2M_ENTRY)
76 #define mfn_to_pfn(mfn) (mfn)
77 #define pfn_to_mfn(pfn) (pfn)
79 #define mfn_to_virt(mfn) (__va((mfn) << PAGE_SHIFT))
80 #define virt_to_mfn(virt) (__pa(virt) >> PAGE_SHIFT)
81 #define virt_to_machine(virt) __pa(virt) // for tpmfront.c
83 #define set_phys_to_machine(pfn, mfn) do { } while (0)
84 #ifdef CONFIG_VMX_GUEST
85 extern void xen_machphys_update(unsigned long mfn, unsigned long pfn);
86 #else /* CONFIG_VMX_GUEST */
87 #define xen_machphys_update(mfn, pfn) do { } while (0)
88 #endif /* CONFIG_VMX_GUEST */
90 typedef unsigned long maddr_t; // to compile netback, netfront
92 #endif /* _ASM_IA64_MADDR_H */