VirtualBox

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

Last change on this file since 115 was 23, checked in by vboxsync, 18 years ago

string.h & stdio.h + header cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.2 KB
Line 
1/* $Id: REMInternal.h 23 2007-01-15 14:08:28Z vboxsync $ */
2/** @file
3 * REM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung 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 4
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 RTGCPHYS GCPhys1;
119 RTHCUINTPTR pChunk2;
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 RTGCPHYS GCPhys;
132 RTHCUINTPTR HCVirt;
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
161 /** Ignore CR3 load notifications from the REM. */
162 bool fIgnoreCR3Load;
163 /** Ignore invlpg notifications from the REM. */
164 bool fIgnoreInvlPg;
165 /** Ignore CR0, CR4 and EFER load. */
166 bool fIgnoreCpuMode;
167 /** Number of times REMR3CanExecuteRaw has been called.
168 * It is used to prevent rescheduling on the first call. */
169 RTUINT cCanExecuteRaw;
170
171 /** Pending interrupt (~0 -> nothing). */
172 RTUINT u32PendingInterrupt;
173
174 /** Number of recorded invlpg instructions. */
175 RTUINT cInvalidatedPages;
176 /** Array of recorded invlpg instruction.
177 * These instructions are replayed when entering REM. */
178 RTGCPTR aGCPtrInvalidatedPages[48];
179
180 /** The number of recorded handler notifications. */
181 RTUINT volatile cHandlerNotifications;
182 /** Array of recorded handler noticications.
183 * These are replayed when entering REM. */
184 REMHANDLERNOTIFICATION aHandlerNotifications[32];
185
186 /** Pointer to an array of hc virt to gc phys records. */
187 PREMCHUNKINFO paHCVirtToGCPhys;
188 /** Pointer to a GC Phys to HC Virt lookup table. */
189 RTHCUINTPTR *paGCPhysToHCVirt;
190
191 /** Number of external RAM and ROM registrations (excluding guest RAM) */
192 RTUINT cPhysRegistrations;
193 REMPHYSREGISTRATION aPhysReg[REM_MAX_PHYS_REGISTRATIONS];
194
195 /** MMIO memory type.
196 * This is used to register MMIO physical access handlers. */
197 RTINT iMMIOMemType;
198 /** Handler memory type.
199 * This is used to register non-MMIO physical access handlers which are executed in HC. */
200 RTINT iHandlerMemType;
201
202 /** Pending exception */
203 uint32_t uPendingException;
204 /** Pending exception's EIP */
205 uint32_t uPendingExcptEIP;
206 /** Pending exception's CR2 */
207 uint32_t uPendingExcptCR2;
208 /** Nr of pending exceptions */
209 uint32_t cPendingExceptions;
210
211 /** Pending rc. */
212 RTINT rc;
213
214 /** Padding for MS / GC alignment difference. */
215 //uint32_t u32Padding;
216 /** Time spent in QEMU. */
217 STAMPROFILEADV StatsInQEMU;
218 /** Time spent in rawmode.c. */
219 STAMPROFILEADV StatsInRAWEx;
220 /** Time spent switching state. */
221 STAMPROFILE StatsState;
222 /** Time spent switching state back. */
223 STAMPROFILE StatsStateBack;
224
225 /** Padding the CPUX86State structure to 32 byte. */
226 uint8_t abPadding[8];
227
228#define REM_ENV_SIZE (HC_ARCH_BITS == 32 ? 0x6440 : 0xb3e0)
229 /** Recompiler CPU state. */
230#ifdef REM_INCLUDE_CPU_H
231 CPUX86State Env;
232#else
233 struct FakeEnv
234 {
235 char achPadding[REM_ENV_SIZE];
236 } Env;
237#endif
238} REM;
239
240/** Pointer to the REM Data. */
241typedef REM *PREM;
242
243
244#ifdef REM_INCLUDE_CPU_H
245bool remR3CanExecuteRaw(CPUState *env, RTGCPTR eip, unsigned fFlags, uint32_t *pExceptionIndex);
246void remR3CSAMCheckEIP(CPUState *env, RTGCPTR GCPtrCode);
247bool remR3GetOpcode(CPUState *env, RTGCPTR GCPtrInstr, uint8_t *pu8Byte);
248bool remR3DisasInstr(CPUState *env, int f32BitCode, char *pszPrefix);
249bool remR3DisasBlock(CPUState *env, int f32BitCode, int nrInstructions, char *pszPrefix);
250void remR3FlushPage(CPUState *env, RTGCPTR GCPtr);
251void remR3SetPage(CPUState *env, CPUTLBEntry *pRead, CPUTLBEntry *pWrite, int prot, int is_user);
252void remR3FlushTLB(CPUState *env, bool fGlobal);
253void remR3ProtectCode(CPUState *env, RTGCPTR GCPtr);
254void remR3ChangeCpuMode(CPUState *env);
255void remR3DmaRun(CPUState *env);
256void remR3TimersRun(CPUState *env);
257int remR3NotifyTrap(CPUState *env, uint32_t uTrap, uint32_t uErrorCode, uint32_t pvNextEIP);
258void remR3TrapStat(CPUState *env, uint32_t uTrap);
259void remR3CpuId(CPUState *env, unsigned uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
260#endif
261void remR3TrapClear(PVM pVM);
262void remR3RaiseRC(PVM pVM, int rc);
263void remR3DumpLnxSyscall(PVM pVM);
264void remR3DumpOBsdSyscall(PVM pVM);
265
266
267/** @todo r=bird: clean up the RAWEx stats. */
268/* temporary hacks */
269#define RAWEx_ProfileStart(a, b) remR3ProfileStart(b)
270#define RAWEx_ProfileStop(a, b) remR3ProfileStop(b)
271
272
273#ifdef VBOX_WITH_STATISTICS
274
275#define STATS_EMULATE_SINGLE_INSTR 1
276#define STATS_QEMU_COMPILATION 2
277#define STATS_QEMU_RUN_EMULATED_CODE 3
278#define STATS_QEMU_TOTAL 4
279#define STATS_QEMU_RUN_TIMERS 5
280#define STATS_TLB_LOOKUP 6
281#define STATS_IRQ_HANDLING 7
282#define STATS_RAW_CHECK 8
283
284
285void remR3ProfileStart(int statcode);
286void remR3ProfileStop(int statcode);
287#else
288#define remR3ProfileStart(c)
289#define remR3ProfileStop(c)
290#endif
291
292/** @} */
293
294#endif
295
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