VirtualBox

source: vbox/trunk/src/recompiler/VBoxREMWrapper.cpp@ 20402

Last change on this file since 20402 was 20402, checked in by vboxsync, 15 years ago

Compile fix

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