1 | /** @file
|
---|
2 | * VMM - The Virtual Machine Monitor.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | *
|
---|
25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___VBox_vmm_h
|
---|
31 | #define ___VBox_vmm_h
|
---|
32 |
|
---|
33 | #include <VBox/cdefs.h>
|
---|
34 | #include <VBox/types.h>
|
---|
35 | #include <VBox/vmapi.h>
|
---|
36 | #include <VBox/sup.h>
|
---|
37 | #include <iprt/stdarg.h>
|
---|
38 |
|
---|
39 | __BEGIN_DECLS
|
---|
40 |
|
---|
41 | /** @defgroup grp_vmm The Virtual Machine Monitor API
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * World switcher identifiers.
|
---|
47 | */
|
---|
48 | typedef enum VMMSWITCHER
|
---|
49 | {
|
---|
50 | /** The usual invalid 0. */
|
---|
51 | VMMSWITCHER_INVALID = 0,
|
---|
52 | /** Switcher for 32-bit host to 32-bit shadow paging. */
|
---|
53 | VMMSWITCHER_32_TO_32,
|
---|
54 | /** Switcher for 32-bit host paging to PAE shadow paging. */
|
---|
55 | VMMSWITCHER_32_TO_PAE,
|
---|
56 | /** Switcher for 32-bit host paging to AMD64 shadow paging. */
|
---|
57 | VMMSWITCHER_32_TO_AMD64,
|
---|
58 | /** Switcher for PAE host to 32-bit shadow paging. */
|
---|
59 | VMMSWITCHER_PAE_TO_32,
|
---|
60 | /** Switcher for PAE host to PAE shadow paging. */
|
---|
61 | VMMSWITCHER_PAE_TO_PAE,
|
---|
62 | /** Switcher for PAE host paging to AMD64 shadow paging. */
|
---|
63 | VMMSWITCHER_PAE_TO_AMD64,
|
---|
64 | /** Switcher for AMD64 host paging to PAE shadow paging. */
|
---|
65 | VMMSWITCHER_AMD64_TO_PAE,
|
---|
66 | /** Switcher for AMD64 host paging to AMD64 shadow paging. */
|
---|
67 | VMMSWITCHER_AMD64_TO_AMD64,
|
---|
68 | /** Used to make a count for array declarations and suchlike. */
|
---|
69 | VMMSWITCHER_MAX,
|
---|
70 | /** The usual 32-bit paranoia. */
|
---|
71 | VMMSWITCHER_32BIT_HACK = 0x7fffffff
|
---|
72 | } VMMSWITCHER;
|
---|
73 |
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * VMMGCCallHost operations.
|
---|
77 | */
|
---|
78 | typedef enum VMMCALLHOST
|
---|
79 | {
|
---|
80 | /** Invalid operation. */
|
---|
81 | VMMCALLHOST_INVALID = 0,
|
---|
82 | /** Acquire the PDM lock. */
|
---|
83 | VMMCALLHOST_PDM_LOCK,
|
---|
84 | /** Call PDMR3QueueFlushWorker. */
|
---|
85 | VMMCALLHOST_PDM_QUEUE_FLUSH,
|
---|
86 | /** Acquire the PGM lock. */
|
---|
87 | VMMCALLHOST_PGM_LOCK,
|
---|
88 | /** Grow the PGM shadow page pool. */
|
---|
89 | VMMCALLHOST_PGM_POOL_GROW,
|
---|
90 | /** Maps a chunk into ring-3. */
|
---|
91 | VMMCALLHOST_PGM_MAP_CHUNK,
|
---|
92 | /** Allocates more handy pages. */
|
---|
93 | VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES,
|
---|
94 | #ifndef VBOX_WITH_NEW_PHYS_CODE
|
---|
95 | /** Dynamically allocate physical guest RAM. */
|
---|
96 | VMMCALLHOST_PGM_RAM_GROW_RANGE,
|
---|
97 | #endif
|
---|
98 | /** Replay the REM handler notifications. */
|
---|
99 | VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS,
|
---|
100 | /** Flush the GC/R0 logger. */
|
---|
101 | VMMCALLHOST_VMM_LOGGER_FLUSH,
|
---|
102 | /** Set the VM error message. */
|
---|
103 | VMMCALLHOST_VM_SET_ERROR,
|
---|
104 | /** Set the VM runtime error message. */
|
---|
105 | VMMCALLHOST_VM_SET_RUNTIME_ERROR,
|
---|
106 | /** Signal a ring 0 assertion. */
|
---|
107 | VMMCALLHOST_VM_R0_ASSERTION,
|
---|
108 | /** The usual 32-bit hack. */
|
---|
109 | VMMCALLHOST_32BIT_HACK = 0x7fffffff
|
---|
110 | } VMMCALLHOST;
|
---|
111 |
|
---|
112 | RTRCPTR VMMGetStackRC(PVM pVM);
|
---|
113 | VMCPUID VMMGetCpuId(PVM pVM);
|
---|
114 | VMMDECL(uint32_t) VMMGetSvnRev(void);
|
---|
115 |
|
---|
116 |
|
---|
117 | #ifdef IN_RING3
|
---|
118 | /** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
|
---|
119 | * @ingroup grp_vmm
|
---|
120 | * @{
|
---|
121 | */
|
---|
122 | VMMR3DECL(int) VMMR3Init(PVM pVM);
|
---|
123 | VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
|
---|
124 | VMMR3DECL(int) VMMR3InitR0(PVM pVM);
|
---|
125 | VMMR3DECL(int) VMMR3InitRC(PVM pVM);
|
---|
126 | VMMR3DECL(int) VMMR3Term(PVM pVM);
|
---|
127 | VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
128 | VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
|
---|
129 | VMMR3DECL(const char *) VMMR3GetGCAssertMsg1(PVM pVM);
|
---|
130 | VMMR3DECL(const char *) VMMR3GetGCAssertMsg2(PVM pVM);
|
---|
131 | VMMR3DECL(int) VMMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
|
---|
132 | VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
|
---|
133 | VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
|
---|
134 | VMMR3DECL(int) VMMR3RawRunGC(PVM pVM);
|
---|
135 | VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM);
|
---|
136 | VMMR3DECL(int) VMMR3CallGC(PVM pVM, RTRCPTR GCPtrEntry, unsigned cArgs, ...);
|
---|
137 | VMMR3DECL(int) VMMR3CallGCV(PVM pVM, RTRCPTR GCPtrEntry, unsigned cArgs, va_list args);
|
---|
138 | VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM);
|
---|
139 | VMMR3DECL(void) VMMR3FatalDump(PVM pVM, int rcErr);
|
---|
140 | VMMR3DECL(int) VMMR3Lock(PVM pVM);
|
---|
141 | VMMR3DECL(int) VMMR3Unlock(PVM pVM);
|
---|
142 | VMMR3DECL(RTNATIVETHREAD) VMMR3LockGetOwner(PVM pVM);
|
---|
143 | VMMR3DECL(bool) VMMR3LockIsOwner(PVM pVM);
|
---|
144 | VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
|
---|
145 | VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
|
---|
146 | VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
|
---|
147 | /** @} */
|
---|
148 | #endif /* IN_RING3 */
|
---|
149 |
|
---|
150 |
|
---|
151 | /** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
|
---|
152 | * @ingroup grp_vmm
|
---|
153 | * @{
|
---|
154 | */
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * The VMMR0Entry() codes.
|
---|
158 | */
|
---|
159 | typedef enum VMMR0OPERATION
|
---|
160 | {
|
---|
161 | /** Run guest context. */
|
---|
162 | VMMR0_DO_RAW_RUN = SUP_VMMR0_DO_RAW_RUN,
|
---|
163 | /** Run guest code using the available hardware acceleration technology. */
|
---|
164 | VMMR0_DO_HWACC_RUN = SUP_VMMR0_DO_HWACC_RUN,
|
---|
165 | /** Official NOP that we use for profiling. */
|
---|
166 | VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
|
---|
167 | /** Official slow iocl NOP that we use for profiling. */
|
---|
168 | VMMR0_DO_SLOW_NOP,
|
---|
169 |
|
---|
170 | /** Ask the GVMM to create a new VM. */
|
---|
171 | VMMR0_DO_GVMM_CREATE_VM,
|
---|
172 | /** Ask the GVMM to destroy the VM. */
|
---|
173 | VMMR0_DO_GVMM_DESTROY_VM,
|
---|
174 | /** Call GVMMR0SchedHalt(). */
|
---|
175 | VMMR0_DO_GVMM_SCHED_HALT,
|
---|
176 | /** Call GVMMR0SchedWakeUp(). */
|
---|
177 | VMMR0_DO_GVMM_SCHED_WAKE_UP,
|
---|
178 | /** Call GVMMR0SchedPoll(). */
|
---|
179 | VMMR0_DO_GVMM_SCHED_POLL,
|
---|
180 | /** Call GVMMR0QueryStatistics(). */
|
---|
181 | VMMR0_DO_GVMM_QUERY_STATISTICS,
|
---|
182 | /** Call GVMMR0ResetStatistics(). */
|
---|
183 | VMMR0_DO_GVMM_RESET_STATISTICS,
|
---|
184 |
|
---|
185 | /** Call VMMR0 Per VM Init. */
|
---|
186 | VMMR0_DO_VMMR0_INIT,
|
---|
187 | /** Call VMMR0 Per VM Termination. */
|
---|
188 | VMMR0_DO_VMMR0_TERM,
|
---|
189 | /** Setup the hardware accelerated raw-mode session. */
|
---|
190 | VMMR0_DO_HWACC_SETUP_VM,
|
---|
191 | /** Attempt to enable or disable hardware accelerated raw-mode. */
|
---|
192 | VMMR0_DO_HWACC_ENABLE,
|
---|
193 | /** Calls function in the hypervisor.
|
---|
194 | * The caller must setup the hypervisor context so the call will be performed.
|
---|
195 | * The difference between VMMR0_DO_RUN_GC and this one is the handling of
|
---|
196 | * the return GC code. The return code will not be interpreted by this operation.
|
---|
197 | */
|
---|
198 | VMMR0_DO_CALL_HYPERVISOR,
|
---|
199 |
|
---|
200 | /** Call PGMR0PhysAllocateHandyPages(). */
|
---|
201 | VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES,
|
---|
202 |
|
---|
203 | /** Call GMMR0InitialReservation(). */
|
---|
204 | VMMR0_DO_GMM_INITIAL_RESERVATION,
|
---|
205 | /** Call GMMR0UpdateReservation(). */
|
---|
206 | VMMR0_DO_GMM_UPDATE_RESERVATION,
|
---|
207 | /** Call GMMR0AllocatePages(). */
|
---|
208 | VMMR0_DO_GMM_ALLOCATE_PAGES,
|
---|
209 | /** Call GMMR0FreePages(). */
|
---|
210 | VMMR0_DO_GMM_FREE_PAGES,
|
---|
211 | /** Call GMMR0BalloonedPages(). */
|
---|
212 | VMMR0_DO_GMM_BALLOONED_PAGES,
|
---|
213 | /** Call GMMR0DeflatedBalloon(). */
|
---|
214 | VMMR0_DO_GMM_DEFLATED_BALLOON,
|
---|
215 | /** Call GMMR0MapUnmapChunk(). */
|
---|
216 | VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
|
---|
217 | /** Call GMMR0SeedChunk(). */
|
---|
218 | VMMR0_DO_GMM_SEED_CHUNK,
|
---|
219 |
|
---|
220 | /** Set a GVMM or GMM configuration value. */
|
---|
221 | VMMR0_DO_GCFGM_SET_VALUE,
|
---|
222 | /** Query a GVMM or GMM configuration value. */
|
---|
223 | VMMR0_DO_GCFGM_QUERY_VALUE,
|
---|
224 |
|
---|
225 | /** The start of the R0 service operations. */
|
---|
226 | VMMR0_DO_SRV_START,
|
---|
227 | /** Call INTNETR0Open(). */
|
---|
228 | VMMR0_DO_INTNET_OPEN,
|
---|
229 | /** Call INTNETR0IfClose(). */
|
---|
230 | VMMR0_DO_INTNET_IF_CLOSE,
|
---|
231 | /** Call INTNETR0IfGetRing3Buffer(). */
|
---|
232 | VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
|
---|
233 | /** Call INTNETR0IfSetPromiscuousMode(). */
|
---|
234 | VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
|
---|
235 | /** Call INTNETR0IfSetMacAddress(). */
|
---|
236 | VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
|
---|
237 | /** Call INTNETR0IfSetActive(). */
|
---|
238 | VMMR0_DO_INTNET_IF_SET_ACTIVE,
|
---|
239 | /** Call INTNETR0IfSend(). */
|
---|
240 | VMMR0_DO_INTNET_IF_SEND,
|
---|
241 | /** Call INTNETR0IfWait(). */
|
---|
242 | VMMR0_DO_INTNET_IF_WAIT,
|
---|
243 | /** The end of the R0 service operations. */
|
---|
244 | VMMR0_DO_SRV_END,
|
---|
245 |
|
---|
246 | /** Official call we use for testing Ring-0 APIs. */
|
---|
247 | VMMR0_DO_TESTS,
|
---|
248 |
|
---|
249 | /** The usual 32-bit type blow up. */
|
---|
250 | VMMR0_DO_32BIT_HACK = 0x7fffffff
|
---|
251 | } VMMR0OPERATION;
|
---|
252 |
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
|
---|
256 | * @todo Move got GCFGM.h when it's implemented.
|
---|
257 | */
|
---|
258 | typedef struct GCFGMVALUEREQ
|
---|
259 | {
|
---|
260 | /** The request header.*/
|
---|
261 | SUPVMMR0REQHDR Hdr;
|
---|
262 | /** The support driver session handle. */
|
---|
263 | PSUPDRVSESSION pSession;
|
---|
264 | /** The value.
|
---|
265 | * This is input for the set request and output for the query. */
|
---|
266 | uint64_t u64Value;
|
---|
267 | /** The variable name.
|
---|
268 | * This is fixed sized just to make things simple for the mock-up. */
|
---|
269 | char szName[48];
|
---|
270 | } GCFGMVALUEREQ;
|
---|
271 | /** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
|
---|
272 | * @todo Move got GCFGM.h when it's implemented.
|
---|
273 | */
|
---|
274 | typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
|
---|
275 |
|
---|
276 | VMMR0DECL(int) VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
|
---|
277 | VMMR0DECL(void) VMMR0EntryFast(PVM pVM, VMMR0OPERATION enmOperation);
|
---|
278 | VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
|
---|
279 | VMMR0DECL(int) VMMR0CallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
|
---|
280 |
|
---|
281 | /** @} */
|
---|
282 |
|
---|
283 |
|
---|
284 | #ifdef IN_GC
|
---|
285 | /** @defgroup grp_vmm_rc The VMM Raw-Mode Context API
|
---|
286 | * @ingroup grp_vmm
|
---|
287 | * @{
|
---|
288 | */
|
---|
289 | VMMRCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
|
---|
290 | VMMRCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
|
---|
291 | VMMRCDECL(int) VMMGCCallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
|
---|
292 | /** @} */
|
---|
293 | #endif /* IN_RC */
|
---|
294 |
|
---|
295 |
|
---|
296 | /** @} */
|
---|
297 | __END_DECLS
|
---|
298 |
|
---|
299 | #endif
|
---|
300 |
|
---|