vmapi.h revision 0f81043c307886fc3e8d0479c4e4120b35c6d0b9
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @file
00314ca59bb0358d05053ee753174724d82adff4vboxsync * VM - The Virtual Machine, API.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/*
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync * Copyright (C) 2006-2010 Oracle Corporation
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync *
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync * available from http://www.virtualbox.org. This file is free software;
c98fb3e16fcd571a790eab772c0c66173d225205vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync *
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * The contents of this file may alternatively be used under the terms
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * of the Common Development and Distribution License Version 1.0
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution, in which case the provisions of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * CDDL are applicable instead of those of the GPL.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync *
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * You may elect to license modified versions of this file under the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * terms and conditions of either the GPL or the CDDL or both.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync#ifndef ___VBox_vmm_vmapi_h
00314ca59bb0358d05053ee753174724d82adff4vboxsync#define ___VBox_vmm_vmapi_h
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync#include <VBox/types.h>
00314ca59bb0358d05053ee753174724d82adff4vboxsync#include <VBox/vmm/stam.h>
00314ca59bb0358d05053ee753174724d82adff4vboxsync#include <VBox/vmm/cfgm.h>
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync#include <iprt/stdarg.h>
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncRT_C_DECLS_BEGIN
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @defgroup grp_vmm_apis VM All Contexts API
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @ingroup grp_vm
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @{ */
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @def VM_RC_ADDR
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Converts a current context address of data within the VM structure to the equivalent
00314ca59bb0358d05053ee753174724d82adff4vboxsync * raw-mode address.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @returns raw-mode virtual address.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pVM Pointer to the VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvInVM CC Pointer within the VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#ifdef IN_RING3
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)((RTRCUINTPTR)pVM->pVMRC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#elif defined(IN_RING0)
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)((RTRCUINTPTR)pVM->pVMRC + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#else
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_RC_ADDR(pVM, pvInVM) ( (RTRCPTR)(pvInVM) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#endif
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @def VM_R3_ADDR
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Converts a current context address of data within the VM structure to the equivalent
00314ca59bb0358d05053ee753174724d82adff4vboxsync * ring-3 host address.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @returns host virtual address.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pVM Pointer to the VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvInVM CC pointer within the VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#ifdef IN_RC
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMRC)) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#elif defined(IN_RING0)
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)((RTR3UINTPTR)pVM->pVMR3 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR0)) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#else
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_R3_ADDR(pVM, pvInVM) ( (RTR3PTR)(pvInVM) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#endif
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @def VM_R0_ADDR
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Converts a current context address of data within the VM structure to the equivalent
00314ca59bb0358d05053ee753174724d82adff4vboxsync * ring-0 host address.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @returns host virtual address.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pVM Pointer to the VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvInVM CC pointer within the VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#ifdef IN_RC
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMRC)) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#elif defined(IN_RING3)
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)((RTR0UINTPTR)pVM->pVMR0 + (uint32_t)((uintptr_t)(pvInVM) - (uintptr_t)pVM->pVMR3)) )
00314ca59bb0358d05053ee753174724d82adff4vboxsync#else
00314ca59bb0358d05053ee753174724d82adff4vboxsync# define VM_R0_ADDR(pVM, pvInVM) ( (RTR0PTR)(pvInVM) )
a74c1d37f653a258a981c18485e9df00b6e86e2evboxsync#endif
a74c1d37f653a258a981c18485e9df00b6e86e2evboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * VM error callback function.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pUVM The user mode VM handle. Can be NULL if an error
00314ca59bb0358d05053ee753174724d82adff4vboxsync * occurred before successfully creating a VM.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvUser The user argument.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param rc VBox status code.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param RT_SRC_POS_DECL The source position arguments. See RT_SRC_POS and RT_SRC_POS_ARGS.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pszFormat Error message format string.
a74c1d37f653a258a981c18485e9df00b6e86e2evboxsync * @param args Error message arguments.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef DECLCALLBACK(void) FNVMATERROR(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszError, va_list args);
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Pointer to a VM error callback. */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef FNVMATERROR *PFNVMATERROR;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMDECL(int) VMSetError(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMDECL(int) VMSetErrorV(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args);
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @def VM_SET_ERROR
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Macro for setting a simple VM error message.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Don't use '%' in the message!
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @returns rc. Meaning you can do:
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @code
00314ca59bb0358d05053ee753174724d82adff4vboxsync * return VM_SET_ERROR(pVM, VERR_OF_YOUR_CHOICE, "descriptive message");
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @endcode
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pVM VM handle.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param rc VBox status code.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pszMessage Error message string.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @thread Any
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#define VM_SET_ERROR(pVM, rc, pszMessage) (VMSetError(pVM, rc, RT_SRC_POS, pszMessage))
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * VM runtime error callback function.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * See VMSetRuntimeError for the detailed description of parameters.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pUVM The user mode VM handle.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvUser The user argument.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param fFlags The error flags.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pszErrorId Error ID string.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pszFormat Error message format string.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param va Error message arguments.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef DECLCALLBACK(void) FNVMATRUNTIMEERROR(PUVM pUVM, void *pvUser, uint32_t fFlags, const char *pszErrorId,
00314ca59bb0358d05053ee753174724d82adff4vboxsync const char *pszFormat, va_list va);
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Pointer to a VM runtime error callback. */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef FNVMATRUNTIMEERROR *PFNVMATRUNTIMEERROR;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMDECL(int) VMSetRuntimeError(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMDECL(int) VMSetRuntimeErrorV(PVM pVM, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list args);
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @name VMSetRuntimeError fFlags
00314ca59bb0358d05053ee753174724d82adff4vboxsync * When no flags are given the VM will continue running and it's up to the front
00314ca59bb0358d05053ee753174724d82adff4vboxsync * end to take action on the error condition.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @{ */
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** The error is fatal.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * The VM is not in a state where it can be saved and will enter a state
00314ca59bb0358d05053ee753174724d82adff4vboxsync * where it can no longer execute code. The caller <b>must</b> propagate status
00314ca59bb0358d05053ee753174724d82adff4vboxsync * codes. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#define VMSETRTERR_FLAGS_FATAL RT_BIT_32(0)
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Suspend the VM after, or if possible before, raising the error on EMT. The
00314ca59bb0358d05053ee753174724d82adff4vboxsync * caller <b>must</b> propagate status codes. */
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync#define VMSETRTERR_FLAGS_SUSPEND RT_BIT_32(1)
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Don't wait for the EMT to handle the request.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Only valid when on a worker thread and there is a high risk of a dead
00314ca59bb0358d05053ee753174724d82adff4vboxsync * lock. Be careful not to flood the user with errors. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#define VMSETRTERR_FLAGS_NO_WAIT RT_BIT_32(2)
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @} */
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * VM state change callback function.
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * You are not allowed to call any function which changes the VM state from a
00314ca59bb0358d05053ee753174724d82adff4vboxsync * state callback, except VMR3Destroy().
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pUVM The user mode VM handle.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param enmState The new state.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param enmOldState The old state.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvUser The user argument.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef DECLCALLBACK(void) FNVMATSTATE(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Pointer to a VM state callback. */
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsynctypedef FNVMATSTATE *PFNVMATSTATE;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMDECL(const char *) VMGetStateName(VMSTATE enmState);
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Request type.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef enum VMREQTYPE
00314ca59bb0358d05053ee753174724d82adff4vboxsync{
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Invalid request. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQTYPE_INVALID = 0,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** VM: Internal. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQTYPE_INTERNAL,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Maximum request type (exclusive). Used for validation. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQTYPE_MAX
00314ca59bb0358d05053ee753174724d82adff4vboxsync} VMREQTYPE;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync * Request state.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef enum VMREQSTATE
00314ca59bb0358d05053ee753174724d82adff4vboxsync{
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The state is invalid. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQSTATE_INVALID = 0,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request have been allocated and is in the process of being filed. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQSTATE_ALLOCATED,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request is queued by the requester. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQSTATE_QUEUED,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request is begin processed. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQSTATE_PROCESSING,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request is completed, the requester is begin notified. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQSTATE_COMPLETED,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request packet is in the free chain. (The requester */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQSTATE_FREE
00314ca59bb0358d05053ee753174724d82adff4vboxsync} VMREQSTATE;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Request flags.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef enum VMREQFLAGS
00314ca59bb0358d05053ee753174724d82adff4vboxsync{
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request returns a VBox status code. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQFLAGS_VBOX_STATUS = 0,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The request is a void request and have no status code. */
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync VMREQFLAGS_VOID = 1,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Return type mask. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQFLAGS_RETURN_MASK = 1,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Caller does not wait on the packet, EMT will free it. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQFLAGS_NO_WAIT = 2,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Poke the destination EMT(s) if executing guest code. Use with care. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQFLAGS_POKE = 4,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Priority request that can safely be processed while doing async
00314ca59bb0358d05053ee753174724d82adff4vboxsync * suspend and power off. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQFLAGS_PRIORITY = 8
00314ca59bb0358d05053ee753174724d82adff4vboxsync} VMREQFLAGS;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * VM Request packet.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * This is used to request an action in the EMT. Usually the requester is
00314ca59bb0358d05053ee753174724d82adff4vboxsync * another thread, but EMT can also end up being the requester in which case
00314ca59bb0358d05053ee753174724d82adff4vboxsync * it's carried out synchronously.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef struct VMREQ
00314ca59bb0358d05053ee753174724d82adff4vboxsync{
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Pointer to the next request in the chain. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync struct VMREQ * volatile pNext;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Pointer to ring-3 VM structure which this request belongs to. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync PUVM pUVM;
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync /** Request state. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync volatile VMREQSTATE enmState;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** VBox status code for the completed request. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync volatile int32_t iStatus;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Requester event sem.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * The request can use this event semaphore to wait/poll for completion
00314ca59bb0358d05053ee753174724d82adff4vboxsync * of the request.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsync RTSEMEVENT EventSem;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Set if the event semaphore is clear. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync volatile bool fEventSemClear;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Flags, VMR3REQ_FLAGS_*. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync unsigned fFlags;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Request type. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMREQTYPE enmType;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Request destination. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMCPUID idDstCpu;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Request specific data. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync union VMREQ_U
00314ca59bb0358d05053ee753174724d82adff4vboxsync {
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** VMREQTYPE_INTERNAL. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync struct
00314ca59bb0358d05053ee753174724d82adff4vboxsync {
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Pointer to the function to be called. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync PFNRT pfn;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Number of arguments. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync unsigned cArgs;
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** Array of arguments. */
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync uintptr_t aArgs[64];
00314ca59bb0358d05053ee753174724d82adff4vboxsync } Internal;
00314ca59bb0358d05053ee753174724d82adff4vboxsync } u;
00314ca59bb0358d05053ee753174724d82adff4vboxsync} VMREQ;
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Pointer to a VM request packet. */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef VMREQ *PVMREQ;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @} */
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync#ifndef IN_RC
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync/** @defgroup grp_vmm_apis_hc VM Host Context API
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @ingroup grp_vm
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @{ */
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @} */
00314ca59bb0358d05053ee753174724d82adff4vboxsync#endif
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync#ifdef IN_RING3
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** @defgroup grp_vmm_apis_r3 VM Host Context Ring 3 API
00314ca59bb0358d05053ee753174724d82adff4vboxsync * This interface is a _draft_!
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @ingroup grp_vm
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @{ */
cb13ee8e628d04a773894bf4f9e8047d74f2ee21vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Completion notification codes.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef enum VMINITCOMPLETED
00314ca59bb0358d05053ee753174724d82adff4vboxsync{
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The ring-3 init is completed. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMINITCOMPLETED_RING3 = 1,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The ring-0 init is completed. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMINITCOMPLETED_RING0,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The hardware accelerated virtualization init is completed.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Used to make decisision depending on whether HMIsEnabled(). */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMINITCOMPLETED_HM,
00314ca59bb0358d05053ee753174724d82adff4vboxsync /** The GC init is completed. */
00314ca59bb0358d05053ee753174724d82adff4vboxsync VMINITCOMPLETED_GC
00314ca59bb0358d05053ee753174724d82adff4vboxsync} VMINITCOMPLETED;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync/**
00314ca59bb0358d05053ee753174724d82adff4vboxsync * Progress callback.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * This will report the completion percentage of an operation.
00314ca59bb0358d05053ee753174724d82adff4vboxsync *
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @returns VINF_SUCCESS.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @returns Error code to cancel the operation with.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pUVM The user mode VM handle.
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param uPercent Completion percentage (0-100).
00314ca59bb0358d05053ee753174724d82adff4vboxsync * @param pvUser User specified argument.
00314ca59bb0358d05053ee753174724d82adff4vboxsync */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef DECLCALLBACK(int) FNVMPROGRESS(PUVM pUVM, unsigned uPercent, void *pvUser);
00314ca59bb0358d05053ee753174724d82adff4vboxsync/** Pointer to a FNVMPROGRESS function. */
00314ca59bb0358d05053ee753174724d82adff4vboxsynctypedef FNVMPROGRESS *PFNVMPROGRESS;
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Create(uint32_t cCpus, PCVMM2USERMETHODS pVm2UserCbs,
00314ca59bb0358d05053ee753174724d82adff4vboxsync PFNVMATERROR pfnVMAtError, void *pvUserVM,
00314ca59bb0358d05053ee753174724d82adff4vboxsync PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM,
00314ca59bb0358d05053ee753174724d82adff4vboxsync PVM *ppVM, PUVM *ppUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3PowerOn(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Suspend(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Resume(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Reset(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Save(PUVM pUVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3_INT_DECL(int) VMR3SaveFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, bool *pfSuspended, bool fSkipStateChanges);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Teleport(PUVM pUVM, uint32_t cMsDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3LoadFromFile(PUVM pUVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3LoadFromStream(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
00314ca59bb0358d05053ee753174724d82adff4vboxsync PFNVMPROGRESS pfnProgress, void *pvProgressUser);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3_INT_DECL(int) VMR3LoadFromStreamFT(PUVM pUVM, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser);
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3PowerOff(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(int) VMR3Destroy(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3_INT_DECL(void) VMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
00314ca59bb0358d05053ee753174724d82adff4vboxsync
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(PVM) VMR3GetVM(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(PUVM) VMR3GetUVM(PVM pVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(uint32_t) VMR3RetainUVM(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(uint32_t) VMR3ReleaseUVM(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(const char *) VMR3GetName(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(PRTUUID) VMR3GetUuid(PUVM pUVM, PRTUUID pUuid);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(VMSTATE) VMR3GetState(PVM pVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(VMSTATE) VMR3GetStateU(PUVM pUVM);
00314ca59bb0358d05053ee753174724d82adff4vboxsyncVMMR3DECL(const char *) VMR3GetStateName(VMSTATE enmState);
VMMR3DECL(int) VMR3AtStateRegister(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);
VMMR3DECL(int) VMR3AtStateDeregister(PUVM pUVM, PFNVMATSTATE pfnAtState, void *pvUser);
VMMR3_INT_DECL(bool) VMR3TeleportedAndNotFullyResumedYet(PVM pVM);
VMMR3DECL(int) VMR3AtErrorRegister(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);
VMMR3DECL(int) VMR3AtErrorDeregister(PUVM pUVM, PFNVMATERROR pfnAtError, void *pvUser);
VMMR3_INT_DECL(void) VMR3SetErrorWorker(PVM pVM);
VMMR3_INT_DECL(uint32_t) VMR3GetErrorCount(PUVM pUVM);
VMMR3DECL(int) VMR3AtRuntimeErrorRegister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
VMMR3DECL(int) VMR3AtRuntimeErrorDeregister(PUVM pUVM, PFNVMATRUNTIMEERROR pfnAtRuntimeError, void *pvUser);
VMMR3_INT_DECL(int) VMR3SetRuntimeErrorWorker(PVM pVM);
VMMR3_INT_DECL(uint32_t) VMR3GetRuntimeErrorCount(PUVM pUVM);
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) VMR3ReqAlloc(PUVM pUVM, PVMREQ *ppReq, VMREQTYPE enmType, VMCPUID idDstCpu);
VMMR3DECL(int) VMR3ReqFree(PVMREQ pReq);
VMMR3DECL(int) VMR3ReqQueue(PVMREQ pReq, RTMSINTERVAL cMillies);
VMMR3DECL(int) VMR3ReqWait(PVMREQ pReq, RTMSINTERVAL cMillies);
VMMR3_INT_DECL(int) VMR3ReqProcessU(PUVM pUVM, VMCPUID idDstCpu, bool fPriorityOnly);
/** @name Flags for VMR3NotifyCpuFFU and VMR3NotifyGlobalFFU.
* @{ */
/** Whether we've done REM or not. */
#define VMNOTIFYFF_FLAGS_DONE_REM RT_BIT_32(0)
/** Whether we should poke the CPU if it's executing guest code. */
#define VMNOTIFYFF_FLAGS_POKE RT_BIT_32(1)
/** @} */
VMMR3_INT_DECL(void) VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
VMMR3_INT_DECL(void) VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
VMMR3_INT_DECL(int) VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
VMMR3_INT_DECL(int) VMR3WaitU(PUVMCPU pUVMCpu);
VMMR3_INT_DECL(int) VMR3AsyncPdmNotificationWaitU(PUVMCPU pUVCpu);
VMMR3_INT_DECL(void) VMR3AsyncPdmNotificationWakeupU(PUVM pUVM);
VMMR3_INT_DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM);
VMMR3DECL(RTTHREAD) VMR3GetVMCPUThread(PUVM pUVM);
VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThread(PVM pVM);
VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThreadU(PUVM pUVM);
VMMR3DECL(int) VMR3GetCpuCoreAndPackageIdFromCpuId(PUVM pUVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
VMMR3DECL(int) VMR3HotUnplugCpu(PUVM pUVM, VMCPUID idCpu);
VMMR3DECL(int) VMR3HotPlugCpu(PUVM pUVM, VMCPUID idCpu);
VMMR3DECL(int) VMR3SetCpuExecutionCap(PUVM pUVM, uint32_t uCpuExecutionCap);
/** @} */
#endif /* IN_RING3 */
#ifdef IN_RC
/** @defgroup grp_vmm_apis_gc VM Guest Context APIs
* @ingroup grp_vm
* @{ */
/** @} */
#endif
RT_C_DECLS_END
/** @} */
#endif