VirtualBox

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

Last change on this file since 3251 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

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