vmm.h revision 86b51be433c7032578ae50e94ebe590cc428448b
/** @file
* VMM - The Virtual Machine Monitor.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___VBox_vmm_h
#define ___VBox_vmm_h
/** @defgroup grp_vmm The Virtual Machine Monitor API
* @{
*/
/**
* World switcher identifiers.
*/
typedef enum VMMSWITCHER
{
/** The usual invalid 0. */
VMMSWITCHER_INVALID = 0,
/** Switcher for 32-bit host to 32-bit shadow paging. */
/** Switcher for 32-bit host paging to PAE shadow paging. */
/** Switcher for 32-bit host paging to AMD64 shadow paging. */
/** Switcher for PAE host to 32-bit shadow paging. */
/** Switcher for PAE host to PAE shadow paging. */
/** Switcher for PAE host paging to AMD64 shadow paging. */
/** Switcher for AMD64 host paging to PAE shadow paging. */
/** Switcher for AMD64 host paging to AMD64 shadow paging. */
/** Used to make a count for array declarations and suchlike. */
/** The usual 32-bit paranoia. */
VMMSWITCHER_32BIT_HACK = 0x7fffffff
} VMMSWITCHER;
/**
* VMMGCCallHost operations.
*/
typedef enum VMMCALLHOST
{
/** Invalid operation. */
VMMCALLHOST_INVALID = 0,
/** Acquire the PDM lock. */
/** Call PDMR3QueueFlushWorker. */
/** Acquire the PGM lock. */
/** Grow the PGM shadow page pool. */
/** Maps a chunk into ring-3. */
/** Allocates more handy pages. */
#ifndef NEW_PHYS_CODE
/** Dynamically allocate physical guest RAM. */
#endif
/** Replay the REM handler notifications. */
/** Set the VM error message. */
/** Set the VM runtime error message. */
/** Signal a ring 0 hypervisor assertion. */
/** The usual 32-bit hack. */
VMMCALLHOST_32BIT_HACK = 0x7fffffff
} VMMCALLHOST;
/**
* Gets the bottom of the hypervisor stack - GC Ptr.
* I.e. the returned address is not actually writable.
*
* @returns bottom of the stack.
* @param pVM The VM handle.
*/
/**
* Gets the bottom of the hypervisor stack - HC Ptr.
* I.e. the returned address is not actually writable.
*
* @returns bottom of the stack.
* @param pVM The VM handle.
*/
#ifdef IN_RING3
/** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
* @ingroup grp_vmm
* @{
*/
/**
* Initializes the VMM.
*
* @returns VBox status code.
* @param pVM The VM to operate on.
*/
/**
* Ring-3 init finalizing.
*
* @returns VBox status code.
* @param pVM The VM handle.
*/
/**
* Initializes the R0 VMM.
*
* @returns VBox status code.
* @param pVM The VM to operate on.
*/
/**
* Initializes the GC VMM.
*
* @returns VBox status code.
* @param pVM The VM to operate on.
*/
/**
* Destroy the VMM bits.
*
* @returns VINF_SUCCESS.
* @param pVM The VM handle.
*/
/**
* Applies relocations to data and code managed by this
* component. This function will be called at init and
* whenever the VMM need to relocate it self inside the GC.
*
* The VMM will need to apply relocations to the core code.
*
* @param pVM The VM handle.
* @param offDelta The relocation delta.
*/
/**
* Updates the settings for the GC (and R0?) loggers.
*
* @returns VBox status code.
* @param pVM The VM handle.
*/
/**
* Gets the pointer to g_szRTAssertMsg1 in GC.
* @returns Pointer to VMMGC::g_szRTAssertMsg1.
* Returns NULL if not present.
* @param pVM The VM handle.
*/
/**
* Gets the pointer to g_szRTAssertMsg2 in GC.
* @returns Pointer to VMMGC::g_szRTAssertMsg2.
* Returns NULL if not present.
* @param pVM The VM handle.
*/
/**
* Resolve a builtin GC symbol.
* Called by PDM when loading or relocating GC modules.
*
* @returns VBox status.
* @param pVM VM Handle.
* @param pszSymbol Symbol to resolv
* @param pGCPtrValue Where to store the symbol value.
* @remark This has to work before VMMR3Relocate() is called.
*/
/**
* Selects the switcher to be used for switching to GC.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param enmSwitcher The new switcher.
* @remark This function may be called before the VMM is initialized.
*/
/**
* Disable the switcher logic permanently.
*
* @returns VBox status code.
* @param pVM VM handle.
*/
/**
* Executes guest code.
*
* @param pVM VM handle.
*/
/**
* Executes guest code (Intel VMX and AMD SVM).
*
* @param pVM VM handle.
*/
/**
* Calls GC a function.
*
* @param pVM The VM handle.
* @param GCPtrEntry The GC function address.
* @param cArgs The number of arguments in the ....
* @param ... Arguments to the function.
*/
/**
* Calls GC a function.
*
* @param pVM The VM handle.
* @param GCPtrEntry The GC function address.
* @param cArgs The number of arguments in the ....
* @param args Arguments to the function.
*/
/**
* Resumes executing hypervisor code when interrupted
* by a queue flush or a debug event.
*
* @returns VBox status code.
* @param pVM VM handle.
*/
/**
* Dumps the VM state on a fatal error.
*
* @param pVM VM Handle.
* @param rcErr VBox status code.
*/
/**
* Acquire global VM lock
*
* @returns VBox status code
* @param pVM The VM to operate on.
*/
/**
* Release global VM lock
*
* @returns VBox status code
* @param pVM The VM to operate on.
*/
/**
* Return global VM lock owner
*
* @returns NIL_RTNATIVETHREAD -> no owner, otherwise thread id of owner
* @param pVM The VM to operate on.
*/
/**
* Checks if the current thread is the owner of the global VM lock.
*
* @returns true if owner.
* @returns false if not owner.
* @param pVM The VM to operate on.
*/
/**
* Suspends the the CPU yielder.
*
* @param pVM The VM handle.
*/
/**
* Stops the the CPU yielder.
*
* @param pVM The VM handle.
*/
/**
* Resumes the CPU yielder when it has been a suspended or stopped.
*
* @param pVM The VM handle.
*/
/** @} */
#endif
/** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
* @ingroup grp_vmm
* @{
*/
/**
* The VMMR0Entry() codes.
*/
typedef enum VMMR0OPERATION
{
/** Run guest context. */
/** Run guest code using the available hardware acceleration technology. */
/** Official NOP that we use for profiling. */
/** Ask the GVMM to create a new VM. */
/** Ask the GVMM to destroy the VM. */
/** Call GVMMR0SchedHalt(). */
/** Call GVMMR0SchedWakeUp(). */
/** Call GVMMR0SchedPoll(). */
/** Call GVMMR0QueryStatistics(). */
/** Call GVMMR0ResetStatistics(). */
/** Call VMMR0 Per VM Init. */
/** Call VMMR0 Per VM Termination. */
/** Setup the hardware accelerated raw-mode session. */
/** Calls function in the hypervisor.
* The caller must setup the hypervisor context so the call will be performed.
* The difference between VMMR0_DO_RUN_GC and this one is the handling of
* the return GC code. The return code will not be interpreted by this operation.
*/
/** Call PGMR0PhysAllocateHandyPages(). */
/** Call GMMR0InitialReservation(). */
/** Call GMMR0UpdateReservation(). */
/** Call GMMR0AllocatePages(). */
/** Call GMMR0FreePages(). */
/** Call GMMR0BalloonedPages(). */
/** Call GMMR0DeflatedBalloon(). */
/** Call GMMR0MapUnmapChunk(). */
/** Call GMMR0SeedChunk(). */
/** Set a GVMM or GMM configuration value. */
/** Query a GVMM or GMM configuration value. */
/** The start of the R0 service operations. */
/** Call INTNETR0Open(). */
/** Call INTNETR0IfClose(). */
/** Call INTNETR0IfGetRing3Buffer(). */
/** Call INTNETR0IfSetPromiscuousMode(). */
/** Call INTNETR0IfSend(). */
/** Call INTNETR0IfWait(). */
/** The end of the R0 service operations. */
/** Official call we use for testing Ring-0 APIs. */
/** The usual 32-bit type blow up. */
VMMR0_DO_32BIT_HACK = 0x7fffffff
/**
* Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
* @todo Move got GCFGM.h when it's implemented.
*/
typedef struct GCFGMVALUEREQ
{
/** The request header.*/
/** The support driver session handle. */
/** The value.
* This is input for the set request and output for the query. */
/** The variable name.
* This is fixed sized just to make things simple for the mock-up. */
char szName[48];
/** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
* @todo Move got GCFGM.h when it's implemented.
*/
typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
/**
* The Ring 0 entry point, called by the interrupt gate.
*
* @returns VBox status code.
* @param pVM The VM to operate on.
* @param enmOperation Which operation to execute.
* @param pvArg Argument to the operation.
* @remarks Assume called with interrupts disabled.
*/
/**
* The Ring 0 entry point, called by the fast-ioctl path.
*
* @returns VBox status code.
* @param pVM The VM to operate on.
* @param enmOperation Which operation to execute.
* @remarks Assume called with interrupts _enabled_.
*/
/**
* The Ring 0 entry point, called by the support library (SUP).
*
* @returns VBox status code.
* @param pVM The VM to operate on.
* @param enmOperation Which operation to execute.
* @param pReq This points to a SUPVMMR0REQHDR packet. Optional.
* @param u64Arg Some simple constant argument.
* @remarks Assume called with interrupts _enabled_.
*/
VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg);
/**
* Calls the ring-3 host code.
*
* @returns VBox status code of the ring-3 call.
* @param pVM The VM handle.
* @param enmOperation The operation.
* @param uArg The argument to the operation.
*/
/** @} */
#ifdef IN_GC
/** @defgroup grp_vmm_gc The VMM Guest Context API
* @ingroup grp_vmm
* @{
*/
/**
* The GC entry point.
*
* @returns VBox status code.
* @param pVM The VM to operate on.
* @param uOperation Which operation to execute (VMMGCOPERATION).
* @param uArg Argument to that operation.
* @param ... Additional arguments.
*/
/**
* Switches from guest context to host context.
*
* @param pVM The VM handle.
* @param rc The status code.
*/
/**
* Calls the ring-3 host code.
*
* @returns VBox status code of the ring-3 call.
* @param pVM The VM handle.
* @param enmOperation The operation.
* @param uArg The argument to the operation.
*/
/** @} */
#endif
/** @} */
#endif