ia64/linux-2.6.18-xen.hg

view include/asm-ia64/maddr.h @ 912:dd42cdb0ab89

[IA64] Build blktap2 driver by default in x86 builds.

add CONFIG_XEN_BLKDEV_TAP2=y to buildconfigs/linux-defconfig_xen_ia64.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 12:09:16 2009 +0900 (2009-06-29)
parents 5e1269aa5c29
children
line source
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>
9 #ifdef CONFIG_XEN
11 #define INVALID_P2M_ENTRY (~0UL)
13 #ifdef CONFIG_XEN_IA64_EXPOSE_P2M
14 extern int p2m_initialized;
15 extern unsigned long p2m_min_low_pfn;
16 extern unsigned long p2m_max_low_pfn;
17 extern unsigned long p2m_convert_min_pfn;
18 extern unsigned long p2m_convert_max_pfn;
19 extern volatile const pte_t* p2m_pte;
20 unsigned long p2m_phystomach(unsigned long gpfn);
21 #else
22 #define p2m_initialized (0)
23 #define p2m_phystomach(gpfn) INVALID_MFN
24 #endif
26 /* XXX xen page size != page size */
27 static inline unsigned long
28 pfn_to_mfn_for_dma(unsigned long pfn)
29 {
30 unsigned long mfn;
31 if (p2m_initialized)
32 return p2m_phystomach(pfn);
33 mfn = HYPERVISOR_phystomach(pfn);
34 BUG_ON(mfn == 0); /* XXX */
35 BUG_ON(mfn == INVALID_P2M_ENTRY); /* XXX */
36 BUG_ON(mfn == INVALID_MFN);
37 return mfn;
38 }
40 static inline unsigned long
41 phys_to_machine_for_dma(unsigned long phys)
42 {
43 unsigned long machine =
44 pfn_to_mfn_for_dma(phys >> PAGE_SHIFT) << PAGE_SHIFT;
45 machine |= (phys & ~PAGE_MASK);
46 return machine;
47 }
49 static inline unsigned long
50 mfn_to_pfn_for_dma(unsigned long mfn)
51 {
52 unsigned long pfn;
53 pfn = HYPERVISOR_machtophys(mfn);
54 BUG_ON(pfn == 0);
55 /* BUG_ON(pfn == INVALID_M2P_ENTRY); */
56 return pfn;
57 }
59 static inline unsigned long
60 machine_to_phys_for_dma(unsigned long machine)
61 {
62 unsigned long phys =
63 mfn_to_pfn_for_dma(machine >> PAGE_SHIFT) << PAGE_SHIFT;
64 phys |= (machine & ~PAGE_MASK);
65 return phys;
66 }
68 #ifdef CONFIG_SPARSEMEM
69 /*
70 * When CONFIG_SPARSEMEM=y, pfn_valid() is defined in
71 * linux/include/linux/mmzone.h. Hoever #include <linux/mmzone.h>
72 * causes the header inclusion hell.
73 */
74 static inline int pfn_valid(unsigned long pfn);
75 #endif
77 static inline unsigned long
78 mfn_to_local_pfn(unsigned long mfn)
79 {
80 unsigned long pfn = mfn_to_pfn_for_dma(mfn);
81 if (!pfn_valid(pfn))
82 return INVALID_P2M_ENTRY;
83 return pfn;
84 }
86 #else /* !CONFIG_XEN */
88 #define pfn_to_mfn_for_dma(pfn) (pfn)
89 #define mfn_to_pfn_for_dma(mfn) (mfn)
90 #define phys_to_machine_for_dma(phys) (phys)
91 #define machine_to_phys_for_dma(machine) (machine)
92 #define mfn_to_local_pfn(mfn) (mfn)
94 #endif /* !CONFIG_XEN */
96 #define mfn_to_pfn(mfn) (mfn)
97 #define pfn_to_mfn(pfn) (pfn)
99 #define mfn_to_virt(mfn) (__va((mfn) << PAGE_SHIFT))
100 #define virt_to_mfn(virt) (__pa(virt) >> PAGE_SHIFT)
101 #define virt_to_machine(virt) __pa(virt) /* for tpmfront.c */
102 #define arbitrary_virt_to_machine(virt) virt_to_machine(ia64_imva(virt))
103 #define ptep_to_machine(virt) virt_to_machine(virt)
105 #define set_phys_to_machine(pfn, mfn) do { } while (0)
107 typedef unsigned long maddr_t; /* to compile netback, netfront */
108 #ifndef _ASM_IA64_SN_TYPES_H /* paddr_t is defined in asm-ia64/sn/types.h */
109 typedef unsigned long paddr_t;
110 #endif
112 #ifdef CONFIG_XEN
113 int range_straddles_page_boundary(paddr_t p, size_t size);
114 #else
115 #define range_straddles_page_boundary(addr, size) (0)
116 #endif
118 #endif /* _ASM_IA64_MADDR_H */