em.h revision 5ae996009ba3ee269b8639ab90a1009b872887b6
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * EM - Execution Monitor. (VMM)
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Copyright (C) 2006-2007 Sun Microsystems, Inc.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * This file is part of VirtualBox Open Source Edition (OSE), as
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * available from http://www.virtualbox.org. This file is free software;
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * you can redistribute it and/or modify it under the terms of the GNU
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * General Public License (GPL) as published by the Free Software
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Foundation, in version 2 as it comes in the "COPYING" file of the
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * The contents of this file may alternatively be used under the terms
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * of the Common Development and Distribution License Version 1.0
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * VirtualBox OSE distribution, in which case the provisions of the
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * CDDL are applicable instead of those of the GPL.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * You may elect to license modified versions of this file under the
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * terms and conditions of either the GPL or the CDDL or both.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Clara, CA 95054 USA or visit http://www.sun.com if you need
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * additional information or have any questions.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** @defgroup grp_em The Execution Monitor / Manager API
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** Enable to allow V86 code to run in raw mode. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * The Execution Manager State.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Not yet started. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Raw-mode execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Hardware accelerated raw-mode execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** PARAV function. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Recompiled mode execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Execution is halted. (waiting for interrupt) */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Application processor execution is halted. (waiting for startup IPI (SIPI)) */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Execution is suspended. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** The VM is terminating. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Guest debug event from raw-mode is being processed. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Guest debug event from hardware accelerated mode is being processed. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Guest debug event from recompiled-mode is being processed. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Hypervisor debug event being processed. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** The VM has encountered a fatal error. (And everyone is panicing....) */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Just a hack to ensure that we get a 32-bit integer. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(void) EMSetState(PVMCPU pVCpu, EMSTATE enmNewState);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** @name Callback handlers for instruction emulation functions.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * These are placed here because IOM wants to use them as well.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicotypedef DECLCALLBACK(uint32_t) FNEMULATEPARAM2UINT32(void *pvParam1, uint64_t val2);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicotypedef FNEMULATEPARAM2UINT32 *PFNEMULATEPARAM2UINT32;
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicotypedef DECLCALLBACK(uint32_t) FNEMULATEPARAM2(void *pvParam1, size_t val2);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicotypedef DECLCALLBACK(uint32_t) FNEMULATEPARAM3(void *pvParam1, uint64_t val2, size_t val3);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicotypedef DECLCALLBACK(int) FNEMULATELOCKPARAM2(void *pvParam1, uint64_t val2, RTGCUINTREG32 *pf);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicotypedef DECLCALLBACK(int) FNEMULATELOCKPARAM3(void *pvParam1, uint64_t val2, size_t cb, RTGCUINTREG32 *pf);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Checks if raw ring-3 execute mode is enabled.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @returns true if enabled.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @returns false if disabled.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @param pVM The VM to operate on.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico#define EMIsRawRing3Enabled(pVM) ((pVM)->fRawR3Enabled)
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Checks if raw ring-0 execute mode is enabled.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @returns true if enabled.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @returns false if disabled.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @param pVM The VM to operate on.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico#define EMIsRawRing0Enabled(pVM) ((pVM)->fRawR0Enabled)
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(void) EMSetInhibitInterruptsPC(PVMCPU pVCpu, RTGCUINTPTR PC);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(RTGCUINTPTR) EMGetInhibitInterruptsPC(PVMCPU pVCpu);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretDisasOne(PVM pVM, PVMCPU pVCpu, PCCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, unsigned *pcbInstr);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretDisasOneEx(PVM pVM, PVMCPU pVCpu, RTGCUINTPTR GCPtrInstr, PCCPUMCTXCORE pCtxCore,
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretInstructionCPU(PVM pVM, PVMCPU pVCpu, PDISCPUSTATE pDISState, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretCpuId(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretRdtsc(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretRdpmc(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretRdtscp(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretInvlpg(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pAddrGC);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretIret(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretMWait(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretDRxWrite(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegDrx, uint32_t SrcRegGen);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretDRxRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegDrx);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretCRxWrite(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegCrx, uint32_t SrcRegGen);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretCRxRead(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegCrx);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretLMSW(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint16_t u16Data);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretCLTS(PVM pVM, PVMCPU pVCpu);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(VBOXSTRICTRC) EMInterpretPortIO(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, uint32_t cbOp);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretRdmsr(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMInterpretWrmsr(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** @name Assembly routines
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateCmp(uint32_t u32Param1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateAnd(void *pvParam1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateInc(void *pvParam1, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateDec(void *pvParam1, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateOr(void *pvParam1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMEmulateLockOr(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateXor(void *pvParam1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMEmulateLockXor(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateAdd(void *pvParam1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMEmulateLockAnd(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateSub(void *pvParam1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateAdcWithCarrySet(void *pvParam1, uint64_t u64Param2, size_t cb);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateBtr(void *pvParam1, uint64_t u64Param2);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(int) EMEmulateLockBtr(void *pvParam1, uint64_t u64Param2, RTGCUINTREG32 *pf);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateBts(void *pvParam1, uint64_t u64Param2);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateBtc(void *pvParam1, uint64_t u64Param2);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateCmpXchg(void *pvParam1, uint64_t *pu32Param2, uint64_t u32Param3, size_t cbSize);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateLockCmpXchg(void *pvParam1, uint64_t *pu64Param2, uint64_t u64Param3, size_t cbSize);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMDECL(uint32_t) EMEmulateLockCmpXchg8b(void *pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** @name REM locking routines
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** @defgroup grp_em_r3 The EM Host Context Ring-3 API
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @ingroup grp_em
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMR3DECL(DECLNORETURN(void)) EMR3FatalError(PVMCPU pVCpu, int rc);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMR3DECL(int) EMR3ExecuteVM(PVM pVM, PVMCPU pVCpu);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMR3DECL(int) EMR3CheckRawForcedActions(PVM pVM, PVMCPU pVCpu);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * Command argument for EMR3RawSetMode().
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * It's possible to extend this interface to change several
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * execution modes at once should the need arise.
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** No raw execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Enable Only ring-3 raw execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Only ring-3 raw execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Enable raw ring-0 execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico /** Disable raw ring-0 execution. */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMR3DECL(int) EMR3RawSetMode(PVM pVM, EMRAWMODE enmMode);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico#endif /* IN_RING3 */
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico/** @defgroup grp_em_gc The EM Guest Context API
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico * @ingroup grp_em
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(int) EMGCTrap(PVM pVM, unsigned uTrap, PCPUMCTXCORE pRegFrame);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(uint32_t) EMGCEmulateLockCmpXchg(RTRCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(uint32_t) EMGCEmulateCmpXchg(RTRCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(uint32_t) EMGCEmulateLockCmpXchg8b(RTRCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(uint32_t) EMGCEmulateCmpXchg8b(RTRCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(uint32_t) EMGCEmulateLockXAdd(RTRCPTR pu32Param1, uint32_t *pu32Param2, size_t cbSize, uint32_t *pEflags);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNicoVMMRCDECL(uint32_t) EMGCEmulateXAdd(RTRCPTR pu32Param1, uint32_t *pu32Param2, size_t cbSize, uint32_t *pEflags);
784a17b07dd7b7acbc0499b915a969f6937533fdJazzyNico#endif /* IN_RC */