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 | */
|
---|
56 | REMDECL(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 | */
|
---|
67 | REMDECL(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 | */
|
---|
79 | REMDECL(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 | */
|
---|
92 | REMDECL(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 | */
|
---|
109 | REMR3DECL(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 | */
|
---|
120 | REMR3DECL(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 | */
|
---|
130 | REMR3DECL(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 | */
|
---|
144 | REMR3DECL(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 | */
|
---|
157 | REMR3DECL(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 | */
|
---|
171 | REMR3DECL(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 | */
|
---|
181 | REMR3DECL(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 | */
|
---|
191 | REMR3DECL(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 | */
|
---|
208 | REMR3DECL(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 | */
|
---|
220 | REMR3DECL(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 | */
|
---|
231 | REMR3DECL(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 | */
|
---|
244 | REMR3DECL(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 | */
|
---|
253 | REMR3DECL(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 | */
|
---|
261 | REMR3DECL(void) REMR3ReplayInvalidatedPages(PVM pVM);
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Replays the recorded physical handler notifications.
|
---|
265 | *
|
---|
266 | * @param pVM VM handle.
|
---|
267 | */
|
---|
268 | REMR3DECL(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 | */
|
---|
277 | REMR3DECL(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 | * @param pvRam The HC address of the RAM.
|
---|
287 | */
|
---|
288 | REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, void *pvRam, unsigned fFlags);
|
---|
289 |
|
---|
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 | */
|
---|
299 | REMR3DECL(void) REMR3NotifyPhysRamChunkRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, RTHCUINTPTR pvRam, unsigned fFlags);
|
---|
300 |
|
---|
301 | /**
|
---|
302 | * Notification about a successful MMR3PhysRomRegister() call.
|
---|
303 | *
|
---|
304 | * @param pVM VM handle.
|
---|
305 | * @param GCPhys The physical address of the ROM.
|
---|
306 | * @param cb The size of the ROM.
|
---|
307 | * @param pvCopy Pointer to the ROM copy.
|
---|
308 | * @param fShadow Whether it's currently writable shadow ROM or normal readonly ROM.
|
---|
309 | * This function will be called when ever the protection of the
|
---|
310 | * shadow ROM changes (at reset and end of POST).
|
---|
311 | */
|
---|
312 | REMR3DECL(void) REMR3NotifyPhysRomRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, void *pvCopy, bool fShadow);
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Notification about a successful MMR3PhysRegister() call.
|
---|
316 | *
|
---|
317 | * @param pVM VM Handle.
|
---|
318 | * @param GCPhys Start physical address.
|
---|
319 | * @param cb The size of the range.
|
---|
320 | */
|
---|
321 | REMR3DECL(void) REMR3NotifyPhysReserve(PVM pVM, RTGCPHYS GCPhys, RTUINT cb);
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Notification about a successful PGMR3HandlerPhysicalRegister() call.
|
---|
325 | *
|
---|
326 | * @param pVM VM Handle.
|
---|
327 | * @param enmType Handler type.
|
---|
328 | * @param GCPhys Handler range address.
|
---|
329 | * @param cb Size of the handler range.
|
---|
330 | * @param fHasHCHandler Set if the handler have a HC callback function.
|
---|
331 | */
|
---|
332 | REMR3DECL(void) REMR3NotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler);
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * Notification about a successful PGMR3HandlerPhysicalDeregister() operation.
|
---|
336 | *
|
---|
337 | * @param pVM VM Handle.
|
---|
338 | * @param enmType Handler type.
|
---|
339 | * @param GCPhys Handler range address.
|
---|
340 | * @param cb Size of the handler range.
|
---|
341 | * @param fHasHCHandler Set if the handler have a HC callback function.
|
---|
342 | * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
|
---|
343 | */
|
---|
344 | REMR3DECL(void) REMR3NotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM);
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * Notification about a successful PGMR3HandlerPhysicalModify() call.
|
---|
348 | *
|
---|
349 | * @param pVM VM Handle.
|
---|
350 | * @param enmType Handler type.
|
---|
351 | * @param GCPhysOld Old handler range address.
|
---|
352 | * @param GCPhysNew New handler range address.
|
---|
353 | * @param cb Size of the handler range.
|
---|
354 | * @param fHasHCHandler Set if the handler have a HC callback function.
|
---|
355 | * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
|
---|
356 | */
|
---|
357 | REMR3DECL(void) REMR3NotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM);
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Notification about a pending interrupt.
|
---|
361 | *
|
---|
362 | * @param pVM VM Handle.
|
---|
363 | * @param u8Interrupt Interrupt
|
---|
364 | * @thread The emulation thread.
|
---|
365 | */
|
---|
366 | REMR3DECL(void) REMR3NotifyPendingInterrupt(PVM pVM, uint8_t u8Interrupt);
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Notification about a pending interrupt.
|
---|
370 | *
|
---|
371 | * @returns Pending interrupt or REM_NO_PENDING_IRQ
|
---|
372 | * @param pVM VM Handle.
|
---|
373 | * @thread The emulation thread.
|
---|
374 | */
|
---|
375 | REMR3DECL(uint32_t) REMR3QueryPendingInterrupt(PVM pVM);
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Notification about the interrupt FF being set.
|
---|
379 | *
|
---|
380 | * @param pVM VM Handle.
|
---|
381 | * @thread The emulation thread.
|
---|
382 | */
|
---|
383 | REMR3DECL(void) REMR3NotifyInterruptSet(PVM pVM);
|
---|
384 |
|
---|
385 | /**
|
---|
386 | * Notification about the interrupt FF being set.
|
---|
387 | *
|
---|
388 | * @param pVM VM Handle.
|
---|
389 | * @thread The emulation thread.
|
---|
390 | */
|
---|
391 | REMR3DECL(void) REMR3NotifyInterruptClear(PVM pVM);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Notification about pending timer(s).
|
---|
395 | *
|
---|
396 | * @param pVM VM Handle.
|
---|
397 | * @thread Any.
|
---|
398 | */
|
---|
399 | REMR3DECL(void) REMR3NotifyTimerPending(PVM pVM);
|
---|
400 |
|
---|
401 | /**
|
---|
402 | * Notification about pending DMA transfers.
|
---|
403 | *
|
---|
404 | * @param pVM VM Handle.
|
---|
405 | * @thread Any.
|
---|
406 | */
|
---|
407 | REMR3DECL(void) REMR3NotifyDmaPending(PVM pVM);
|
---|
408 |
|
---|
409 | /**
|
---|
410 | * Notification about pending timer(s).
|
---|
411 | *
|
---|
412 | * @param pVM VM Handle.
|
---|
413 | * @thread Any.
|
---|
414 | */
|
---|
415 | REMR3DECL(void) REMR3NotifyQueuePending(PVM pVM);
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Notification about pending FF set by an external thread.
|
---|
419 | *
|
---|
420 | * @param pVM VM handle.
|
---|
421 | * @thread Any.
|
---|
422 | */
|
---|
423 | REMR3DECL(void) REMR3NotifyFF(PVM pVM);
|
---|
424 |
|
---|
425 | #ifdef VBOX_STRICT
|
---|
426 | /**
|
---|
427 | * Checks if we're handling access to this page or not.
|
---|
428 | *
|
---|
429 | * @returns true if we're trapping access.
|
---|
430 | * @returns false if we aren't.
|
---|
431 | * @param pVM The VM handle.
|
---|
432 | * @param GCPhys The physical address.
|
---|
433 | *
|
---|
434 | * @remark This function will only work correctly in VBOX_STRICT builds!
|
---|
435 | */
|
---|
436 | REMDECL(bool) REMR3IsPageAccessHandled(PVM pVM, RTGCPHYS GCPhys);
|
---|
437 | #endif
|
---|
438 |
|
---|
439 | /** @} */
|
---|
440 | #endif
|
---|
441 |
|
---|
442 |
|
---|
443 | /** @} */
|
---|
444 | __END_DECLS
|
---|
445 |
|
---|
446 |
|
---|
447 | #endif
|
---|