blob: f954701c184132b476f972d2b9f593162c2ed1e8 (
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
|
/*
* Copyright (C) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* 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;
/* 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)))
#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((vm_offset_t)(__a))) << PAGE_SHIFT) | (__a & PAGE_MASK); })
#define kv_to_mfn(a) pa_to_mfn(_kvtophys(a))
#define kv_to_ma(a) pa_to_ma(_kvtophys(a))
#define mfn_to_kv(mfn) (phystokv(ma_to_pa(ptoa(mfn))))
#include <machine/xen.h>
#endif /* MACH_XEN */
#endif /* _MACH_XEN_H */
|