vmapi.h revision 84161d024cfbfa8f0fd7e79b8c925e1f2ba77009
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * VM - The Virtual Machine, API.
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * Copyright (C) 2006-2013 Oracle Corporation
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * available from http://www.virtualbox.org. This file is free software;
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * you can redistribute it and/or modify it under the terms of the GNU
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * General Public License (GPL) as published by the Free Software
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * The contents of this file may alternatively be used under the terms
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * of the Common Development and Distribution License Version 1.0
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * VirtualBox OSE distribution, in which case the provisions of the
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync * CDDL are applicable instead of those of the GPL.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * You may elect to license modified versions of this file under the
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * terms and conditions of either the GPL or the CDDL or both.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync/** @defgroup grp_vmm_apis VM All Contexts API
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @ingroup grp_vm
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync/** @def VM_RC_ADDR
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * Converts a current context address of data within the VM structure to the equivalent
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * raw-mode address.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @returns raw-mode virtual address.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @param pVM Pointer to the VM.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @param pvInVM CC Pointer within the VM.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)((RTRCUINTPTR)pVM->pVMRC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) )
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)((RTRCUINTPTR)pVM->pVMRC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) )
db4e05173041f696b1362c454bbf7e3a41fbe955vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)(pvInVM) )
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync/** @def VM_R3_ADDR
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * Converts a current context address of data within the VM structure to the equivalent
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * ring-3 host address.
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * @returns host virtual address.
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * @param pVM Pointer to the VM.
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync * @param pvInVM CC pointer within the VM.
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMRC)) )
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) )
99ed66b1a390b4f20a1a921c6f8b4d3d2d251adbvboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)(pvInVM) )
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync/** @def VM_R0_ADDR
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync * Converts a current context address of data within the VM structure to the equivalent
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync * ring-0 host address.
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync * @returns host virtual address.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @param pVM Pointer to the VM.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @param pvInVM CC pointer within the VM.
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMRC)) )
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) )
2b2d2111baf3a01b7144b5b3ed0b19007bf08a50vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)(pvInVM) )
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * VM error callback function.
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * @param pUVM The user mode VM handle. Can be NULL if an error
68e0b366071a6dd88182866e8852ec5ec90a8b66vboxsync * occurred before successfully creating a VM.
typedef DECLCALLBACK(void) FNVMATERROR(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszError, va_list args);
#define VM_SET_ERROR_U(a_pUVM, a_rc, a_pszMessage) (VMR3SetError(a_pUVM, a_rc, RT_SRC_POS, a_pszMessage))
typedef DECLCALLBACK(void) FNVMATRUNTIMEERROR(PUVM pUVM, void *pvUser, uint32_t fFlags, const char *pszErrorId,
VMMDECL(int) VMSetRuntimeError(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...);
VMMDECL(int) VMSetRuntimeErrorV(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list args);
typedef DECLCALLBACK(void) FNVMATSTATE(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
typedef enum VMREQTYPE
VMREQTYPE_INVALID = 0,
} VMREQTYPE;
typedef enum VMREQSTATE
VMREQSTATE_INVALID = 0,
} VMREQSTATE;
typedef enum VMREQFLAGS
} VMREQFLAGS;
typedef struct VMREQ
volatile bool fEventSemClear;
unsigned fFlags;
union VMREQ_U
unsigned cArgs;
} Internal;
} VMREQ;
#ifndef IN_RC
#ifdef IN_RING3
typedef enum VMINITCOMPLETED
typedef enum VMRESUMEREASON
typedef enum VMSUSPENDREASON
VMMR3DECL(int) VMR3Save(PUVM pUVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
VMMR3_INT_DECL(int) VMR3SaveFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, bool *pfSuspended, bool fSkipStateChanges);
VMMR3DECL(int) VMR3Teleport(PUVM pUVM, uint32_t cMsDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended);
VMMR3DECL(int) VMR3LoadFromFile(PUVM pUVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
VMMR3_INT_DECL(int) VMR3LoadFromStreamFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser);
VMMR3DECL(int) VMR3SetErrorV(PUVM pUVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
VMMR3DECL(int) VMR3AtRuntimeErrorRegister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
VMMR3DECL(int) VMR3AtRuntimeErrorDeregister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
VMMR3DECL(int) VMR3ReqCallU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVU(PUVM pUVM, VMCPUID idDstCpu, PVMREQ *ppReq, RTMSINTERVAL cMillies, uint32_t fFlags, PFNRT pfnFunction, unsigned cArgs, va_list Args);
VMMR3_INT_DECL(int) VMR3ReqCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallNoWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3_INT_DECL(int) VMR3ReqCallVoidWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqCallVoidNoWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqPriorityCallWait(PVM pVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqPriorityCallWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3ReqPriorityCallVoidWaitU(PUVM pUVM, VMCPUID idDstCpu, PFNRT pfnFunction, unsigned cArgs, ...);
VMMR3DECL(int) VMR3GetCpuCoreAndPackageIdFromCpuId(PUVM pUVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
#ifdef IN_RC