VirtualBox

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

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

Import STAMR3Deregister.

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