VirtualBox

source: vbox/trunk/include/VBox/rem.h@ 6546

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

VBOX_WITH_NEW_PHYS_CODE changes mostly realted to REM. Killed a warning in cpu-exec.c.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.9 KB
Line 
1/** @file
2 * REM - The Recompiled Execution Manager.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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
26#ifndef ___VBox_rem_h
27#define ___VBox_rem_h
28
29#include <VBox/cdefs.h>
30#include <VBox/types.h>
31#include <VBox/pgm.h>
32#include <VBox/vmapi.h>
33
34
35__BEGIN_DECLS
36
37/** @defgroup grp_rem The Recompiled Execution Manager API
38 * @{
39 */
40
41/** No pending interrupt. */
42#define REM_NO_PENDING_IRQ (~(uint32_t)0)
43
44
45#if defined(IN_RING0) || defined(IN_GC)
46
47/**
48 * Records a invlpg instruction for replaying upon REM entry.
49 *
50 * @returns VINF_SUCCESS on success.
51 * @returns VERR_REM_FLUSHED_PAGES_OVERFLOW if a return to HC for flushing of
52 * recorded pages is required before the call can succeed.
53 * @param pVM The VM handle.
54 * @param GCPtrPage The address of the invalidated page.
55 */
56REMDECL(int) REMNotifyInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
57
58/**
59 * Notification about a successful PGMR3HandlerPhysicalRegister() call.
60 *
61 * @param pVM VM Handle.
62 * @param enmType Handler type.
63 * @param GCPhys Handler range address.
64 * @param cb Size of the handler range.
65 * @param fHasHCHandler Set if the handler have a HC callback function.
66 */
67REMDECL(void) REMNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler);
68
69/**
70 * Notification about a successful PGMR3HandlerPhysicalDeregister() operation.
71 *
72 * @param pVM VM Handle.
73 * @param enmType Handler type.
74 * @param GCPhys Handler range address.
75 * @param cb Size of the handler range.
76 * @param fHasHCHandler Set if the handler have a HC callback function.
77 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
78 */
79REMDECL(void) REMNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM);
80
81/**
82 * Notification about a successful PGMR3HandlerPhysicalModify() call.
83 *
84 * @param pVM VM Handle.
85 * @param enmType Handler type.
86 * @param GCPhysOld Old handler range address.
87 * @param GCPhysNew New handler range address.
88 * @param cb Size of the handler range.
89 * @param fHasHCHandler Set if the handler have a HC callback function.
90 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
91 */
92REMDECL(void) REMNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM);
93
94#endif /* IN_RING0 || IN_GC */
95
96
97#ifdef IN_RING3
98/** @defgroup grp_rem_r3 REM Host Context Ring 3 API
99 * @ingroup grp_rem
100 * @{
101 */
102
103/**
104 * Initializes the REM.
105 *
106 * @returns VBox status code.
107 * @param pVM The VM to operate on.
108 */
109REMR3DECL(int) REMR3Init(PVM pVM);
110
111/**
112 * Terminates the REM.
113 *
114 * Termination means cleaning up and freeing all resources,
115 * the VM it self is at this point powered off or suspended.
116 *
117 * @returns VBox status code.
118 * @param pVM The VM to operate on.
119 */
120REMR3DECL(int) REMR3Term(PVM pVM);
121
122/**
123 * The VM is being reset.
124 *
125 * For the REM component this means to call the cpu_reset() and
126 * reinitialize some state variables.
127 *
128 * @param pVM VM handle.
129 */
130REMR3DECL(void) REMR3Reset(PVM pVM);
131
132/**
133 * Runs code in recompiled mode.
134 *
135 * Before calling this function the REM state needs to be in sync with
136 * the VM. Call REMR3State() to perform the sync. It's only necessary
137 * (and permitted) to sync at the first call to REMR3Step()/REMR3Run()
138 * and after calling REMR3StateBack().
139 *
140 * @returns VBox status code.
141 *
142 * @param pVM VM Handle.
143 */
144REMR3DECL(int) REMR3Run(PVM pVM);
145
146/**
147 * Emulate an instruction.
148 *
149 * This function executes one instruction without letting anyone
150 * interrupt it. This is intended for being called while being in
151 * raw mode and thus will take care of all the state syncing between
152 * REM and the rest.
153 *
154 * @returns VBox status code.
155 * @param pVM VM handle.
156 */
157REMR3DECL(int) REMR3EmulateInstruction(PVM pVM);
158
159/**
160 * Single steps an instruction in recompiled mode.
161 *
162 * Before calling this function the REM state needs to be in sync with
163 * the VM. Call REMR3State() to perform the sync. It's only necessary
164 * (and permitted) to sync at the first call to REMR3Step()/REMR3Run()
165 * and after calling REMR3StateBack().
166 *
167 * @returns VBox status code.
168 *
169 * @param pVM VM Handle.
170 */
171REMR3DECL(int) REMR3Step(PVM pVM);
172
173/**
174 * Set a breakpoint using the REM facilities.
175 *
176 * @returns VBox status code.
177 * @param pVM The VM handle.
178 * @param Address The breakpoint address.
179 * @thread The emulation thread.
180 */
181REMR3DECL(int) REMR3BreakpointSet(PVM pVM, RTGCUINTPTR Address);
182
183/**
184 * Clears a breakpoint set by REMR3BreakpointSet().
185 *
186 * @returns VBox status code.
187 * @param pVM The VM handle.
188 * @param Address The breakpoint address.
189 * @thread The emulation thread.
190 */
191REMR3DECL(int) REMR3BreakpointClear(PVM pVM, RTGCUINTPTR Address);
192
193/**
194 * Syncs the internal REM state with the VM.
195 *
196 * This must be called before REMR3Run() is invoked whenever when the REM
197 * state is not up to date. Calling it several times in a row is not
198 * permitted.
199 *
200 * @returns VBox status code.
201 *
202 * @param pVM VM Handle.
203 *
204 * @remark The caller has to check for important FFs before calling REMR3Run. REMR3State will
205 * no do this since the majority of the callers don't want any unnecessary of events
206 * pending that would immediatly interrupt execution.
207 */
208REMR3DECL(int) REMR3State(PVM pVM);
209
210/**
211 * Syncs back changes in the REM state to the the VM state.
212 *
213 * This must be called after invoking REMR3Run().
214 * Calling it several times in a row is not permitted.
215 *
216 * @returns VBox status code.
217 *
218 * @param pVM VM Handle.
219 */
220REMR3DECL(int) REMR3StateBack(PVM pVM);
221
222/**
223 * Update the VMM state information if we're currently in REM.
224 *
225 * This method is used by the DBGF and PDMDevice when there is any uncertainty of whether
226 * we're currently executing in REM and the VMM state is invalid. This method will of
227 * course check that we're executing in REM before syncing any data over to the VMM.
228 *
229 * @param pVM The VM handle.
230 */
231REMR3DECL(void) REMR3StateUpdate(PVM pVM);
232
233/**
234 * Notify the recompiler about Address Gate 20 state change.
235 *
236 * This notification is required since A20 gate changes are
237 * initialized from a device driver and the VM might just as
238 * well be in REM mode as in RAW mode.
239 *
240 * @param pVM VM handle.
241 * @param fEnable True if the gate should be enabled.
242 * False if the gate should be disabled.
243 */
244REMR3DECL(void) REMR3A20Set(PVM pVM, bool fEnable);
245
246/**
247 * Enables or disables singled stepped disassembly.
248 *
249 * @returns VBox status code.
250 * @param pVM VM handle.
251 * @param fEnable To enable set this flag, to disable clear it.
252 */
253REMR3DECL(int) REMR3DisasEnableStepping(PVM pVM, bool fEnable);
254
255/**
256 * Replays the recorded invalidated pages.
257 * Called in response to VERR_REM_FLUSHED_PAGES_OVERFLOW from the RAW execution loop.
258 *
259 * @param pVM VM handle.
260 */
261REMR3DECL(void) REMR3ReplayInvalidatedPages(PVM pVM);
262
263/**
264 * Replays the recorded physical handler notifications.
265 *
266 * @param pVM VM handle.
267 */
268REMR3DECL(void) REMR3ReplayHandlerNotifications(PVM pVM);
269
270/**
271 * Notify REM about changed code page.
272 *
273 * @returns VBox status code.
274 * @param pVM VM handle.
275 * @param pvCodePage Code page address
276 */
277REMR3DECL(int) REMR3NotifyCodePageChanged(PVM pVM, RTGCPTR pvCodePage);
278
279/**
280 * Notification about a successful MMR3RamRegister() call.
281 *
282 * @param pVM VM handle.
283 * @param GCPhys The physical address the RAM.
284 * @param cb Size of the memory.
285 * @param fFlags Flags of the MM_RAM_FLAGS_* defines.
286 */
287REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, unsigned fFlags);
288
289#ifndef VBOX_WITH_NEW_PHYS_CODE
290/**
291 * Notification about a successful PGMR3PhysRegisterChunk() call.
292 *
293 * @param pVM VM handle.
294 * @param GCPhys The physical address the RAM.
295 * @param cb Size of the memory.
296 * @param pvRam The HC address of the RAM.
297 * @param fFlags Flags of the MM_RAM_FLAGS_* defines.
298 */
299REMR3DECL(void) REMR3NotifyPhysRamChunkRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, RTHCUINTPTR pvRam, unsigned fFlags);
300#endif
301
302/**
303 * Notification about a successful MMR3PhysRomRegister() call.
304 *
305 * @param pVM VM handle.
306 * @param GCPhys The physical address of the ROM.
307 * @param cb The size of the ROM.
308 * @param pvCopy Pointer to the ROM copy.
309 * @param fShadow Whether it's currently writable shadow ROM or normal readonly ROM.
310 * This function will be called when ever the protection of the
311 * shadow ROM changes (at reset and end of POST).
312 */
313REMR3DECL(void) REMR3NotifyPhysRomRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, void *pvCopy, bool fShadow);
314
315/**
316 * Notification about a successful MMR3PhysRegister() call.
317 *
318 * @param pVM VM Handle.
319 * @param GCPhys Start physical address.
320 * @param cb The size of the range.
321 */
322REMR3DECL(void) REMR3NotifyPhysReserve(PVM pVM, RTGCPHYS GCPhys, RTUINT cb);
323
324/**
325 * Notification about a successful PGMR3HandlerPhysicalRegister() call.
326 *
327 * @param pVM VM Handle.
328 * @param enmType Handler type.
329 * @param GCPhys Handler range address.
330 * @param cb Size of the handler range.
331 * @param fHasHCHandler Set if the handler have a HC callback function.
332 */
333REMR3DECL(void) REMR3NotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler);
334
335/**
336 * Notification about a successful PGMR3HandlerPhysicalDeregister() operation.
337 *
338 * @param pVM VM Handle.
339 * @param enmType Handler type.
340 * @param GCPhys Handler range address.
341 * @param cb Size of the handler range.
342 * @param fHasHCHandler Set if the handler have a HC callback function.
343 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
344 */
345REMR3DECL(void) REMR3NotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM);
346
347/**
348 * Notification about a successful PGMR3HandlerPhysicalModify() call.
349 *
350 * @param pVM VM Handle.
351 * @param enmType Handler type.
352 * @param GCPhysOld Old handler range address.
353 * @param GCPhysNew New handler range address.
354 * @param cb Size of the handler range.
355 * @param fHasHCHandler Set if the handler have a HC callback function.
356 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
357 */
358REMR3DECL(void) REMR3NotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM);
359
360/**
361 * Notification about a pending interrupt.
362 *
363 * @param pVM VM Handle.
364 * @param u8Interrupt Interrupt
365 * @thread The emulation thread.
366 */
367REMR3DECL(void) REMR3NotifyPendingInterrupt(PVM pVM, uint8_t u8Interrupt);
368
369/**
370 * Notification about a pending interrupt.
371 *
372 * @returns Pending interrupt or REM_NO_PENDING_IRQ
373 * @param pVM VM Handle.
374 * @thread The emulation thread.
375 */
376REMR3DECL(uint32_t) REMR3QueryPendingInterrupt(PVM pVM);
377
378/**
379 * Notification about the interrupt FF being set.
380 *
381 * @param pVM VM Handle.
382 * @thread The emulation thread.
383 */
384REMR3DECL(void) REMR3NotifyInterruptSet(PVM pVM);
385
386/**
387 * Notification about the interrupt FF being set.
388 *
389 * @param pVM VM Handle.
390 * @thread The emulation thread.
391 */
392REMR3DECL(void) REMR3NotifyInterruptClear(PVM pVM);
393
394/**
395 * Notification about pending timer(s).
396 *
397 * @param pVM VM Handle.
398 * @thread Any.
399 */
400REMR3DECL(void) REMR3NotifyTimerPending(PVM pVM);
401
402/**
403 * Notification about pending DMA transfers.
404 *
405 * @param pVM VM Handle.
406 * @thread Any.
407 */
408REMR3DECL(void) REMR3NotifyDmaPending(PVM pVM);
409
410/**
411 * Notification about pending timer(s).
412 *
413 * @param pVM VM Handle.
414 * @thread Any.
415 */
416REMR3DECL(void) REMR3NotifyQueuePending(PVM pVM);
417
418/**
419 * Notification about pending FF set by an external thread.
420 *
421 * @param pVM VM handle.
422 * @thread Any.
423 */
424REMR3DECL(void) REMR3NotifyFF(PVM pVM);
425
426#ifdef VBOX_STRICT
427/**
428 * Checks if we're handling access to this page or not.
429 *
430 * @returns true if we're trapping access.
431 * @returns false if we aren't.
432 * @param pVM The VM handle.
433 * @param GCPhys The physical address.
434 *
435 * @remark This function will only work correctly in VBOX_STRICT builds!
436 */
437REMDECL(bool) REMR3IsPageAccessHandled(PVM pVM, RTGCPHYS GCPhys);
438#endif
439
440/** @} */
441#endif
442
443
444/** @} */
445__END_DECLS
446
447
448#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use