VirtualBox

source: vbox/trunk/include/VBox/vmm.h@ 3632

Last change on this file since 3632 was 3632, checked in by vboxsync, 17 years ago

VBox_hdr_h -> _VBox_hdr_h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 KB
Line 
1/** @file
2 * VMM - The Virtual Machine Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef ___VBox_vmm_h
22#define ___VBox_vmm_h
23
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26#include <VBox/vmapi.h>
27#include <iprt/stdarg.h>
28
29__BEGIN_DECLS
30
31/** @defgroup grp_vmm The Virtual Machine Monitor API
32 * @{
33 */
34
35/**
36 * World switcher identifiers.
37 */
38typedef enum VMMSWITCHER
39{
40 /** The usual invalid 0. */
41 VMMSWITCHER_INVALID = 0,
42 /** Switcher for 32-bit host to 32-bit shadow paging. */
43 VMMSWITCHER_32_TO_32,
44 /** Switcher for 32-bit host paging to PAE shadow paging. */
45 VMMSWITCHER_32_TO_PAE,
46 /** Switcher for 32-bit host paging to AMD64 shadow paging. */
47 VMMSWITCHER_32_TO_AMD64,
48 /** Switcher for PAE host to 32-bit shadow paging. */
49 VMMSWITCHER_PAE_TO_32,
50 /** Switcher for PAE host to PAE shadow paging. */
51 VMMSWITCHER_PAE_TO_PAE,
52 /** Switcher for PAE host paging to AMD64 shadow paging. */
53 VMMSWITCHER_PAE_TO_AMD64,
54 /** Switcher for AMD64 host paging to PAE shadow paging. */
55 VMMSWITCHER_AMD64_TO_PAE,
56 /** Switcher for AMD64 host paging to AMD64 shadow paging. */
57 VMMSWITCHER_AMD64_TO_AMD64,
58 /** Used to make a count for array declarations and suchlike. */
59 VMMSWITCHER_MAX,
60 /** The usual 32-bit paranoia. */
61 VMMSWITCHER_32BIT_HACK = 0x7fffffff
62} VMMSWITCHER;
63
64
65/**
66 * VMMGCCallHost operations.
67 */
68typedef enum VMMCALLHOST
69{
70 /** Invalid operation. */
71 VMMCALLHOST_INVALID = 0,
72 /** Acquire the PDM lock. */
73 VMMCALLHOST_PDM_LOCK,
74 /** Call PDMR3QueueFlushWorker. */
75 VMMCALLHOST_PDM_QUEUE_FLUSH,
76 /** Acquire the PGM lock. */
77 VMMCALLHOST_PGM_LOCK,
78 /** Grow the PGM shadow page pool. */
79 VMMCALLHOST_PGM_POOL_GROW,
80 /** Dynamically allocate physical guest RAM. */
81 VMMCALLHOST_PGM_RAM_GROW_RANGE,
82 /** Replay the REM handler notifications. */
83 VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS,
84 /** Flush the GC/R0 logger. */
85 VMMCALLHOST_VMM_LOGGER_FLUSH,
86 /** Set the VM error message. */
87 VMMCALLHOST_VM_SET_ERROR,
88 /** Set the VM runtime error message. */
89 VMMCALLHOST_VM_SET_RUNTIME_ERROR,
90 /** The usual 32-bit hack. */
91 VMMCALLHOST_32BIT_HACK = 0x7fffffff
92} VMMCALLHOST;
93
94
95
96/**
97 * Gets the bottom of the hypervisor stack - GC Ptr.
98 * I.e. the returned address is not actually writable.
99 *
100 * @returns bottom of the stack.
101 * @param pVM The VM handle.
102 */
103RTGCPTR VMMGetStackGC(PVM pVM);
104
105/**
106 * Gets the bottom of the hypervisor stack - HC Ptr.
107 * I.e. the returned address is not actually writable.
108 *
109 * @returns bottom of the stack.
110 * @param pVM The VM handle.
111 */
112RTHCPTR VMMGetHCStack(PVM pVM);
113
114
115
116#ifdef IN_RING3
117/** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
118 * @ingroup grp_vmm
119 * @{
120 */
121
122/**
123 * Initializes the VMM.
124 *
125 * @returns VBox status code.
126 * @param pVM The VM to operate on.
127 */
128VMMR3DECL(int) VMMR3Init(PVM pVM);
129
130/**
131 * Ring-3 init finalizing.
132 *
133 * @returns VBox status code.
134 * @param pVM The VM handle.
135 */
136VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
137
138/**
139 * Initializes the R0 VMM.
140 *
141 * @returns VBox status code.
142 * @param pVM The VM to operate on.
143 */
144VMMR3DECL(int) VMMR3InitR0(PVM pVM);
145
146/**
147 * Initializes the GC VMM.
148 *
149 * @returns VBox status code.
150 * @param pVM The VM to operate on.
151 */
152VMMR3DECL(int) VMMR3InitGC(PVM pVM);
153
154/**
155 * Destroy the VMM bits.
156 *
157 * @returns VINF_SUCCESS.
158 * @param pVM The VM handle.
159 */
160VMMR3DECL(int) VMMR3Term(PVM pVM);
161
162/**
163 * Applies relocations to data and code managed by this
164 * component. This function will be called at init and
165 * whenever the VMM need to relocate it self inside the GC.
166 *
167 * The VMM will need to apply relocations to the core code.
168 *
169 * @param pVM The VM handle.
170 * @param offDelta The relocation delta.
171 */
172VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
173
174/**
175 * Updates the settings for the GC (and R0?) loggers.
176 *
177 * @returns VBox status code.
178 * @param pVM The VM handle.
179 */
180VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
181
182/**
183 * Gets the pointer to g_szRTAssertMsg1 in GC.
184 * @returns Pointer to VMMGC::g_szRTAssertMsg1.
185 * Returns NULL if not present.
186 * @param pVM The VM handle.
187 */
188VMMR3DECL(const char *) VMMR3GetGCAssertMsg1(PVM pVM);
189
190/**
191 * Gets the pointer to g_szRTAssertMsg2 in GC.
192 * @returns Pointer to VMMGC::g_szRTAssertMsg2.
193 * Returns NULL if not present.
194 * @param pVM The VM handle.
195 */
196VMMR3DECL(const char *) VMMR3GetGCAssertMsg2(PVM pVM);
197
198/**
199 * Resolve a builtin GC symbol.
200 * Called by PDM when loading or relocating GC modules.
201 *
202 * @returns VBox status.
203 * @param pVM VM Handle.
204 * @param pszSymbol Symbol to resolv
205 * @param pGCPtrValue Where to store the symbol value.
206 * @remark This has to work before VMMR3Relocate() is called.
207 */
208VMMR3DECL(int) VMMR3GetImportGC(PVM pVM, const char *pszSymbol, PRTGCPTR pGCPtrValue);
209
210/**
211 * Selects the switcher to be used for switching to GC.
212 *
213 * @returns VBox status code.
214 * @param pVM VM handle.
215 * @param enmSwitcher The new switcher.
216 * @remark This function may be called before the VMM is initialized.
217 */
218VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
219
220/**
221 * Disable the switcher logic permanently.
222 *
223 * @returns VBox status code.
224 * @param pVM VM handle.
225 */
226VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
227
228/**
229 * Executes guest code.
230 *
231 * @param pVM VM handle.
232 */
233VMMR3DECL(int) VMMR3RawRunGC(PVM pVM);
234
235/**
236 * Executes guest code (Intel VMX and AMD SVM).
237 *
238 * @param pVM VM handle.
239 */
240VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM);
241
242/**
243 * Calls GC a function.
244 *
245 * @param pVM The VM handle.
246 * @param GCPtrEntry The GC function address.
247 * @param cArgs The number of arguments in the ....
248 * @param ... Arguments to the function.
249 */
250VMMR3DECL(int) VMMR3CallGC(PVM pVM, RTGCPTR GCPtrEntry, unsigned cArgs, ...);
251
252/**
253 * Calls GC a function.
254 *
255 * @param pVM The VM handle.
256 * @param GCPtrEntry The GC function address.
257 * @param cArgs The number of arguments in the ....
258 * @param args Arguments to the function.
259 */
260VMMR3DECL(int) VMMR3CallGCV(PVM pVM, RTGCPTR GCPtrEntry, unsigned cArgs, va_list args);
261
262/**
263 * Resumes executing hypervisor code when interrupted
264 * by a queue flush or a debug event.
265 *
266 * @returns VBox status code.
267 * @param pVM VM handle.
268 */
269VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM);
270
271/**
272 * Dumps the VM state on a fatal error.
273 *
274 * @param pVM VM Handle.
275 * @param rcErr VBox status code.
276 */
277VMMR3DECL(void) VMMR3FatalDump(PVM pVM, int rcErr);
278
279/**
280 * Acquire global VM lock
281 *
282 * @returns VBox status code
283 * @param pVM The VM to operate on.
284 */
285VMMR3DECL(int) VMMR3Lock(PVM pVM);
286
287/**
288 * Release global VM lock
289 *
290 * @returns VBox status code
291 * @param pVM The VM to operate on.
292 */
293VMMR3DECL(int) VMMR3Unlock(PVM pVM);
294
295/**
296 * Return global VM lock owner
297 *
298 * @returns NIL_RTNATIVETHREAD -> no owner, otherwise thread id of owner
299 * @param pVM The VM to operate on.
300 */
301VMMR3DECL(RTNATIVETHREAD) VMMR3LockGetOwner(PVM pVM);
302
303/**
304 * Checks if the current thread is the owner of the global VM lock.
305 *
306 * @returns true if owner.
307 * @returns false if not owner.
308 * @param pVM The VM to operate on.
309 */
310VMMR3DECL(bool) VMMR3LockIsOwner(PVM pVM);
311
312/**
313 * Suspends the the CPU yielder.
314 *
315 * @param pVM The VM handle.
316 */
317VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
318
319/**
320 * Stops the the CPU yielder.
321 *
322 * @param pVM The VM handle.
323 */
324VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
325
326/**
327 * Resumes the CPU yielder when it has been a suspended or stopped.
328 *
329 * @param pVM The VM handle.
330 */
331VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
332
333/** @} */
334#endif
335
336/** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
337 * @ingroup grp_vmm
338 * @{
339 */
340
341/**
342 * The VMMR0Entry() codes.
343 */
344typedef enum VMMR0OPERATION
345{
346 /** Run guest context. */
347 VMMR0_DO_RAW_RUN = 0,
348 VMMR0_DO_RUN_GC = VMMR0_DO_RAW_RUN,
349 /** Run guest code using the available hardware acceleration technology. */
350 VMMR0_DO_HWACC_RUN,
351 /** Call VMMR0 Per VM Init. */
352 VMMR0_DO_VMMR0_INIT,
353 /** Call VMMR0 Per VM Termination. */
354 VMMR0_DO_VMMR0_TERM,
355 /** Setup the hardware accelerated raw-mode session. */
356 VMMR0_DO_HWACC_SETUP_VM,
357 /** Calls function in the hypervisor.
358 * The caller must setup the hypervisor context so the call will be performed.
359 * The difference between VMMR0_DO_RUN_GC and this one is the handling of
360 * the return GC code. The return code will not be interpreted by this operation.
361 */
362 VMMR0_DO_CALL_HYPERVISOR,
363
364 /** The start of the R0 service operations. */
365 VMMR0_DO_SRV_START,
366 /** Call INTNETR0Open(). */
367 VMMR0_DO_INTNET_OPEN,
368 /** Call INTNETR0IfClose(). */
369 VMMR0_DO_INTNET_IF_CLOSE,
370 /** Call INTNETR0IfGetRing3Buffer(). */
371 VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
372 /** Call INTNETR0IfSetPromiscuousMode(). */
373 VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
374 /** Call INTNETR0IfSend(). */
375 VMMR0_DO_INTNET_IF_SEND,
376 /** Call INTNETR0IfWait(). */
377 VMMR0_DO_INTNET_IF_WAIT,
378 /** The end of the R0 service operations. */
379 VMMR0_DO_SRV_END,
380
381 /** Official NOP that we use for profiling. */
382 VMMR0_DO_NOP,
383 /** Official call we use for testing Ring-0 APIs. */
384 VMMR0_DO_TESTS,
385
386 /** The usual 32-bit type blow up. */
387 VMMR0_DO_32BIT_HACK = 0x7fffffff
388} VMMR0OPERATION;
389
390/**
391 * The Ring 0 entry point, called by the support library (SUP).
392 *
393 * @returns VBox status code.
394 * @param pVM The VM to operate on.
395 * @param uOperation Which operation to execute (VMMR0OPERATION).
396 * @param pvArg Argument to the operation.
397 */
398VMMR0DECL(int) VMMR0Entry(PVM pVM, unsigned /* make me an enum */ uOperation, void *pvArg);
399
400/**
401 * Calls the ring-3 host code.
402 *
403 * @returns VBox status code of the ring-3 call.
404 * @param pVM The VM handle.
405 * @param enmOperation The operation.
406 * @param uArg The argument to the operation.
407 */
408VMMR0DECL(int) VMMR0CallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
409
410/** @} */
411
412
413#ifdef IN_GC
414/** @defgroup grp_vmm_gc The VMM Guest Context API
415 * @ingroup grp_vmm
416 * @{
417 */
418
419/**
420 * The GC entry point.
421 *
422 * @returns VBox status code.
423 * @param pVM The VM to operate on.
424 * @param uOperation Which operation to execute (VMMGCOPERATION).
425 * @param uArg Argument to that operation.
426 * @param ... Additional arguments.
427 */
428VMMGCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
429
430/**
431 * Switches from guest context to host context.
432 *
433 * @param pVM The VM handle.
434 * @param rc The status code.
435 */
436VMMGCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
437
438/**
439 * Calls the ring-3 host code.
440 *
441 * @returns VBox status code of the ring-3 call.
442 * @param pVM The VM handle.
443 * @param enmOperation The operation.
444 * @param uArg The argument to the operation.
445 */
446VMMGCDECL(int) VMMGCCallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
447
448/** @} */
449#endif
450
451
452/** @} */
453__END_DECLS
454
455
456#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette