VirtualBox

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

Last change on this file since 11266 was 10843, checked in by vboxsync, 16 years ago

intnet: Implemented activation on power on & resume, deactivation on power off and suspend, and setting/updating of the mac address.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.9 KB
Line 
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 */
48typedef 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 */
78typedef 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 hypervisor assertion. */
107 VMMCALLHOST_VM_R0_HYPER_ASSERTION,
108 /** The usual 32-bit hack. */
109 VMMCALLHOST_32BIT_HACK = 0x7fffffff
110} VMMCALLHOST;
111
112
113
114/**
115 * Gets the bottom of the hypervisor stack - GC Ptr.
116 * I.e. the returned address is not actually writable.
117 *
118 * @returns bottom of the stack.
119 * @param pVM The VM handle.
120 */
121RTGCPTR VMMGetStackGC(PVM pVM);
122
123/**
124 * Gets the bottom of the hypervisor stack - HC Ptr.
125 * I.e. the returned address is not actually writable.
126 *
127 * @returns bottom of the stack.
128 * @param pVM The VM handle.
129 */
130RTHCPTR VMMGetHCStack(PVM pVM);
131
132
133VMMDECL(uint32_t) VMMGetSvnRev(void);
134
135
136#ifdef IN_RING3
137/** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
138 * @ingroup grp_vmm
139 * @{
140 */
141
142/**
143 * Initializes the VMM.
144 *
145 * @returns VBox status code.
146 * @param pVM The VM to operate on.
147 */
148VMMR3DECL(int) VMMR3Init(PVM pVM);
149
150/**
151 * Ring-3 init finalizing.
152 *
153 * @returns VBox status code.
154 * @param pVM The VM handle.
155 */
156VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
157
158/**
159 * Initializes the R0 VMM.
160 *
161 * @returns VBox status code.
162 * @param pVM The VM to operate on.
163 */
164VMMR3DECL(int) VMMR3InitR0(PVM pVM);
165
166/**
167 * Initializes the GC VMM.
168 *
169 * @returns VBox status code.
170 * @param pVM The VM to operate on.
171 */
172VMMR3DECL(int) VMMR3InitGC(PVM pVM);
173
174/**
175 * Destroy the VMM bits.
176 *
177 * @returns VINF_SUCCESS.
178 * @param pVM The VM handle.
179 */
180VMMR3DECL(int) VMMR3Term(PVM pVM);
181
182/**
183 * Applies relocations to data and code managed by this
184 * component. This function will be called at init and
185 * whenever the VMM need to relocate it self inside the GC.
186 *
187 * The VMM will need to apply relocations to the core code.
188 *
189 * @param pVM The VM handle.
190 * @param offDelta The relocation delta.
191 */
192VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
193
194/**
195 * Updates the settings for the GC (and R0?) loggers.
196 *
197 * @returns VBox status code.
198 * @param pVM The VM handle.
199 */
200VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
201
202/**
203 * Gets the pointer to g_szRTAssertMsg1 in GC.
204 * @returns Pointer to VMMGC::g_szRTAssertMsg1.
205 * Returns NULL if not present.
206 * @param pVM The VM handle.
207 */
208VMMR3DECL(const char *) VMMR3GetGCAssertMsg1(PVM pVM);
209
210/**
211 * Gets the pointer to g_szRTAssertMsg2 in GC.
212 * @returns Pointer to VMMGC::g_szRTAssertMsg2.
213 * Returns NULL if not present.
214 * @param pVM The VM handle.
215 */
216VMMR3DECL(const char *) VMMR3GetGCAssertMsg2(PVM pVM);
217
218/**
219 * Resolve a builtin GC symbol.
220 * Called by PDM when loading or relocating GC modules.
221 *
222 * @returns VBox status.
223 * @param pVM VM Handle.
224 * @param pszSymbol Symbol to resolv
225 * @param pGCPtrValue Where to store the symbol value.
226 * @remark This has to work before VMMR3Relocate() is called.
227 */
228VMMR3DECL(int) VMMR3GetImportGC(PVM pVM, const char *pszSymbol, PRTGCPTR pGCPtrValue);
229
230/**
231 * Selects the switcher to be used for switching to GC.
232 *
233 * @returns VBox status code.
234 * @param pVM VM handle.
235 * @param enmSwitcher The new switcher.
236 * @remark This function may be called before the VMM is initialized.
237 */
238VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
239
240/**
241 * Disable the switcher logic permanently.
242 *
243 * @returns VBox status code.
244 * @param pVM VM handle.
245 */
246VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
247
248/**
249 * Executes guest code.
250 *
251 * @param pVM VM handle.
252 */
253VMMR3DECL(int) VMMR3RawRunGC(PVM pVM);
254
255/**
256 * Executes guest code (Intel VMX and AMD SVM).
257 *
258 * @param pVM VM handle.
259 */
260VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM);
261
262/**
263 * Calls GC a function.
264 *
265 * @param pVM The VM handle.
266 * @param GCPtrEntry The GC function address.
267 * @param cArgs The number of arguments in the ....
268 * @param ... Arguments to the function.
269 */
270VMMR3DECL(int) VMMR3CallGC(PVM pVM, RTGCPTR GCPtrEntry, unsigned cArgs, ...);
271
272/**
273 * Calls GC a function.
274 *
275 * @param pVM The VM handle.
276 * @param GCPtrEntry The GC function address.
277 * @param cArgs The number of arguments in the ....
278 * @param args Arguments to the function.
279 */
280VMMR3DECL(int) VMMR3CallGCV(PVM pVM, RTGCPTR GCPtrEntry, unsigned cArgs, va_list args);
281
282/**
283 * Resumes executing hypervisor code when interrupted
284 * by a queue flush or a debug event.
285 *
286 * @returns VBox status code.
287 * @param pVM VM handle.
288 */
289VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM);
290
291/**
292 * Dumps the VM state on a fatal error.
293 *
294 * @param pVM VM Handle.
295 * @param rcErr VBox status code.
296 */
297VMMR3DECL(void) VMMR3FatalDump(PVM pVM, int rcErr);
298
299/**
300 * Acquire global VM lock
301 *
302 * @returns VBox status code
303 * @param pVM The VM to operate on.
304 */
305VMMR3DECL(int) VMMR3Lock(PVM pVM);
306
307/**
308 * Release global VM lock
309 *
310 * @returns VBox status code
311 * @param pVM The VM to operate on.
312 */
313VMMR3DECL(int) VMMR3Unlock(PVM pVM);
314
315/**
316 * Return global VM lock owner
317 *
318 * @returns NIL_RTNATIVETHREAD -> no owner, otherwise thread id of owner
319 * @param pVM The VM to operate on.
320 */
321VMMR3DECL(RTNATIVETHREAD) VMMR3LockGetOwner(PVM pVM);
322
323/**
324 * Checks if the current thread is the owner of the global VM lock.
325 *
326 * @returns true if owner.
327 * @returns false if not owner.
328 * @param pVM The VM to operate on.
329 */
330VMMR3DECL(bool) VMMR3LockIsOwner(PVM pVM);
331
332/**
333 * Suspends the the CPU yielder.
334 *
335 * @param pVM The VM handle.
336 */
337VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
338
339/**
340 * Stops the the CPU yielder.
341 *
342 * @param pVM The VM handle.
343 */
344VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
345
346/**
347 * Resumes the CPU yielder when it has been a suspended or stopped.
348 *
349 * @param pVM The VM handle.
350 */
351VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
352
353/** @} */
354#endif
355
356/** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
357 * @ingroup grp_vmm
358 * @{
359 */
360
361/**
362 * The VMMR0Entry() codes.
363 */
364typedef enum VMMR0OPERATION
365{
366 /** Run guest context. */
367 VMMR0_DO_RAW_RUN = SUP_VMMR0_DO_RAW_RUN,
368 /** Run guest code using the available hardware acceleration technology. */
369 VMMR0_DO_HWACC_RUN = SUP_VMMR0_DO_HWACC_RUN,
370 /** Official NOP that we use for profiling. */
371 VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
372 /** Official slow iocl NOP that we use for profiling. */
373 VMMR0_DO_SLOW_NOP,
374
375 /** Ask the GVMM to create a new VM. */
376 VMMR0_DO_GVMM_CREATE_VM,
377 /** Ask the GVMM to destroy the VM. */
378 VMMR0_DO_GVMM_DESTROY_VM,
379 /** Call GVMMR0SchedHalt(). */
380 VMMR0_DO_GVMM_SCHED_HALT,
381 /** Call GVMMR0SchedWakeUp(). */
382 VMMR0_DO_GVMM_SCHED_WAKE_UP,
383 /** Call GVMMR0SchedPoll(). */
384 VMMR0_DO_GVMM_SCHED_POLL,
385 /** Call GVMMR0QueryStatistics(). */
386 VMMR0_DO_GVMM_QUERY_STATISTICS,
387 /** Call GVMMR0ResetStatistics(). */
388 VMMR0_DO_GVMM_RESET_STATISTICS,
389
390 /** Call VMMR0 Per VM Init. */
391 VMMR0_DO_VMMR0_INIT,
392 /** Call VMMR0 Per VM Termination. */
393 VMMR0_DO_VMMR0_TERM,
394 /** Setup the hardware accelerated raw-mode session. */
395 VMMR0_DO_HWACC_SETUP_VM,
396 /** Attempt to enable or disable hardware accelerated raw-mode. */
397 VMMR0_DO_HWACC_ENABLE,
398 /** Calls function in the hypervisor.
399 * The caller must setup the hypervisor context so the call will be performed.
400 * The difference between VMMR0_DO_RUN_GC and this one is the handling of
401 * the return GC code. The return code will not be interpreted by this operation.
402 */
403 VMMR0_DO_CALL_HYPERVISOR,
404
405 /** Call PGMR0PhysAllocateHandyPages(). */
406 VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES,
407
408 /** Call GMMR0InitialReservation(). */
409 VMMR0_DO_GMM_INITIAL_RESERVATION,
410 /** Call GMMR0UpdateReservation(). */
411 VMMR0_DO_GMM_UPDATE_RESERVATION,
412 /** Call GMMR0AllocatePages(). */
413 VMMR0_DO_GMM_ALLOCATE_PAGES,
414 /** Call GMMR0FreePages(). */
415 VMMR0_DO_GMM_FREE_PAGES,
416 /** Call GMMR0BalloonedPages(). */
417 VMMR0_DO_GMM_BALLOONED_PAGES,
418 /** Call GMMR0DeflatedBalloon(). */
419 VMMR0_DO_GMM_DEFLATED_BALLOON,
420 /** Call GMMR0MapUnmapChunk(). */
421 VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
422 /** Call GMMR0SeedChunk(). */
423 VMMR0_DO_GMM_SEED_CHUNK,
424
425 /** Set a GVMM or GMM configuration value. */
426 VMMR0_DO_GCFGM_SET_VALUE,
427 /** Query a GVMM or GMM configuration value. */
428 VMMR0_DO_GCFGM_QUERY_VALUE,
429
430 /** The start of the R0 service operations. */
431 VMMR0_DO_SRV_START,
432 /** Call INTNETR0Open(). */
433 VMMR0_DO_INTNET_OPEN,
434 /** Call INTNETR0IfClose(). */
435 VMMR0_DO_INTNET_IF_CLOSE,
436 /** Call INTNETR0IfGetRing3Buffer(). */
437 VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
438 /** Call INTNETR0IfSetPromiscuousMode(). */
439 VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
440 /** Call INTNETR0IfSetMacAddress(). */
441 VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
442 /** Call INTNETR0IfSetActive(). */
443 VMMR0_DO_INTNET_IF_SET_ACTIVE,
444 /** Call INTNETR0IfSend(). */
445 VMMR0_DO_INTNET_IF_SEND,
446 /** Call INTNETR0IfWait(). */
447 VMMR0_DO_INTNET_IF_WAIT,
448 /** The end of the R0 service operations. */
449 VMMR0_DO_SRV_END,
450
451 /** Official call we use for testing Ring-0 APIs. */
452 VMMR0_DO_TESTS,
453
454 /** The usual 32-bit type blow up. */
455 VMMR0_DO_32BIT_HACK = 0x7fffffff
456} VMMR0OPERATION;
457
458
459/**
460 * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
461 * @todo Move got GCFGM.h when it's implemented.
462 */
463typedef struct GCFGMVALUEREQ
464{
465 /** The request header.*/
466 SUPVMMR0REQHDR Hdr;
467 /** The support driver session handle. */
468 PSUPDRVSESSION pSession;
469 /** The value.
470 * This is input for the set request and output for the query. */
471 uint64_t u64Value;
472 /** The variable name.
473 * This is fixed sized just to make things simple for the mock-up. */
474 char szName[48];
475} GCFGMVALUEREQ;
476/** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
477 * @todo Move got GCFGM.h when it's implemented.
478 */
479typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
480
481
482/**
483 * The Ring 0 entry point, called by the interrupt gate.
484 *
485 * @returns VBox status code.
486 * @param pVM The VM to operate on.
487 * @param enmOperation Which operation to execute.
488 * @param pvArg Argument to the operation.
489 * @remarks Assume called with interrupts or preemption disabled.
490 */
491VMMR0DECL(int) VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
492
493/**
494 * The Ring 0 entry point, called by the fast-ioctl path.
495 *
496 * @returns VBox status code.
497 * @param pVM The VM to operate on.
498 * @param enmOperation Which operation to execute.
499 * @remarks Assume called with interrupts _enabled_.
500 */
501VMMR0DECL(void) VMMR0EntryFast(PVM pVM, VMMR0OPERATION enmOperation);
502
503/**
504 * The Ring 0 entry point, called by the support library (SUP).
505 *
506 * @returns VBox status code.
507 * @param pVM The VM to operate on.
508 * @param enmOperation Which operation to execute.
509 * @param pReq This points to a SUPVMMR0REQHDR packet. Optional.
510 * @param u64Arg Some simple constant argument.
511 * @param pSession The session of the caller.
512 * @remarks Assume called with interrupts _enabled_.
513 */
514VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
515
516/**
517 * Calls the ring-3 host code.
518 *
519 * @returns VBox status code of the ring-3 call.
520 * @param pVM The VM handle.
521 * @param enmOperation The operation.
522 * @param uArg The argument to the operation.
523 */
524VMMR0DECL(int) VMMR0CallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
525
526/** @} */
527
528
529#ifdef IN_GC
530/** @defgroup grp_vmm_gc The VMM Guest Context API
531 * @ingroup grp_vmm
532 * @{
533 */
534
535/**
536 * The GC entry point.
537 *
538 * @returns VBox status code.
539 * @param pVM The VM to operate on.
540 * @param uOperation Which operation to execute (VMMGCOPERATION).
541 * @param uArg Argument to that operation.
542 * @param ... Additional arguments.
543 */
544VMMGCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
545
546/**
547 * Switches from guest context to host context.
548 *
549 * @param pVM The VM handle.
550 * @param rc The status code.
551 */
552VMMGCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
553
554/**
555 * Calls the ring-3 host code.
556 *
557 * @returns VBox status code of the ring-3 call.
558 * @param pVM The VM handle.
559 * @param enmOperation The operation.
560 * @param uArg The argument to the operation.
561 */
562VMMGCDECL(int) VMMGCCallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
563
564/** @} */
565#endif
566
567
568/** @} */
569__END_DECLS
570
571
572#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