aboutsummaryrefslogtreecommitdiffstats
path: root/linux-2.6-xen-sparse/include/asm-ia64/maddr.h
blob: 55c6f94d10962f46ad34e0fb88089817c0decd32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _ASM_IA64_MADDR_H
#define _ASM_IA64_MADDR_H

#include <linux/kernel.h>
#include <asm/hypervisor.h>
#include <xen/features.h>
#include <xen/interface/xen.h>

#ifdef CONFIG_XEN

#define INVALID_P2M_ENTRY       (~0UL)

/* XXX xen page size != page size */
static inline unsigned long
pfn_to_mfn_for_dma(unsigned long pfn)
{
	unsigned long mfn;
	mfn = HYPERVISOR_phystomach(pfn);
	BUG_ON(mfn == 0); // XXX
	BUG_ON(mfn == INVALID_P2M_ENTRY); // XXX
	BUG_ON(mfn == INVALID_MFN);
	return mfn;
}

static inline unsigned long
phys_to_machine_for_dma(unsigned long phys)
{
	unsigned long machine =
	              pfn_to_mfn_for_dma(phys >> PAGE_SHIFT) << PAGE_SHIFT;
	machine |= (phys & ~PAGE_MASK);
	return machine;
}

static inline unsigned long
mfn_to_pfn_for_dma(unsigned long mfn)
{
	unsigned long pfn;
	pfn = HYPERVISOR_machtophys(mfn);
	BUG_ON(pfn == 0);
	//BUG_ON(pfn == INVALID_M2P_ENTRY);
	return pfn;
}

static inline unsigned long
machine_to_phys_for_dma(unsigned long machine)
{
	unsigned long phys =
	              mfn_to_pfn_for_dma(machine >> PAGE_SHIFT) << PAGE_SHIFT;
	phys |= (machine & ~PAGE_MASK);
	return phys;
}

static inline unsigned long
mfn_to_local_pfn(unsigned long mfn)
{
	extern unsigned long max_mapnr;
	unsigned long pfn = mfn_to_pfn_for_dma(mfn);
	if (!pfn_valid(pfn))
		return INVALID_P2M_ENTRY;
	return pfn;
}

#else /* !CONFIG_XEN */

#define pfn_to_mfn_for_dma(pfn) (pfn)
#define mfn_to_pfn_for_dma(mfn) (mfn)
#define phys_to_machine_for_dma(phys) (phys)
#define machine_to_phys_for_dma(machine) (machine)
#define mfn_to_local_pfn(mfn) (mfn)

#endif /* !CONFIG_XEN */

/* XXX to compile set_phys_to_machine(vaddr, FOREIGN_FRAME(m)) */
#define FOREIGN_FRAME(m)        (INVALID_P2M_ENTRY)

#define mfn_to_pfn(mfn) (mfn)
#define pfn_to_mfn(pfn) (pfn)

#define mfn_to_virt(mfn) (__va((mfn) << PAGE_SHIFT))
#define virt_to_mfn(virt) (__pa(virt) >> PAGE_SHIFT)
#define virt_to_machine(virt) __pa(virt) // for tpmfront.c

#define set_phys_to_machine(pfn, mfn) do { } while (0)
#ifdef CONFIG_VMX_GUEST
extern void xen_machphys_update(unsigned long mfn, unsigned long pfn);
#else /* CONFIG_VMX_GUEST */
#define xen_machphys_update(mfn, pfn) do { } while (0)
#endif /* CONFIG_VMX_GUEST */

typedef unsigned long maddr_t;	// to compile netback, netfront

#endif /* _ASM_IA64_MADDR_H */