summaryrefslogtreecommitdiff
path: root/include/mach/xen.h
blob: 6fc626f2a751a9b5a19d60267e819d116d47a042 (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

/*
 *  Copyright (C) 2006-2009, 2011 Free Software Foundation
 *
 * This program is free software ; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation ; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY ; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the program ; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef _MACH_XEN_H
#define _MACH_XEN_H
#ifdef	MACH_XEN
#include <sys/types.h>
#include <xen/public/xen.h>
#include <i386/vm_param.h>

extern struct start_info boot_info;

extern volatile struct shared_info hyp_shared_info;

#ifdef	MACH_PV_PAGETABLES
/* Memory translations */

/* pa are physical addresses, from 0 to size of memory */
/* ma are machine addresses, i.e. _real_ hardware adresses */
/* la are linear addresses, i.e. without segmentation */

/* This might also be useful out of Xen */
#if VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS
extern unsigned long la_shift;
#else
#define la_shift LINEAR_MIN_KERNEL_ADDRESS
#endif
#define la_to_pa(a)		((vm_offset_t)(((vm_offset_t)(a)) - la_shift))
#define pa_to_la(a)		((vm_offset_t)(((vm_offset_t)(a)) + la_shift))

#define kv_to_la(a)		pa_to_la(_kvtophys(a))
#define la_to_kv(a)		phystokv(la_to_pa(a))

#ifdef	MACH_PSEUDO_PHYS
#if PAE
#define PFN_LIST MACH2PHYS_VIRT_START_PAE
#else
#define PFN_LIST MACH2PHYS_VIRT_START_NONPAE
#endif
#if VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS
extern unsigned long *pfn_list;
#else
#define pfn_list ((unsigned long *) PFN_LIST)
#endif
#define mfn_to_pfn(n)		(pfn_list[n])

extern unsigned long *mfn_list;
#define pfn_to_mfn(n)		(mfn_list[n])
#else
#define mfn_to_pfn(n)		(n)
#define pfn_to_mfn(n)		(n)
#endif	/* MACH_PSEUDO_PHYS */

#define pa_to_mfn(a)		(pfn_to_mfn(atop(a)))
#ifdef PAE
#define pa_to_ma(a)		({ vm_offset_t __a = (vm_offset_t) (a); (((pt_entry_t) pa_to_mfn(__a)) << PAGE_SHIFT) | (__a & PAGE_MASK); })
#define ma_to_pa(a)		({ pt_entry_t __a = (pt_entry_t) (a); (mfn_to_pfn(__a >> PAGE_SHIFT) << PAGE_SHIFT) | (__a & PAGE_MASK); })
#else
#define pa_to_ma(a)		({ vm_offset_t __a = (vm_offset_t) (a); ptoa(pa_to_mfn(__a)) | (__a & PAGE_MASK); })
#define ma_to_pa(a)		({ vm_offset_t __a = (vm_offset_t) (a); (mfn_to_pfn(atop((__a))) << PAGE_SHIFT) | (__a & PAGE_MASK); })
#endif

#define kv_to_mfn(a)		pa_to_mfn(_kvtophys(a))
#define kv_to_ma(a)		pa_to_ma(_kvtophys(a))
#else	/* MACH_PV_PAGETABLES */
#define mfn_to_pfn(n)		(n)
#define pfn_to_mfn(n)		(n)
#endif	/* MACH_PV_PAGETABLES */

#define mfn_to_kv(mfn)		phystokv(ptoa(mfn_to_pfn(mfn)))

#include <machine/xen.h>

#endif	/* MACH_XEN */
#endif /* _MACH_XEN_H */