VirtualBox

source: vbox/trunk/include/VBox/em.h@ 12794

Last change on this file since 12794 was 12688, checked in by vboxsync, 16 years ago

#1865: EM - one pointer and statistics. Added a couple of more samples to the release statistics.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1/** @file
2 * EM - Execution Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_em_h
31#define ___VBox_em_h
32
33#include <VBox/cdefs.h>
34#include <VBox/types.h>
35#include <VBox/trpm.h>
36#include <VBox/dis.h>
37
38__BEGIN_DECLS
39
40/** @defgroup grp_em The Execution Monitor API
41 * @{
42 */
43
44/** Enable to allow V86 code to run in raw mode. */
45#define VBOX_RAW_V86
46
47/**
48 * The Execution Manager State.
49 */
50typedef enum EMSTATE
51{
52 /** Not yet started. */
53 EMSTATE_NONE = 1,
54 /** Raw-mode execution. */
55 EMSTATE_RAW,
56 /** Hardware accelerated raw-mode execution. */
57 EMSTATE_HWACC,
58 /** Recompiled mode execution. */
59 EMSTATE_REM,
60 /** Execution is halted. (waiting for interrupt) */
61 EMSTATE_HALTED,
62 /** Execution is suspended. */
63 EMSTATE_SUSPENDED,
64 /** The VM is terminating. */
65 EMSTATE_TERMINATING,
66 /** Guest debug event from raw-mode is being processed. */
67 EMSTATE_DEBUG_GUEST_RAW,
68 /** Guest debug event from hardware accelerated mode is being processed. */
69 EMSTATE_DEBUG_GUEST_HWACC,
70 /** Guest debug event from recompiled-mode is being processed. */
71 EMSTATE_DEBUG_GUEST_REM,
72 /** Hypervisor debug event being processed. */
73 EMSTATE_DEBUG_HYPER,
74 /** The VM has encountered a fatal error. (And everyone is panicing....) */
75 EMSTATE_GURU_MEDITATION,
76 /** Just a hack to ensure that we get a 32-bit integer. */
77 EMSTATE_MAKE_32BIT_HACK = 0x7fffffff
78} EMSTATE;
79
80EMDECL(EMSTATE) EMGetState(PVM pVM);
81
82/** @name Callback handlers for instruction emulation functions.
83 * These are placed here because IOM wants to use them as well.
84 * @{
85 */
86typedef DECLCALLBACK(uint32_t) FNEMULATEPARAM2UINT32(void *pvParam1, uint64_t val2);
87typedef FNEMULATEPARAM2UINT32 *PFNEMULATEPARAM2UINT32;
88typedef DECLCALLBACK(uint32_t) FNEMULATEPARAM2(void *pvParam1, size_t val2);
89typedef FNEMULATEPARAM2 *PFNEMULATEPARAM2;
90typedef DECLCALLBACK(uint32_t) FNEMULATEPARAM3(void *pvParam1, uint64_t val2, size_t val3);
91typedef FNEMULATEPARAM3 *PFNEMULATEPARAM3;
92typedef DECLCALLBACK(int) FNEMULATELOCKPARAM2(void *pvParam1, uint64_t val2, RTGCUINTREG32 *pf);
93typedef FNEMULATELOCKPARAM2 *PFNEMULATELOCKPARAM2;
94typedef DECLCALLBACK(int) FNEMULATELOCKPARAM3(void *pvParam1, uint64_t val2, size_t cb, RTGCUINTREG32 *pf);
95typedef FNEMULATELOCKPARAM3 *PFNEMULATELOCKPARAM3;
96/** @} */
97
98
99/**
100 * Checks if raw ring-3 execute mode is enabled.
101 *
102 * @returns true if enabled.
103 * @returns false if disabled.
104 * @param pVM The VM to operate on.
105 */
106#define EMIsRawRing3Enabled(pVM) ((pVM)->fRawR3Enabled)
107
108/**
109 * Checks if raw ring-0 execute mode is enabled.
110 *
111 * @returns true if enabled.
112 * @returns false if disabled.
113 * @param pVM The VM to operate on.
114 */
115#define EMIsRawRing0Enabled(pVM) ((pVM)->fRawR0Enabled)
116
117EMDECL(void) EMSetInhibitInterruptsPC(PVM pVM, RTGCUINTPTR PC);
118EMDECL(RTGCUINTPTR) EMGetInhibitInterruptsPC(PVM pVM);
119EMDECL(int) EMInterpretDisasOne(PVM pVM, PCCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, unsigned *pcbInstr);
120EMDECL(int) EMInterpretDisasOneEx(PVM pVM, RTGCUINTPTR GCPtrInstr, PCCPUMCTXCORE pCtxCore,
121 PDISCPUSTATE pCpu, unsigned *pcbInstr);
122EMDECL(int) EMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
123EMDECL(int) EMInterpretInstructionCPU(PVM pVM, PDISCPUSTATE pCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize);
124EMDECL(int) EMInterpretCpuId(PVM pVM, PCPUMCTXCORE pRegFrame);
125EMDECL(int) EMInterpretRdtsc(PVM pVM, PCPUMCTXCORE pRegFrame);
126EMDECL(int) EMInterpretInvlpg(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pAddrGC);
127EMDECL(int) EMInterpretIret(PVM pVM, PCPUMCTXCORE pRegFrame);
128EMDECL(int) EMInterpretDRxWrite(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t DestRegDrx, uint32_t SrcRegGen);
129EMDECL(int) EMInterpretDRxRead(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegDrx);
130EMDECL(int) EMInterpretCRxWrite(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t DestRegCrx, uint32_t SrcRegGen);
131EMDECL(int) EMInterpretCRxRead(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t DestRegGen, uint32_t SrcRegCrx);
132EMDECL(int) EMInterpretLMSW(PVM pVM, uint16_t u16Data);
133EMDECL(int) EMInterpretCLTS(PVM pVM);
134EMDECL(int) EMInterpretPortIO(PVM pVM, PCPUMCTXCORE pCtxCore, PDISCPUSTATE pCpu, uint32_t cbOp);
135EMDECL(int) EMInterpretRdmsr(PVM pVM, PCPUMCTXCORE pRegFrame);
136EMDECL(int) EMInterpretWrmsr(PVM pVM, PCPUMCTXCORE pRegFrame);
137EMDECL(void) EMFlushREMTBs(PVM pVM);
138
139/** @name Assembly routines
140 * @{ */
141EMDECL(uint32_t) EMEmulateCmp(uint32_t u32Param1, uint64_t u64Param2, size_t cb);
142EMDECL(uint32_t) EMEmulateAnd(void *pvParam1, uint64_t u64Param2, size_t cb);
143EMDECL(uint32_t) EMEmulateInc(void *pvParam1, size_t cb);
144EMDECL(uint32_t) EMEmulateDec(void *pvParam1, size_t cb);
145EMDECL(uint32_t) EMEmulateOr(void *pvParam1, uint64_t u64Param2, size_t cb);
146EMDECL(int) EMEmulateLockOr(void *pvParam1, uint64_t u64Param2, size_t cbSize, RTGCUINTREG32 *pf);
147EMDECL(uint32_t) EMEmulateXor(void *pvParam1, uint64_t u64Param2, size_t cb);
148EMDECL(uint32_t) EMEmulateAdd(void *pvParam1, uint64_t u64Param2, size_t cb);
149EMDECL(uint32_t) EMEmulateSub(void *pvParam1, uint64_t u64Param2, size_t cb);
150EMDECL(uint32_t) EMEmulateAdcWithCarrySet(void *pvParam1, uint64_t u64Param2, size_t cb);
151EMDECL(uint32_t) EMEmulateBtr(void *pvParam1, uint64_t u64Param2);
152EMDECL(int) EMEmulateLockBtr(void *pvParam1, uint64_t u64Param2, RTGCUINTREG32 *pf);
153EMDECL(uint32_t) EMEmulateBts(void *pvParam1, uint64_t u64Param2);
154EMDECL(uint32_t) EMEmulateBtc(void *pvParam1, uint64_t u64Param2);
155EMDECL(uint32_t) EMEmulateCmpXchg(void *pvParam1, uint64_t *pu32Param2, uint64_t u32Param3, size_t cbSize);
156EMDECL(uint32_t) EMEmulateLockCmpXchg(void *pvParam1, uint64_t *pu64Param2, uint64_t u64Param3, size_t cbSize);
157EMDECL(uint32_t) EMEmulateCmpXchg8b32(RTHCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
158EMDECL(uint32_t) EMEmulateLockCmpXchg8b(RTHCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX);
159/** @} */
160
161#ifdef IN_RING3
162/** @defgroup grp_em_r3 The EM Host Context Ring-3 API
163 * @ingroup grp_em
164 * @{
165 */
166EMR3DECL(int) EMR3Init(PVM pVM);
167EMR3DECL(void) EMR3Relocate(PVM pVM);
168EMR3DECL(void) EMR3Reset(PVM pVM);
169EMR3DECL(int) EMR3Term(PVM pVM);
170EMR3DECL(DECLNORETURN(void)) EMR3FatalError(PVM pVM, int rc);
171EMR3DECL(int) EMR3ExecuteVM(PVM pVM);
172EMR3DECL(int) EMR3CheckRawForcedActions(PVM pVM);
173EMR3DECL(int) EMR3Interpret(PVM pVM);
174
175/**
176 * Command argument for EMR3RawSetMode().
177 *
178 * It's possible to extend this interface to change several
179 * execution modes at once should the need arise.
180 */
181typedef enum EMRAWMODE
182{
183 /** No raw execution. */
184 EMRAW_NONE = 0,
185 /** Enable Only ring-3 raw execution. */
186 EMRAW_RING3_ENABLE,
187 /** Only ring-3 raw execution. */
188 EMRAW_RING3_DISABLE,
189 /** Enable raw ring-0 execution. */
190 EMRAW_RING0_ENABLE,
191 /** Disable raw ring-0 execution. */
192 EMRAW_RING0_DISABLE,
193 EMRAW_END
194} EMRAWMODE;
195
196EMR3DECL(int) EMR3RawSetMode(PVM pVM, EMRAWMODE enmMode);
197/** @} */
198#endif /* IN_RING3 */
199
200
201#ifdef IN_GC
202/** @defgroup grp_em_gc The EM Guest Context API
203 * @ingroup grp_em
204 * @{
205 */
206EMGCDECL(int) EMGCTrap(PVM pVM, unsigned uTrap, PCPUMCTXCORE pRegFrame);
207EMGCDECL(uint32_t) EMGCEmulateLockCmpXchg(RTRCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);
208EMGCDECL(uint32_t) EMGCEmulateCmpXchg(RTRCPTR pu32Param1, uint32_t *pu32Param2, uint32_t u32Param3, size_t cbSize, uint32_t *pEflags);
209EMGCDECL(uint32_t) EMGCEmulateLockCmpXchg8b(RTRCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);
210EMGCDECL(uint32_t) EMGCEmulateCmpXchg8b(RTRCPTR pu32Param1, uint32_t *pEAX, uint32_t *pEDX, uint32_t uEBX, uint32_t uECX, uint32_t *pEflags);
211EMGCDECL(uint32_t) EMGCEmulateLockXAdd(RTRCPTR pu32Param1, uint32_t *pu32Param2, size_t cbSize, uint32_t *pEflags);
212EMGCDECL(uint32_t) EMGCEmulateXAdd(RTRCPTR pu32Param1, uint32_t *pu32Param2, size_t cbSize, uint32_t *pEflags);
213/** @} */
214#endif /* IN_GC */
215
216/** @} */
217
218__END_DECLS
219
220#endif
221
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette