VirtualBox

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

Last change on this file since 4799 was 4799, checked in by vboxsync, 18 years ago

blanks.

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

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