VirtualBox

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

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

REM: Added REMR3InitFinalize and moved the dirty page bit map allocation over there. REMR3NotifyPhysRamRegister now just tracks the highest ram address. Removed some old obsolete bits in REMInternal.h.

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