VirtualBox

source: vbox/trunk/src/VBox/VMM/REMInternal.h@ 4044

Last change on this file since 4044 was 3723, checked in by vboxsync, 17 years ago

Double underscore cleanup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.6 KB
Line 
1/* $Id: REMInternal.h 3723 2007-07-19 18:46:00Z vboxsync $ */
2/** @file
3 * REM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef ___REMInternal_h
23#define ___REMInternal_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/cpum.h>
28#include <VBox/stam.h>
29#include <VBox/pgm.h>
30#ifdef REM_INCLUDE_CPU_H
31# include "target-i386/cpu.h"
32#endif
33
34
35#if !defined(IN_REM_R3) && !defined(IN_REM_R0) && !defined(IN_REM_GC)
36# error "Not in REM! This is an internal header!"
37#endif
38
39/** @defgroup grp_rem_int Internals
40 * @ingroup grp_rem
41 * @internal
42 * @{
43 */
44
45/** The saved state version number. */
46#define REM_SAVED_STATE_VERSION 6
47
48
49/** @def REM_MONITOR_CODE_PAGES
50 * Enable to monitor code pages that have been translated by the recompiler. */
51#define REM_MONITOR_CODE_PAGES
52
53typedef enum REMHANDLERNOTIFICATIONKIND
54{
55 /** The usual invalid 0 entry. */
56 REMHANDLERNOTIFICATIONKIND_INVALID = 0,
57 /** REMR3NotifyHandlerPhysicalRegister. */
58 REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER,
59 /** REMR3NotifyHandlerPhysicalDeregister. */
60 REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER,
61 /** REMR3NotifyHandlerPhysicalModify. */
62 REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY,
63 /** The usual 32-bit hack. */
64 REMHANDLERNOTIFICATIONKIND_32BIT_HACK = 0x7fffffff
65} REMHANDLERNOTIFICATIONKIND;
66
67
68/**
69 * A recorded handler notificiation.
70 */
71typedef struct REMHANDLERNOTIFICATION
72{
73 /** The notification kind. */
74 REMHANDLERNOTIFICATIONKIND enmKind;
75 uint32_t padding;
76 /** Type specific data. */
77 union
78 {
79 struct
80 {
81 RTGCPHYS GCPhys;
82 RTGCPHYS cb;
83 PGMPHYSHANDLERTYPE enmType;
84 bool fHasHCHandler;
85 } PhysicalRegister;
86
87 struct
88 {
89 RTGCPHYS GCPhys;
90 RTGCPHYS cb;
91 RTHCPTR pvHCPtr;
92 PGMPHYSHANDLERTYPE enmType;
93 bool fHasHCHandler;
94 } PhysicalDeregister;
95
96 struct
97 {
98 RTHCPTR pvHCPtr;
99 RTGCPHYS GCPhysOld;
100 RTGCPHYS GCPhysNew;
101 RTGCPHYS cb;
102 PGMPHYSHANDLERTYPE enmType;
103 bool fHasHCHandler;
104 } PhysicalModify;
105 uint64_t padding[3 + (HC_ARCH_BITS == 64)];
106 } u;
107} REMHANDLERNOTIFICATION, *PREMHANDLERNOTIFICATION;
108
109/**
110 * Dynamically allocated guest RAM chunk information
111 * HC virt to GC Phys
112 *
113 * A RAM chunk can spawn two chunk regions as we don't align them on chunk boundaries.
114 */
115typedef struct REMCHUNKINFO
116{
117 RTHCUINTPTR pChunk1;
118 RTHCUINTPTR pChunk2;
119 RTGCPHYS GCPhys1;
120 RTGCPHYS GCPhys2;
121} REMCHUNKINFO, *PREMCHUNKINFO;
122
123/** Maximum number of external guest RAM/ROM registrations. */
124#define REM_MAX_PHYS_REGISTRATIONS 16
125
126/**
127 * Registration record for external guest RAM & ROM
128 */
129typedef struct REMPHYSREGISTRATION
130{
131 RTHCUINTPTR HCVirt;
132 RTGCPHYS GCPhys;
133 RTUINT cb;
134} REMPHYSREGISTRATION, *PREMPHYSREGISTRATION;
135
136/**
137 * Converts a REM pointer into a VM pointer.
138 * @returns Pointer to the VM structure the REM is part of.
139 * @param pREM Pointer to REM instance data.
140 */
141#define REM2VM(pREM) ( (PVM)((char*)pREM - pREM->offVM) )
142
143
144/**
145 * REM Data (part of VM)
146 */
147typedef struct REM
148{
149 /** Offset to the VM structure. */
150 RTINT offVM;
151 /** Alignment padding. */
152 RTUINT uPadding0;
153
154 /** Cached guest cpu context pointer. */
155 HCPTRTYPE(PCPUMCTX) pCtx;
156
157 /** In REM mode.
158 * I.e. the correct CPU state and some other bits are with REM. */
159 bool fInREM;
160 /** In REMR3State. */
161 bool fInStateSync;
162
163 /** Ignore all that can be ignored. */
164 bool fIgnoreAll;
165 /** Ignore CR3 load notifications from the REM. */
166 bool fIgnoreCR3Load;
167 /** Ignore invlpg notifications from the REM. */
168 bool fIgnoreInvlPg;
169 /** Ignore CR0, CR4 and EFER load. */
170 bool fIgnoreCpuMode;
171 /** Ignore set page. */
172 bool fIgnoreSetPage;
173
174 /** Number of times REMR3CanExecuteRaw has been called.
175 * It is used to prevent rescheduling on the first call. */
176 RTUINT cCanExecuteRaw;
177
178 /** Pending interrupt (~0 -> nothing). */
179 RTUINT u32PendingInterrupt;
180
181#if HC_ARCH_BITS == 64
182 /** Alignment padding. */
183 uint32_t u32Padding;
184#endif
185 /** Number of recorded invlpg instructions. */
186 RTUINT cInvalidatedPages;
187 /** Array of recorded invlpg instruction.
188 * These instructions are replayed when entering REM. */
189 RTGCPTR aGCPtrInvalidatedPages[48];
190 /** The number of recorded handler notifications. */
191 RTUINT volatile cHandlerNotifications;
192 RTUINT padding0; /**< Padding. */
193 /** Array of recorded handler noticications.
194 * These are replayed when entering REM. */
195 REMHANDLERNOTIFICATION aHandlerNotifications[32];
196
197 /** Pointer to an array of hc virt to gc phys records. */
198 HCPTRTYPE(PREMCHUNKINFO) paHCVirtToGCPhys;
199 /** Pointer to a GC Phys to HC Virt lookup table. */
200 HCPTRTYPE(PRTHCUINTPTR) paGCPhysToHCVirt;
201
202 /** Array of external RAM and ROM registrations (excluding guest RAM). */
203 REMPHYSREGISTRATION aPhysReg[REM_MAX_PHYS_REGISTRATIONS];
204 /** Number of external RAM and ROM registrations (excluding guest RAM). */
205 RTUINT cPhysRegistrations;
206
207 /** MMIO memory type.
208 * This is used to register MMIO physical access handlers. */
209 RTINT iMMIOMemType;
210 /** Handler memory type.
211 * This is used to register non-MMIO physical access handlers which are executed in HC. */
212 RTINT iHandlerMemType;
213
214 /** Pending exception */
215 uint32_t uPendingException;
216 /** Pending exception's EIP */
217 uint32_t uPendingExcptEIP;
218 /** Pending exception's CR2 */
219 uint32_t uPendingExcptCR2;
220 /** Nr of pending exceptions */
221 uint32_t cPendingExceptions;
222
223 /** Pending rc. */
224 RTINT rc;
225
226 /** Time spent in QEMU. */
227 STAMPROFILEADV StatsInQEMU;
228 /** Time spent in rawmode.c. */
229 STAMPROFILEADV StatsInRAWEx;
230 /** Time spent switching state. */
231 STAMPROFILE StatsState;
232 /** Time spent switching state back. */
233 STAMPROFILE StatsStateBack;
234
235#if HC_ARCH_BITS != 32
236 /** Padding the CPUX86State structure to 32 byte. */
237 uint32_t abPadding[HC_ARCH_BITS == 32 ? 0 : 4];
238#endif
239
240#define REM_ENV_SIZE (HC_ARCH_BITS == 32 ? 0x6440 : 0xb4a0)
241 /** Recompiler CPU state. */
242#ifdef REM_INCLUDE_CPU_H
243 CPUX86State Env;
244#else
245 struct FakeEnv
246 {
247 char achPadding[REM_ENV_SIZE];
248 } Env;
249#endif
250} REM;
251
252/** Pointer to the REM Data. */
253typedef REM *PREM;
254
255
256#ifdef REM_INCLUDE_CPU_H
257bool remR3CanExecuteRaw(CPUState *env, RTGCPTR eip, unsigned fFlags, uint32_t *pExceptionIndex);
258void remR3CSAMCheckEIP(CPUState *env, RTGCPTR GCPtrCode);
259bool remR3GetOpcode(CPUState *env, RTGCPTR GCPtrInstr, uint8_t *pu8Byte);
260bool remR3DisasInstr(CPUState *env, int f32BitCode, char *pszPrefix);
261bool remR3DisasBlock(CPUState *env, int f32BitCode, int nrInstructions, char *pszPrefix);
262void remR3FlushPage(CPUState *env, RTGCPTR GCPtr);
263void remR3SetPage(CPUState *env, CPUTLBEntry *pRead, CPUTLBEntry *pWrite, int prot, int is_user);
264void remR3FlushTLB(CPUState *env, bool fGlobal);
265void remR3ProtectCode(CPUState *env, RTGCPTR GCPtr);
266void remR3ChangeCpuMode(CPUState *env);
267void remR3DmaRun(CPUState *env);
268void remR3TimersRun(CPUState *env);
269int remR3NotifyTrap(CPUState *env, uint32_t uTrap, uint32_t uErrorCode, uint32_t pvNextEIP);
270void remR3TrapStat(CPUState *env, uint32_t uTrap);
271void remR3CpuId(CPUState *env, unsigned uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
272#endif
273void remR3TrapClear(PVM pVM);
274void remR3RaiseRC(PVM pVM, int rc);
275void remR3DumpLnxSyscall(PVM pVM);
276void remR3DumpOBsdSyscall(PVM pVM);
277
278
279/** @todo r=bird: clean up the RAWEx stats. */
280/* temporary hacks */
281#define RAWEx_ProfileStart(a, b) remR3ProfileStart(b)
282#define RAWEx_ProfileStop(a, b) remR3ProfileStop(b)
283
284
285#ifdef VBOX_WITH_STATISTICS
286
287#define STATS_EMULATE_SINGLE_INSTR 1
288#define STATS_QEMU_COMPILATION 2
289#define STATS_QEMU_RUN_EMULATED_CODE 3
290#define STATS_QEMU_TOTAL 4
291#define STATS_QEMU_RUN_TIMERS 5
292#define STATS_TLB_LOOKUP 6
293#define STATS_IRQ_HANDLING 7
294#define STATS_RAW_CHECK 8
295
296
297void remR3ProfileStart(int statcode);
298void remR3ProfileStop(int statcode);
299#else
300#define remR3ProfileStart(c)
301#define remR3ProfileStop(c)
302#endif
303
304/** @} */
305
306#endif
307
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