xref: /titanic_41/usr/src/uts/i86xpv/sys/xen_mmu.h (revision 299d957d28501350bcae7fa4333ff183c062c427)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_XEN_MMU_H
27 #define	_SYS_XEN_MMU_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Platform-dependent MMU routines and types for the hypervisor.
37  *
38  * WARNING: this header file is used by both dboot and i86pc, so don't go using
39  * normal kernel headers.
40  */
41 
42 #if (defined(_BOOT) && defined(_BOOT_TARGET_amd64)) || \
43 	(!defined(_BOOT) && defined(__amd64))
44 #define	__target_amd64
45 #endif
46 
47 #ifdef __target_amd64
48 
49 #define	IN_HYPERVISOR_VA(va) \
50 	((va) >= HYPERVISOR_VIRT_START && (va) < HYPERVISOR_VIRT_END)
51 
52 #else
53 
54 #define	IN_HYPERVISOR_VA(va) ((va) >= xen_virt_start)
55 
56 /*
57  * Do this to help catch any uses.
58  */
59 #undef	HYPERVISOR_VIRT_START
60 #undef	machine_to_phys_mapping
61 
62 #endif
63 
64 #undef __target_amd64
65 
66 typedef uint64_t maddr_t;
67 
68 paddr_t ma_to_pa(maddr_t);
69 maddr_t pa_to_ma(paddr_t);
70 #define	mfn_to_ma(mfn)	((maddr_t)(mfn) << MMU_PAGESHIFT)
71 
72 extern uintptr_t xen_virt_start;
73 extern pfn_t *mfn_to_pfn_mapping;
74 
75 #ifndef _BOOT
76 
77 /*
78  * On the hypervisor we need:
79  * - a way to map a machine address (ie, not pseudo-physical).
80  * - to relocate initial hypervisor data structures into kernel VA range.
81  * - a way to translate between physical addresses and machine addresses.
82  * - a way to change the machine address behind a physical address.
83  */
84 typedef ulong_t mfn_t;
85 
86 extern mfn_t *mfn_list;
87 extern mfn_t *mfn_list_pages;
88 extern mfn_t *mfn_list_pages_page;
89 extern ulong_t mfn_count;
90 extern mfn_t cached_max_mfn;
91 
92 /*
93  * locks for mfn_list[] and machine_to_phys_mapping[] when migration / suspend
94  * events happen
95  */
96 extern void xen_block_migrate(void);
97 extern void xen_allow_migrate(void);
98 extern void xen_start_migrate(void);
99 extern void xen_end_migrate(void);
100 
101 /*
102  * Conversion between machine (hardware) addresses and pseudo-physical
103  * addresses.
104  */
105 pfn_t mfn_to_pfn(mfn_t);
106 mfn_t pfn_to_mfn(pfn_t);
107 
108 struct page;
109 
110 void xen_relocate_start_info(void);
111 
112 /*
113  * interfaces to create/destroy pfn_t values for devices or foreign memory
114  *
115  * xen_assign_pfn() creates (or looks up) a local pfn value to use for things
116  * like a foreign domain memory mfn or a device mfn.
117  *
118  * xen_release_pfn() destroys the association between a pfn and foreign mfn.
119  */
120 pfn_t xen_assign_pfn(mfn_t mfn);
121 void xen_release_pfn(pfn_t);
122 uint_t pfn_is_foreign(pfn_t);
123 void reassign_pfn(pfn_t pfn, mfn_t mfn);
124 
125 #define	MFN_INVALID	(-(mfn_t)1)
126 
127 #endif /* !_BOOT */
128 
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif	/* _SYS_XEN_MMU_H */
134