VirtualBox

source: vbox/trunk/src/recompiler_new/VBoxREMWrapper.cpp@ 15310

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

REM: implement config check heuristic, to select which REM to load

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 115.4 KB
Line 
1/* $Id: VBoxREMWrapper.cpp 15305 2008-12-11 15:31:29Z vboxsync $ */
2/** @file
3 *
4 * VBoxREM Win64 DLL Wrapper.
5 */
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/** @page pg_vboxrem_amd64 VBoxREM Hacks on AMD64
24 *
25 * There are problems with building BoxREM both on WIN64 and 64-bit linux.
26 *
27 * On linux binutils refuses to link shared objects without -fPIC compiled code
28 * (bitches about some fixup types). But when trying to build with -fPIC dyngen
29 * doesn't like the code anymore. Sweet. The current solution is to build the
30 * VBoxREM code as a relocatable module and use our ELF loader to load it.
31 *
32 * On WIN64 we're not aware of any GCC port which can emit code using the MSC
33 * calling convention. So, we're in for some real fun here. The choice is between
34 * porting GCC to AMD64 WIN64 and comming up with some kind of wrapper around
35 * either the win32 build or the 64-bit linux build.
36 *
37 * -# Porting GCC will be a lot of work. For one thing the calling convention differs
38 * and messing with such stuff can easily create ugly bugs. We would also have to
39 * do some binutils changes, but I think those are rather small compared to GCC.
40 * (That said, the MSC calling convention is far simpler than the linux one, it
41 * reminds me of _Optlink which we have working already.)
42 * -# Wrapping win32 code will work, but addresses outside the first 4GB are
43 * inaccessible and we will have to create 32-64 thunks for all imported functions.
44 * (To switch between 32-bit and 64-bit is load the right CS using far jmps (32->64)
45 * or far returns (both).)
46 * -# Wrapping 64-bit linux code might be the easier solution. The requirements here
47 * are:
48 * - Remove all CRT references we possibly, either by using intrinsics or using
49 * IPRT. Part of IPRT will be linked into VBoxREM2.rel, this will be yet another
50 * IPRT mode which I've dubbed 'no-crt'. The no-crt mode provide basic non-system
51 * dependent stuff.
52 * - Compile and link it into a relocatable object (include the gcc intrinsics
53 * in libgcc). Call this VBoxREM2.rel.
54 * - Write a wrapper dll, VBoxREM.dll, for which during REMR3Init() will load
55 * VBoxREM2.rel (using IPRT) and generate calling convention wrappers
56 * for all IPRT functions and VBoxVMM functions that it uses. All exports
57 * will be wrapped vice versa.
58 * - For building on windows hosts, we will use a mingw32 hosted cross compiler.
59 * and add a 'no-crt' mode to IPRT where it provides the necessary CRT headers
60 * and function implementations.
61 *
62 * The 3rd solution will be tried out first since it requires the least effort and
63 * will let us make use of the full 64-bit register set.
64 *
65 *
66 *
67 * @section sec_vboxrem_amd64_compare Comparing the GCC and MSC calling conventions
68 *
69 * GCC expects the following (cut & past from page 20 in the ABI draft 0.96):
70 *
71 * @verbatim
72 %rax temporary register; with variable arguments passes information about the
73 number of SSE registers used; 1st return register.
74 [Not preserved]
75 %rbx callee-saved register; optionally used as base pointer.
76 [Preserved]
77 %rcx used to pass 4th integer argument to functions.
78 [Not preserved]
79 %rdx used to pass 3rd argument to functions; 2nd return register
80 [Not preserved]
81 %rsp stack pointer
82 [Preserved]
83 %rbp callee-saved register; optionally used as frame pointer
84 [Preserved]
85 %rsi used to pass 2nd argument to functions
86 [Not preserved]
87 %rdi used to pass 1st argument to functions
88 [Not preserved]
89 %r8 used to pass 5th argument to functions
90 [Not preserved]
91 %r9 used to pass 6th argument to functions
92 [Not preserved]
93 %r10 temporary register, used for passing a function's static chain
94 pointer [Not preserved]
95 %r11 temporary register
96 [Not preserved]
97 %r12-r15 callee-saved registers
98 [Preserved]
99 %xmm0-%xmm1 used to pass and return floating point arguments
100 [Not preserved]
101 %xmm2-%xmm7 used to pass floating point arguments
102 [Not preserved]
103 %xmm8-%xmm15 temporary registers
104 [Not preserved]
105 %mmx0-%mmx7 temporary registers
106 [Not preserved]
107 %st0 temporary register; used to return long double arguments
108 [Not preserved]
109 %st1 temporary registers; used to return long double arguments
110 [Not preserved]
111 %st2-%st7 temporary registers
112 [Not preserved]
113 %fs Reserved for system use (as thread specific data register)
114 [Not preserved]
115 @endverbatim
116 *
117 * Direction flag is preserved as cleared.
118 * The stack must be aligned on a 16-byte boundrary before the 'call/jmp' instruction.
119 *
120 *
121 *
122 * MSC expects the following:
123 * @verbatim
124 rax return value, not preserved.
125 rbx preserved.
126 rcx 1st argument, integer, not preserved.
127 rdx 2nd argument, integer, not preserved.
128 rbp preserved.
129 rsp preserved.
130 rsi preserved.
131 rdi preserved.
132 r8 3rd argument, integer, not preserved.
133 r9 4th argument, integer, not preserved.
134 r10 scratch register, not preserved.
135 r11 scratch register, not preserved.
136 r12-r15 preserved.
137 xmm0 1st argument, fp, return value, not preserved.
138 xmm1 2st argument, fp, not preserved.
139 xmm2 3st argument, fp, not preserved.
140 xmm3 4st argument, fp, not preserved.
141 xmm4-xmm5 scratch, not preserved.
142 xmm6-xmm15 preserved.
143 @endverbatim
144 *
145 * Dunno what the direction flag is...
146 * The stack must be aligned on a 16-byte boundrary before the 'call/jmp' instruction.
147 *
148 *
149 * Thus, When GCC code is calling MSC code we don't really have to preserve
150 * anything. But but MSC code is calling GCC code, we'll have to save esi and edi.
151 *
152 */
153
154
155/*******************************************************************************
156* Defined Constants And Macros *
157*******************************************************************************/
158/** @def USE_REM_STUBS
159 * Define USE_REM_STUBS to stub the entire REM stuff. This is useful during
160 * early porting (before we start running stuff).
161 */
162#if defined(__DOXYGEN__)
163# define USE_REM_STUBS
164#endif
165
166/** @def USE_REM_CALLING_CONVENTION_GLUE
167 * Define USE_REM_CALLING_CONVENTION_GLUE for platforms where it's necessary to
168 * use calling convention wrappers.
169 */
170#if (defined(RT_ARCH_AMD64) && defined(RT_OS_WINDOWS)) || defined(__DOXYGEN__)
171# define USE_REM_CALLING_CONVENTION_GLUE
172#endif
173
174/** @def USE_REM_IMPORT_JUMP_GLUE
175 * Define USE_REM_IMPORT_JUMP_GLUE for platforms where we need to
176 * emit some jump glue to deal with big addresses.
177 */
178#if (defined(RT_ARCH_AMD64) && !defined(USE_REM_CALLING_CONVENTION_GLUE) && !defined(RT_OS_DARWIN)) || defined(__DOXYGEN__)
179# define USE_REM_IMPORT_JUMP_GLUE
180#endif
181
182/*******************************************************************************
183* Header Files *
184*******************************************************************************/
185#define LOG_GROUP LOG_GROUP_REM
186#include <VBox/rem.h>
187#include <VBox/vmm.h>
188#include <VBox/dbgf.h>
189#include <VBox/dbg.h>
190#include <VBox/csam.h>
191#include <VBox/mm.h>
192#include <VBox/em.h>
193#include <VBox/ssm.h>
194#include <VBox/hwaccm.h>
195#include <VBox/patm.h>
196#ifdef VBOX_WITH_VMI
197# include <VBox/parav.h>
198#endif
199#include <VBox/pdm.h>
200#include <VBox/pgm.h>
201#include <VBox/iom.h>
202#include <VBox/vm.h>
203#include <VBox/err.h>
204#include <VBox/log.h>
205#include <VBox/dis.h>
206
207#include <iprt/alloc.h>
208#include <iprt/assert.h>
209#include <iprt/ldr.h>
210#include <iprt/param.h>
211#include <iprt/path.h>
212#include <iprt/string.h>
213#include <iprt/stream.h>
214
215
216/*******************************************************************************
217* Structures and Typedefs *
218*******************************************************************************/
219/**
220 * Parameter descriptor.
221 */
222typedef struct REMPARMDESC
223{
224 /** Parameter flags (REMPARMDESC_FLAGS_*). */
225 uint8_t fFlags;
226 /** The parameter size if REMPARMDESC_FLAGS_SIZE is set. */
227 uint8_t cb;
228 /** Pointer to additional data.
229 * For REMPARMDESC_FLAGS_PFN this is a PREMFNDESC. */
230 void *pvExtra;
231
232} REMPARMDESC, *PREMPARMDESC;
233/** Pointer to a constant parameter descriptor. */
234typedef const REMPARMDESC *PCREMPARMDESC;
235
236/** @name Parameter descriptor flags.
237 * @{ */
238/** The parameter type is a kind of integer which could fit in a register. This includes pointers. */
239#define REMPARMDESC_FLAGS_INT 0
240/** The parameter is a GC pointer. */
241#define REMPARMDESC_FLAGS_GCPTR 1
242/** The parameter is a GC physical address. */
243#define REMPARMDESC_FLAGS_GCPHYS 2
244/** The parameter is a HC physical address. */
245#define REMPARMDESC_FLAGS_HCPHYS 3
246/** The parameter type is a kind of floating point. */
247#define REMPARMDESC_FLAGS_FLOAT 4
248/** The parameter value is a struct. This type takes a size. */
249#define REMPARMDESC_FLAGS_STRUCT 5
250/** The parameter is an elipsis. */
251#define REMPARMDESC_FLAGS_ELLIPSIS 6
252/** The parameter is a va_list. */
253#define REMPARMDESC_FLAGS_VALIST 7
254/** The parameter is a function pointer. pvExtra is a PREMFNDESC. */
255#define REMPARMDESC_FLAGS_PFN 8
256/** The parameter type mask. */
257#define REMPARMDESC_FLAGS_TYPE_MASK 15
258/** The parameter size field is valid. */
259#define REMPARMDESC_FLAGS_SIZE RT_BIT(7)
260/** @} */
261
262/**
263 * Function descriptor.
264 */
265typedef struct REMFNDESC
266{
267 /** The function name. */
268 const char *pszName;
269 /** Exports: Pointer to the function pointer.
270 * Imports: Pointer to the function. */
271 void *pv;
272 /** Array of parameter descriptors. */
273 PCREMPARMDESC paParams;
274 /** The number of parameter descriptors pointed to by paParams. */
275 uint8_t cParams;
276 /** Function flags (REMFNDESC_FLAGS_*). */
277 uint8_t fFlags;
278 /** The size of the return value. */
279 uint8_t cbReturn;
280 /** Pointer to the wrapper code for imports. */
281 void *pvWrapper;
282} REMFNDESC, *PREMFNDESC;
283/** Pointer to a constant function descriptor. */
284typedef const REMFNDESC *PCREMFNDESC;
285
286/** @name Function descriptor flags.
287 * @{ */
288/** The return type is void. */
289#define REMFNDESC_FLAGS_RET_VOID 0
290/** The return type is a kind of integer passed in rax/eax. This includes pointers. */
291#define REMFNDESC_FLAGS_RET_INT 1
292/** The return type is a kind of floating point. */
293#define REMFNDESC_FLAGS_RET_FLOAT 2
294/** The return value is a struct. This type take a size. */
295#define REMFNDESC_FLAGS_RET_STRUCT 3
296/** The return type mask. */
297#define REMFNDESC_FLAGS_RET_TYPE_MASK 7
298/** The argument list contains one or more va_list arguments (i.e. problems). */
299#define REMFNDESC_FLAGS_VALIST RT_BIT(6)
300/** The function has an ellipsis (i.e. a problem). */
301#define REMFNDESC_FLAGS_ELLIPSIS RT_BIT(7)
302/** @} */
303
304/**
305 * Chunk of read-write-executable memory.
306 */
307typedef struct REMEXECMEM
308{
309 /** The number of bytes left. */
310 struct REMEXECMEM *pNext;
311 /** The size of this chunk. */
312 uint32_t cb;
313 /** The offset of the next code block. */
314 uint32_t off;
315#if ARCH_BITS == 32
316 uint32_t padding;
317#endif
318} REMEXECMEM, *PREMEXECMEM;
319
320
321/*******************************************************************************
322* Global Variables *
323*******************************************************************************/
324#ifndef USE_REM_STUBS
325/** Loader handle of the REM object/DLL. */
326static RTLDRMOD g_ModREM2;
327/** Pointer to the memory containing the loaded REM2 object/DLL. */
328static void *g_pvREM2;
329
330/** Linux object export addresses.
331 * These are references from the assembly wrapper code.
332 * @{ */
333static DECLCALLBACKPTR(int, pfnREMR3Init)(PVM);
334static DECLCALLBACKPTR(int, pfnREMR3Term)(PVM);
335static DECLCALLBACKPTR(void, pfnREMR3Reset)(PVM);
336static DECLCALLBACKPTR(int, pfnREMR3Step)(PVM);
337static DECLCALLBACKPTR(int, pfnREMR3BreakpointSet)(PVM, RTGCUINTPTR);
338static DECLCALLBACKPTR(int, pfnREMR3BreakpointClear)(PVM, RTGCUINTPTR);
339static DECLCALLBACKPTR(int, pfnREMR3EmulateInstruction)(PVM);
340static DECLCALLBACKPTR(int, pfnREMR3Run)(PVM);
341static DECLCALLBACKPTR(int, pfnREMR3State)(PVM);
342static DECLCALLBACKPTR(int, pfnREMR3StateBack)(PVM);
343static DECLCALLBACKPTR(void, pfnREMR3StateUpdate)(PVM);
344static DECLCALLBACKPTR(void, pfnREMR3A20Set)(PVM, bool);
345static DECLCALLBACKPTR(void, pfnREMR3ReplayInvalidatedPages)(PVM);
346static DECLCALLBACKPTR(void, pfnREMR3ReplayHandlerNotifications)(PVM pVM);
347static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RTUINT, unsigned);
348static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamChunkRegister)(PVM, RTGCPHYS, RTUINT, RTHCUINTPTR, unsigned);
349static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysReserve)(PVM, RTGCPHYS, RTUINT);
350static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRomRegister)(PVM, RTGCPHYS, RTUINT, void *, bool);
351static DECLCALLBACKPTR(void, pfnREMR3NotifyHandlerPhysicalModify)(PVM, PGMPHYSHANDLERTYPE, RTGCPHYS, RTGCPHYS, RTGCPHYS, bool, bool);
352static DECLCALLBACKPTR(void, pfnREMR3NotifyHandlerPhysicalRegister)(PVM, PGMPHYSHANDLERTYPE, RTGCPHYS, RTGCPHYS, bool);
353static DECLCALLBACKPTR(void, pfnREMR3NotifyHandlerPhysicalDeregister)(PVM, PGMPHYSHANDLERTYPE, RTGCPHYS, RTGCPHYS, bool, bool);
354static DECLCALLBACKPTR(void, pfnREMR3NotifyInterruptSet)(PVM);
355static DECLCALLBACKPTR(void, pfnREMR3NotifyInterruptClear)(PVM);
356static DECLCALLBACKPTR(void, pfnREMR3NotifyTimerPending)(PVM);
357static DECLCALLBACKPTR(void, pfnREMR3NotifyDmaPending)(PVM);
358static DECLCALLBACKPTR(void, pfnREMR3NotifyQueuePending)(PVM);
359static DECLCALLBACKPTR(void, pfnREMR3NotifyFF)(PVM);
360static DECLCALLBACKPTR(int, pfnREMR3NotifyCodePageChanged)(PVM, RTGCPTR);
361static DECLCALLBACKPTR(void, pfnREMR3NotifyPendingInterrupt)(PVM, uint8_t);
362static DECLCALLBACKPTR(uint32_t, pfnREMR3QueryPendingInterrupt)(PVM);
363static DECLCALLBACKPTR(int, pfnREMR3DisasEnableStepping)(PVM, bool);
364static DECLCALLBACKPTR(bool, pfnREMR3IsPageAccessHandled)(PVM, RTGCPHYS);
365/** @} */
366
367/** Export and import parameter descriptors.
368 * @{
369 */
370/* Common args. */
371static const REMPARMDESC g_aArgsSIZE_T[] =
372{
373 { REMPARMDESC_FLAGS_INT, sizeof(size_t) }
374};
375static const REMPARMDESC g_aArgsPTR[] =
376{
377 { REMPARMDESC_FLAGS_INT, sizeof(void *) }
378};
379static const REMPARMDESC g_aArgsVM[] =
380{
381 { REMPARMDESC_FLAGS_INT, sizeof(PVM) }
382};
383
384/* REM args */
385static const REMPARMDESC g_aArgsBreakpoint[] =
386{
387 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
388 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINTPTR), NULL }
389};
390static const REMPARMDESC g_aArgsA20Set[] =
391{
392 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
393 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
394};
395static const REMPARMDESC g_aArgsNotifyPhysRamRegister[] =
396{
397 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
398 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
399 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
400 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
401 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
402};
403static const REMPARMDESC g_aArgsNotifyPhysRamChunkRegister[] =
404{
405 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
406 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
407 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
408 { REMPARMDESC_FLAGS_INT, sizeof(RTHCUINTPTR), NULL },
409 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
410};
411static const REMPARMDESC g_aArgsNotifyPhysReserve[] =
412{
413 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
414 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
415 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL }
416};
417static const REMPARMDESC g_aArgsNotifyPhysRomRegister[] =
418{
419 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
420 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
421 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
422 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
423 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
424};
425static const REMPARMDESC g_aArgsNotifyHandlerPhysicalModify[] =
426{
427 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
428 { REMPARMDESC_FLAGS_INT, sizeof(PGMPHYSHANDLERTYPE), NULL },
429 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
430 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
431 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
432 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL },
433 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
434};
435static const REMPARMDESC g_aArgsNotifyHandlerPhysicalRegister[] =
436{
437 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
438 { REMPARMDESC_FLAGS_INT, sizeof(PGMPHYSHANDLERTYPE), NULL },
439 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
440 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
441 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
442};
443static const REMPARMDESC g_aArgsNotifyHandlerPhysicalDeregister[] =
444{
445 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
446 { REMPARMDESC_FLAGS_INT, sizeof(PGMPHYSHANDLERTYPE), NULL },
447 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
448 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
449 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL },
450 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
451};
452static const REMPARMDESC g_aArgsNotifyCodePageChanged[] =
453{
454 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
455 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINTPTR), NULL }
456};
457static const REMPARMDESC g_aArgsNotifyPendingInterrupt[] =
458{
459 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
460 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
461};
462static const REMPARMDESC g_aArgsDisasEnableStepping[] =
463{
464 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
465 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
466};
467static const REMPARMDESC g_aArgsIsPageAccessHandled[] =
468{
469 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
470 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }
471};
472
473
474/* VMM args */
475static const REMPARMDESC g_aArgsCPUMGetGuestCpl[] =
476{
477 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
478 { REMPARMDESC_FLAGS_INT, sizeof(PCPUMCTXCORE), NULL },
479};
480
481/* CPUMGetGuestMsr args */
482static const REMPARMDESC g_aArgsCPUMGetGuestMsr[] =
483{
484 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
485 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
486};
487
488/* CPUMGetGuestMsr args */
489static const REMPARMDESC g_aArgsCPUMSetGuestMsr[] =
490{
491 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
492 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
493 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
494};
495
496static const REMPARMDESC g_aArgsCPUMGetGuestCpuId[] =
497{
498 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
499 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
500 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
501 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
502 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
503 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
504};
505
506static const REMPARMDESC g_aArgsCPUMSetChangedFlags[] =
507{
508 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
509 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
510};
511
512static const REMPARMDESC g_aArgsCPUMQueryGuestCtxPtr[] =
513{
514 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }
515};
516static const REMPARMDESC g_aArgsCSAMR3MonitorPage[] =
517{
518 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
519 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL },
520 { REMPARMDESC_FLAGS_INT, sizeof(CSAMTAG), NULL }
521};
522static const REMPARMDESC g_aArgsCSAMR3UnmonitorPage[] =
523{
524 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
525 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL },
526 { REMPARMDESC_FLAGS_INT, sizeof(CSAMTAG), NULL }
527};
528
529static const REMPARMDESC g_aArgsCSAMR3RecordCallAddress[] =
530{
531 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
532 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL }
533};
534
535#if defined(VBOX_WITH_DEBUGGER) && !(defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)) /* the callbacks are problematic */
536static const REMPARMDESC g_aArgsDBGCRegisterCommands[] =
537{
538 { REMPARMDESC_FLAGS_INT, sizeof(PCDBGCCMD), NULL },
539 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
540};
541#endif
542static const REMPARMDESC g_aArgsDBGFR3DisasInstrEx[] =
543{
544 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
545 { REMPARMDESC_FLAGS_INT, sizeof(RTSEL), NULL },
546 { REMPARMDESC_FLAGS_INT, sizeof(RTGCPTR), NULL },
547 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
548 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
549 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
550 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
551};
552static const REMPARMDESC g_aArgsDBGFR3Info[] =
553{
554 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
555 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
556 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
557 { REMPARMDESC_FLAGS_INT, sizeof(PCDBGFINFOHLP), NULL }
558};
559static const REMPARMDESC g_aArgsDBGFR3SymbolByAddr[] =
560{
561 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
562 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINTPTR), NULL },
563 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCINTPTR), NULL },
564 { REMPARMDESC_FLAGS_INT, sizeof(PDBGFSYMBOL), NULL }
565};
566static const REMPARMDESC g_aArgsDISInstr[] =
567{
568 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
569 { REMPARMDESC_FLAGS_INT, sizeof(RTUINTPTR), NULL },
570 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
571 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
572 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL }
573};
574static const REMPARMDESC g_aArgsEMR3FatalError[] =
575{
576 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
577 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL }
578};
579static const REMPARMDESC g_aArgsHWACCMR3CanExecuteGuest[] =
580{
581 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
582 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
583 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
584 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
585};
586static const REMPARMDESC g_aArgsIOMIOPortRead[] =
587{
588 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
589 { REMPARMDESC_FLAGS_INT, sizeof(RTIOPORT), NULL },
590 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
591 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
592};
593static const REMPARMDESC g_aArgsIOMIOPortWrite[] =
594{
595 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
596 { REMPARMDESC_FLAGS_INT, sizeof(RTIOPORT), NULL },
597 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
598 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
599};
600static const REMPARMDESC g_aArgsIOMMMIORead[] =
601{
602 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
603 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
604 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
605 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
606};
607static const REMPARMDESC g_aArgsIOMMMIOWrite[] =
608{
609 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
610 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
611 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
612 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
613};
614static const REMPARMDESC g_aArgsMMR3HeapAlloc[] =
615{
616 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
617 { REMPARMDESC_FLAGS_INT, sizeof(MMTAG), NULL },
618 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
619};
620static const REMPARMDESC g_aArgsMMR3HeapAllocZ[] =
621{
622 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
623 { REMPARMDESC_FLAGS_INT, sizeof(MMTAG), NULL },
624 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
625};
626static const REMPARMDESC g_aArgsPATMIsPatchGCAddr[] =
627{
628 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
629 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL }
630};
631static const REMPARMDESC g_aArgsPATMR3QueryOpcode[] =
632{
633 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
634 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL },
635 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL }
636};
637static const REMPARMDESC g_aArgsPATMR3QueryPatchMem[] =
638{
639 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
640 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
641};
642#ifdef VBOX_WITH_VMI
643static const REMPARMDESC g_aArgsPARAVIsBiosCall[] =
644{
645 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
646 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
647 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
648};
649#endif
650static const REMPARMDESC g_aArgsPDMApicGetBase[] =
651{
652 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
653 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL }
654};
655static const REMPARMDESC g_aArgsPDMApicGetTPR[] =
656{
657 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
658 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL },
659 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL }
660};
661static const REMPARMDESC g_aArgsPDMApicSetBase[] =
662{
663 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
664 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
665};
666static const REMPARMDESC g_aArgsPDMApicSetTPR[] =
667{
668 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
669 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
670};
671static const REMPARMDESC g_aArgsPDMApicWriteMSR[] =
672{
673 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
674 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL },
675 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
676 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
677};
678static const REMPARMDESC g_aArgsPDMApicReadMSR[] =
679{
680 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
681 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL },
682 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
683 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL }
684};
685static const REMPARMDESC g_aArgsPDMGetInterrupt[] =
686{
687 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
688 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL }
689};
690static const REMPARMDESC g_aArgsPDMIsaSetIrq[] =
691{
692 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
693 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL },
694 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
695};
696static const REMPARMDESC g_aArgsPGMGetGuestMode[] =
697{
698 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
699};
700static const REMPARMDESC g_aArgsPGMGstGetPage[] =
701{
702 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
703 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
704 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL },
705 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPHYS), NULL }
706};
707static const REMPARMDESC g_aArgsPGMInvalidatePage[] =
708{
709 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
710 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL }
711};
712static const REMPARMDESC g_aArgsPGMPhysGCPhys2R3Ptr[] =
713{
714 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
715 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
716 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
717 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL }
718};
719static const REMPARMDESC g_aArgsPGMR3PhysTlbGCPhys2Ptr[] =
720{
721 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
722 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
723 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL },
724 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL }
725};
726static const REMPARMDESC g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[] =
727{
728 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
729 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
730 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
731 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
732 { REMPARMDESC_FLAGS_INT, sizeof(PRTR3PTR), NULL }
733};
734static const REMPARMDESC g_aArgsPGM3PhysGrowRange[] =
735{
736 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
737 { REMPARMDESC_FLAGS_INT, sizeof(PCRTGCPHYS), NULL }
738};
739static const REMPARMDESC g_aArgsPGMPhysIsGCPhysValid[] =
740{
741 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
742 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }
743};
744static const REMPARMDESC g_aArgsPGMPhysRead[] =
745{
746 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
747 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
748 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
749 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
750};
751static const REMPARMDESC g_aArgsPGMPhysSimpleReadGCPtr[] =
752{
753 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
754 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
755 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
756 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
757};
758static const REMPARMDESC g_aArgsPGMPhysWrite[] =
759{
760 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
761 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
762 { REMPARMDESC_FLAGS_INT, sizeof(const void *), NULL },
763 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
764};
765static const REMPARMDESC g_aArgsPGMChangeMode[] =
766{
767 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
768 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
769 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
770 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
771};
772static const REMPARMDESC g_aArgsPGMFlushTLB[] =
773{
774 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
775 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
776 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
777};
778static const REMPARMDESC g_aArgsPGMR3PhysReadUxx[] =
779{
780 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
781 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }
782};
783static const REMPARMDESC g_aArgsPGMR3PhysWriteU8[] =
784{
785 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
786 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
787 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
788};
789static const REMPARMDESC g_aArgsPGMR3PhysWriteU16[] =
790{
791 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
792 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
793 { REMPARMDESC_FLAGS_INT, sizeof(uint16_t), NULL }
794};
795static const REMPARMDESC g_aArgsPGMR3PhysWriteU32[] =
796{
797 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
798 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
799 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
800};
801static const REMPARMDESC g_aArgsPGMR3PhysWriteU64[] =
802{
803 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
804 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
805 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
806};
807static const REMPARMDESC g_aArgsPGMR3DbgR3Ptr2GCPhys[] =
808{
809 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
810 { REMPARMDESC_FLAGS_INT, sizeof(void*), NULL },
811 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPHYS), NULL }
812};
813static const REMPARMDESC g_aArgsRTMemRealloc[] =
814{
815 { REMPARMDESC_FLAGS_INT, sizeof(void*), NULL },
816 { REMPARMDESC_FLAGS_INT, sizeof(size_t) }
817};
818static const REMPARMDESC g_aArgsSSMR3GetGCPtr[] =
819{
820 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
821 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPTR), NULL }
822};
823static const REMPARMDESC g_aArgsSSMR3GetMem[] =
824{
825 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
826 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
827 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
828};
829static const REMPARMDESC g_aArgsSSMR3GetU32[] =
830{
831 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
832 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
833};
834static const REMPARMDESC g_aArgsSSMR3GetUInt[] =
835{
836 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
837 { REMPARMDESC_FLAGS_INT, sizeof(PRTUINT), NULL }
838};
839static const REMPARMDESC g_aArgsSSMR3PutGCPtr[] =
840{
841 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
842 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL }
843};
844static const REMPARMDESC g_aArgsSSMR3PutMem[] =
845{
846 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
847 { REMPARMDESC_FLAGS_INT, sizeof(const void *), NULL },
848 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
849};
850static const REMPARMDESC g_aArgsSSMR3PutU32[] =
851{
852 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
853 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
854};
855static const REMPARMDESC g_aArgsSSMR3PutUInt[] =
856{
857 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
858 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
859};
860
861static const REMPARMDESC g_aArgsSSMIntCallback[] =
862{
863 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
864 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
865};
866static REMFNDESC g_SSMIntCallback =
867{
868 "SSMIntCallback", NULL, &g_aArgsSSMIntCallback[0], RT_ELEMENTS(g_aArgsSSMIntCallback), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL
869};
870
871static const REMPARMDESC g_aArgsSSMIntLoadExecCallback[] =
872{
873 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
874 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
875 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
876};
877static REMFNDESC g_SSMIntLoadExecCallback =
878{
879 "SSMIntLoadExecCallback", NULL, &g_aArgsSSMIntLoadExecCallback[0], RT_ELEMENTS(g_aArgsSSMIntLoadExecCallback), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL
880};
881static const REMPARMDESC g_aArgsSSMR3RegisterInternal[] =
882{
883 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
884 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
885 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
886 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
887 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
888 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTSAVEPREP), &g_SSMIntCallback },
889 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTSAVEEXEC), &g_SSMIntCallback },
890 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTSAVEDONE), &g_SSMIntCallback },
891 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLOADPREP), &g_SSMIntCallback },
892 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLOADEXEC), &g_SSMIntLoadExecCallback },
893 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLOADDONE), &g_SSMIntCallback },
894};
895
896static const REMPARMDESC g_aArgsSTAMR3Register[] =
897{
898 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
899 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
900 { REMPARMDESC_FLAGS_INT, sizeof(STAMTYPE), NULL },
901 { REMPARMDESC_FLAGS_INT, sizeof(STAMVISIBILITY), NULL },
902 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
903 { REMPARMDESC_FLAGS_INT, sizeof(STAMUNIT), NULL },
904 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
905};
906static const REMPARMDESC g_aArgsTRPMAssertTrap[] =
907{
908 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
909 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL },
910 { REMPARMDESC_FLAGS_INT, sizeof(TRPMEVENT), NULL }
911};
912static const REMPARMDESC g_aArgsTRPMQueryTrap[] =
913{
914 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
915 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL },
916 { REMPARMDESC_FLAGS_INT, sizeof(TRPMEVENT *), NULL }
917};
918static const REMPARMDESC g_aArgsTRPMSetErrorCode[] =
919{
920 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
921 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINT), NULL }
922};
923static const REMPARMDESC g_aArgsTRPMSetFaultAddress[] =
924{
925 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
926 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINT), NULL }
927};
928static const REMPARMDESC g_aArgsVMR3ReqCall[] =
929{
930 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
931 { REMPARMDESC_FLAGS_INT, sizeof(VMREQDEST), NULL },
932 { REMPARMDESC_FLAGS_INT, sizeof(PVMREQ *), NULL },
933 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
934 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
935 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
936 { REMPARMDESC_FLAGS_ELLIPSIS, 0 }
937};
938static const REMPARMDESC g_aArgsVMR3ReqFree[] =
939{
940 { REMPARMDESC_FLAGS_INT, sizeof(PVMREQ), NULL }
941};
942
943/* IPRT args */
944static const REMPARMDESC g_aArgsAssertMsg1[] =
945{
946 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
947 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
948 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
949 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
950};
951static const REMPARMDESC g_aArgsAssertMsg2[] =
952{
953 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
954 { REMPARMDESC_FLAGS_ELLIPSIS, 0 }
955};
956static const REMPARMDESC g_aArgsRTLogFlags[] =
957{
958 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL },
959 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
960};
961static const REMPARMDESC g_aArgsRTLogFlush[] =
962{
963 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL }
964};
965static const REMPARMDESC g_aArgsRTLogLoggerEx[] =
966{
967 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL },
968 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
969 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
970 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
971 { REMPARMDESC_FLAGS_ELLIPSIS, 0 }
972};
973static const REMPARMDESC g_aArgsRTLogLoggerExV[] =
974{
975 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL },
976 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
977 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
978 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
979 { REMPARMDESC_FLAGS_VALIST, 0 }
980};
981static const REMPARMDESC g_aArgsRTLogPrintf[] =
982{
983 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
984 { REMPARMDESC_FLAGS_ELLIPSIS, 0 }
985};
986static const REMPARMDESC g_aArgsRTMemProtect[] =
987{
988 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
989 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
990 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
991};
992static const REMPARMDESC g_aArgsRTStrPrintf[] =
993{
994 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
995 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
996 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
997 { REMPARMDESC_FLAGS_ELLIPSIS, 0 }
998};
999static const REMPARMDESC g_aArgsRTStrPrintfV[] =
1000{
1001 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
1002 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
1003 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1004 { REMPARMDESC_FLAGS_VALIST, 0 }
1005};
1006static const REMPARMDESC g_aArgsThread[] =
1007{
1008 { REMPARMDESC_FLAGS_INT, sizeof(RTTHREAD), NULL }
1009};
1010
1011
1012/* CRT args */
1013static const REMPARMDESC g_aArgsmemcpy[] =
1014{
1015 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1016 { REMPARMDESC_FLAGS_INT, sizeof(const void *), NULL },
1017 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
1018};
1019static const REMPARMDESC g_aArgsmemset[] =
1020{
1021 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1022 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL },
1023 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
1024};
1025
1026/** @} */
1027
1028/**
1029 * Descriptors for the exported functions.
1030 */
1031static const REMFNDESC g_aExports[] =
1032{ /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */
1033 { "REMR3Init", (void *)&pfnREMR3Init, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1034 { "REMR3Term", (void *)&pfnREMR3Term, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1035 { "REMR3Reset", (void *)&pfnREMR3Reset, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1036 { "REMR3Step", (void *)&pfnREMR3Step, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1037 { "REMR3BreakpointSet", (void *)&pfnREMR3BreakpointSet, &g_aArgsBreakpoint[0], RT_ELEMENTS(g_aArgsBreakpoint), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1038 { "REMR3BreakpointClear", (void *)&pfnREMR3BreakpointClear, &g_aArgsBreakpoint[0], RT_ELEMENTS(g_aArgsBreakpoint), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1039 { "REMR3EmulateInstruction", (void *)&pfnREMR3EmulateInstruction, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1040 { "REMR3Run", (void *)&pfnREMR3Run, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1041 { "REMR3State", (void *)&pfnREMR3State, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1042 { "REMR3StateBack", (void *)&pfnREMR3StateBack, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1043 { "REMR3StateUpdate", (void *)&pfnREMR3StateUpdate, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1044 { "REMR3A20Set", (void *)&pfnREMR3A20Set, &g_aArgsA20Set[0], RT_ELEMENTS(g_aArgsA20Set), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1045 { "REMR3ReplayInvalidatedPages", (void *)&pfnREMR3ReplayInvalidatedPages, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1046 { "REMR3ReplayHandlerNotifications", (void *)&pfnREMR3ReplayHandlerNotifications, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1047 { "REMR3NotifyPhysRamRegister", (void *)&pfnREMR3NotifyPhysRamRegister, &g_aArgsNotifyPhysRamRegister[0], RT_ELEMENTS(g_aArgsNotifyPhysRamRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1048 { "REMR3NotifyPhysRamChunkRegister", (void *)&pfnREMR3NotifyPhysRamChunkRegister, &g_aArgsNotifyPhysRamChunkRegister[0], RT_ELEMENTS(g_aArgsNotifyPhysRamChunkRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1049 { "REMR3NotifyPhysReserve", (void *)&pfnREMR3NotifyPhysReserve, &g_aArgsNotifyPhysReserve[0], RT_ELEMENTS(g_aArgsNotifyPhysReserve), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1050 { "REMR3NotifyPhysRomRegister", (void *)&pfnREMR3NotifyPhysRomRegister, &g_aArgsNotifyPhysRomRegister[0], RT_ELEMENTS(g_aArgsNotifyPhysRomRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1051 { "REMR3NotifyHandlerPhysicalModify", (void *)&pfnREMR3NotifyHandlerPhysicalModify, &g_aArgsNotifyHandlerPhysicalModify[0], RT_ELEMENTS(g_aArgsNotifyHandlerPhysicalModify), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1052 { "REMR3NotifyHandlerPhysicalRegister", (void *)&pfnREMR3NotifyHandlerPhysicalRegister, &g_aArgsNotifyHandlerPhysicalRegister[0], RT_ELEMENTS(g_aArgsNotifyHandlerPhysicalRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1053 { "REMR3NotifyHandlerPhysicalDeregister", (void *)&pfnREMR3NotifyHandlerPhysicalDeregister, &g_aArgsNotifyHandlerPhysicalDeregister[0], RT_ELEMENTS(g_aArgsNotifyHandlerPhysicalDeregister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1054 { "REMR3NotifyInterruptSet", (void *)&pfnREMR3NotifyInterruptSet, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1055 { "REMR3NotifyInterruptClear", (void *)&pfnREMR3NotifyInterruptClear, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1056 { "REMR3NotifyTimerPending", (void *)&pfnREMR3NotifyTimerPending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1057 { "REMR3NotifyDmaPending", (void *)&pfnREMR3NotifyDmaPending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1058 { "REMR3NotifyQueuePending", (void *)&pfnREMR3NotifyQueuePending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1059 { "REMR3NotifyFF", (void *)&pfnREMR3NotifyFF, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1060 { "REMR3NotifyCodePageChanged", (void *)&pfnREMR3NotifyCodePageChanged, &g_aArgsNotifyCodePageChanged[0], RT_ELEMENTS(g_aArgsNotifyCodePageChanged), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1061 { "REMR3NotifyPendingInterrupt", (void *)&pfnREMR3NotifyPendingInterrupt, &g_aArgsNotifyPendingInterrupt[0], RT_ELEMENTS(g_aArgsNotifyPendingInterrupt), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1062 { "REMR3QueryPendingInterrupt", (void *)&pfnREMR3QueryPendingInterrupt, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1063 { "REMR3DisasEnableStepping", (void *)&pfnREMR3DisasEnableStepping, &g_aArgsDisasEnableStepping[0], RT_ELEMENTS(g_aArgsDisasEnableStepping), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1064 { "REMR3IsPageAccessHandled", (void *)&pfnREMR3IsPageAccessHandled, &g_aArgsIsPageAccessHandled[0], RT_ELEMENTS(g_aArgsIsPageAccessHandled), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL }
1065};
1066
1067
1068/**
1069 * Descriptors for the functions imported from VBoxVMM.
1070 */
1071static REMFNDESC g_aVMMImports[] =
1072{
1073 { "CPUMAreHiddenSelRegsValid", (void *)(uintptr_t)&CPUMAreHiddenSelRegsValid, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1074 { "CPUMGetAndClearChangedFlagsREM", (void *)(uintptr_t)&CPUMGetAndClearChangedFlagsREM, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(unsigned), NULL },
1075 { "CPUMSetChangedFlags", (void *)(uintptr_t)&CPUMSetChangedFlags, &g_aArgsCPUMSetChangedFlags[0], RT_ELEMENTS(g_aArgsCPUMSetChangedFlags), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1076 { "CPUMGetGuestCPL", (void *)(uintptr_t)&CPUMGetGuestCPL, &g_aArgsCPUMGetGuestCpl[0], RT_ELEMENTS(g_aArgsCPUMGetGuestCpl), REMFNDESC_FLAGS_RET_INT, sizeof(unsigned), NULL },
1077 { "CPUMGetGuestMsr", (void *)(uintptr_t)&CPUMGetGuestMsr, &g_aArgsCPUMGetGuestMsr[0], RT_ELEMENTS(g_aArgsCPUMGetGuestMsr), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1078 { "CPUMSetGuestMsr", (void *)(uintptr_t)&CPUMSetGuestMsr, &g_aArgsCPUMSetGuestMsr[0], RT_ELEMENTS(g_aArgsCPUMSetGuestMsr), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1079 { "CPUMGetGuestCpuId", (void *)(uintptr_t)&CPUMGetGuestCpuId, &g_aArgsCPUMGetGuestCpuId[0], RT_ELEMENTS(g_aArgsCPUMGetGuestCpuId), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1080 { "CPUMGetGuestEAX", (void *)(uintptr_t)&CPUMGetGuestEAX, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1081 { "CPUMGetGuestEBP", (void *)(uintptr_t)&CPUMGetGuestEBP, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1082 { "CPUMGetGuestEBX", (void *)(uintptr_t)&CPUMGetGuestEBX, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1083 { "CPUMGetGuestECX", (void *)(uintptr_t)&CPUMGetGuestECX, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1084 { "CPUMGetGuestEDI", (void *)(uintptr_t)&CPUMGetGuestEDI, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1085 { "CPUMGetGuestEDX", (void *)(uintptr_t)&CPUMGetGuestEDX, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1086 { "CPUMGetGuestEIP", (void *)(uintptr_t)&CPUMGetGuestEIP, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1087 { "CPUMGetGuestESI", (void *)(uintptr_t)&CPUMGetGuestESI, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1088 { "CPUMGetGuestESP", (void *)(uintptr_t)&CPUMGetGuestESP, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1089 { "CPUMGetGuestCS", (void *)(uintptr_t)&CPUMGetGuestCS, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(RTSEL), NULL },
1090 { "CPUMGetGuestSS", (void *)(uintptr_t)&CPUMGetGuestSS, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(RTSEL), NULL },
1091 { "CPUMQueryGuestCtxPtr", (void *)(uintptr_t)&CPUMQueryGuestCtxPtr, &g_aArgsCPUMQueryGuestCtxPtr[0], RT_ELEMENTS(g_aArgsCPUMQueryGuestCtxPtr), REMFNDESC_FLAGS_RET_INT, sizeof(PCPUMCTX), NULL },
1092 { "CSAMR3MonitorPage", (void *)(uintptr_t)&CSAMR3MonitorPage, &g_aArgsCSAMR3MonitorPage[0], RT_ELEMENTS(g_aArgsCSAMR3MonitorPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1093 { "CSAMR3UnmonitorPage", (void *)(uintptr_t)&CSAMR3UnmonitorPage, &g_aArgsCSAMR3UnmonitorPage[0], RT_ELEMENTS(g_aArgsCSAMR3UnmonitorPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1094 { "CSAMR3RecordCallAddress", (void *)(uintptr_t)&CSAMR3RecordCallAddress, &g_aArgsCSAMR3RecordCallAddress[0], RT_ELEMENTS(g_aArgsCSAMR3RecordCallAddress), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1095#if defined(VBOX_WITH_DEBUGGER) && !(defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)) /* the callbacks are problematic */
1096 { "DBGCRegisterCommands", (void *)(uintptr_t)&DBGCRegisterCommands, &g_aArgsDBGCRegisterCommands[0], RT_ELEMENTS(g_aArgsDBGCRegisterCommands), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1097#endif
1098 { "DBGFR3DisasInstrEx", (void *)(uintptr_t)&DBGFR3DisasInstrEx, &g_aArgsDBGFR3DisasInstrEx[0], RT_ELEMENTS(g_aArgsDBGFR3DisasInstrEx), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1099 { "DBGFR3Info", (void *)(uintptr_t)&DBGFR3Info, &g_aArgsDBGFR3Info[0], RT_ELEMENTS(g_aArgsDBGFR3Info), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1100 { "DBGFR3InfoLogRelHlp", (void *)(uintptr_t)&DBGFR3InfoLogRelHlp, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1101 { "DBGFR3SymbolByAddr", (void *)(uintptr_t)&DBGFR3SymbolByAddr, &g_aArgsDBGFR3SymbolByAddr[0], RT_ELEMENTS(g_aArgsDBGFR3SymbolByAddr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1102 { "DISInstr", (void *)(uintptr_t)&DISInstr, &g_aArgsDISInstr[0], RT_ELEMENTS(g_aArgsDISInstr), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1103 { "EMR3FatalError", (void *)(uintptr_t)&EMR3FatalError, &g_aArgsEMR3FatalError[0], RT_ELEMENTS(g_aArgsEMR3FatalError), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1104 { "HWACCMR3CanExecuteGuest", (void *)(uintptr_t)&HWACCMR3CanExecuteGuest, &g_aArgsHWACCMR3CanExecuteGuest[0], RT_ELEMENTS(g_aArgsHWACCMR3CanExecuteGuest), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1105 { "IOMIOPortRead", (void *)(uintptr_t)&IOMIOPortRead, &g_aArgsIOMIOPortRead[0], RT_ELEMENTS(g_aArgsIOMIOPortRead), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1106 { "IOMIOPortWrite", (void *)(uintptr_t)&IOMIOPortWrite, &g_aArgsIOMIOPortWrite[0], RT_ELEMENTS(g_aArgsIOMIOPortWrite), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1107 { "IOMMMIORead", (void *)(uintptr_t)&IOMMMIORead, &g_aArgsIOMMMIORead[0], RT_ELEMENTS(g_aArgsIOMMMIORead), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1108 { "IOMMMIOWrite", (void *)(uintptr_t)&IOMMMIOWrite, &g_aArgsIOMMMIOWrite[0], RT_ELEMENTS(g_aArgsIOMMMIOWrite), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1109 { "MMR3HeapAlloc", (void *)(uintptr_t)&MMR3HeapAlloc, &g_aArgsMMR3HeapAlloc[0], RT_ELEMENTS(g_aArgsMMR3HeapAlloc), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1110 { "MMR3HeapAllocZ", (void *)(uintptr_t)&MMR3HeapAllocZ, &g_aArgsMMR3HeapAllocZ[0], RT_ELEMENTS(g_aArgsMMR3HeapAllocZ), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1111 { "MMR3PhysGetRamSize", (void *)(uintptr_t)&MMR3PhysGetRamSize, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1112 { "PATMIsPatchGCAddr", (void *)(uintptr_t)&PATMIsPatchGCAddr, &g_aArgsPATMIsPatchGCAddr[0], RT_ELEMENTS(g_aArgsPATMIsPatchGCAddr), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1113 { "PATMR3QueryOpcode", (void *)(uintptr_t)&PATMR3QueryOpcode, &g_aArgsPATMR3QueryOpcode[0], RT_ELEMENTS(g_aArgsPATMR3QueryOpcode), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1114 { "PATMR3QueryPatchMemGC", (void *)(uintptr_t)&PATMR3QueryPatchMemGC, &g_aArgsPATMR3QueryPatchMem[0], RT_ELEMENTS(g_aArgsPATMR3QueryPatchMem), REMFNDESC_FLAGS_RET_INT, sizeof(RTGCPTR), NULL },
1115 { "PATMR3QueryPatchMemHC", (void *)(uintptr_t)&PATMR3QueryPatchMemHC, &g_aArgsPATMR3QueryPatchMem[0], RT_ELEMENTS(g_aArgsPATMR3QueryPatchMem), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1116#ifdef VBOX_WITH_VMI
1117 { "PARAVIsBiosCall", (void *)(uintptr_t)&PARAVIsBiosCall, &g_aArgsPARAVIsBiosCall[0], RT_ELEMENTS(g_aArgsPARAVIsBiosCall), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1118#endif
1119 { "PDMApicGetBase", (void *)(uintptr_t)&PDMApicGetBase, &g_aArgsPDMApicGetBase[0], RT_ELEMENTS(g_aArgsPDMApicGetBase), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1120 { "PDMApicGetTPR", (void *)(uintptr_t)&PDMApicGetTPR, &g_aArgsPDMApicGetTPR[0], RT_ELEMENTS(g_aArgsPDMApicGetTPR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1121 { "PDMApicSetBase", (void *)(uintptr_t)&PDMApicSetBase, &g_aArgsPDMApicSetBase[0], RT_ELEMENTS(g_aArgsPDMApicSetBase), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1122 { "PDMApicSetTPR", (void *)(uintptr_t)&PDMApicSetTPR, &g_aArgsPDMApicSetTPR[0], RT_ELEMENTS(g_aArgsPDMApicSetTPR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1123 { "PDMApicWriteMSR", (void *)(uintptr_t)&PDMApicWriteMSR, &g_aArgsPDMApicWriteMSR[0], RT_ELEMENTS(g_aArgsPDMApicWriteMSR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1124 { "PDMApicReadMSR", (void *)(uintptr_t)&PDMApicReadMSR, &g_aArgsPDMApicReadMSR[0], RT_ELEMENTS(g_aArgsPDMApicReadMSR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1125 { "PDMR3DmaRun", (void *)(uintptr_t)&PDMR3DmaRun, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1126 { "PDMGetInterrupt", (void *)(uintptr_t)&PDMGetInterrupt, &g_aArgsPDMGetInterrupt[0], RT_ELEMENTS(g_aArgsPDMGetInterrupt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1127 { "PDMIsaSetIrq", (void *)(uintptr_t)&PDMIsaSetIrq, &g_aArgsPDMIsaSetIrq[0], RT_ELEMENTS(g_aArgsPDMIsaSetIrq), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1128 { "PGMGetGuestMode", (void *)(uintptr_t)&PGMGetGuestMode, &g_aArgsPGMGetGuestMode[0], RT_ELEMENTS(g_aArgsPGMGetGuestMode), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1129 { "PGMGstGetPage", (void *)(uintptr_t)&PGMGstGetPage, &g_aArgsPGMGstGetPage[0], RT_ELEMENTS(g_aArgsPGMGstGetPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1130 { "PGMInvalidatePage", (void *)(uintptr_t)&PGMInvalidatePage, &g_aArgsPGMInvalidatePage[0], RT_ELEMENTS(g_aArgsPGMInvalidatePage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1131 { "PGMPhysGCPhys2R3Ptr", (void *)(uintptr_t)&PGMPhysGCPhys2R3Ptr, &g_aArgsPGMPhysGCPhys2R3Ptr[0], RT_ELEMENTS(g_aArgsPGMPhysGCPhys2R3Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1132 { "PGMPhysGCPtr2R3PtrByGstCR3", (void *)(uintptr_t)&PGMPhysGCPtr2R3PtrByGstCR3, &g_aArgsPGMPhysGCPtr2R3PtrByGstCR3[0], RT_ELEMENTS(g_aArgsPGMPhysGCPtr2R3PtrByGstCR3), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1133#ifndef VBOX_WITH_NEW_PHYS_CODE
1134 { "PGM3PhysGrowRange", (void *)(uintptr_t)&PGM3PhysGrowRange, &g_aArgsPGM3PhysGrowRange[0], RT_ELEMENTS(g_aArgsPGM3PhysGrowRange), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1135#endif
1136 { "PGMPhysIsGCPhysValid", (void *)(uintptr_t)&PGMPhysIsGCPhysValid, &g_aArgsPGMPhysIsGCPhysValid[0], RT_ELEMENTS(g_aArgsPGMPhysIsGCPhysValid), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1137 { "PGMPhysIsA20Enabled", (void *)(uintptr_t)&PGMPhysIsA20Enabled, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1138 { "PGMPhysRead", (void *)(uintptr_t)&PGMPhysRead, &g_aArgsPGMPhysRead[0], RT_ELEMENTS(g_aArgsPGMPhysRead), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1139 { "PGMPhysSimpleReadGCPtr", (void *)(uintptr_t)&PGMPhysSimpleReadGCPtr, &g_aArgsPGMPhysSimpleReadGCPtr[0], RT_ELEMENTS(g_aArgsPGMPhysSimpleReadGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1140 { "PGMPhysWrite", (void *)(uintptr_t)&PGMPhysWrite, &g_aArgsPGMPhysWrite[0], RT_ELEMENTS(g_aArgsPGMPhysWrite), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1141 { "PGMChangeMode", (void *)(uintptr_t)&PGMChangeMode, &g_aArgsPGMChangeMode[0], RT_ELEMENTS(g_aArgsPGMChangeMode), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1142 { "PGMFlushTLB", (void *)(uintptr_t)&PGMFlushTLB, &g_aArgsPGMFlushTLB[0], RT_ELEMENTS(g_aArgsPGMFlushTLB), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1143 { "PGMR3PhysReadU8", (void *)(uintptr_t)&PGMR3PhysReadU8, &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint8_t), NULL },
1144 { "PGMR3PhysReadU16", (void *)(uintptr_t)&PGMR3PhysReadU16, &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint16_t), NULL },
1145 { "PGMR3PhysReadU32", (void *)(uintptr_t)&PGMR3PhysReadU32, &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1146 { "PGMR3PhysReadU64", (void *)(uintptr_t)&PGMR3PhysReadU64, &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1147 { "PGMR3PhysWriteU8", (void *)(uintptr_t)&PGMR3PhysWriteU8, &g_aArgsPGMR3PhysWriteU8[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU8), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1148 { "PGMR3PhysWriteU16", (void *)(uintptr_t)&PGMR3PhysWriteU16, &g_aArgsPGMR3PhysWriteU16[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU16), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1149 { "PGMR3PhysWriteU32", (void *)(uintptr_t)&PGMR3PhysWriteU32, &g_aArgsPGMR3PhysWriteU32[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1150 { "PGMR3PhysWriteU64", (void *)(uintptr_t)&PGMR3PhysWriteU64, &g_aArgsPGMR3PhysWriteU64[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1151 { "PGMR3DbgR3Ptr2GCPhys", (void *)(uintptr_t)&PGMR3DbgR3Ptr2GCPhys, &g_aArgsPGMR3DbgR3Ptr2GCPhys[0], RT_ELEMENTS(g_aArgsPGMR3DbgR3Ptr2GCPhys), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1152 { "PGMR3PhysGCPhys2Ptr", (void *)(uintptr_t)&PGMR3PhysTlbGCPhys2Ptr, &g_aArgsPGMR3PhysTlbGCPhys2Ptr[0], RT_ELEMENTS(g_aArgsPGMR3PhysTlbGCPhys2Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1153 { "SSMR3GetGCPtr", (void *)(uintptr_t)&SSMR3GetGCPtr, &g_aArgsSSMR3GetGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3GetGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1154 { "SSMR3GetMem", (void *)(uintptr_t)&SSMR3GetMem, &g_aArgsSSMR3GetMem[0], RT_ELEMENTS(g_aArgsSSMR3GetMem), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1155 { "SSMR3GetU32", (void *)(uintptr_t)&SSMR3GetU32, &g_aArgsSSMR3GetU32[0], RT_ELEMENTS(g_aArgsSSMR3GetU32), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1156 { "SSMR3GetUInt", (void *)(uintptr_t)&SSMR3GetUInt, &g_aArgsSSMR3GetUInt[0], RT_ELEMENTS(g_aArgsSSMR3GetUInt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1157 { "SSMR3PutGCPtr", (void *)(uintptr_t)&SSMR3PutGCPtr, &g_aArgsSSMR3PutGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3PutGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1158 { "SSMR3PutMem", (void *)(uintptr_t)&SSMR3PutMem, &g_aArgsSSMR3PutMem[0], RT_ELEMENTS(g_aArgsSSMR3PutMem), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1159 { "SSMR3PutU32", (void *)(uintptr_t)&SSMR3PutU32, &g_aArgsSSMR3PutU32[0], RT_ELEMENTS(g_aArgsSSMR3PutU32), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1160 { "SSMR3PutUInt", (void *)(uintptr_t)&SSMR3PutUInt, &g_aArgsSSMR3PutUInt[0], RT_ELEMENTS(g_aArgsSSMR3PutUInt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1161 { "SSMR3RegisterInternal", (void *)(uintptr_t)&SSMR3RegisterInternal, &g_aArgsSSMR3RegisterInternal[0], RT_ELEMENTS(g_aArgsSSMR3RegisterInternal), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1162 { "STAMR3Register", (void *)(uintptr_t)&STAMR3Register, &g_aArgsSTAMR3Register[0], RT_ELEMENTS(g_aArgsSTAMR3Register), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1163 { "TMCpuTickGet", (void *)(uintptr_t)&TMCpuTickGet, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1164 { "TMCpuTickPause", (void *)(uintptr_t)&TMCpuTickPause, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1165 { "TMCpuTickResume", (void *)(uintptr_t)&TMCpuTickResume, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1166 { "TMNotifyEndOfExecution", (void *)(uintptr_t)&TMNotifyEndOfExecution, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1167 { "TMNotifyStartOfExecution", (void *)(uintptr_t)&TMNotifyStartOfExecution, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1168 { "TMTimerPoll", (void *)(uintptr_t)&TMTimerPoll, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1169 { "TMR3TimerQueuesDo", (void *)(uintptr_t)&TMR3TimerQueuesDo, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1170 { "TMVirtualPause", (void *)(uintptr_t)&TMVirtualPause, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1171 { "TMVirtualResume", (void *)(uintptr_t)&TMVirtualResume, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1172 { "TRPMAssertTrap", (void *)(uintptr_t)&TRPMAssertTrap, &g_aArgsTRPMAssertTrap[0], RT_ELEMENTS(g_aArgsTRPMAssertTrap), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1173 { "TRPMGetErrorCode", (void *)(uintptr_t)&TRPMGetErrorCode, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(RTGCUINT), NULL },
1174 { "TRPMGetFaultAddress", (void *)(uintptr_t)&TRPMGetFaultAddress, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(RTGCUINTPTR),NULL },
1175 { "TRPMQueryTrap", (void *)(uintptr_t)&TRPMQueryTrap, &g_aArgsTRPMQueryTrap[0], RT_ELEMENTS(g_aArgsTRPMQueryTrap), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1176 { "TRPMResetTrap", (void *)(uintptr_t)&TRPMResetTrap, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1177 { "TRPMSetErrorCode", (void *)(uintptr_t)&TRPMSetErrorCode, &g_aArgsTRPMSetErrorCode[0], RT_ELEMENTS(g_aArgsTRPMSetErrorCode), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1178 { "TRPMSetFaultAddress", (void *)(uintptr_t)&TRPMSetFaultAddress, &g_aArgsTRPMSetFaultAddress[0], RT_ELEMENTS(g_aArgsTRPMSetFaultAddress), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1179 { "VMMR3Lock", (void *)(uintptr_t)&VMMR3Lock, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1180 { "VMMR3Unlock", (void *)(uintptr_t)&VMMR3Unlock, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1181 { "VMR3ReqCall", (void *)(uintptr_t)&VMR3ReqCall, &g_aArgsVMR3ReqCall[0], RT_ELEMENTS(g_aArgsVMR3ReqCall), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1182 { "VMR3ReqFree", (void *)(uintptr_t)&VMR3ReqFree, &g_aArgsVMR3ReqFree[0], RT_ELEMENTS(g_aArgsVMR3ReqFree), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(int), NULL },
1183 { "VMR3GetVMCPUId", (void *)(uintptr_t)&VMR3GetVMCPUId, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1184 { "VMR3GetVMCPUNativeThread", (void *)(uintptr_t)&VMR3GetVMCPUNativeThread, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1185// { "", (void *)(uintptr_t)&, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1186};
1187
1188
1189/**
1190 * Descriptors for the functions imported from VBoxRT.
1191 */
1192static REMFNDESC g_aRTImports[] =
1193{
1194 { "AssertMsg1", (void *)(uintptr_t)&AssertMsg1, &g_aArgsAssertMsg1[0], RT_ELEMENTS(g_aArgsAssertMsg1), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1195 { "AssertMsg2", (void *)(uintptr_t)&AssertMsg2, &g_aArgsAssertMsg2[0], RT_ELEMENTS(g_aArgsAssertMsg2), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_ELLIPSIS, 0, NULL },
1196 { "RTAssertShouldPanic", (void *)(uintptr_t)&RTAssertShouldPanic, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1197 { "RTLogDefaultInstance", (void *)(uintptr_t)&RTLogDefaultInstance, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(PRTLOGGER), NULL },
1198 { "RTLogRelDefaultInstance", (void *)(uintptr_t)&RTLogRelDefaultInstance, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(PRTLOGGER), NULL },
1199 { "RTLogFlags", (void *)(uintptr_t)&RTLogFlags, &g_aArgsRTLogFlags[0], RT_ELEMENTS(g_aArgsRTLogFlags), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1200 { "RTLogFlush", (void *)(uintptr_t)&RTLogFlush, &g_aArgsRTLogFlush[0], RT_ELEMENTS(g_aArgsRTLogFlush), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1201 { "RTLogLoggerEx", (void *)(uintptr_t)&RTLogLoggerEx, &g_aArgsRTLogLoggerEx[0], RT_ELEMENTS(g_aArgsRTLogLoggerEx), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_ELLIPSIS, 0, NULL },
1202 { "RTLogLoggerExV", (void *)(uintptr_t)&RTLogLoggerExV, &g_aArgsRTLogLoggerExV[0], RT_ELEMENTS(g_aArgsRTLogLoggerExV), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_VALIST, 0, NULL },
1203 { "RTLogPrintf", (void *)(uintptr_t)&RTLogPrintf, &g_aArgsRTLogPrintf[0], RT_ELEMENTS(g_aArgsRTLogPrintf), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1204 { "RTMemAlloc", (void *)(uintptr_t)&RTMemAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1205 { "RTMemAllocZ", (void *)(uintptr_t)&RTMemAllocZ, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1206 { "RTMemRealloc", (void *)(uintptr_t)&RTMemRealloc, &g_aArgsRTMemRealloc[0], RT_ELEMENTS(g_aArgsRTMemRealloc), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1207 { "RTMemExecAlloc", (void *)(uintptr_t)&RTMemExecAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1208
1209 { "RTMemExecFree", (void *)(uintptr_t)&RTMemExecFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1210 { "RTMemFree", (void *)(uintptr_t)&RTMemFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1211 { "RTMemPageAlloc", (void *)(uintptr_t)&RTMemPageAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1212 { "RTMemPageFree", (void *)(uintptr_t)&RTMemPageFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1213 { "RTMemProtect", (void *)(uintptr_t)&RTMemProtect, &g_aArgsRTMemProtect[0], RT_ELEMENTS(g_aArgsRTMemProtect), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1214 { "RTStrPrintf", (void *)(uintptr_t)&RTStrPrintf, &g_aArgsRTStrPrintf[0], RT_ELEMENTS(g_aArgsRTStrPrintf), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(size_t), NULL },
1215 { "RTStrPrintfV", (void *)(uintptr_t)&RTStrPrintfV, &g_aArgsRTStrPrintfV[0], RT_ELEMENTS(g_aArgsRTStrPrintfV), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_VALIST, sizeof(size_t), NULL },
1216 { "RTThreadSelf", (void *)(uintptr_t)&RTThreadSelf, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(RTTHREAD), NULL },
1217 { "RTThreadNativeSelf", (void *)(uintptr_t)&RTThreadNativeSelf, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(RTNATIVETHREAD), NULL },
1218 { "RTThreadGetWriteLockCount", (void *)(uintptr_t)&RTThreadGetWriteLockCount, &g_aArgsThread[0], 0, REMFNDESC_FLAGS_RET_INT, sizeof(int32_t), NULL },
1219};
1220
1221
1222/**
1223 * Descriptors for the functions imported from VBoxRT.
1224 */
1225static REMFNDESC g_aCRTImports[] =
1226{
1227 { "memcpy", (void *)(uintptr_t)&memcpy, &g_aArgsmemcpy[0], RT_ELEMENTS(g_aArgsmemcpy), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1228 { "memset", (void *)(uintptr_t)&memset, &g_aArgsmemset[0], RT_ELEMENTS(g_aArgsmemset), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }
1229/*
1230floor floor
1231memcpy memcpy
1232sqrt sqrt
1233sqrtf sqrtf
1234*/
1235};
1236
1237
1238# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1239/** LIFO of read-write-executable memory chunks used for wrappers. */
1240static PREMEXECMEM g_pExecMemHead;
1241# endif
1242
1243
1244/*******************************************************************************
1245* Internal Functions *
1246*******************************************************************************/
1247static int remGenerateExportGlue(PRTUINTPTR pValue, PCREMFNDESC pDesc);
1248
1249# ifdef USE_REM_CALLING_CONVENTION_GLUE
1250DECLASM(int) WrapGCC2MSC0Int(void); DECLASM(int) WrapGCC2MSC0Int_EndProc(void);
1251DECLASM(int) WrapGCC2MSC1Int(void); DECLASM(int) WrapGCC2MSC1Int_EndProc(void);
1252DECLASM(int) WrapGCC2MSC2Int(void); DECLASM(int) WrapGCC2MSC2Int_EndProc(void);
1253DECLASM(int) WrapGCC2MSC3Int(void); DECLASM(int) WrapGCC2MSC3Int_EndProc(void);
1254DECLASM(int) WrapGCC2MSC4Int(void); DECLASM(int) WrapGCC2MSC4Int_EndProc(void);
1255DECLASM(int) WrapGCC2MSC5Int(void); DECLASM(int) WrapGCC2MSC5Int_EndProc(void);
1256DECLASM(int) WrapGCC2MSC6Int(void); DECLASM(int) WrapGCC2MSC6Int_EndProc(void);
1257DECLASM(int) WrapGCC2MSC7Int(void); DECLASM(int) WrapGCC2MSC7Int_EndProc(void);
1258DECLASM(int) WrapGCC2MSC8Int(void); DECLASM(int) WrapGCC2MSC8Int_EndProc(void);
1259DECLASM(int) WrapGCC2MSC9Int(void); DECLASM(int) WrapGCC2MSC9Int_EndProc(void);
1260DECLASM(int) WrapGCC2MSC10Int(void); DECLASM(int) WrapGCC2MSC10Int_EndProc(void);
1261DECLASM(int) WrapGCC2MSC11Int(void); DECLASM(int) WrapGCC2MSC11Int_EndProc(void);
1262DECLASM(int) WrapGCC2MSC12Int(void); DECLASM(int) WrapGCC2MSC12Int_EndProc(void);
1263DECLASM(int) WrapGCC2MSCVariadictInt(void); DECLASM(int) WrapGCC2MSCVariadictInt_EndProc(void);
1264DECLASM(int) WrapGCC2MSC_SSMR3RegisterInternal(void); DECLASM(int) WrapGCC2MSC_SSMR3RegisterInternal_EndProc(void);
1265
1266DECLASM(int) WrapMSC2GCC0Int(void); DECLASM(int) WrapMSC2GCC0Int_EndProc(void);
1267DECLASM(int) WrapMSC2GCC1Int(void); DECLASM(int) WrapMSC2GCC1Int_EndProc(void);
1268DECLASM(int) WrapMSC2GCC2Int(void); DECLASM(int) WrapMSC2GCC2Int_EndProc(void);
1269DECLASM(int) WrapMSC2GCC3Int(void); DECLASM(int) WrapMSC2GCC3Int_EndProc(void);
1270DECLASM(int) WrapMSC2GCC4Int(void); DECLASM(int) WrapMSC2GCC4Int_EndProc(void);
1271DECLASM(int) WrapMSC2GCC5Int(void); DECLASM(int) WrapMSC2GCC5Int_EndProc(void);
1272DECLASM(int) WrapMSC2GCC6Int(void); DECLASM(int) WrapMSC2GCC6Int_EndProc(void);
1273DECLASM(int) WrapMSC2GCC7Int(void); DECLASM(int) WrapMSC2GCC7Int_EndProc(void);
1274DECLASM(int) WrapMSC2GCC8Int(void); DECLASM(int) WrapMSC2GCC8Int_EndProc(void);
1275DECLASM(int) WrapMSC2GCC9Int(void); DECLASM(int) WrapMSC2GCC9Int_EndProc(void);
1276# endif
1277
1278
1279# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1280/**
1281 * Allocates a block of memory for glue code.
1282 *
1283 * The returned memory is padded with INT3s.
1284 *
1285 * @returns Pointer to the allocated memory.
1286 * @param The amount of memory to allocate.
1287 */
1288static void *remAllocGlue(size_t cb)
1289{
1290 PREMEXECMEM pCur = g_pExecMemHead;
1291 uint32_t cbAligned = (uint32_t)RT_ALIGN_32(cb, 32);
1292 while (pCur)
1293 {
1294 if (pCur->cb - pCur->off >= cbAligned)
1295 {
1296 void *pv = (uint8_t *)pCur + pCur->off;
1297 pCur->off += cbAligned;
1298 return memset(pv, 0xcc, cbAligned);
1299 }
1300 pCur = pCur->pNext;
1301 }
1302
1303 /* add a new chunk */
1304 AssertReturn(_64K - RT_ALIGN_Z(sizeof(*pCur), 32) > cbAligned, NULL);
1305 pCur = (PREMEXECMEM)RTMemExecAlloc(_64K);
1306 AssertReturn(pCur, NULL);
1307 pCur->cb = _64K;
1308 pCur->off = RT_ALIGN_32(sizeof(*pCur), 32) + cbAligned;
1309 pCur->pNext = g_pExecMemHead;
1310 g_pExecMemHead = pCur;
1311 return memset((uint8_t *)pCur + RT_ALIGN_Z(sizeof(*pCur), 32), 0xcc, cbAligned);
1312}
1313# endif /* USE_REM_CALLING_CONVENTION_GLUE || USE_REM_IMPORT_JUMP_GLUE */
1314
1315
1316# ifdef USE_REM_CALLING_CONVENTION_GLUE
1317/**
1318 * Checks if a function is all straight forward integers.
1319 *
1320 * @returns True if it's simple, false if it's bothersome.
1321 * @param pDesc The function descriptor.
1322 */
1323static bool remIsFunctionAllInts(PCREMFNDESC pDesc)
1324{
1325 if ( ( (pDesc->fFlags & REMFNDESC_FLAGS_RET_TYPE_MASK) != REMFNDESC_FLAGS_RET_INT
1326 || pDesc->cbReturn > sizeof(uint64_t))
1327 && (pDesc->fFlags & REMFNDESC_FLAGS_RET_TYPE_MASK) != REMFNDESC_FLAGS_RET_VOID)
1328 return false;
1329 unsigned i = pDesc->cParams;
1330 while (i-- > 0)
1331 switch (pDesc->paParams[i].fFlags & REMPARMDESC_FLAGS_TYPE_MASK)
1332 {
1333 case REMPARMDESC_FLAGS_INT:
1334 case REMPARMDESC_FLAGS_GCPTR:
1335 case REMPARMDESC_FLAGS_GCPHYS:
1336 case REMPARMDESC_FLAGS_HCPHYS:
1337 break;
1338
1339 default:
1340 AssertReleaseMsgFailed(("Invalid param flags %#x for #%d of %s!\n", pDesc->paParams[i].fFlags, i, pDesc->pszName));
1341 case REMPARMDESC_FLAGS_VALIST:
1342 case REMPARMDESC_FLAGS_ELLIPSIS:
1343 case REMPARMDESC_FLAGS_FLOAT:
1344 case REMPARMDESC_FLAGS_STRUCT:
1345 case REMPARMDESC_FLAGS_PFN:
1346 return false;
1347 }
1348 return true;
1349}
1350
1351
1352/**
1353 * Checks if the function has an ellipsis (...) argument.
1354 *
1355 * @returns true if it has an ellipsis, otherwise false.
1356 * @param pDesc The function descriptor.
1357 */
1358static bool remHasFunctionEllipsis(PCREMFNDESC pDesc)
1359{
1360 unsigned i = pDesc->cParams;
1361 while (i-- > 0)
1362 if ((pDesc->paParams[i].fFlags & REMPARMDESC_FLAGS_TYPE_MASK) == REMPARMDESC_FLAGS_ELLIPSIS)
1363 return true;
1364 return false;
1365}
1366
1367
1368/**
1369 * Checks if the function uses floating point (FP) arguments or return value.
1370 *
1371 * @returns true if it uses floating point, otherwise false.
1372 * @param pDesc The function descriptor.
1373 */
1374static bool remIsFunctionUsingFP(PCREMFNDESC pDesc)
1375{
1376 if ((pDesc->fFlags & REMFNDESC_FLAGS_RET_TYPE_MASK) == REMFNDESC_FLAGS_RET_FLOAT)
1377 return true;
1378 unsigned i = pDesc->cParams;
1379 while (i-- > 0)
1380 if ((pDesc->paParams[i].fFlags & REMPARMDESC_FLAGS_TYPE_MASK) == REMPARMDESC_FLAGS_FLOAT)
1381 return true;
1382 return false;
1383}
1384
1385
1386/** @name The export and import fixups.
1387 * @{ */
1388#define REM_FIXUP_32_REAL_STUFF UINT32_C(0xdeadbeef)
1389#define REM_FIXUP_64_REAL_STUFF UINT64_C(0xdeadf00df00ddead)
1390#define REM_FIXUP_64_DESC UINT64_C(0xdead00010001dead)
1391#define REM_FIXUP_64_LOG_ENTRY UINT64_C(0xdead00020002dead)
1392#define REM_FIXUP_64_LOG_EXIT UINT64_C(0xdead00030003dead)
1393#define REM_FIXUP_64_WRAP_GCC_CB UINT64_C(0xdead00040004dead)
1394/** @} */
1395
1396
1397/**
1398 * Entry logger function.
1399 *
1400 * @param pDesc The description.
1401 */
1402DECLASM(void) remLogEntry(PCREMFNDESC pDesc)
1403{
1404 RTPrintf("calling %s\n", pDesc->pszName);
1405}
1406
1407
1408/**
1409 * Exit logger function.
1410 *
1411 * @param pDesc The description.
1412 * @param pvRet The return code.
1413 */
1414DECLASM(void) remLogExit(PCREMFNDESC pDesc, void *pvRet)
1415{
1416 RTPrintf("returning %p from %s\n", pvRet, pDesc->pszName);
1417}
1418
1419
1420/**
1421 * Creates a wrapper for the specified callback function at run time.
1422 *
1423 * @param pDesc The function descriptor.
1424 * @param pValue Upon entry *pValue contains the address of the function to be wrapped.
1425 * Upon return *pValue contains the address of the wrapper glue function.
1426 * @param iParam The parameter index in the function descriptor (0 based).
1427 * If UINT32_MAX pDesc is the descriptor for *pValue.
1428 */
1429DECLASM(void) remWrapGCCCallback(PCREMFNDESC pDesc, PRTUINTPTR pValue, uint32_t iParam)
1430{
1431 AssertPtr(pDesc);
1432 AssertPtr(pValue);
1433
1434 /*
1435 * Simple?
1436 */
1437 if (!*pValue)
1438 return;
1439
1440 /*
1441 * Locate the right function descriptor.
1442 */
1443 if (iParam != UINT32_MAX)
1444 {
1445 AssertRelease(iParam < pDesc->cParams);
1446 pDesc = (PCREMFNDESC)pDesc->paParams[iParam].pvExtra;
1447 AssertPtr(pDesc);
1448 }
1449
1450 /*
1451 * When we get serious, here is where to insert the hash table lookup.
1452 */
1453
1454 /*
1455 * Create a new glue patch.
1456 */
1457#ifdef RT_OS_WINDOWS
1458 int rc = remGenerateExportGlue(pValue, pDesc);
1459#else
1460#error "port me"
1461#endif
1462 AssertReleaseRC(rc);
1463
1464 /*
1465 * Add it to the hash (later)
1466 */
1467}
1468
1469
1470/**
1471 * Fixes export glue.
1472 *
1473 * @param pvGlue The glue code.
1474 * @param cb The size of the glue code.
1475 * @param pvExport The address of the export we're wrapping.
1476 * @param pDesc The export descriptor.
1477 */
1478static void remGenerateExportGlueFixup(void *pvGlue, size_t cb, uintptr_t uExport, PCREMFNDESC pDesc)
1479{
1480 union
1481 {
1482 uint8_t *pu8;
1483 int32_t *pi32;
1484 uint32_t *pu32;
1485 uint64_t *pu64;
1486 void *pv;
1487 } u;
1488 u.pv = pvGlue;
1489
1490 while (cb >= 4)
1491 {
1492 /** @todo add defines for the fixup constants... */
1493 if (*u.pu32 == REM_FIXUP_32_REAL_STUFF)
1494 {
1495 /* 32-bit rel jmp/call to real export. */
1496 *u.pi32 = uExport - (uintptr_t)(u.pi32 + 1);
1497 Assert((uintptr_t)(u.pi32 + 1) + *u.pi32 == uExport);
1498 u.pi32++;
1499 cb -= 4;
1500 continue;
1501 }
1502 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_REAL_STUFF)
1503 {
1504 /* 64-bit address to the real export. */
1505 *u.pu64++ = uExport;
1506 cb -= 8;
1507 continue;
1508 }
1509 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_DESC)
1510 {
1511 /* 64-bit address to the descriptor. */
1512 *u.pu64++ = (uintptr_t)pDesc;
1513 cb -= 8;
1514 continue;
1515 }
1516 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_WRAP_GCC_CB)
1517 {
1518 /* 64-bit address to the entry logger function. */
1519 *u.pu64++ = (uintptr_t)remWrapGCCCallback;
1520 cb -= 8;
1521 continue;
1522 }
1523 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_ENTRY)
1524 {
1525 /* 64-bit address to the entry logger function. */
1526 *u.pu64++ = (uintptr_t)remLogEntry;
1527 cb -= 8;
1528 continue;
1529 }
1530 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_EXIT)
1531 {
1532 /* 64-bit address to the entry logger function. */
1533 *u.pu64++ = (uintptr_t)remLogExit;
1534 cb -= 8;
1535 continue;
1536 }
1537
1538 /* move on. */
1539 u.pu8++;
1540 cb--;
1541 }
1542}
1543
1544
1545/**
1546 * Fixes import glue.
1547 *
1548 * @param pvGlue The glue code.
1549 * @param cb The size of the glue code.
1550 * @param pDesc The import descriptor.
1551 */
1552static void remGenerateImportGlueFixup(void *pvGlue, size_t cb, PCREMFNDESC pDesc)
1553{
1554 union
1555 {
1556 uint8_t *pu8;
1557 int32_t *pi32;
1558 uint32_t *pu32;
1559 uint64_t *pu64;
1560 void *pv;
1561 } u;
1562 u.pv = pvGlue;
1563
1564 while (cb >= 4)
1565 {
1566 if (*u.pu32 == REM_FIXUP_32_REAL_STUFF)
1567 {
1568 /* 32-bit rel jmp/call to real function. */
1569 *u.pi32 = (uintptr_t)pDesc->pv - (uintptr_t)(u.pi32 + 1);
1570 Assert((uintptr_t)(u.pi32 + 1) + *u.pi32 == (uintptr_t)pDesc->pv);
1571 u.pi32++;
1572 cb -= 4;
1573 continue;
1574 }
1575 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_REAL_STUFF)
1576 {
1577 /* 64-bit address to the real function. */
1578 *u.pu64++ = (uintptr_t)pDesc->pv;
1579 cb -= 8;
1580 continue;
1581 }
1582 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_DESC)
1583 {
1584 /* 64-bit address to the descriptor. */
1585 *u.pu64++ = (uintptr_t)pDesc;
1586 cb -= 8;
1587 continue;
1588 }
1589 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_WRAP_GCC_CB)
1590 {
1591 /* 64-bit address to the entry logger function. */
1592 *u.pu64++ = (uintptr_t)remWrapGCCCallback;
1593 cb -= 8;
1594 continue;
1595 }
1596 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_ENTRY)
1597 {
1598 /* 64-bit address to the entry logger function. */
1599 *u.pu64++ = (uintptr_t)remLogEntry;
1600 cb -= 8;
1601 continue;
1602 }
1603 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_EXIT)
1604 {
1605 /* 64-bit address to the entry logger function. */
1606 *u.pu64++ = (uintptr_t)remLogExit;
1607 cb -= 8;
1608 continue;
1609 }
1610
1611 /* move on. */
1612 u.pu8++;
1613 cb--;
1614 }
1615}
1616
1617# endif /* USE_REM_CALLING_CONVENTION_GLUE */
1618
1619
1620/**
1621 * Generate wrapper glue code for an export.
1622 *
1623 * This is only used on win64 when loading a 64-bit linux module. So, on other
1624 * platforms it will not do anything.
1625 *
1626 * @returns VBox status code.
1627 * @param pValue IN: Where to get the address of the function to wrap.
1628 * OUT: Where to store the glue address.
1629 * @param pDesc The export descriptor.
1630 */
1631static int remGenerateExportGlue(PRTUINTPTR pValue, PCREMFNDESC pDesc)
1632{
1633# ifdef USE_REM_CALLING_CONVENTION_GLUE
1634 uintptr_t *ppfn = (uintptr_t *)pDesc->pv;
1635
1636 uintptr_t pfn = 0; /* a little hack for the callback glue */
1637 if (!ppfn)
1638 ppfn = &pfn;
1639
1640 if (!*ppfn)
1641 {
1642 if (remIsFunctionAllInts(pDesc))
1643 {
1644 static const struct { void *pvStart, *pvEnd; } s_aTemplates[] =
1645 {
1646 { (void *)&WrapMSC2GCC0Int, (void *)&WrapMSC2GCC0Int_EndProc },
1647 { (void *)&WrapMSC2GCC1Int, (void *)&WrapMSC2GCC1Int_EndProc },
1648 { (void *)&WrapMSC2GCC2Int, (void *)&WrapMSC2GCC2Int_EndProc },
1649 { (void *)&WrapMSC2GCC3Int, (void *)&WrapMSC2GCC3Int_EndProc },
1650 { (void *)&WrapMSC2GCC4Int, (void *)&WrapMSC2GCC4Int_EndProc },
1651 { (void *)&WrapMSC2GCC5Int, (void *)&WrapMSC2GCC5Int_EndProc },
1652 { (void *)&WrapMSC2GCC6Int, (void *)&WrapMSC2GCC6Int_EndProc },
1653 { (void *)&WrapMSC2GCC7Int, (void *)&WrapMSC2GCC7Int_EndProc },
1654 { (void *)&WrapMSC2GCC8Int, (void *)&WrapMSC2GCC8Int_EndProc },
1655 { (void *)&WrapMSC2GCC9Int, (void *)&WrapMSC2GCC9Int_EndProc },
1656 };
1657 const unsigned i = pDesc->cParams;
1658 AssertReleaseMsg(i < RT_ELEMENTS(s_aTemplates), ("%d (%s)\n", i, pDesc->pszName));
1659
1660 /* duplicate the patch. */
1661 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1662 uint8_t *pb = (uint8_t *)remAllocGlue(cb);
1663 AssertReturn(pb, VERR_NO_MEMORY);
1664 memcpy(pb, s_aTemplates[i].pvStart, cb);
1665
1666 /* fix it up. */
1667 remGenerateExportGlueFixup(pb, cb, *pValue, pDesc);
1668 *ppfn = (uintptr_t)pb;
1669 }
1670 else
1671 {
1672 /* custom hacks - it's simpler to make assembly templates than writing a more generic code generator... */
1673 static const struct { const char *pszName; PFNRT pvStart, pvEnd; } s_aTemplates[] =
1674 {
1675 { "somefunction", (PFNRT)&WrapMSC2GCC9Int, (PFNRT)&WrapMSC2GCC9Int_EndProc },
1676 };
1677 unsigned i;
1678 for (i = 0; i < RT_ELEMENTS(s_aTemplates); i++)
1679 if (!strcmp(pDesc->pszName, s_aTemplates[i].pszName))
1680 break;
1681 AssertReleaseMsgReturn(i < RT_ELEMENTS(s_aTemplates), ("Not implemented! %s\n", pDesc->pszName), VERR_NOT_IMPLEMENTED);
1682
1683 /* duplicate the patch. */
1684 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1685 uint8_t *pb = (uint8_t *)remAllocGlue(cb);
1686 AssertReturn(pb, VERR_NO_MEMORY);
1687 memcpy(pb, s_aTemplates[i].pvStart, cb);
1688
1689 /* fix it up. */
1690 remGenerateExportGlueFixup(pb, cb, *pValue, pDesc);
1691 *ppfn = (uintptr_t)pb;
1692 }
1693 }
1694 *pValue = *ppfn;
1695 return VINF_SUCCESS;
1696# else /* !USE_REM_CALLING_CONVENTION_GLUE */
1697 return VINF_SUCCESS;
1698# endif /* !USE_REM_CALLING_CONVENTION_GLUE */
1699}
1700
1701
1702/**
1703 * Generate wrapper glue code for an import.
1704 *
1705 * This is only used on win64 when loading a 64-bit linux module. So, on other
1706 * platforms it will simply return the address of the imported function
1707 * without generating any glue code.
1708 *
1709 * @returns VBox status code.
1710 * @param pValue Where to store the glue address.
1711 * @param pDesc The export descriptor.
1712 */
1713static int remGenerateImportGlue(PRTUINTPTR pValue, PREMFNDESC pDesc)
1714{
1715# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1716 if (!pDesc->pvWrapper)
1717 {
1718# ifdef USE_REM_CALLING_CONVENTION_GLUE
1719 if (remIsFunctionAllInts(pDesc))
1720 {
1721 static const struct { void *pvStart, *pvEnd; } s_aTemplates[] =
1722 {
1723 { (void *)&WrapGCC2MSC0Int, (void *)&WrapGCC2MSC0Int_EndProc },
1724 { (void *)&WrapGCC2MSC1Int, (void *)&WrapGCC2MSC1Int_EndProc },
1725 { (void *)&WrapGCC2MSC2Int, (void *)&WrapGCC2MSC2Int_EndProc },
1726 { (void *)&WrapGCC2MSC3Int, (void *)&WrapGCC2MSC3Int_EndProc },
1727 { (void *)&WrapGCC2MSC4Int, (void *)&WrapGCC2MSC4Int_EndProc },
1728 { (void *)&WrapGCC2MSC5Int, (void *)&WrapGCC2MSC5Int_EndProc },
1729 { (void *)&WrapGCC2MSC6Int, (void *)&WrapGCC2MSC6Int_EndProc },
1730 { (void *)&WrapGCC2MSC7Int, (void *)&WrapGCC2MSC7Int_EndProc },
1731 { (void *)&WrapGCC2MSC8Int, (void *)&WrapGCC2MSC8Int_EndProc },
1732 { (void *)&WrapGCC2MSC9Int, (void *)&WrapGCC2MSC9Int_EndProc },
1733 { (void *)&WrapGCC2MSC10Int, (void *)&WrapGCC2MSC10Int_EndProc },
1734 { (void *)&WrapGCC2MSC11Int, (void *)&WrapGCC2MSC11Int_EndProc },
1735 { (void *)&WrapGCC2MSC12Int, (void *)&WrapGCC2MSC12Int_EndProc }
1736 };
1737 const unsigned i = pDesc->cParams;
1738 AssertReleaseMsg(i < RT_ELEMENTS(s_aTemplates), ("%d (%s)\n", i, pDesc->pszName));
1739
1740 /* duplicate the patch. */
1741 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1742 pDesc->pvWrapper = remAllocGlue(cb);
1743 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1744 memcpy(pDesc->pvWrapper, s_aTemplates[i].pvStart, cb);
1745
1746 /* fix it up. */
1747 remGenerateImportGlueFixup((uint8_t *)pDesc->pvWrapper, cb, pDesc);
1748 }
1749 else if ( remHasFunctionEllipsis(pDesc)
1750 && !remIsFunctionUsingFP(pDesc))
1751 {
1752 /* duplicate the patch. */
1753 const size_t cb = (uintptr_t)&WrapGCC2MSCVariadictInt_EndProc - (uintptr_t)&WrapGCC2MSCVariadictInt;
1754 pDesc->pvWrapper = remAllocGlue(cb);
1755 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1756 memcpy(pDesc->pvWrapper, (void *)&WrapGCC2MSCVariadictInt, cb);
1757
1758 /* fix it up. */
1759 remGenerateImportGlueFixup((uint8_t *)pDesc->pvWrapper, cb, pDesc);
1760 }
1761 else
1762 {
1763 /* custom hacks - it's simpler to make assembly templates than writing a more generic code generator... */
1764 static const struct { const char *pszName; PFNRT pvStart, pvEnd; } s_aTemplates[] =
1765 {
1766 { "SSMR3RegisterInternal", (PFNRT)&WrapGCC2MSC_SSMR3RegisterInternal, (PFNRT)&WrapGCC2MSC_SSMR3RegisterInternal_EndProc },
1767 };
1768 unsigned i;
1769 for (i = 0; i < RT_ELEMENTS(s_aTemplates); i++)
1770 if (!strcmp(pDesc->pszName, s_aTemplates[i].pszName))
1771 break;
1772 AssertReleaseMsgReturn(i < RT_ELEMENTS(s_aTemplates), ("Not implemented! %s\n", pDesc->pszName), VERR_NOT_IMPLEMENTED);
1773
1774 /* duplicate the patch. */
1775 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1776 pDesc->pvWrapper = remAllocGlue(cb);
1777 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1778 memcpy(pDesc->pvWrapper, s_aTemplates[i].pvStart, cb);
1779
1780 /* fix it up. */
1781 remGenerateImportGlueFixup((uint8_t *)pDesc->pvWrapper, cb, pDesc);
1782 }
1783# else /* !USE_REM_CALLING_CONVENTION_GLUE */
1784
1785 /*
1786 * Generate a jump patch.
1787 */
1788 uint8_t *pb;
1789# ifdef RT_ARCH_AMD64
1790 pDesc->pvWrapper = pb = (uint8_t *)remAllocGlue(32);
1791 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1792 /**pb++ = 0xcc;*/
1793 *pb++ = 0xff;
1794 *pb++ = 0x24;
1795 *pb++ = 0x25;
1796 *(uint32_t *)pb = (uintptr_t)pb + 5;
1797 pb += 5;
1798 *(uint64_t *)pb = (uint64_t)pDesc->pv;
1799# else
1800 pDesc->pvWrapper = pb = (uint8_t *)remAllocGlue(8);
1801 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1802 *pb++ = 0xea;
1803 *(uint32_t *)pb = (uint32_t)pDesc->pv;
1804# endif
1805# endif /* !USE_REM_CALLING_CONVENTION_GLUE */
1806 }
1807 *pValue = (uintptr_t)pDesc->pvWrapper;
1808# else /* !USE_REM_CALLING_CONVENTION_GLUE */
1809 *pValue = (uintptr_t)pDesc->pv;
1810# endif /* !USE_REM_CALLING_CONVENTION_GLUE */
1811 return VINF_SUCCESS;
1812}
1813
1814
1815/**
1816 * Resolve an external symbol during RTLdrGetBits().
1817 *
1818 * @returns iprt status code.
1819 * @param hLdrMod The loader module handle.
1820 * @param pszModule Module name.
1821 * @param pszSymbol Symbol name, NULL if uSymbol should be used.
1822 * @param uSymbol Symbol ordinal, ~0 if pszSymbol should be used.
1823 * @param pValue Where to store the symbol value (address).
1824 * @param pvUser User argument.
1825 */
1826static DECLCALLBACK(int) remGetImport(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol, RTUINTPTR *pValue, void *pvUser)
1827{
1828 unsigned i;
1829 for (i = 0; i < RT_ELEMENTS(g_aVMMImports); i++)
1830 if (!strcmp(g_aVMMImports[i].pszName, pszSymbol))
1831 return remGenerateImportGlue(pValue, &g_aVMMImports[i]);
1832 for (i = 0; i < RT_ELEMENTS(g_aRTImports); i++)
1833 if (!strcmp(g_aRTImports[i].pszName, pszSymbol))
1834 return remGenerateImportGlue(pValue, &g_aRTImports[i]);
1835 for (i = 0; i < RT_ELEMENTS(g_aCRTImports); i++)
1836 if (!strcmp(g_aCRTImports[i].pszName, pszSymbol))
1837 return remGenerateImportGlue(pValue, &g_aCRTImports[i]);
1838 LogRel(("Missing REM Import: %s\n", pszSymbol));
1839#if 1
1840 *pValue = 0;
1841 AssertMsgFailed(("%s.%s\n", pszModule, pszSymbol));
1842 return VERR_SYMBOL_NOT_FOUND;
1843#else
1844 return remGenerateImportGlue(pValue, &g_aCRTImports[0]);
1845#endif
1846}
1847
1848/**
1849 * Loads the linux object, resolves all imports and exports.
1850 *
1851 * @returns VBox status code.
1852 */
1853static int remLoadLinuxObj(void)
1854{
1855 size_t offFilename;
1856 char szPath[RTPATH_MAX];
1857 int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 32);
1858 AssertRCReturn(rc, rc);
1859 offFilename = strlen(szPath);
1860
1861 /*
1862 * Load the VBoxREM2.rel object/DLL.
1863 */
1864 strcpy(&szPath[offFilename], "/VBoxREM2.rel");
1865 rc = RTLdrOpen(szPath, &g_ModREM2);
1866 if (RT_SUCCESS(rc))
1867 {
1868 g_pvREM2 = RTMemExecAlloc(RTLdrSize(g_ModREM2));
1869 if (g_pvREM2)
1870 {
1871#ifdef DEBUG /* How to load the VBoxREM2.rel symbols into the GNU debugger. */
1872 RTPrintf("VBoxREMWrapper: (gdb) add-symbol-file %s 0x%p\n", szPath, g_pvREM2);
1873#endif
1874 LogRel(("REM: Loading %s at 0x%p (%d bytes)\n"
1875 "REM: (gdb) add-symbol-file %s 0x%p\n",
1876 szPath, g_pvREM2, RTLdrSize(g_ModREM2), szPath, g_pvREM2));
1877 rc = RTLdrGetBits(g_ModREM2, g_pvREM2, (RTUINTPTR)g_pvREM2, remGetImport, NULL);
1878 if (RT_SUCCESS(rc))
1879 {
1880 /*
1881 * Resolve exports.
1882 */
1883 unsigned i;
1884 for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
1885 {
1886 RTUINTPTR Value;
1887 rc = RTLdrGetSymbolEx(g_ModREM2, g_pvREM2, (RTUINTPTR)g_pvREM2, g_aExports[i].pszName, &Value);
1888 AssertMsgRC(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
1889 if (RT_FAILURE(rc))
1890 break;
1891 rc = remGenerateExportGlue(&Value, &g_aExports[i]);
1892 if (RT_FAILURE(rc))
1893 break;
1894 *(void **)g_aExports[i].pv = (void *)(uintptr_t)Value;
1895 }
1896 return rc;
1897 }
1898 RTMemExecFree(g_pvREM2);
1899 }
1900 RTLdrClose(g_ModREM2);
1901 g_ModREM2 = NIL_RTLDRMOD;
1902 }
1903 LogRel(("REM: failed loading '%s', rc=%Rrc\n", szPath, rc));
1904 return rc;
1905}
1906
1907
1908/**
1909 * Unloads the linux object, freeing up all resources (dlls and
1910 * import glue) we allocated during remLoadLinuxObj().
1911 */
1912static void remUnloadLinuxObj(void)
1913{
1914 unsigned i;
1915
1916 /* close modules. */
1917 RTLdrClose(g_ModREM2);
1918 g_ModREM2 = NIL_RTLDRMOD;
1919 RTMemExecFree(g_pvREM2);
1920 g_pvREM2 = NULL;
1921
1922 /* clear the pointers. */
1923 for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
1924 *(void **)g_aExports[i].pv = NULL;
1925# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1926 for (i = 0; i < RT_ELEMENTS(g_aVMMImports); i++)
1927 g_aVMMImports[i].pvWrapper = NULL;
1928 for (i = 0; i < RT_ELEMENTS(g_aRTImports); i++)
1929 g_aRTImports[i].pvWrapper = NULL;
1930 for (i = 0; i < RT_ELEMENTS(g_aCRTImports); i++)
1931 g_aCRTImports[i].pvWrapper = NULL;
1932
1933 /* free wrapper memory. */
1934 while (g_pExecMemHead)
1935 {
1936 PREMEXECMEM pCur = g_pExecMemHead;
1937 g_pExecMemHead = pCur->pNext;
1938 memset(pCur, 0xcc, pCur->cb);
1939 RTMemExecFree(pCur);
1940 }
1941# endif
1942}
1943#endif
1944
1945#ifdef VBOX_USE_BITNESS_SELECTOR
1946static bool isRem64Needed(PVM pVM)
1947{
1948 PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
1949 uint64_t u64Value = 0;
1950
1951 CFGMR3QueryIntegerDef(pRoot, "Rem64Enabled", &u64Value, 0);
1952
1953 return u64Value == 1;
1954}
1955
1956/**
1957 * Loads real REM object, resolves all exports (imports are done by native loader).
1958 *
1959 * @returns VBox status code.
1960 */
1961static int remLoadProperObj(PVM pVM)
1962{
1963 size_t offFilename;
1964 char szPath[RTPATH_MAX];
1965 int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 32);
1966 AssertRCReturn(rc, rc);
1967 offFilename = strlen(szPath);
1968
1969 /*
1970 * Load the VBoxREM32/64 object/DLL.
1971 */
1972 strcpy(&szPath[offFilename], isRem64Needed(pVM) ? "/VBoxREM64" : "/VBoxREM32");
1973 rc = RTLdrLoad(szPath, &g_ModREM2);
1974 if (RT_SUCCESS(rc))
1975 {
1976 if (RT_SUCCESS(rc))
1977 {
1978 /*
1979 * Resolve exports.
1980 */
1981 unsigned i;
1982 for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
1983 {
1984 void* Value;
1985 rc = RTLdrGetSymbol(g_ModREM2, g_aExports[i].pszName, &Value);
1986 AssertMsgRC(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
1987 if (RT_FAILURE(rc))
1988 break;
1989 *(void **)g_aExports[i].pv = Value;
1990 }
1991 }
1992 }
1993
1994 return rc;
1995}
1996
1997/**
1998 * Unloads the real REM object.
1999 */
2000static void remUnloadProperObj(void)
2001{
2002 unsigned i;
2003
2004 /* close module. */
2005 RTLdrClose(g_ModREM2);
2006 g_ModREM2 = NIL_RTLDRMOD;
2007}
2008#endif
2009
2010
2011REMR3DECL(int) REMR3Init(PVM pVM)
2012{
2013#ifdef USE_REM_STUBS
2014 return VINF_SUCCESS;
2015#elif VBOX_USE_BITNESS_SELECTOR
2016 if (!pfnREMR3Init)
2017 {
2018 int rc = remLoadProperObj(pVM);
2019 if (RT_FAILURE(rc))
2020 return rc;
2021 }
2022 return pfnREMR3Init(pVM);
2023#else
2024 if (!pfnREMR3Init)
2025 {
2026 int rc = remLoadLinuxObj();
2027 if (RT_FAILURE(rc))
2028 return rc;
2029 }
2030 return pfnREMR3Init(pVM);
2031#endif
2032}
2033
2034REMR3DECL(int) REMR3Term(PVM pVM)
2035{
2036#ifdef USE_REM_STUBS
2037 return VINF_SUCCESS;
2038#elif VBOX_USE_BITNESS_SELECTOR
2039 int rc;
2040 Assert(VALID_PTR(pfnREMR3Term));
2041 rc = pfnREMR3Term(pVM);
2042 remUnloadProperObj();
2043 return rc;
2044#else
2045 int rc;
2046 Assert(VALID_PTR(pfnREMR3Term));
2047 rc = pfnREMR3Term(pVM);
2048 remUnloadLinuxObj();
2049 return rc;
2050#endif
2051}
2052
2053REMR3DECL(void) REMR3Reset(PVM pVM)
2054{
2055#ifndef USE_REM_STUBS
2056 Assert(VALID_PTR(pfnREMR3Reset));
2057 pfnREMR3Reset(pVM);
2058#endif
2059}
2060
2061REMR3DECL(int) REMR3Step(PVM pVM)
2062{
2063#ifdef USE_REM_STUBS
2064 return VERR_NOT_IMPLEMENTED;
2065#else
2066 Assert(VALID_PTR(pfnREMR3Step));
2067 return pfnREMR3Step(pVM);
2068#endif
2069}
2070
2071REMR3DECL(int) REMR3BreakpointSet(PVM pVM, RTGCUINTPTR Address)
2072{
2073#ifdef USE_REM_STUBS
2074 return VERR_REM_NO_MORE_BP_SLOTS;
2075#else
2076 Assert(VALID_PTR(pfnREMR3BreakpointSet));
2077 return pfnREMR3BreakpointSet(pVM, Address);
2078#endif
2079}
2080
2081REMR3DECL(int) REMR3BreakpointClear(PVM pVM, RTGCUINTPTR Address)
2082{
2083#ifdef USE_REM_STUBS
2084 return VERR_NOT_IMPLEMENTED;
2085#else
2086 Assert(VALID_PTR(pfnREMR3BreakpointClear));
2087 return pfnREMR3BreakpointClear(pVM, Address);
2088#endif
2089}
2090
2091REMR3DECL(int) REMR3EmulateInstruction(PVM pVM)
2092{
2093#ifdef USE_REM_STUBS
2094 return VERR_NOT_IMPLEMENTED;
2095#else
2096 Assert(VALID_PTR(pfnREMR3EmulateInstruction));
2097 return pfnREMR3EmulateInstruction(pVM);
2098#endif
2099}
2100
2101REMR3DECL(int) REMR3Run(PVM pVM)
2102{
2103#ifdef USE_REM_STUBS
2104 return VERR_NOT_IMPLEMENTED;
2105#else
2106 Assert(VALID_PTR(pfnREMR3Run));
2107 return pfnREMR3Run(pVM);
2108#endif
2109}
2110
2111REMR3DECL(int) REMR3State(PVM pVM)
2112{
2113#ifdef USE_REM_STUBS
2114 return VERR_NOT_IMPLEMENTED;
2115#else
2116 Assert(VALID_PTR(pfnREMR3State));
2117 return pfnREMR3State(pVM);
2118#endif
2119}
2120
2121REMR3DECL(int) REMR3StateBack(PVM pVM)
2122{
2123#ifdef USE_REM_STUBS
2124 return VERR_NOT_IMPLEMENTED;
2125#else
2126 Assert(VALID_PTR(pfnREMR3StateBack));
2127 return pfnREMR3StateBack(pVM);
2128#endif
2129}
2130
2131REMR3DECL(void) REMR3StateUpdate(PVM pVM)
2132{
2133#ifndef USE_REM_STUBS
2134 Assert(VALID_PTR(pfnREMR3StateUpdate));
2135 pfnREMR3StateUpdate(pVM);
2136#endif
2137}
2138
2139REMR3DECL(void) REMR3A20Set(PVM pVM, bool fEnable)
2140{
2141#ifndef USE_REM_STUBS
2142 Assert(VALID_PTR(pfnREMR3A20Set));
2143 pfnREMR3A20Set(pVM, fEnable);
2144#endif
2145}
2146
2147REMR3DECL(void) REMR3ReplayInvalidatedPages(PVM pVM)
2148{
2149#ifndef USE_REM_STUBS
2150 Assert(VALID_PTR(pfnREMR3ReplayInvalidatedPages));
2151 pfnREMR3ReplayInvalidatedPages(pVM);
2152#endif
2153}
2154
2155REMR3DECL(void) REMR3ReplayHandlerNotifications(PVM pVM)
2156{
2157#ifndef USE_REM_STUBS
2158 Assert(VALID_PTR(pfnREMR3ReplayHandlerNotifications));
2159 pfnREMR3ReplayHandlerNotifications(pVM);
2160#endif
2161}
2162
2163REMR3DECL(int) REMR3NotifyCodePageChanged(PVM pVM, RTGCPTR pvCodePage)
2164{
2165#ifdef USE_REM_STUBS
2166 return VINF_SUCCESS;
2167#else
2168 Assert(VALID_PTR(pfnREMR3NotifyCodePageChanged));
2169 return pfnREMR3NotifyCodePageChanged(pVM, pvCodePage);
2170#endif
2171}
2172
2173REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, unsigned fFlags)
2174{
2175#ifndef USE_REM_STUBS
2176 Assert(VALID_PTR(pfnREMR3NotifyPhysRamRegister));
2177 pfnREMR3NotifyPhysRamRegister(pVM, GCPhys, cb, fFlags);
2178#endif
2179}
2180
2181#ifndef VBOX_WITH_NEW_PHYS_CODE
2182REMR3DECL(void) REMR3NotifyPhysRamChunkRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, RTHCUINTPTR pvRam, unsigned fFlags)
2183{
2184#ifndef USE_REM_STUBS
2185 Assert(VALID_PTR(pfnREMR3NotifyPhysRamChunkRegister));
2186 pfnREMR3NotifyPhysRamChunkRegister(pVM, GCPhys, cb, pvRam, fFlags);
2187#endif
2188}
2189#endif
2190
2191REMR3DECL(void) REMR3NotifyPhysRomRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, void *pvCopy, bool fShadow)
2192{
2193#ifndef USE_REM_STUBS
2194 Assert(VALID_PTR(pfnREMR3NotifyPhysRomRegister));
2195 pfnREMR3NotifyPhysRomRegister(pVM, GCPhys, cb, pvCopy, fShadow);
2196#endif
2197}
2198
2199REMR3DECL(void) REMR3NotifyPhysReserve(PVM pVM, RTGCPHYS GCPhys, RTUINT cb)
2200{
2201#ifndef USE_REM_STUBS
2202 Assert(VALID_PTR(pfnREMR3NotifyPhysReserve));
2203 pfnREMR3NotifyPhysReserve(pVM, GCPhys, cb);
2204#endif
2205}
2206
2207REMR3DECL(void) REMR3NotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler)
2208{
2209#ifndef USE_REM_STUBS
2210 Assert(VALID_PTR(pfnREMR3NotifyHandlerPhysicalRegister));
2211 pfnREMR3NotifyHandlerPhysicalRegister(pVM, enmType, GCPhys, cb, fHasHCHandler);
2212#endif
2213}
2214
2215REMR3DECL(void) REMR3NotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
2216{
2217#ifndef USE_REM_STUBS
2218 Assert(VALID_PTR(pfnREMR3NotifyHandlerPhysicalDeregister));
2219 pfnREMR3NotifyHandlerPhysicalDeregister(pVM, enmType, GCPhys, cb, fHasHCHandler, fRestoreAsRAM);
2220#endif
2221}
2222
2223REMR3DECL(void) REMR3NotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
2224{
2225#ifndef USE_REM_STUBS
2226 Assert(VALID_PTR(pfnREMR3NotifyHandlerPhysicalModify));
2227 pfnREMR3NotifyHandlerPhysicalModify(pVM, enmType, GCPhysOld, GCPhysNew, cb, fHasHCHandler, fRestoreAsRAM);
2228#endif
2229}
2230
2231REMR3DECL(bool) REMR3IsPageAccessHandled(PVM pVM, RTGCPHYS GCPhys)
2232{
2233#ifdef USE_REM_STUBS
2234 return false;
2235#else
2236 Assert(VALID_PTR(pfnREMR3IsPageAccessHandled));
2237 return pfnREMR3IsPageAccessHandled(pVM, GCPhys);
2238#endif
2239}
2240
2241REMR3DECL(int) REMR3DisasEnableStepping(PVM pVM, bool fEnable)
2242{
2243#ifdef USE_REM_STUBS
2244 return VERR_NOT_IMPLEMENTED;
2245#else
2246 Assert(VALID_PTR(pfnREMR3DisasEnableStepping));
2247 return pfnREMR3DisasEnableStepping(pVM, fEnable);
2248#endif
2249}
2250
2251REMR3DECL(void) REMR3NotifyPendingInterrupt(PVM pVM, uint8_t u8Interrupt)
2252{
2253#ifndef USE_REM_STUBS
2254 Assert(VALID_PTR(pfnREMR3NotifyPendingInterrupt));
2255 pfnREMR3NotifyPendingInterrupt(pVM, u8Interrupt);
2256#endif
2257}
2258
2259REMR3DECL(uint32_t) REMR3QueryPendingInterrupt(PVM pVM)
2260{
2261#ifdef USE_REM_STUBS
2262 return REM_NO_PENDING_IRQ;
2263#else
2264 Assert(VALID_PTR(pfnREMR3QueryPendingInterrupt));
2265 return pfnREMR3QueryPendingInterrupt(pVM);
2266#endif
2267}
2268
2269REMR3DECL(void) REMR3NotifyInterruptSet(PVM pVM)
2270{
2271#ifndef USE_REM_STUBS
2272 Assert(VALID_PTR(pfnREMR3NotifyInterruptSet));
2273 pfnREMR3NotifyInterruptSet(pVM);
2274#endif
2275}
2276
2277REMR3DECL(void) REMR3NotifyInterruptClear(PVM pVM)
2278{
2279#ifndef USE_REM_STUBS
2280 Assert(VALID_PTR(pfnREMR3NotifyInterruptClear));
2281 pfnREMR3NotifyInterruptClear(pVM);
2282#endif
2283}
2284
2285REMR3DECL(void) REMR3NotifyTimerPending(PVM pVM)
2286{
2287#ifndef USE_REM_STUBS
2288 Assert(VALID_PTR(pfnREMR3NotifyTimerPending));
2289 pfnREMR3NotifyTimerPending(pVM);
2290#endif
2291}
2292
2293REMR3DECL(void) REMR3NotifyDmaPending(PVM pVM)
2294{
2295#ifndef USE_REM_STUBS
2296 Assert(VALID_PTR(pfnREMR3NotifyDmaPending));
2297 pfnREMR3NotifyDmaPending(pVM);
2298#endif
2299}
2300
2301REMR3DECL(void) REMR3NotifyQueuePending(PVM pVM)
2302{
2303#ifndef USE_REM_STUBS
2304 Assert(VALID_PTR(pfnREMR3NotifyQueuePending));
2305 pfnREMR3NotifyQueuePending(pVM);
2306#endif
2307}
2308
2309REMR3DECL(void) REMR3NotifyFF(PVM pVM)
2310{
2311#ifndef USE_REM_STUBS
2312 /* the timer can call this early on, so don't be picky. */
2313 if (pfnREMR3NotifyFF)
2314 pfnREMR3NotifyFF(pVM);
2315#endif
2316}
2317
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