em.h revision f351fab06d1e1507b72f5c574df71193061fd393
/** @file
* EM - Execution Monitor. (VMM)
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* 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 (GPL) 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_em_h
#define ___VBox_em_h
/** @defgroup grp_em The Execution Monitor / Manager API
* @{
*/
/** Enable to allow V86 code to run in raw mode. */
#define VBOX_RAW_V86
/**
* The Execution Manager State.
*/
typedef enum EMSTATE
{
/** Not yet started. */
EMSTATE_NONE = 1,
/** Raw-mode execution. */
/** Hardware accelerated raw-mode execution. */
/** PARAV function. */
/** Recompiled mode execution. */
/** Execution is halted. (waiting for interrupt) */
/** Application processor execution is halted. (waiting for startup IPI (SIPI)) */
/** Execution is suspended. */
/** The VM is terminating. */
/** Guest debug event from raw-mode is being processed. */
/** Guest debug event from hardware accelerated mode is being processed. */
/** Guest debug event from recompiled-mode is being processed. */
/** Hypervisor debug event being processed. */
/** The VM has encountered a fatal error. (And everyone is panicing....) */
/** Just a hack to ensure that we get a 32-bit integer. */
EMSTATE_MAKE_32BIT_HACK = 0x7fffffff
} EMSTATE;
/**
* EMInterpretInstructionCPUEx execution modes.
*/
typedef enum
{
/** Only supervisor code (CPL=0). */
/** User-level code only. */
/** Supervisor and user-level code (use with great care!). */
/** Just a hack to ensure that we get a 32-bit integer. */
EMCODETYPE_32BIT_HACK = 0x7fffffff
} EMCODETYPE;
/** @name Callback handlers for instruction emulation functions.
* These are placed here because IOM wants to use them as well.
* @{
*/
typedef FNEMULATEPARAM2UINT32 *PFNEMULATEPARAM2UINT32;
typedef FNEMULATEPARAM2 *PFNEMULATEPARAM2;
typedef FNEMULATEPARAM3 *PFNEMULATEPARAM3;
typedef FNEMULATELOCKPARAM2 *PFNEMULATELOCKPARAM2;
typedef DECLCALLBACK(int) FNEMULATELOCKPARAM3(void *pvParam1, uint64_t val2, size_t cb, RTGCUINTREG32 *pf);
typedef FNEMULATELOCKPARAM3 *PFNEMULATELOCKPARAM3;
/** @} */
/**
* Checks if raw ring-3 execute mode is enabled.
*
* @returns true if enabled.
* @returns false if disabled.
* @param pVM The VM to operate on.
*/
/**
* Checks if raw ring-0 execute mode is enabled.
*
* @returns true if enabled.
* @returns false if disabled.
* @param pVM The VM to operate on.
*/
VMMDECL(int) EMInterpretDisasOne(PVM pVM, PVMCPU pVCpu, PCCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, unsigned *pcbInstr);
VMMDECL(int) EMInterpretDisasOneEx(PVM pVM, PVMCPU pVCpu, RTGCUINTPTR GCPtrInstr, PCCPUMCTXCORE pCtxCore,
VMMDECL(VBOXSTRICTRC) EMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
VMMDECL(VBOXSTRICTRC) EMInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDISState, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, EMCODETYPE enmCodeType, uint32_t *pcbSize);
VMMDECL(VBOXSTRICTRC) EMInterpretInvlpg(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pAddrGC);
VMMDECL(int) EMInterpretDRxWrite(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegDrx, uint32_t SrcRegGen);
VMMDECL(int) EMInterpretDRxRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegDrx);
VMMDECL(int) EMInterpretCRxWrite(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegCrx, uint32_t SrcRegGen);
VMMDECL(int) EMInterpretCRxRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegCrx);
VMMDECL(VBOXSTRICTRC) EMInterpretPortIO(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, uint32_t cbOp);
/** @name Assembly routines
* @{ */
VMMDECL(int) EMEmulateLockXor(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
VMMDECL(int) EMEmulateLockAnd(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
VMMDECL(uint32_t) EMEmulateCmpXchg(void *pvParam1, uint64_t *pu32Param2, uint64_t u32Param3, size_t cbSize);
VMMDECL(uint32_t) EMEmulateLockCmpXchg(void *pvParam1, uint64_t *pu64Param2, uint64_t u64Param3, size_t cbSize);
VMMDECL(uint32_t) EMEmulateCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
VMMDECL(uint32_t) EMEmulateLockCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
/** @} */
/** @name REM locking routines
* @{ */
/** @} */
#ifdef IN_RING3
/** @defgroup grp_em_r3 The EM Host Context Ring-3 API
* @ingroup grp_em
* @{
*/
/**
* Command argument for EMR3RawSetMode().
*
* It's possible to extend this interface to change several
* execution modes at once should the need arise.
*/
typedef enum EMRAWMODE
{
/** No raw execution. */
EMRAW_NONE = 0,
/** Enable Only ring-3 raw execution. */
/** Only ring-3 raw execution. */
/** Enable raw ring-0 execution. */
/** Disable raw ring-0 execution. */
} EMRAWMODE;
/** @} */
#endif /* IN_RING3 */
#ifdef IN_RC
/** @defgroup grp_em_gc The EM Guest Context API
* @ingroup grp_em
* @{
*/
/** @} */
#endif /* IN_RC */
/** @} */
#endif