VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmdrv.h@ 93963

Last change on this file since 93963 was 93912, checked in by vboxsync, 3 years ago

VMM: Add driver helper to destroy a timer, bugref:10196

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 106.8 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Drivers.
3 */
4
5/*
6 * Copyright (C) 2006-2022 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_vmm_pdmdrv_h
27#define VBOX_INCLUDED_vmm_pdmdrv_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/vmm/pdmqueue.h>
33#include <VBox/vmm/pdmcritsect.h>
34#include <VBox/vmm/pdmifs.h>
35#include <VBox/vmm/pdmins.h>
36#include <VBox/vmm/pdmcommon.h>
37#ifdef IN_RING3
38# include <VBox/vmm/pdmthread.h>
39# include <VBox/vmm/pdmasynccompletion.h>
40# include <VBox/vmm/pdmblkcache.h>
41#endif
42#include <VBox/vmm/tm.h>
43#include <VBox/vmm/ssm.h>
44#include <VBox/vmm/cfgm.h>
45#include <VBox/vmm/dbgf.h>
46#include <VBox/vmm/mm.h>
47#include <iprt/stdarg.h>
48
49
50RT_C_DECLS_BEGIN
51
52/** @defgroup grp_pdm_driver The PDM Drivers API
53 * @ingroup grp_pdm
54 * @{
55 */
56
57/** Pointer const PDM Driver API, ring-3. */
58typedef R3PTRTYPE(struct PDMDRVHLPR3 const *) PCPDMDRVHLPR3;
59/** Pointer const PDM Driver API, ring-0. */
60typedef R0PTRTYPE(struct PDMDRVHLPR0 const *) PCPDMDRVHLPR0;
61/** Pointer const PDM Driver API, raw-mode context. */
62typedef RCPTRTYPE(struct PDMDRVHLPRC const *) PCPDMDRVHLPRC;
63
64
65/**
66 * Construct a driver instance for a VM.
67 *
68 * @returns VBox status.
69 * @param pDrvIns The driver instance data. If the registration structure
70 * is needed, it can be accessed thru pDrvIns->pReg.
71 * @param pCfg Configuration node handle for the driver. This is
72 * expected to be in high demand in the constructor and is
73 * therefore passed as an argument. When using it at other
74 * times, it can be accessed via pDrvIns->pCfg.
75 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
76 */
77typedef DECLCALLBACKTYPE(int, FNPDMDRVCONSTRUCT,(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags));
78/** Pointer to a FNPDMDRVCONSTRUCT() function. */
79typedef FNPDMDRVCONSTRUCT *PFNPDMDRVCONSTRUCT;
80
81/**
82 * Destruct a driver instance.
83 *
84 * Most VM resources are freed by the VM. This callback is provided so that
85 * any non-VM resources can be freed correctly.
86 *
87 * @param pDrvIns The driver instance data.
88 */
89typedef DECLCALLBACKTYPE(void, FNPDMDRVDESTRUCT,(PPDMDRVINS pDrvIns));
90/** Pointer to a FNPDMDRVDESTRUCT() function. */
91typedef FNPDMDRVDESTRUCT *PFNPDMDRVDESTRUCT;
92
93/**
94 * Driver relocation callback.
95 *
96 * This is called when the instance data has been relocated in raw-mode context
97 * (RC). It is also called when the RC hypervisor selects changes. The driver
98 * must fixup all necessary pointers and re-query all interfaces to other RC
99 * devices and drivers.
100 *
101 * Before the RC code is executed the first time, this function will be called
102 * with a 0 delta so RC pointer calculations can be one in one place.
103 *
104 * @param pDrvIns Pointer to the driver instance.
105 * @param offDelta The relocation delta relative to the old location.
106 *
107 * @remark A relocation CANNOT fail.
108 */
109typedef DECLCALLBACKTYPE(void, FNPDMDRVRELOCATE,(PPDMDRVINS pDrvIns, RTGCINTPTR offDelta));
110/** Pointer to a FNPDMDRVRELOCATE() function. */
111typedef FNPDMDRVRELOCATE *PFNPDMDRVRELOCATE;
112
113/**
114 * Driver I/O Control interface.
115 *
116 * This is used by external components, such as the COM interface, to
117 * communicate with a driver using a driver specific interface. Generally,
118 * the driver interfaces are used for this task.
119 *
120 * @returns VBox status code.
121 * @param pDrvIns Pointer to the driver instance.
122 * @param uFunction Function to perform.
123 * @param pvIn Pointer to input data.
124 * @param cbIn Size of input data.
125 * @param pvOut Pointer to output data.
126 * @param cbOut Size of output data.
127 * @param pcbOut Where to store the actual size of the output data.
128 */
129typedef DECLCALLBACKTYPE(int, FNPDMDRVIOCTL,(PPDMDRVINS pDrvIns, uint32_t uFunction,
130 void *pvIn, uint32_t cbIn,
131 void *pvOut, uint32_t cbOut, uint32_t *pcbOut));
132/** Pointer to a FNPDMDRVIOCTL() function. */
133typedef FNPDMDRVIOCTL *PFNPDMDRVIOCTL;
134
135/**
136 * Power On notification.
137 *
138 * @param pDrvIns The driver instance data.
139 */
140typedef DECLCALLBACKTYPE(void, FNPDMDRVPOWERON,(PPDMDRVINS pDrvIns));
141/** Pointer to a FNPDMDRVPOWERON() function. */
142typedef FNPDMDRVPOWERON *PFNPDMDRVPOWERON;
143
144/**
145 * Reset notification.
146 *
147 * @returns VBox status.
148 * @param pDrvIns The driver instance data.
149 */
150typedef DECLCALLBACKTYPE(void, FNPDMDRVRESET,(PPDMDRVINS pDrvIns));
151/** Pointer to a FNPDMDRVRESET() function. */
152typedef FNPDMDRVRESET *PFNPDMDRVRESET;
153
154/**
155 * Suspend notification.
156 *
157 * @returns VBox status.
158 * @param pDrvIns The driver instance data.
159 */
160typedef DECLCALLBACKTYPE(void, FNPDMDRVSUSPEND,(PPDMDRVINS pDrvIns));
161/** Pointer to a FNPDMDRVSUSPEND() function. */
162typedef FNPDMDRVSUSPEND *PFNPDMDRVSUSPEND;
163
164/**
165 * Resume notification.
166 *
167 * @returns VBox status.
168 * @param pDrvIns The driver instance data.
169 */
170typedef DECLCALLBACKTYPE(void, FNPDMDRVRESUME,(PPDMDRVINS pDrvIns));
171/** Pointer to a FNPDMDRVRESUME() function. */
172typedef FNPDMDRVRESUME *PFNPDMDRVRESUME;
173
174/**
175 * Power Off notification.
176 *
177 * This is always called when VMR3PowerOff is called.
178 * There will be no callback when hot plugging devices or when replumbing the driver
179 * stack.
180 *
181 * @param pDrvIns The driver instance data.
182 */
183typedef DECLCALLBACKTYPE(void, FNPDMDRVPOWEROFF,(PPDMDRVINS pDrvIns));
184/** Pointer to a FNPDMDRVPOWEROFF() function. */
185typedef FNPDMDRVPOWEROFF *PFNPDMDRVPOWEROFF;
186
187/**
188 * Attach command.
189 *
190 * This is called to let the driver attach to a driver at runtime. This is not
191 * called during VM construction, the driver constructor have to do this by
192 * calling PDMDrvHlpAttach.
193 *
194 * This is like plugging in the keyboard or mouse after turning on the PC.
195 *
196 * @returns VBox status code.
197 * @param pDrvIns The driver instance.
198 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
199 */
200typedef DECLCALLBACKTYPE(int, FNPDMDRVATTACH,(PPDMDRVINS pDrvIns, uint32_t fFlags));
201/** Pointer to a FNPDMDRVATTACH() function. */
202typedef FNPDMDRVATTACH *PFNPDMDRVATTACH;
203
204/**
205 * Detach notification.
206 *
207 * This is called when a driver below it in the chain is detaching itself
208 * from it. The driver should adjust it's state to reflect this.
209 *
210 * This is like ejecting a cdrom or floppy.
211 *
212 * @param pDrvIns The driver instance.
213 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
214 */
215typedef DECLCALLBACKTYPE(void, FNPDMDRVDETACH,(PPDMDRVINS pDrvIns, uint32_t fFlags));
216/** Pointer to a FNPDMDRVDETACH() function. */
217typedef FNPDMDRVDETACH *PFNPDMDRVDETACH;
218
219
220
221/**
222 * PDM Driver Registration Structure.
223 *
224 * This structure is used when registering a driver from VBoxInitDrivers() (in
225 * host ring-3 context). PDM will continue use till the VM is terminated.
226 */
227typedef struct PDMDRVREG
228{
229 /** Structure version. PDM_DRVREG_VERSION defines the current version. */
230 uint32_t u32Version;
231 /** Driver name. */
232 char szName[32];
233 /** Name of the raw-mode context module (no path).
234 * Only evalutated if PDM_DRVREG_FLAGS_RC is set. */
235 char szRCMod[32];
236 /** Name of the ring-0 module (no path).
237 * Only evalutated if PDM_DRVREG_FLAGS_R0 is set. */
238 char szR0Mod[32];
239 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
240 * remain unchanged from registration till VM destruction. */
241 const char *pszDescription;
242
243 /** Flags, combination of the PDM_DRVREG_FLAGS_* \#defines. */
244 uint32_t fFlags;
245 /** Driver class(es), combination of the PDM_DRVREG_CLASS_* \#defines. */
246 uint32_t fClass;
247 /** Maximum number of instances (per VM). */
248 uint32_t cMaxInstances;
249 /** Size of the instance data. */
250 uint32_t cbInstance;
251
252 /** Construct instance - required. */
253 PFNPDMDRVCONSTRUCT pfnConstruct;
254 /** Destruct instance - optional. */
255 PFNPDMDRVDESTRUCT pfnDestruct;
256 /** Relocation command - optional. */
257 PFNPDMDRVRELOCATE pfnRelocate;
258 /** I/O control - optional. */
259 PFNPDMDRVIOCTL pfnIOCtl;
260 /** Power on notification - optional. */
261 PFNPDMDRVPOWERON pfnPowerOn;
262 /** Reset notification - optional. */
263 PFNPDMDRVRESET pfnReset;
264 /** Suspend notification - optional. */
265 PFNPDMDRVSUSPEND pfnSuspend;
266 /** Resume notification - optional. */
267 PFNPDMDRVRESUME pfnResume;
268 /** Attach command - optional. */
269 PFNPDMDRVATTACH pfnAttach;
270 /** Detach notification - optional. */
271 PFNPDMDRVDETACH pfnDetach;
272 /** Power off notification - optional. */
273 PFNPDMDRVPOWEROFF pfnPowerOff;
274 /** @todo */
275 PFNRT pfnSoftReset;
276 /** Initialization safty marker. */
277 uint32_t u32VersionEnd;
278} PDMDRVREG;
279/** Pointer to a PDM Driver Structure. */
280typedef PDMDRVREG *PPDMDRVREG;
281/** Const pointer to a PDM Driver Structure. */
282typedef PDMDRVREG const *PCPDMDRVREG;
283
284/** Current DRVREG version number. */
285#define PDM_DRVREG_VERSION PDM_VERSION_MAKE(0xf0ff, 1, 0)
286
287/** PDM Driver Flags.
288 * @{ */
289/** @def PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT
290 * The bit count for the current host. */
291#if HC_ARCH_BITS == 32
292# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000001)
293#elif HC_ARCH_BITS == 64
294# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000002)
295#else
296# error Unsupported HC_ARCH_BITS value.
297#endif
298/** The host bit count mask. */
299#define PDM_DRVREG_FLAGS_HOST_BITS_MASK UINT32_C(0x00000003)
300/** This flag is used to indicate that the driver has a RC component. */
301#define PDM_DRVREG_FLAGS_RC UINT32_C(0x00000010)
302/** This flag is used to indicate that the driver has a R0 component. */
303#define PDM_DRVREG_FLAGS_R0 UINT32_C(0x00000020)
304
305/** @} */
306
307
308/** PDM Driver Classes.
309 * @{ */
310/** Mouse input driver. */
311#define PDM_DRVREG_CLASS_MOUSE RT_BIT(0)
312/** Keyboard input driver. */
313#define PDM_DRVREG_CLASS_KEYBOARD RT_BIT(1)
314/** Display driver. */
315#define PDM_DRVREG_CLASS_DISPLAY RT_BIT(2)
316/** Network transport driver. */
317#define PDM_DRVREG_CLASS_NETWORK RT_BIT(3)
318/** Block driver. */
319#define PDM_DRVREG_CLASS_BLOCK RT_BIT(4)
320/** Media driver. */
321#define PDM_DRVREG_CLASS_MEDIA RT_BIT(5)
322/** Mountable driver. */
323#define PDM_DRVREG_CLASS_MOUNTABLE RT_BIT(6)
324/** Audio driver. */
325#define PDM_DRVREG_CLASS_AUDIO RT_BIT(7)
326/** VMMDev driver. */
327#define PDM_DRVREG_CLASS_VMMDEV RT_BIT(8)
328/** Status driver. */
329#define PDM_DRVREG_CLASS_STATUS RT_BIT(9)
330/** ACPI driver. */
331#define PDM_DRVREG_CLASS_ACPI RT_BIT(10)
332/** USB related driver. */
333#define PDM_DRVREG_CLASS_USB RT_BIT(11)
334/** ISCSI Transport related driver. */
335#define PDM_DRVREG_CLASS_ISCSITRANSPORT RT_BIT(12)
336/** Char driver. */
337#define PDM_DRVREG_CLASS_CHAR RT_BIT(13)
338/** Stream driver. */
339#define PDM_DRVREG_CLASS_STREAM RT_BIT(14)
340/** SCSI driver. */
341#define PDM_DRVREG_CLASS_SCSI RT_BIT(15)
342/** Generic raw PCI device driver. */
343#define PDM_DRVREG_CLASS_PCIRAW RT_BIT(16)
344/** @} */
345
346
347/**
348 * PDM Driver Instance.
349 *
350 * @implements PDMIBASE
351 */
352typedef struct PDMDRVINS
353{
354 /** Structure version. PDM_DRVINS_VERSION defines the current version. */
355 uint32_t u32Version;
356 /** Driver instance number. */
357 uint32_t iInstance;
358
359 /** Pointer the PDM Driver API. */
360 RCPTRTYPE(PCPDMDRVHLPRC) pHlpRC;
361 /** Pointer to driver instance data. */
362 RCPTRTYPE(void *) pvInstanceDataRC;
363
364 /** Pointer the PDM Driver API. */
365 R0PTRTYPE(PCPDMDRVHLPR0) pHlpR0;
366 /** Pointer to driver instance data. */
367 R0PTRTYPE(void *) pvInstanceDataR0;
368
369 /** Pointer the PDM Driver API. */
370 R3PTRTYPE(PCPDMDRVHLPR3) pHlpR3;
371 /** Pointer to driver instance data. */
372 R3PTRTYPE(void *) pvInstanceDataR3;
373
374 /** Pointer to driver registration structure. */
375 R3PTRTYPE(PCPDMDRVREG) pReg;
376 /** Configuration handle. */
377 R3PTRTYPE(PCFGMNODE) pCfg;
378
379 /** Pointer to the base interface of the device/driver instance above. */
380 R3PTRTYPE(PPDMIBASE) pUpBase;
381 /** Pointer to the base interface of the driver instance below. */
382 R3PTRTYPE(PPDMIBASE) pDownBase;
383
384 /** The base interface of the driver.
385 * The driver constructor initializes this. */
386 PDMIBASE IBase;
387
388 /** Tracing indicator. */
389 uint32_t fTracing;
390 /** The tracing ID of this device. */
391 uint32_t idTracing;
392#if HC_ARCH_BITS == 32
393 /** Align the internal data more naturally. */
394 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 7 : 0];
395#endif
396
397 /** Internal data. */
398 union
399 {
400#ifdef PDMDRVINSINT_DECLARED
401 PDMDRVINSINT s;
402#endif
403 uint8_t padding[HC_ARCH_BITS == 32 ? 40 + 32 : 72 + 24];
404 } Internal;
405
406 /** Driver instance data. The size of this area is defined
407 * in the PDMDRVREG::cbInstanceData field. */
408 char achInstanceData[4];
409} PDMDRVINS;
410
411/** Current DRVREG version number. */
412#define PDM_DRVINS_VERSION PDM_VERSION_MAKE(0xf0fe, 2, 0)
413
414/** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */
415#define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMDRVINS, IBase)) )
416
417/** @def PDMDRVINS_2_RCPTR
418 * Converts a PDM Driver instance pointer a RC PDM Driver instance pointer.
419 */
420#define PDMDRVINS_2_RCPTR(pDrvIns) ( (RCPTRTYPE(PPDMDRVINS))((RTRCUINTPTR)(pDrvIns)->pvInstanceDataRC - (RTRCUINTPTR)RT_UOFFSETOF(PDMDRVINS, achInstanceData)) )
421
422/** @def PDMDRVINS_2_R3PTR
423 * Converts a PDM Driver instance pointer a R3 PDM Driver instance pointer.
424 */
425#define PDMDRVINS_2_R3PTR(pDrvIns) ( (R3PTRTYPE(PPDMDRVINS))((RTHCUINTPTR)(pDrvIns)->pvInstanceDataR3 - RT_UOFFSETOF(PDMDRVINS, achInstanceData)) )
426
427/** @def PDMDRVINS_2_R0PTR
428 * Converts a PDM Driver instance pointer a R0 PDM Driver instance pointer.
429 */
430#define PDMDRVINS_2_R0PTR(pDrvIns) ( (R0PTRTYPE(PPDMDRVINS))((RTR0UINTPTR)(pDrvIns)->pvInstanceDataR0 - RT_UOFFSETOF(PDMDRVINS, achInstanceData)) )
431
432
433
434/**
435 * Checks the structure versions of the drive instance and driver helpers,
436 * returning if they are incompatible.
437 *
438 * Intended for the constructor.
439 *
440 * @param pDrvIns Pointer to the PDM driver instance.
441 */
442#define PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns) \
443 do \
444 { \
445 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
446 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
447 ("DrvIns=%#x mine=%#x\n", (pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
448 VERR_PDM_DRVINS_VERSION_MISMATCH); \
449 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
450 ("DrvHlp=%#x mine=%#x\n", (pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
451 VERR_PDM_DRVHLPR3_VERSION_MISMATCH); \
452 } while (0)
453
454/**
455 * Quietly checks the structure versions of the drive instance and driver
456 * helpers, returning if they are incompatible.
457 *
458 * Intended for the destructor.
459 *
460 * @param pDrvIns Pointer to the PDM driver instance.
461 */
462#define PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns) \
463 do \
464 { \
465 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
466 if (RT_LIKELY( PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION) \
467 && PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION)) ) \
468 { /* likely */ } else return; \
469 } while (0)
470
471/**
472 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
473 * constructor - returns on failure.
474 *
475 * This should be invoked after having initialized the instance data
476 * sufficiently for the correct operation of the destructor. The destructor is
477 * always called!
478 *
479 * @param pDrvIns Pointer to the PDM driver instance.
480 * @param pszValidValues Patterns describing the valid value names. See
481 * RTStrSimplePatternMultiMatch for details on the
482 * pattern syntax.
483 * @param pszValidNodes Patterns describing the valid node (key) names.
484 * Pass empty string if no valid nodess.
485 */
486#define PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, pszValidValues, pszValidNodes) \
487 do \
488 { \
489 int rcValCfg = pDrvIns->pHlpR3->pfnCFGMValidateConfig((pDrvIns)->pCfg, "/", pszValidValues, pszValidNodes, \
490 (pDrvIns)->pReg->szName, (pDrvIns)->iInstance); \
491 if (RT_SUCCESS(rcValCfg)) \
492 { /* likely */ } else return rcValCfg; \
493 } while (0)
494
495
496
497/**
498 * USB hub registration structure.
499 */
500typedef struct PDMUSBHUBREG
501{
502 /** Structure version number. PDM_USBHUBREG_VERSION defines the current version. */
503 uint32_t u32Version;
504
505 /**
506 * Request the hub to attach of the specified device.
507 *
508 * @returns VBox status code.
509 * @param pDrvIns The hub instance.
510 * @param pUsbIns The device to attach.
511 * @param pszCaptureFilename Path to the file for USB traffic capturing, optional.
512 * @param piPort Where to store the port number the device was attached to.
513 * @thread EMT.
514 */
515 DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, const char *pszCaptureFilename, uint32_t *piPort));
516
517 /**
518 * Request the hub to detach of the specified device.
519 *
520 * The device has previously been attached to the hub with the
521 * pfnAttachDevice call. This call is not currently expected to
522 * fail.
523 *
524 * @returns VBox status code.
525 * @param pDrvIns The hub instance.
526 * @param pUsbIns The device to detach.
527 * @param iPort The port number returned by the attach call.
528 * @thread EMT.
529 */
530 DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t iPort));
531
532 /** Counterpart to u32Version, same value. */
533 uint32_t u32TheEnd;
534} PDMUSBHUBREG;
535/** Pointer to a const USB hub registration structure. */
536typedef const PDMUSBHUBREG *PCPDMUSBHUBREG;
537
538/** Current PDMUSBHUBREG version number. */
539#define PDM_USBHUBREG_VERSION PDM_VERSION_MAKE(0xf0fd, 2, 0)
540
541
542/**
543 * USB hub helpers.
544 * This is currently just a place holder.
545 */
546typedef struct PDMUSBHUBHLP
547{
548 /** Structure version. PDM_USBHUBHLP_VERSION defines the current version. */
549 uint32_t u32Version;
550
551 /** Just a safety precaution. */
552 uint32_t u32TheEnd;
553} PDMUSBHUBHLP;
554/** Pointer to PCI helpers. */
555typedef PDMUSBHUBHLP *PPDMUSBHUBHLP;
556/** Pointer to const PCI helpers. */
557typedef const PDMUSBHUBHLP *PCPDMUSBHUBHLP;
558/** Pointer to const PCI helpers pointer. */
559typedef PCPDMUSBHUBHLP *PPCPDMUSBHUBHLP;
560
561/** Current PDMUSBHUBHLP version number. */
562#define PDM_USBHUBHLP_VERSION PDM_VERSION_MAKE(0xf0fc, 1, 0)
563
564
565/**
566 * PDM Driver API - raw-mode context variant.
567 */
568typedef struct PDMDRVHLPRC
569{
570 /** Structure version. PDM_DRVHLPRC_VERSION defines the current version. */
571 uint32_t u32Version;
572
573 /**
574 * Assert that the current thread is the emulation thread.
575 *
576 * @returns True if correct.
577 * @returns False if wrong.
578 * @param pDrvIns Driver instance.
579 * @param pszFile Filename of the assertion location.
580 * @param iLine Linenumber of the assertion location.
581 * @param pszFunction Function of the assertion location.
582 */
583 DECLRCCALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
584
585 /**
586 * Assert that the current thread is NOT the emulation thread.
587 *
588 * @returns True if correct.
589 * @returns False if wrong.
590 * @param pDrvIns Driver instance.
591 * @param pszFile Filename of the assertion location.
592 * @param iLine Linenumber of the assertion location.
593 * @param pszFunction Function of the assertion location.
594 */
595 DECLRCCALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
596
597 /** @name Exported PDM Critical Section Functions
598 * @{ */
599 DECLRCCALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy));
600 DECLRCCALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
601 DECLRCCALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
602 DECLRCCALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
603 DECLRCCALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
604 DECLRCCALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
605 DECLRCCALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
606 DECLRCCALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
607 DECLRCCALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
608 /** @} */
609
610 /**
611 * Obtains bandwidth in a bandwidth group.
612 *
613 * @returns True if bandwidth was allocated, false if not.
614 * @param pDrvIns The driver instance.
615 * @param pFilter Pointer to the filter that allocates bandwidth.
616 * @param cbTransfer Number of bytes to allocate.
617 */
618 DECLRCCALLBACKMEMBER(bool, pfnNetShaperAllocateBandwidth,(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter, size_t cbTransfer));
619
620 /** Just a safety precaution. */
621 uint32_t u32TheEnd;
622} PDMDRVHLPRC;
623/** Current PDMDRVHLPRC version number. */
624#define PDM_DRVHLPRC_VERSION PDM_VERSION_MAKE(0xf0f9, 6, 0)
625
626
627/**
628 * PDM Driver API, ring-0 context.
629 */
630typedef struct PDMDRVHLPR0
631{
632 /** Structure version. PDM_DRVHLPR0_VERSION defines the current version. */
633 uint32_t u32Version;
634
635 /**
636 * Assert that the current thread is the emulation thread.
637 *
638 * @returns True if correct.
639 * @returns False if wrong.
640 * @param pDrvIns Driver instance.
641 * @param pszFile Filename of the assertion location.
642 * @param iLine Linenumber of the assertion location.
643 * @param pszFunction Function of the assertion location.
644 */
645 DECLR0CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
646
647 /**
648 * Assert that the current thread is NOT the emulation thread.
649 *
650 * @returns True if correct.
651 * @returns False if wrong.
652 * @param pDrvIns Driver instance.
653 * @param pszFile Filename of the assertion location.
654 * @param iLine Linenumber of the assertion location.
655 * @param pszFunction Function of the assertion location.
656 */
657 DECLR0CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
658
659 /** @name Exported PDM Critical Section Functions
660 * @{ */
661 DECLR0CALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy));
662 DECLR0CALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
663 DECLR0CALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
664 DECLR0CALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
665 DECLR0CALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
666 DECLR0CALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
667 DECLR0CALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
668 DECLR0CALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
669 DECLR0CALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
670 DECLR0CALLBACKMEMBER(int, pfnCritSectScheduleExitEvent,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal));
671 /** @} */
672
673 /**
674 * Obtains bandwidth in a bandwidth group.
675 *
676 * @returns True if bandwidth was allocated, false if not.
677 * @param pDrvIns The driver instance.
678 * @param pFilter Pointer to the filter that allocates bandwidth.
679 * @param cbTransfer Number of bytes to allocate.
680 */
681 DECLR0CALLBACKMEMBER(bool, pfnNetShaperAllocateBandwidth,(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter, size_t cbTransfer));
682
683 /** Just a safety precaution. */
684 uint32_t u32TheEnd;
685} PDMDRVHLPR0;
686/** Current DRVHLP version number. */
687#define PDM_DRVHLPR0_VERSION PDM_VERSION_MAKE(0xf0f8, 6, 0)
688
689
690#ifdef IN_RING3
691
692/**
693 * PDM Driver API.
694 */
695typedef struct PDMDRVHLPR3
696{
697 /** Structure version. PDM_DRVHLPR3_VERSION defines the current version. */
698 uint32_t u32Version;
699
700 /**
701 * Attaches a driver (chain) to the driver.
702 *
703 * @returns VBox status code.
704 * @param pDrvIns Driver instance.
705 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
706 * @param ppBaseInterface Where to store the pointer to the base interface.
707 */
708 DECLR3CALLBACKMEMBER(int, pfnAttach,(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface));
709
710 /**
711 * Detach the driver the drivers below us.
712 *
713 * @returns VBox status code.
714 * @param pDrvIns Driver instance.
715 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
716 */
717 DECLR3CALLBACKMEMBER(int, pfnDetach,(PPDMDRVINS pDrvIns, uint32_t fFlags));
718
719 /**
720 * Detach the driver from the driver above it and destroy this
721 * driver and all drivers below it.
722 *
723 * @returns VBox status code.
724 * @param pDrvIns Driver instance.
725 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
726 */
727 DECLR3CALLBACKMEMBER(int, pfnDetachSelf,(PPDMDRVINS pDrvIns, uint32_t fFlags));
728
729 /**
730 * Prepare a media mount.
731 *
732 * The driver must not have anything attached to itself
733 * when calling this function as the purpose is to set up the configuration
734 * of an future attachment.
735 *
736 * @returns VBox status code
737 * @param pDrvIns Driver instance.
738 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
739 * constructed a configuration which can be attached to the bottom driver.
740 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
741 */
742 DECLR3CALLBACKMEMBER(int, pfnMountPrepare,(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver));
743
744 /**
745 * Assert that the current thread is the emulation thread.
746 *
747 * @returns True if correct.
748 * @returns False if wrong.
749 * @param pDrvIns Driver instance.
750 * @param pszFile Filename of the assertion location.
751 * @param iLine Linenumber of the assertion location.
752 * @param pszFunction Function of the assertion location.
753 */
754 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
755
756 /**
757 * Assert that the current thread is NOT the emulation thread.
758 *
759 * @returns True if correct.
760 * @returns False if wrong.
761 * @param pDrvIns Driver instance.
762 * @param pszFile Filename of the assertion location.
763 * @param iLine Linenumber of the assertion location.
764 * @param pszFunction Function of the assertion location.
765 */
766 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
767
768 /**
769 * Set the VM error message
770 *
771 * @returns rc.
772 * @param pDrvIns Driver instance.
773 * @param rc VBox status code.
774 * @param SRC_POS Use RT_SRC_POS.
775 * @param pszFormat Error message format string.
776 * @param va Error message arguments.
777 */
778 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
779 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
780
781 /**
782 * Set the VM runtime error message
783 *
784 * @returns VBox status code.
785 * @param pDrvIns Driver instance.
786 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
787 * @param pszErrorId Error ID string.
788 * @param pszFormat Error message format string.
789 * @param va Error message arguments.
790 */
791 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
792 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
793
794 /**
795 * Gets the VM state.
796 *
797 * @returns VM state.
798 * @param pDrvIns The driver instance.
799 * @thread Any thread (just keep in mind that it's volatile info).
800 */
801 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDRVINS pDrvIns));
802
803 /**
804 * Checks if the VM was teleported and hasn't been fully resumed yet.
805 *
806 * @returns true / false.
807 * @param pDrvIns The driver instance.
808 * @thread Any thread.
809 */
810 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDRVINS pDrvIns));
811
812 /**
813 * Gets the support driver session.
814 *
815 * This is intended for working using the semaphore API.
816 *
817 * @returns Support driver session handle.
818 * @param pDrvIns The driver instance.
819 */
820 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDRVINS pDrvIns));
821
822 /** @name Exported PDM Queue Functions
823 * @{ */
824 /**
825 * Create a queue.
826 *
827 * @returns VBox status code.
828 * @param pDrvIns Driver instance.
829 * @param cbItem Size a queue item.
830 * @param cItems Number of items in the queue.
831 * @param cMilliesInterval Number of milliseconds between polling the queue.
832 * If 0 then the emulation thread will be notified whenever an item arrives.
833 * @param pfnCallback The consumer function.
834 * @param pszName The queue base name. The instance number will be
835 * appended automatically.
836 * @param phQueue Where to store the queue handle on success.
837 * @thread The emulation thread.
838 */
839 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
840 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PDMQUEUEHANDLE *phQueue));
841
842 DECLR3CALLBACKMEMBER(PPDMQUEUEITEMCORE, pfnQueueAlloc,(PPDMDRVINS pDrvIns, PDMQUEUEHANDLE hQueue));
843 DECLR3CALLBACKMEMBER(int, pfnQueueInsert,(PPDMDRVINS pDrvIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem));
844 DECLR3CALLBACKMEMBER(bool, pfnQueueFlushIfNecessary,(PPDMDRVINS pDrvIns, PDMQUEUEHANDLE hQueue));
845 /** @} */
846
847 /**
848 * Query the virtual timer frequency.
849 *
850 * @returns Frequency in Hz.
851 * @param pDrvIns Driver instance.
852 * @thread Any thread.
853 */
854 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMDRVINS pDrvIns));
855
856 /**
857 * Query the virtual time.
858 *
859 * @returns The current virtual time.
860 * @param pDrvIns Driver instance.
861 * @thread Any thread.
862 */
863 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMDRVINS pDrvIns));
864
865 /**
866 * Creates a timer.
867 *
868 * @returns VBox status.
869 * @param pDrvIns Driver instance.
870 * @param enmClock The clock to use on this timer.
871 * @param pfnCallback Callback function.
872 * @param pvUser The user argument to the callback.
873 * @param fFlags Timer creation flags, see grp_tm_timer_flags.
874 * @param pszDesc Pointer to description string which must stay around
875 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
876 * @param phTimer Where to store the timer handle on success.
877 * @thread EMT
878 *
879 * @todo Need to add a bunch of timer helpers for this to be useful again.
880 * Will do when required.
881 */
882 DECLR3CALLBACKMEMBER(int, pfnTimerCreate,(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser,
883 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer));
884
885 /**
886 * Destroys a timer.
887 *
888 * @returns VBox status.
889 * @param pDrvIns Driver instance.
890 * @param hTimer The timer handle to destroy.
891 */
892 DECLR3CALLBACKMEMBER(int, pfnTimerDestroy,(PPDMDRVINS pDrvIns, TMTIMERHANDLE hTimer));
893
894 /**
895 * Register a save state data unit.
896 *
897 * @returns VBox status.
898 * @param pDrvIns Driver instance.
899 * @param uVersion Data layout version number.
900 * @param cbGuess The approximate amount of data in the unit.
901 * Only for progress indicators.
902 *
903 * @param pfnLivePrep Prepare live save callback, optional.
904 * @param pfnLiveExec Execute live save callback, optional.
905 * @param pfnLiveVote Vote live save callback, optional.
906 *
907 * @param pfnSavePrep Prepare save callback, optional.
908 * @param pfnSaveExec Execute save callback, optional.
909 * @param pfnSaveDone Done save callback, optional.
910 *
911 * @param pfnLoadPrep Prepare load callback, optional.
912 * @param pfnLoadExec Execute load callback, optional.
913 * @param pfnLoadDone Done load callback, optional.
914 */
915 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
916 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
917 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
918 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone));
919
920 /**
921 * Deregister a save state data unit.
922 *
923 * @returns VBox status.
924 * @param pDrvIns Driver instance.
925 * @param pszName Data unit name.
926 * @param uInstance The instance identifier of the data unit.
927 * This must together with the name be unique.
928 */
929 DECLR3CALLBACKMEMBER(int, pfnSSMDeregister,(PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance));
930
931 /** @name Exported SSM Functions
932 * @{ */
933 DECLR3CALLBACKMEMBER(int, pfnSSMPutStruct,(PSSMHANDLE pSSM, const void *pvStruct, PCSSMFIELD paFields));
934 DECLR3CALLBACKMEMBER(int, pfnSSMPutStructEx,(PSSMHANDLE pSSM, const void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
935 DECLR3CALLBACKMEMBER(int, pfnSSMPutBool,(PSSMHANDLE pSSM, bool fBool));
936 DECLR3CALLBACKMEMBER(int, pfnSSMPutU8,(PSSMHANDLE pSSM, uint8_t u8));
937 DECLR3CALLBACKMEMBER(int, pfnSSMPutS8,(PSSMHANDLE pSSM, int8_t i8));
938 DECLR3CALLBACKMEMBER(int, pfnSSMPutU16,(PSSMHANDLE pSSM, uint16_t u16));
939 DECLR3CALLBACKMEMBER(int, pfnSSMPutS16,(PSSMHANDLE pSSM, int16_t i16));
940 DECLR3CALLBACKMEMBER(int, pfnSSMPutU32,(PSSMHANDLE pSSM, uint32_t u32));
941 DECLR3CALLBACKMEMBER(int, pfnSSMPutS32,(PSSMHANDLE pSSM, int32_t i32));
942 DECLR3CALLBACKMEMBER(int, pfnSSMPutU64,(PSSMHANDLE pSSM, uint64_t u64));
943 DECLR3CALLBACKMEMBER(int, pfnSSMPutS64,(PSSMHANDLE pSSM, int64_t i64));
944 DECLR3CALLBACKMEMBER(int, pfnSSMPutU128,(PSSMHANDLE pSSM, uint128_t u128));
945 DECLR3CALLBACKMEMBER(int, pfnSSMPutS128,(PSSMHANDLE pSSM, int128_t i128));
946 DECLR3CALLBACKMEMBER(int, pfnSSMPutUInt,(PSSMHANDLE pSSM, RTUINT u));
947 DECLR3CALLBACKMEMBER(int, pfnSSMPutSInt,(PSSMHANDLE pSSM, RTINT i));
948 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUInt,(PSSMHANDLE pSSM, RTGCUINT u));
949 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntReg,(PSSMHANDLE pSSM, RTGCUINTREG u));
950 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys32,(PSSMHANDLE pSSM, RTGCPHYS32 GCPhys));
951 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys64,(PSSMHANDLE pSSM, RTGCPHYS64 GCPhys));
952 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPhys,(PSSMHANDLE pSSM, RTGCPHYS GCPhys));
953 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCPtr,(PSSMHANDLE pSSM, RTGCPTR GCPtr));
954 DECLR3CALLBACKMEMBER(int, pfnSSMPutGCUIntPtr,(PSSMHANDLE pSSM, RTGCUINTPTR GCPtr));
955 DECLR3CALLBACKMEMBER(int, pfnSSMPutRCPtr,(PSSMHANDLE pSSM, RTRCPTR RCPtr));
956 DECLR3CALLBACKMEMBER(int, pfnSSMPutIOPort,(PSSMHANDLE pSSM, RTIOPORT IOPort));
957 DECLR3CALLBACKMEMBER(int, pfnSSMPutSel,(PSSMHANDLE pSSM, RTSEL Sel));
958 DECLR3CALLBACKMEMBER(int, pfnSSMPutMem,(PSSMHANDLE pSSM, const void *pv, size_t cb));
959 DECLR3CALLBACKMEMBER(int, pfnSSMPutStrZ,(PSSMHANDLE pSSM, const char *psz));
960 DECLR3CALLBACKMEMBER(int, pfnSSMGetStruct,(PSSMHANDLE pSSM, void *pvStruct, PCSSMFIELD paFields));
961 DECLR3CALLBACKMEMBER(int, pfnSSMGetStructEx,(PSSMHANDLE pSSM, void *pvStruct, size_t cbStruct, uint32_t fFlags, PCSSMFIELD paFields, void *pvUser));
962 DECLR3CALLBACKMEMBER(int, pfnSSMGetBool,(PSSMHANDLE pSSM, bool *pfBool));
963 DECLR3CALLBACKMEMBER(int, pfnSSMGetBoolV,(PSSMHANDLE pSSM, bool volatile *pfBool));
964 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8,(PSSMHANDLE pSSM, uint8_t *pu8));
965 DECLR3CALLBACKMEMBER(int, pfnSSMGetU8V,(PSSMHANDLE pSSM, uint8_t volatile *pu8));
966 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8,(PSSMHANDLE pSSM, int8_t *pi8));
967 DECLR3CALLBACKMEMBER(int, pfnSSMGetS8V,(PSSMHANDLE pSSM, int8_t volatile *pi8));
968 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16,(PSSMHANDLE pSSM, uint16_t *pu16));
969 DECLR3CALLBACKMEMBER(int, pfnSSMGetU16V,(PSSMHANDLE pSSM, uint16_t volatile *pu16));
970 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16,(PSSMHANDLE pSSM, int16_t *pi16));
971 DECLR3CALLBACKMEMBER(int, pfnSSMGetS16V,(PSSMHANDLE pSSM, int16_t volatile *pi16));
972 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32,(PSSMHANDLE pSSM, uint32_t *pu32));
973 DECLR3CALLBACKMEMBER(int, pfnSSMGetU32V,(PSSMHANDLE pSSM, uint32_t volatile *pu32));
974 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32,(PSSMHANDLE pSSM, int32_t *pi32));
975 DECLR3CALLBACKMEMBER(int, pfnSSMGetS32V,(PSSMHANDLE pSSM, int32_t volatile *pi32));
976 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64,(PSSMHANDLE pSSM, uint64_t *pu64));
977 DECLR3CALLBACKMEMBER(int, pfnSSMGetU64V,(PSSMHANDLE pSSM, uint64_t volatile *pu64));
978 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64,(PSSMHANDLE pSSM, int64_t *pi64));
979 DECLR3CALLBACKMEMBER(int, pfnSSMGetS64V,(PSSMHANDLE pSSM, int64_t volatile *pi64));
980 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128,(PSSMHANDLE pSSM, uint128_t *pu128));
981 DECLR3CALLBACKMEMBER(int, pfnSSMGetU128V,(PSSMHANDLE pSSM, uint128_t volatile *pu128));
982 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128,(PSSMHANDLE pSSM, int128_t *pi128));
983 DECLR3CALLBACKMEMBER(int, pfnSSMGetS128V,(PSSMHANDLE pSSM, int128_t volatile *pi128));
984 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32,(PSSMHANDLE pSSM, PRTGCPHYS32 pGCPhys));
985 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys32V,(PSSMHANDLE pSSM, RTGCPHYS32 volatile *pGCPhys));
986 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64,(PSSMHANDLE pSSM, PRTGCPHYS64 pGCPhys));
987 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys64V,(PSSMHANDLE pSSM, RTGCPHYS64 volatile *pGCPhys));
988 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhys,(PSSMHANDLE pSSM, PRTGCPHYS pGCPhys));
989 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPhysV,(PSSMHANDLE pSSM, RTGCPHYS volatile *pGCPhys));
990 DECLR3CALLBACKMEMBER(int, pfnSSMGetUInt,(PSSMHANDLE pSSM, PRTUINT pu));
991 DECLR3CALLBACKMEMBER(int, pfnSSMGetSInt,(PSSMHANDLE pSSM, PRTINT pi));
992 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUInt,(PSSMHANDLE pSSM, PRTGCUINT pu));
993 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntReg,(PSSMHANDLE pSSM, PRTGCUINTREG pu));
994 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCPtr,(PSSMHANDLE pSSM, PRTGCPTR pGCPtr));
995 DECLR3CALLBACKMEMBER(int, pfnSSMGetGCUIntPtr,(PSSMHANDLE pSSM, PRTGCUINTPTR pGCPtr));
996 DECLR3CALLBACKMEMBER(int, pfnSSMGetRCPtr,(PSSMHANDLE pSSM, PRTRCPTR pRCPtr));
997 DECLR3CALLBACKMEMBER(int, pfnSSMGetIOPort,(PSSMHANDLE pSSM, PRTIOPORT pIOPort));
998 DECLR3CALLBACKMEMBER(int, pfnSSMGetSel,(PSSMHANDLE pSSM, PRTSEL pSel));
999 DECLR3CALLBACKMEMBER(int, pfnSSMGetMem,(PSSMHANDLE pSSM, void *pv, size_t cb));
1000 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZ,(PSSMHANDLE pSSM, char *psz, size_t cbMax));
1001 DECLR3CALLBACKMEMBER(int, pfnSSMGetStrZEx,(PSSMHANDLE pSSM, char *psz, size_t cbMax, size_t *pcbStr));
1002 DECLR3CALLBACKMEMBER(int, pfnSSMSkip,(PSSMHANDLE pSSM, size_t cb));
1003 DECLR3CALLBACKMEMBER(int, pfnSSMSkipToEndOfUnit,(PSSMHANDLE pSSM));
1004 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadError,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
1005 DECLR3CALLBACKMEMBER(int, pfnSSMSetLoadErrorV,(PSSMHANDLE pSSM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
1006 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgError,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(5, 6));
1007 DECLR3CALLBACKMEMBER(int, pfnSSMSetCfgErrorV,(PSSMHANDLE pSSM, RT_SRC_POS_DECL, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(5, 0));
1008 DECLR3CALLBACKMEMBER(int, pfnSSMHandleGetStatus,(PSSMHANDLE pSSM));
1009 DECLR3CALLBACKMEMBER(SSMAFTER, pfnSSMHandleGetAfter,(PSSMHANDLE pSSM));
1010 DECLR3CALLBACKMEMBER(bool, pfnSSMHandleIsLiveSave,(PSSMHANDLE pSSM));
1011 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleMaxDowntime,(PSSMHANDLE pSSM));
1012 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleHostBits,(PSSMHANDLE pSSM));
1013 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleRevision,(PSSMHANDLE pSSM));
1014 DECLR3CALLBACKMEMBER(uint32_t, pfnSSMHandleVersion,(PSSMHANDLE pSSM));
1015 DECLR3CALLBACKMEMBER(const char *, pfnSSMHandleHostOSAndArch,(PSSMHANDLE pSSM));
1016 /** @} */
1017
1018 /** @name Exported CFGM Functions.
1019 * @{ */
1020 DECLR3CALLBACKMEMBER(bool, pfnCFGMExists,( PCFGMNODE pNode, const char *pszName));
1021 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryType,( PCFGMNODE pNode, const char *pszName, PCFGMVALUETYPE penmType));
1022 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySize,( PCFGMNODE pNode, const char *pszName, size_t *pcb));
1023 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryInteger,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
1024 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryIntegerDef,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
1025 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryString,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString));
1026 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringDef,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef));
1027 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPassword,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString));
1028 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPasswordDef,( PCFGMNODE pNode, const char *pszName, char *pszString, size_t cchString, const char *pszDef));
1029 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBytes,( PCFGMNODE pNode, const char *pszName, void *pvData, size_t cbData));
1030 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64));
1031 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU64Def,( PCFGMNODE pNode, const char *pszName, uint64_t *pu64, uint64_t u64Def));
1032 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64,( PCFGMNODE pNode, const char *pszName, int64_t *pi64));
1033 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS64Def,( PCFGMNODE pNode, const char *pszName, int64_t *pi64, int64_t i64Def));
1034 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32));
1035 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU32Def,( PCFGMNODE pNode, const char *pszName, uint32_t *pu32, uint32_t u32Def));
1036 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32,( PCFGMNODE pNode, const char *pszName, int32_t *pi32));
1037 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS32Def,( PCFGMNODE pNode, const char *pszName, int32_t *pi32, int32_t i32Def));
1038 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16));
1039 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU16Def,( PCFGMNODE pNode, const char *pszName, uint16_t *pu16, uint16_t u16Def));
1040 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16,( PCFGMNODE pNode, const char *pszName, int16_t *pi16));
1041 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS16Def,( PCFGMNODE pNode, const char *pszName, int16_t *pi16, int16_t i16Def));
1042 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8));
1043 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryU8Def,( PCFGMNODE pNode, const char *pszName, uint8_t *pu8, uint8_t u8Def));
1044 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8,( PCFGMNODE pNode, const char *pszName, int8_t *pi8));
1045 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryS8Def,( PCFGMNODE pNode, const char *pszName, int8_t *pi8, int8_t i8Def));
1046 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBool,( PCFGMNODE pNode, const char *pszName, bool *pf));
1047 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryBoolDef,( PCFGMNODE pNode, const char *pszName, bool *pf, bool fDef));
1048 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPort,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort));
1049 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPortDef,( PCFGMNODE pNode, const char *pszName, PRTIOPORT pPort, RTIOPORT PortDef));
1050 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUInt,( PCFGMNODE pNode, const char *pszName, unsigned int *pu));
1051 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryUIntDef,( PCFGMNODE pNode, const char *pszName, unsigned int *pu, unsigned int uDef));
1052 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySInt,( PCFGMNODE pNode, const char *pszName, signed int *pi));
1053 DECLR3CALLBACKMEMBER(int, pfnCFGMQuerySIntDef,( PCFGMNODE pNode, const char *pszName, signed int *pi, signed int iDef));
1054 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPtr,( PCFGMNODE pNode, const char *pszName, void **ppv));
1055 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryPtrDef,( PCFGMNODE pNode, const char *pszName, void **ppv, void *pvDef));
1056 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtr,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr));
1057 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrDef,( PCFGMNODE pNode, const char *pszName, PRTGCPTR pGCPtr, RTGCPTR GCPtrDef));
1058 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrU,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr));
1059 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrUDef,( PCFGMNODE pNode, const char *pszName, PRTGCUINTPTR pGCPtr, RTGCUINTPTR GCPtrDef));
1060 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrS,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr));
1061 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryGCPtrSDef,( PCFGMNODE pNode, const char *pszName, PRTGCINTPTR pGCPtr, RTGCINTPTR GCPtrDef));
1062 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAlloc,( PCFGMNODE pNode, const char *pszName, char **ppszString));
1063 DECLR3CALLBACKMEMBER(int, pfnCFGMQueryStringAllocDef,(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef));
1064 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetParent,(PCFGMNODE pNode));
1065 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChild,(PCFGMNODE pNode, const char *pszPath));
1066 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildF,(PCFGMNODE pNode, const char *pszPathFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3));
1067 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetChildFV,(PCFGMNODE pNode, const char *pszPathFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0));
1068 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetFirstChild,(PCFGMNODE pNode));
1069 DECLR3CALLBACKMEMBER(PCFGMNODE, pfnCFGMGetNextChild,(PCFGMNODE pCur));
1070 DECLR3CALLBACKMEMBER(int, pfnCFGMGetName,(PCFGMNODE pCur, char *pszName, size_t cchName));
1071 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetNameLen,(PCFGMNODE pCur));
1072 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreChildrenValid,(PCFGMNODE pNode, const char *pszzValid));
1073 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetFirstValue,(PCFGMNODE pCur));
1074 DECLR3CALLBACKMEMBER(PCFGMLEAF, pfnCFGMGetNextValue,(PCFGMLEAF pCur));
1075 DECLR3CALLBACKMEMBER(int, pfnCFGMGetValueName,(PCFGMLEAF pCur, char *pszName, size_t cchName));
1076 DECLR3CALLBACKMEMBER(size_t, pfnCFGMGetValueNameLen,(PCFGMLEAF pCur));
1077 DECLR3CALLBACKMEMBER(CFGMVALUETYPE, pfnCFGMGetValueType,(PCFGMLEAF pCur));
1078 DECLR3CALLBACKMEMBER(bool, pfnCFGMAreValuesValid,(PCFGMNODE pNode, const char *pszzValid));
1079 DECLR3CALLBACKMEMBER(int, pfnCFGMValidateConfig,(PCFGMNODE pNode, const char *pszNode,
1080 const char *pszValidValues, const char *pszValidNodes,
1081 const char *pszWho, uint32_t uInstance));
1082 /** @} */
1083
1084 /**
1085 * Free memory allocated with pfnMMHeapAlloc() and pfnMMHeapAllocZ().
1086 *
1087 * @param pDrvIns Driver instance.
1088 * @param pv Pointer to the memory to free.
1089 */
1090 DECLR3CALLBACKMEMBER(void, pfnMMHeapFree,(PPDMDRVINS pDrvIns, void *pv));
1091
1092 /**
1093 * Register an info handler with DBGF.
1094 *
1095 * @returns VBox status code.
1096 * @param pDrvIns Driver instance.
1097 * @param pszName Data unit name.
1098 * @param pszDesc The description of the info and any arguments
1099 * the handler may take.
1100 * @param pfnHandler The handler function to be called to display the
1101 * info.
1102 */
1103 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler));
1104
1105 /**
1106 * Register an info handler with DBGF, argv style.
1107 *
1108 * @returns VBox status code.
1109 * @param pDrvIns Driver instance.
1110 * @param pszName Data unit name.
1111 * @param pszDesc The description of the info and any arguments
1112 * the handler may take.
1113 * @param pfnHandler The handler function to be called to display the
1114 * info.
1115 */
1116 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegisterArgv,(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDRV pfnHandler));
1117
1118 /**
1119 * Deregister an info handler from DBGF.
1120 *
1121 * @returns VBox status code.
1122 * @param pDrvIns Driver instance.
1123 * @param pszName Data unit name.
1124 */
1125 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoDeregister,(PPDMDRVINS pDrvIns, const char *pszName));
1126
1127 /**
1128 * Registers a statistics sample if statistics are enabled.
1129 *
1130 * @param pDrvIns Driver instance.
1131 * @param pvSample Pointer to the sample.
1132 * @param enmType Sample type. This indicates what pvSample is pointing at.
1133 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
1134 * Further nesting is possible. If this does not start
1135 * with a '/', the default prefix will be prepended,
1136 * otherwise it will be used as-is.
1137 * @param enmUnit Sample unit.
1138 * @param pszDesc Sample description.
1139 */
1140 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName,
1141 STAMUNIT enmUnit, const char *pszDesc));
1142
1143 /**
1144 * Same as pfnSTAMRegister except that the name is specified in a
1145 * RTStrPrintf like fashion.
1146 *
1147 * @param pDrvIns Driver instance.
1148 * @param pvSample Pointer to the sample.
1149 * @param enmType Sample type. This indicates what pvSample is pointing at.
1150 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
1151 * @param enmUnit Sample unit.
1152 * @param pszDesc Sample description.
1153 * @param pszName The sample name format string. If this does not start
1154 * with a '/', the default prefix will be prepended,
1155 * otherwise it will be used as-is.
1156 * @param ... Arguments to the format string.
1157 */
1158 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1159 STAMUNIT enmUnit, const char *pszDesc,
1160 const char *pszName, ...) RT_IPRT_FORMAT_ATTR(7, 8));
1161
1162 /**
1163 * Same as pfnSTAMRegister except that the name is specified in a
1164 * RTStrPrintfV like fashion.
1165 *
1166 * @param pDrvIns Driver instance.
1167 * @param pvSample Pointer to the sample.
1168 * @param enmType Sample type. This indicates what pvSample is pointing at.
1169 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
1170 * @param enmUnit Sample unit.
1171 * @param pszDesc Sample description.
1172 * @param pszName The sample name format string. If this does not
1173 * start with a '/', the default prefix will be prepended,
1174 * otherwise it will be used as-is.
1175 * @param args Arguments to the format string.
1176 */
1177 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1178 STAMUNIT enmUnit, const char *pszDesc,
1179 const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0));
1180
1181 /**
1182 * Deregister a statistic item previously registered with pfnSTAMRegister,
1183 * pfnSTAMRegisterF or pfnSTAMRegisterV
1184 *
1185 * @returns VBox status.
1186 * @param pDrvIns Driver instance.
1187 * @param pvSample Pointer to the sample.
1188 */
1189 DECLR3CALLBACKMEMBER(int, pfnSTAMDeregister,(PPDMDRVINS pDrvIns, void *pvSample));
1190
1191 /**
1192 * Calls the HC R0 VMM entry point, in a safer but slower manner than
1193 * SUPR3CallVMMR0.
1194 *
1195 * When entering using this call the R0 components can call into the host kernel
1196 * (i.e. use the SUPR0 and RT APIs).
1197 *
1198 * See VMMR0Entry() for more details.
1199 *
1200 * @returns error code specific to uFunction.
1201 * @param pDrvIns The driver instance.
1202 * @param uOperation Operation to execute.
1203 * This is limited to services.
1204 * @param pvArg Pointer to argument structure or if cbArg is 0 just an value.
1205 * @param cbArg The size of the argument. This is used to copy whatever the argument
1206 * points at into a kernel buffer to avoid problems like the user page
1207 * being invalidated while we're executing the call.
1208 */
1209 DECLR3CALLBACKMEMBER(int, pfnSUPCallVMMR0Ex,(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg));
1210
1211 /**
1212 * Registers a USB HUB.
1213 *
1214 * @returns VBox status code.
1215 * @param pDrvIns The driver instance.
1216 * @param fVersions Indicates the kinds of USB devices that can be attached to this HUB.
1217 * @param cPorts The number of ports.
1218 * @param pUsbHubReg The hub callback structure that PDMUsb uses to interact with it.
1219 * @param ppUsbHubHlp The helper callback structure that the hub uses to talk to PDMUsb.
1220 *
1221 * @thread EMT.
1222 */
1223 DECLR3CALLBACKMEMBER(int, pfnUSBRegisterHub,(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp));
1224
1225 /**
1226 * Set up asynchronous handling of a suspend, reset or power off notification.
1227 *
1228 * This shall only be called when getting the notification. It must be called
1229 * for each one.
1230 *
1231 * @returns VBox status code.
1232 * @param pDrvIns The driver instance.
1233 * @param pfnAsyncNotify The callback.
1234 * @thread EMT(0)
1235 */
1236 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify));
1237
1238 /**
1239 * Notify EMT(0) that the driver has completed the asynchronous notification
1240 * handling.
1241 *
1242 * This can be called at any time, spurious calls will simply be ignored.
1243 *
1244 * @param pDrvIns The driver instance.
1245 * @thread Any
1246 */
1247 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDRVINS pDrvIns));
1248
1249 /**
1250 * Creates a PDM thread.
1251 *
1252 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
1253 * resuming, and destroying the thread as the VM state changes.
1254 *
1255 * @returns VBox status code.
1256 * @param pDrvIns The driver instance.
1257 * @param ppThread Where to store the thread 'handle'.
1258 * @param pvUser The user argument to the thread function.
1259 * @param pfnThread The thread function.
1260 * @param pfnWakeup The wakup callback. This is called on the EMT thread when
1261 * a state change is pending.
1262 * @param cbStack See RTThreadCreate.
1263 * @param enmType See RTThreadCreate.
1264 * @param pszName See RTThreadCreate.
1265 */
1266 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1267 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
1268
1269 /** @name Exported PDM Thread Functions
1270 * @{ */
1271 DECLR3CALLBACKMEMBER(int, pfnThreadDestroy,(PPDMTHREAD pThread, int *pRcThread));
1272 DECLR3CALLBACKMEMBER(int, pfnThreadIAmSuspending,(PPDMTHREAD pThread));
1273 DECLR3CALLBACKMEMBER(int, pfnThreadIAmRunning,(PPDMTHREAD pThread));
1274 DECLR3CALLBACKMEMBER(int, pfnThreadSleep,(PPDMTHREAD pThread, RTMSINTERVAL cMillies));
1275 DECLR3CALLBACKMEMBER(int, pfnThreadSuspend,(PPDMTHREAD pThread));
1276 DECLR3CALLBACKMEMBER(int, pfnThreadResume,(PPDMTHREAD pThread));
1277 /** @} */
1278
1279 /**
1280 * Creates an async completion template for a driver instance.
1281 *
1282 * The template is used when creating new completion tasks.
1283 *
1284 * @returns VBox status code.
1285 * @param pDrvIns The driver instance.
1286 * @param ppTemplate Where to store the template pointer on success.
1287 * @param pfnCompleted The completion callback routine.
1288 * @param pvTemplateUser Template user argument.
1289 * @param pszDesc Description.
1290 */
1291 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionTemplateCreate,(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1292 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
1293 const char *pszDesc));
1294
1295 /** @name Exported PDM Async Completion Functions
1296 * @{ */
1297 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionTemplateDestroy,(PPDMASYNCCOMPLETIONTEMPLATE pTemplate));
1298 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpCreateForFile,(PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
1299 const char *pszFilename, uint32_t fFlags,
1300 PPDMASYNCCOMPLETIONTEMPLATE pTemplate));
1301 DECLR3CALLBACKMEMBER(void, pfnAsyncCompletionEpClose,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint));
1302 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpGetSize,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t *pcbSize));
1303 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpSetSize,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t cbSize));
1304 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpSetBwMgr,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, const char *pszBwMgr));
1305 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpFlush,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, void *pvUser, PPPDMASYNCCOMPLETIONTASK ppTask));
1306 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpRead,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
1307 PCRTSGSEG paSegments, unsigned cSegments,
1308 size_t cbRead, void *pvUser,
1309 PPPDMASYNCCOMPLETIONTASK ppTask));
1310 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionEpWrite,(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
1311 PCRTSGSEG paSegments, unsigned cSegments,
1312 size_t cbWrite, void *pvUser,
1313 PPPDMASYNCCOMPLETIONTASK ppTask));
1314 /** @} */
1315
1316
1317 /**
1318 * Attaches a network filter driver to a named bandwidth group.
1319 *
1320 * @returns VBox status code.
1321 * @retval VERR_ALREADY_INITIALIZED if already attached to a group.
1322 * @param pDrvIns The driver instance.
1323 * @param pszBwGroup Name of the bandwidth group to attach to.
1324 * @param pFilter Pointer to the filter we attach.
1325 */
1326 DECLR3CALLBACKMEMBER(int, pfnNetShaperAttach,(PPDMDRVINS pDrvIns, const char *pszBwGroup, PPDMNSFILTER pFilter));
1327
1328 /**
1329 * Detaches a network filter driver from its current bandwidth group (if any).
1330 *
1331 * @returns VBox status code.
1332 * @param pDrvIns The driver instance.
1333 * @param pFilter Pointer to the filter we attach.
1334 */
1335 DECLR3CALLBACKMEMBER(int, pfnNetShaperDetach,(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter));
1336
1337 /**
1338 * Obtains bandwidth in a bandwidth group.
1339 *
1340 * @returns True if bandwidth was allocated, false if not.
1341 * @param pDrvIns The driver instance.
1342 * @param pFilter Pointer to the filter that allocates bandwidth.
1343 * @param cbTransfer Number of bytes to allocate.
1344 */
1345 DECLR3CALLBACKMEMBER(bool, pfnNetShaperAllocateBandwidth,(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter, size_t cbTransfer));
1346
1347 /**
1348 * Resolves the symbol for a raw-mode context interface.
1349 *
1350 * @returns VBox status code.
1351 * @param pDrvIns The driver instance.
1352 * @param pvInterface The interface structure.
1353 * @param cbInterface The size of the interface structure.
1354 * @param pszSymPrefix What to prefix the symbols in the list with before
1355 * resolving them. This must start with 'drv' and
1356 * contain the driver name.
1357 * @param pszSymList List of symbols corresponding to the interface.
1358 * There is generally a there is generally a define
1359 * holding this list associated with the interface
1360 * definition (INTERFACE_SYM_LIST). For more details
1361 * see PDMR3LdrGetInterfaceSymbols.
1362 * @thread EMT
1363 */
1364 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1365 const char *pszSymPrefix, const char *pszSymList));
1366
1367 /**
1368 * Resolves the symbol for a ring-0 context interface.
1369 *
1370 * @returns VBox status code.
1371 * @param pDrvIns The driver instance.
1372 * @param pvInterface The interface structure.
1373 * @param cbInterface The size of the interface structure.
1374 * @param pszSymPrefix What to prefix the symbols in the list with before
1375 * resolving them. This must start with 'drv' and
1376 * contain the driver name.
1377 * @param pszSymList List of symbols corresponding to the interface.
1378 * There is generally a there is generally a define
1379 * holding this list associated with the interface
1380 * definition (INTERFACE_SYM_LIST). For more details
1381 * see PDMR3LdrGetInterfaceSymbols.
1382 * @thread EMT
1383 */
1384 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1385 const char *pszSymPrefix, const char *pszSymList));
1386 /**
1387 * Initializes a PDM critical section.
1388 *
1389 * The PDM critical sections are derived from the IPRT critical sections, but
1390 * works in both RC and R0 as well as R3.
1391 *
1392 * @returns VBox status code.
1393 * @param pDrvIns The driver instance.
1394 * @param pCritSect Pointer to the critical section.
1395 * @param SRC_POS Use RT_SRC_POS.
1396 * @param pszName The base name of the critical section. Will be
1397 * mangeled with the instance number. For
1398 * statistics and lock validation.
1399 * @thread EMT
1400 */
1401 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszName));
1402
1403 /** @name Exported PDM Critical Section Functions
1404 * @{ */
1405 DECLR3CALLBACKMEMBER(bool, pfnCritSectYield,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
1406 DECLR3CALLBACKMEMBER(int, pfnCritSectEnter,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy));
1407 DECLR3CALLBACKMEMBER(int, pfnCritSectEnterDebug,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL));
1408 DECLR3CALLBACKMEMBER(int, pfnCritSectTryEnter,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
1409 DECLR3CALLBACKMEMBER(int, pfnCritSectTryEnterDebug,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL));
1410 DECLR3CALLBACKMEMBER(int, pfnCritSectLeave,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
1411 DECLR3CALLBACKMEMBER(bool, pfnCritSectIsOwner,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
1412 DECLR3CALLBACKMEMBER(bool, pfnCritSectIsInitialized,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
1413 DECLR3CALLBACKMEMBER(bool, pfnCritSectHasWaiters,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
1414 DECLR3CALLBACKMEMBER(uint32_t, pfnCritSectGetRecursion,(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect));
1415 DECLR3CALLBACKMEMBER(int, pfnCritSectScheduleExitEvent,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal));
1416 DECLR3CALLBACKMEMBER(int, pfnCritSectDelete,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect));
1417 /** @} */
1418
1419 /**
1420 * Call the ring-0 request handler routine of the driver.
1421 *
1422 * For this to work, the driver must be ring-0 enabled and export a request
1423 * handler function. The name of the function must be the driver name in the
1424 * PDMDRVREG struct prefixed with 'drvR0' and suffixed with 'ReqHandler'.
1425 * The driver name will be capitalized. It shall take the exact same
1426 * arguments as this function and be declared using PDMBOTHCBDECL. See
1427 * FNPDMDRVREQHANDLERR0.
1428 *
1429 * @returns VBox status code.
1430 * @retval VERR_SYMBOL_NOT_FOUND if the driver doesn't export the required
1431 * handler function.
1432 * @retval VERR_ACCESS_DENIED if the driver isn't ring-0 capable.
1433 *
1434 * @param pDrvIns The driver instance.
1435 * @param uOperation The operation to perform.
1436 * @param u64Arg 64-bit integer argument.
1437 * @thread Any
1438 */
1439 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg));
1440
1441 /**
1442 * Creates a block cache for a driver driver instance.
1443 *
1444 * @returns VBox status code.
1445 * @param pDrvIns The driver instance.
1446 * @param ppBlkCache Where to store the handle to the block cache.
1447 * @param pfnXferComplete The I/O transfer complete callback.
1448 * @param pfnXferEnqueue The I/O request enqueue callback.
1449 * @param pfnXferEnqueueDiscard The discard request enqueue callback.
1450 * @param pcszId Unique ID used to identify the user.
1451 */
1452 DECLR3CALLBACKMEMBER(int, pfnBlkCacheRetain, (PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
1453 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
1454 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
1455 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
1456 const char *pcszId));
1457
1458 /** @name Exported PDM Block Cache Functions
1459 * @{ */
1460 DECLR3CALLBACKMEMBER(void, pfnBlkCacheRelease,(PPDMBLKCACHE pBlkCache));
1461 DECLR3CALLBACKMEMBER(int, pfnBlkCacheClear,(PPDMBLKCACHE pBlkCache));
1462 DECLR3CALLBACKMEMBER(int, pfnBlkCacheSuspend,(PPDMBLKCACHE pBlkCache));
1463 DECLR3CALLBACKMEMBER(int, pfnBlkCacheResume,(PPDMBLKCACHE pBlkCache));
1464 DECLR3CALLBACKMEMBER(void, pfnBlkCacheIoXferComplete,(PPDMBLKCACHE pBlkCache, PPDMBLKCACHEIOXFER hIoXfer, int rcIoXfer));
1465 DECLR3CALLBACKMEMBER(int, pfnBlkCacheRead,(PPDMBLKCACHE pBlkCache, uint64_t off, PCRTSGBUF pSgBuf, size_t cbRead, void *pvUser));
1466 DECLR3CALLBACKMEMBER(int, pfnBlkCacheWrite,(PPDMBLKCACHE pBlkCache, uint64_t off, PCRTSGBUF pSgBuf, size_t cbRead, void *pvUser));
1467 DECLR3CALLBACKMEMBER(int, pfnBlkCacheFlush,(PPDMBLKCACHE pBlkCache, void *pvUser));
1468 DECLR3CALLBACKMEMBER(int, pfnBlkCacheDiscard,(PPDMBLKCACHE pBlkCache, PCRTRANGE paRanges, unsigned cRanges, void *pvUser));
1469 /** @} */
1470
1471 /**
1472 * Gets the reason for the most recent VM suspend.
1473 *
1474 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
1475 * suspend has been made or if the pDrvIns is invalid.
1476 * @param pDrvIns The driver instance.
1477 */
1478 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDRVINS pDrvIns));
1479
1480 /**
1481 * Gets the reason for the most recent VM resume.
1482 *
1483 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
1484 * resume has been made or if the pDrvIns is invalid.
1485 * @param pDrvIns The driver instance.
1486 */
1487 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDRVINS pDrvIns));
1488
1489 /** @name Space reserved for minor interface changes.
1490 * @{ */
1491 DECLR3CALLBACKMEMBER(int, pfnTimerSetMillies,(PPDMDRVINS pDrvIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext));
1492
1493 /**
1494 * Deregister zero or more samples given their name prefix.
1495 *
1496 * @returns VBox status code.
1497 * @param pDrvIns The driver instance.
1498 * @param pszPrefix The name prefix of the samples to remove. If this does
1499 * not start with a '/', the default prefix will be
1500 * prepended, otherwise it will be used as-is.
1501 */
1502 DECLR3CALLBACKMEMBER(int, pfnSTAMDeregisterByPrefix,(PPDMDRVINS pDrvIns, const char *pszPrefix));
1503
1504 /**
1505 * Queries a generic object from the VMM user.
1506 *
1507 * @returns Pointer to the object if found, NULL if not.
1508 * @param pDrvIns The driver instance.
1509 * @param pUuid The UUID of what's being queried. The UUIDs and
1510 * the usage conventions are defined by the user.
1511 */
1512 DECLR3CALLBACKMEMBER(void *, pfnQueryGenericUserObject,(PPDMDRVINS pDrvIns, PCRTUUID pUuid));
1513
1514 DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMDRVINS pDrvIns));
1515 DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMDRVINS pDrvIns));
1516 DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMDRVINS pDrvIns));
1517 DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMDRVINS pDrvIns));
1518 DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMDRVINS pDrvIns));
1519 DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMDRVINS pDrvIns));
1520 DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMDRVINS pDrvIns));
1521 DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMDRVINS pDrvIns));
1522 DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMDRVINS pDrvIns));
1523 /** @} */
1524
1525 /** Just a safety precaution. */
1526 uint32_t u32TheEnd;
1527} PDMDRVHLPR3;
1528/** Current DRVHLP version number. */
1529#define PDM_DRVHLPR3_VERSION PDM_VERSION_MAKE(0xf0fb, 15, 0)
1530
1531
1532/**
1533 * Set the VM error message
1534 *
1535 * @returns rc.
1536 * @param pDrvIns Driver instance.
1537 * @param rc VBox status code.
1538 * @param SRC_POS Use RT_SRC_POS.
1539 * @param pszFormat Error message format string.
1540 * @param ... Error message arguments.
1541 * @sa PDMDRV_SET_ERROR, PDMDrvHlpVMSetErrorV, VMSetError
1542 */
1543DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDrvHlpVMSetError(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL,
1544 const char *pszFormat, ...)
1545{
1546 va_list va;
1547 va_start(va, pszFormat);
1548 pDrvIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1549 va_end(va);
1550 return rc;
1551}
1552
1553/** @def PDMDRV_SET_ERROR
1554 * Set the VM error. See PDMDrvHlpVMSetError() for printf like message formatting.
1555 */
1556#define PDMDRV_SET_ERROR(pDrvIns, rc, pszError) \
1557 PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, "%s", pszError)
1558
1559/**
1560 * @copydoc PDMDRVHLPR3::pfnVMSetErrorV
1561 */
1562DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 0) PDMDrvHlpVMSetErrorV(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL,
1563 const char *pszFormat, va_list va)
1564{
1565 return pDrvIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1566}
1567
1568
1569/**
1570 * Set the VM runtime error message
1571 *
1572 * @returns VBox status code.
1573 * @param pDrvIns Driver instance.
1574 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
1575 * @param pszErrorId Error ID string.
1576 * @param pszFormat Error message format string.
1577 * @param ... Error message arguments.
1578 * @sa PDMDRV_SET_RUNTIME_ERROR, PDMDrvHlpVMSetRuntimeErrorV,
1579 * VMSetRuntimeError
1580 */
1581DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 5) PDMDrvHlpVMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
1582 const char *pszFormat, ...)
1583{
1584 va_list va;
1585 int rc;
1586 va_start(va, pszFormat);
1587 rc = pDrvIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
1588 va_end(va);
1589 return rc;
1590}
1591
1592/** @def PDMDRV_SET_RUNTIME_ERROR
1593 * Set the VM runtime error. See PDMDrvHlpVMSetRuntimeError() for printf like message formatting.
1594 */
1595#define PDMDRV_SET_RUNTIME_ERROR(pDrvIns, fFlags, pszErrorId, pszError) \
1596 PDMDrvHlpVMSetRuntimeError(pDrvIns, fFlags, pszErrorId, "%s", pszError)
1597
1598/**
1599 * @copydoc PDMDRVHLPR3::pfnVMSetRuntimeErrorV
1600 */
1601DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 0) PDMDrvHlpVMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags,
1602 const char *pszErrorId, const char *pszFormat, va_list va)
1603{
1604 return pDrvIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
1605}
1606
1607#endif /* IN_RING3 */
1608
1609/** @def PDMDRV_ASSERT_EMT
1610 * Assert that the current thread is the emulation thread.
1611 */
1612#ifdef VBOX_STRICT
1613# define PDMDRV_ASSERT_EMT(pDrvIns) pDrvIns->CTX_SUFF(pHlp)->pfnAssertEMT(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1614#else
1615# define PDMDRV_ASSERT_EMT(pDrvIns) do { } while (0)
1616#endif
1617
1618/** @def PDMDRV_ASSERT_OTHER
1619 * Assert that the current thread is NOT the emulation thread.
1620 */
1621#ifdef VBOX_STRICT
1622# define PDMDRV_ASSERT_OTHER(pDrvIns) pDrvIns->CTX_SUFF(pHlp)->pfnAssertOther(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1623#else
1624# define PDMDRV_ASSERT_OTHER(pDrvIns) do { } while (0)
1625#endif
1626
1627
1628#ifdef IN_RING3
1629
1630/**
1631 * @copydoc PDMDRVHLPR3::pfnAttach
1632 */
1633DECLINLINE(int) PDMDrvHlpAttach(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface)
1634{
1635 return pDrvIns->pHlpR3->pfnAttach(pDrvIns, fFlags, ppBaseInterface);
1636}
1637
1638/**
1639 * Check that there is no driver below the us that we should attach to.
1640 *
1641 * @returns VERR_PDM_NO_ATTACHED_DRIVER if there is no driver.
1642 * @param pDrvIns The driver instance.
1643 */
1644DECLINLINE(int) PDMDrvHlpNoAttach(PPDMDRVINS pDrvIns)
1645{
1646 return pDrvIns->pHlpR3->pfnAttach(pDrvIns, 0, NULL);
1647}
1648
1649/**
1650 * @copydoc PDMDRVHLPR3::pfnDetach
1651 */
1652DECLINLINE(int) PDMDrvHlpDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1653{
1654 return pDrvIns->pHlpR3->pfnDetach(pDrvIns, fFlags);
1655}
1656
1657/**
1658 * @copydoc PDMDRVHLPR3::pfnDetachSelf
1659 */
1660DECLINLINE(int) PDMDrvHlpDetachSelf(PPDMDRVINS pDrvIns, uint32_t fFlags)
1661{
1662 return pDrvIns->pHlpR3->pfnDetachSelf(pDrvIns, fFlags);
1663}
1664
1665/**
1666 * @copydoc PDMDRVHLPR3::pfnMountPrepare
1667 */
1668DECLINLINE(int) PDMDrvHlpMountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver)
1669{
1670 return pDrvIns->pHlpR3->pfnMountPrepare(pDrvIns, pszFilename, pszCoreDriver);
1671}
1672
1673/**
1674 * @copydoc PDMDRVHLPR3::pfnVMState
1675 */
1676DECLINLINE(VMSTATE) PDMDrvHlpVMState(PPDMDRVINS pDrvIns)
1677{
1678 return pDrvIns->CTX_SUFF(pHlp)->pfnVMState(pDrvIns);
1679}
1680
1681/**
1682 * @copydoc PDMDRVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
1683 */
1684DECLINLINE(bool) PDMDrvHlpVMTeleportedAndNotFullyResumedYet(PPDMDRVINS pDrvIns)
1685{
1686 return pDrvIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDrvIns);
1687}
1688
1689/**
1690 * @copydoc PDMDRVHLPR3::pfnGetSupDrvSession
1691 */
1692DECLINLINE(PSUPDRVSESSION) PDMDrvHlpGetSupDrvSession(PPDMDRVINS pDrvIns)
1693{
1694 return pDrvIns->pHlpR3->pfnGetSupDrvSession(pDrvIns);
1695}
1696
1697/**
1698 * @copydoc PDMDRVHLPR3::pfnQueueCreate
1699 */
1700DECLINLINE(int) PDMDrvHlpQueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
1701 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PDMQUEUEHANDLE *phQueue)
1702{
1703 return pDrvIns->pHlpR3->pfnQueueCreate(pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, phQueue);
1704}
1705
1706/**
1707 * @copydoc PDMDRVHLPR3::pfnQueueAlloc
1708 */
1709DECLINLINE(PPDMQUEUEITEMCORE) PDMDrvHlpQueueAlloc(PPDMDRVINS pDrvIns, PDMQUEUEHANDLE hQueue)
1710{
1711 return pDrvIns->CTX_SUFF(pHlp)->pfnQueueAlloc(pDrvIns, hQueue);
1712}
1713
1714/**
1715 * @copydoc PDMDRVHLPR3::pfnQueueInsert
1716 */
1717DECLINLINE(int) PDMDrvHlpQueueInsert(PPDMDRVINS pDrvIns, PDMQUEUEHANDLE hQueue, PPDMQUEUEITEMCORE pItem)
1718{
1719 return pDrvIns->CTX_SUFF(pHlp)->pfnQueueInsert(pDrvIns, hQueue, pItem);
1720}
1721
1722/**
1723 * @copydoc PDMDRVHLPR3::pfnQueueFlushIfNecessary
1724 */
1725DECLINLINE(bool) PDMDrvHlpQueueFlushIfNecessary(PPDMDRVINS pDrvIns, PDMQUEUEHANDLE hQueue)
1726{
1727 return pDrvIns->CTX_SUFF(pHlp)->pfnQueueFlushIfNecessary(pDrvIns, hQueue);
1728}
1729
1730/**
1731 * @copydoc PDMDRVHLPR3::pfnTMGetVirtualFreq
1732 */
1733DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualFreq(PPDMDRVINS pDrvIns)
1734{
1735 return pDrvIns->pHlpR3->pfnTMGetVirtualFreq(pDrvIns);
1736}
1737
1738/**
1739 * @copydoc PDMDRVHLPR3::pfnTMGetVirtualTime
1740 */
1741DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualTime(PPDMDRVINS pDrvIns)
1742{
1743 return pDrvIns->pHlpR3->pfnTMGetVirtualTime(pDrvIns);
1744}
1745
1746/**
1747 * @copydoc PDMDRVHLPR3::pfnTimerCreate
1748 */
1749DECLINLINE(int) PDMDrvHlpTMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser,
1750 uint32_t fFlags, const char *pszDesc, PTMTIMERHANDLE phTimer)
1751
1752{
1753 return pDrvIns->pHlpR3->pfnTimerCreate(pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, phTimer);
1754}
1755
1756/**
1757 * @copydoc PDMDRVHLPR3::pfnTimerDestroy
1758 */
1759DECLINLINE(int) PDMDrvHlpTimerDestroy(PPDMDRVINS pDrvIns, TMTIMERHANDLE hTimer)
1760
1761{
1762 return pDrvIns->pHlpR3->pfnTimerDestroy(pDrvIns, hTimer);
1763}
1764
1765/**
1766 * @copydoc PDMDRVHLPR3::pfnTimerSetMillies
1767 */
1768DECLINLINE(int) PDMDrvHlpTimerSetMillies(PPDMDRVINS pDrvIns, TMTIMERHANDLE hTimer, uint64_t cMilliesToNext)
1769
1770{
1771 return pDrvIns->pHlpR3->pfnTimerSetMillies(pDrvIns, hTimer, cMilliesToNext);
1772}
1773
1774/**
1775 * Register a save state data unit.
1776 *
1777 * @returns VBox status.
1778 * @param pDrvIns Driver instance.
1779 * @param uVersion Data layout version number.
1780 * @param cbGuess The approximate amount of data in the unit.
1781 * Only for progress indicators.
1782 * @param pfnSaveExec Execute save callback, optional.
1783 * @param pfnLoadExec Execute load callback, optional.
1784 */
1785DECLINLINE(int) PDMDrvHlpSSMRegister(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1786 PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVLOADEXEC pfnLoadExec)
1787{
1788 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1789 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1790 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
1791 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
1792}
1793
1794/**
1795 * @copydoc PDMDRVHLPR3::pfnSSMRegister
1796 */
1797DECLINLINE(int) PDMDrvHlpSSMRegisterEx(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1798 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1799 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1800 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
1801{
1802 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1803 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1804 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1805 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1806}
1807
1808/**
1809 * Register a load done callback.
1810 *
1811 * @returns VBox status.
1812 * @param pDrvIns Driver instance.
1813 * @param pfnLoadDone Done load callback, optional.
1814 */
1815DECLINLINE(int) PDMDrvHlpSSMRegisterLoadDone(PPDMDRVINS pDrvIns, PFNSSMDRVLOADDONE pfnLoadDone)
1816{
1817 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, 0 /*uVersion*/, 0 /*cbGuess*/,
1818 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1819 NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/,
1820 NULL /*pfnLoadPrep*/, NULL /*pfnLoadExec*/, pfnLoadDone);
1821}
1822
1823/**
1824 * @copydoc PDMDRVHLPR3::pfnMMHeapFree
1825 */
1826DECLINLINE(void) PDMDrvHlpMMHeapFree(PPDMDRVINS pDrvIns, void *pv)
1827{
1828 pDrvIns->pHlpR3->pfnMMHeapFree(pDrvIns, pv);
1829}
1830
1831/**
1832 * @copydoc PDMDRVHLPR3::pfnDBGFInfoRegister
1833 */
1834DECLINLINE(int) PDMDrvHlpDBGFInfoRegister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1835{
1836 return pDrvIns->pHlpR3->pfnDBGFInfoRegister(pDrvIns, pszName, pszDesc, pfnHandler);
1837}
1838
1839/**
1840 * @copydoc PDMDRVHLPR3::pfnDBGFInfoRegisterArgv
1841 */
1842DECLINLINE(int) PDMDrvHlpDBGFInfoRegisterArgv(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDRV pfnHandler)
1843{
1844 return pDrvIns->pHlpR3->pfnDBGFInfoRegisterArgv(pDrvIns, pszName, pszDesc, pfnHandler);
1845}
1846
1847/**
1848 * @copydoc PDMDRVHLPR3::pfnDBGFInfoRegister
1849 */
1850DECLINLINE(int) PDMDrvHlpDBGFInfoDeregister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1851{
1852 return pDrvIns->pHlpR3->pfnDBGFInfoRegister(pDrvIns, pszName, pszDesc, pfnHandler);
1853}
1854
1855/**
1856 * @copydoc PDMDRVHLPR3::pfnSTAMRegister
1857 */
1858DECLINLINE(void) PDMDrvHlpSTAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1859{
1860 pDrvIns->pHlpR3->pfnSTAMRegister(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
1861}
1862
1863/**
1864 * @copydoc PDMDRVHLPR3::pfnSTAMRegisterF
1865 */
1866DECLINLINE(void) RT_IPRT_FORMAT_ATTR(7, 8) PDMDrvHlpSTAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType,
1867 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
1868 const char *pszDesc, const char *pszName, ...)
1869{
1870 va_list va;
1871 va_start(va, pszName);
1872 pDrvIns->pHlpR3->pfnSTAMRegisterV(pDrvIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
1873 va_end(va);
1874}
1875
1876/**
1877 * Convenience wrapper that registers counter which is always visible.
1878 *
1879 * @param pDrvIns The driver instance.
1880 * @param pCounter Pointer to the counter variable.
1881 * @param pszName The name of the sample. This is prefixed with
1882 * "/Drivers/<drivername>-<instance no>/".
1883 * @param enmUnit The unit.
1884 * @param pszDesc The description.
1885 */
1886DECLINLINE(void) PDMDrvHlpSTAMRegCounterEx(PPDMDRVINS pDrvIns, PSTAMCOUNTER pCounter, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1887{
1888 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pCounter, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1889 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1890}
1891
1892/**
1893 * Convenience wrapper that registers counter which is always visible and has
1894 * the STAMUNIT_COUNT unit.
1895 *
1896 * @param pDrvIns The driver instance.
1897 * @param pCounter Pointer to the counter variable.
1898 * @param pszName The name of the sample. This is prefixed with
1899 * "/Drivers/<drivername>-<instance no>/".
1900 * @param pszDesc The description.
1901 */
1902DECLINLINE(void) PDMDrvHlpSTAMRegCounter(PPDMDRVINS pDrvIns, PSTAMCOUNTER pCounter, const char *pszName, const char *pszDesc)
1903{
1904 PDMDrvHlpSTAMRegCounterEx(pDrvIns, pCounter, pszName, STAMUNIT_COUNT, pszDesc);
1905}
1906
1907/**
1908 * Convenience wrapper that registers profiling sample which is always visible.
1909 *
1910 * @param pDrvIns The driver instance.
1911 * @param pProfile Pointer to the profiling variable.
1912 * @param pszName The name of the sample. This is prefixed with
1913 * "/Drivers/<drivername>-<instance no>/".
1914 * @param enmUnit The unit.
1915 * @param pszDesc The description.
1916 */
1917DECLINLINE(void) PDMDrvHlpSTAMRegProfileEx(PPDMDRVINS pDrvIns, PSTAMPROFILE pProfile, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1918{
1919 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pProfile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1920 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1921}
1922
1923/**
1924 * Convenience wrapper that registers profiling sample which is always visible
1925 * hand counts ticks per call (STAMUNIT_TICKS_PER_CALL).
1926 *
1927 * @param pDrvIns The driver instance.
1928 * @param pProfile Pointer to the profiling variable.
1929 * @param pszName The name of the sample. This is prefixed with
1930 * "/Drivers/<drivername>-<instance no>/".
1931 * @param pszDesc The description.
1932 */
1933DECLINLINE(void) PDMDrvHlpSTAMRegProfile(PPDMDRVINS pDrvIns, PSTAMPROFILE pProfile, const char *pszName, const char *pszDesc)
1934{
1935 PDMDrvHlpSTAMRegProfileEx(pDrvIns, pProfile, pszName, STAMUNIT_TICKS_PER_CALL, pszDesc);
1936}
1937
1938/**
1939 * Convenience wrapper that registers an advanced profiling sample which is
1940 * always visible.
1941 *
1942 * @param pDrvIns The driver instance.
1943 * @param pProfile Pointer to the profiling variable.
1944 * @param enmUnit The unit.
1945 * @param pszName The name of the sample. This is prefixed with
1946 * "/Drivers/<drivername>-<instance no>/".
1947 * @param pszDesc The description.
1948 */
1949DECLINLINE(void) PDMDrvHlpSTAMRegProfileAdvEx(PPDMDRVINS pDrvIns, PSTAMPROFILEADV pProfile, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1950{
1951 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pProfile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1952 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1953}
1954
1955/**
1956 * Convenience wrapper that registers an advanced profiling sample which is
1957 * always visible.
1958 *
1959 * @param pDrvIns The driver instance.
1960 * @param pProfile Pointer to the profiling variable.
1961 * @param pszName The name of the sample. This is prefixed with
1962 * "/Drivers/<drivername>-<instance no>/".
1963 * @param pszDesc The description.
1964 */
1965DECLINLINE(void) PDMDrvHlpSTAMRegProfileAdv(PPDMDRVINS pDrvIns, PSTAMPROFILEADV pProfile, const char *pszName, const char *pszDesc)
1966{
1967 PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, pProfile, pszName, STAMUNIT_TICKS_PER_CALL, pszDesc);
1968}
1969
1970/**
1971 * @copydoc PDMDRVHLPR3::pfnSTAMDeregister
1972 */
1973DECLINLINE(int) PDMDrvHlpSTAMDeregister(PPDMDRVINS pDrvIns, void *pvSample)
1974{
1975 return pDrvIns->pHlpR3->pfnSTAMDeregister(pDrvIns, pvSample);
1976}
1977
1978/**
1979 * @copydoc PDMDRVHLPR3::pfnSTAMDeregisterByPrefix
1980 */
1981DECLINLINE(int) PDMDrvHlpSTAMDeregisterByPrefix(PPDMDRVINS pDrvIns, const char *pszPrefix)
1982{
1983 return pDrvIns->pHlpR3->pfnSTAMDeregisterByPrefix(pDrvIns, pszPrefix);
1984}
1985
1986/**
1987 * @copydoc PDMDRVHLPR3::pfnSUPCallVMMR0Ex
1988 */
1989DECLINLINE(int) PDMDrvHlpSUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg)
1990{
1991 return pDrvIns->pHlpR3->pfnSUPCallVMMR0Ex(pDrvIns, uOperation, pvArg, cbArg);
1992}
1993
1994/**
1995 * @copydoc PDMDRVHLPR3::pfnUSBRegisterHub
1996 */
1997DECLINLINE(int) PDMDrvHlpUSBRegisterHub(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp)
1998{
1999 return pDrvIns->pHlpR3->pfnUSBRegisterHub(pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp);
2000}
2001
2002/**
2003 * @copydoc PDMDRVHLPR3::pfnSetAsyncNotification
2004 */
2005DECLINLINE(int) PDMDrvHlpSetAsyncNotification(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
2006{
2007 return pDrvIns->pHlpR3->pfnSetAsyncNotification(pDrvIns, pfnAsyncNotify);
2008}
2009
2010/**
2011 * @copydoc PDMDRVHLPR3::pfnAsyncNotificationCompleted
2012 */
2013DECLINLINE(void) PDMDrvHlpAsyncNotificationCompleted(PPDMDRVINS pDrvIns)
2014{
2015 pDrvIns->pHlpR3->pfnAsyncNotificationCompleted(pDrvIns);
2016}
2017
2018/**
2019 * @copydoc PDMDRVHLPR3::pfnThreadCreate
2020 */
2021DECLINLINE(int) PDMDrvHlpThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
2022 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
2023{
2024 return pDrvIns->pHlpR3->pfnThreadCreate(pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
2025}
2026
2027/**
2028 * @copydoc PDMR3ThreadDestroy
2029 * @param pDrvIns The driver instance.
2030 */
2031DECLINLINE(int) PDMDrvHlpThreadDestroy(PPDMDRVINS pDrvIns, PPDMTHREAD pThread, int *pRcThread)
2032{
2033 return pDrvIns->pHlpR3->pfnThreadDestroy(pThread, pRcThread);
2034}
2035
2036/**
2037 * @copydoc PDMR3ThreadIAmSuspending
2038 * @param pDrvIns The driver instance.
2039 */
2040DECLINLINE(int) PDMDrvHlpThreadIAmSuspending(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
2041{
2042 return pDrvIns->pHlpR3->pfnThreadIAmSuspending(pThread);
2043}
2044
2045/**
2046 * @copydoc PDMR3ThreadIAmRunning
2047 * @param pDrvIns The driver instance.
2048 */
2049DECLINLINE(int) PDMDrvHlpThreadIAmRunning(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
2050{
2051 return pDrvIns->pHlpR3->pfnThreadIAmRunning(pThread);
2052}
2053
2054/**
2055 * @copydoc PDMR3ThreadSleep
2056 * @param pDrvIns The driver instance.
2057 */
2058DECLINLINE(int) PDMDrvHlpThreadSleep(PPDMDRVINS pDrvIns, PPDMTHREAD pThread, RTMSINTERVAL cMillies)
2059{
2060 return pDrvIns->pHlpR3->pfnThreadSleep(pThread, cMillies);
2061}
2062
2063/**
2064 * @copydoc PDMR3ThreadSuspend
2065 * @param pDrvIns The driver instance.
2066 */
2067DECLINLINE(int) PDMDrvHlpThreadSuspend(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
2068{
2069 return pDrvIns->pHlpR3->pfnThreadSuspend(pThread);
2070}
2071
2072/**
2073 * @copydoc PDMR3ThreadResume
2074 * @param pDrvIns The driver instance.
2075 */
2076DECLINLINE(int) PDMDrvHlpThreadResume(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
2077{
2078 return pDrvIns->pHlpR3->pfnThreadResume(pThread);
2079}
2080
2081# ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
2082/**
2083 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionTemplateCreate
2084 */
2085DECLINLINE(int) PDMDrvHlpAsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
2086 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc)
2087{
2088 return pDrvIns->pHlpR3->pfnAsyncCompletionTemplateCreate(pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
2089}
2090
2091/**
2092 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionTemplateDestroy
2093 */
2094DECLINLINE(int) PDMDrvHlpAsyncCompletionTemplateDestroy(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONTEMPLATE pTemplate)
2095{
2096 return pDrvIns->pHlpR3->pfnAsyncCompletionTemplateDestroy(pTemplate);
2097}
2098
2099/**
2100 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpCreateForFile
2101 */
2102DECLINLINE(int) PDMDrvHlpAsyncCompletionEpCreateForFile(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
2103 const char *pszFilename, uint32_t fFlags,
2104 PPDMASYNCCOMPLETIONTEMPLATE pTemplate)
2105{
2106 return pDrvIns->pHlpR3->pfnAsyncCompletionEpCreateForFile(ppEndpoint, pszFilename, fFlags, pTemplate);
2107}
2108
2109/**
2110 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpClose
2111 */
2112DECLINLINE(void) PDMDrvHlpAsyncCompletionEpClose(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint)
2113{
2114 pDrvIns->pHlpR3->pfnAsyncCompletionEpClose(pEndpoint);
2115}
2116
2117/**
2118 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpGetSize
2119 */
2120DECLINLINE(int) PDMDrvHlpAsyncCompletionEpGetSize(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t *pcbSize)
2121{
2122 return pDrvIns->pHlpR3->pfnAsyncCompletionEpGetSize(pEndpoint, pcbSize);
2123}
2124
2125/**
2126 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpSetSize
2127 */
2128DECLINLINE(int) PDMDrvHlpAsyncCompletionEpSetSize(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t cbSize)
2129{
2130 return pDrvIns->pHlpR3->pfnAsyncCompletionEpSetSize(pEndpoint, cbSize);
2131}
2132
2133/**
2134 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpSetBwMgr
2135 */
2136DECLINLINE(int) PDMDrvHlpAsyncCompletionEpSetBwMgr(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint, const char *pszBwMgr)
2137{
2138 return pDrvIns->pHlpR3->pfnAsyncCompletionEpSetBwMgr(pEndpoint, pszBwMgr);
2139}
2140
2141/**
2142 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpFlush
2143 */
2144DECLINLINE(int) PDMDrvHlpAsyncCompletionEpFlush(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint, void *pvUser,
2145 PPPDMASYNCCOMPLETIONTASK ppTask)
2146{
2147 return pDrvIns->pHlpR3->pfnAsyncCompletionEpFlush(pEndpoint, pvUser, ppTask);
2148}
2149
2150/**
2151 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpRead
2152 */
2153DECLINLINE(int) PDMDrvHlpAsyncCompletionEpRead(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
2154 PCRTSGSEG paSegments, unsigned cSegments,
2155 size_t cbRead, void *pvUser,
2156 PPPDMASYNCCOMPLETIONTASK ppTask)
2157{
2158 return pDrvIns->pHlpR3->pfnAsyncCompletionEpRead(pEndpoint, off, paSegments, cSegments, cbRead, pvUser, ppTask);
2159}
2160
2161/**
2162 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionEpWrite
2163 */
2164DECLINLINE(int) PDMDrvHlpAsyncCompletionEpWrite(PPDMDRVINS pDrvIns, PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
2165 PCRTSGSEG paSegments, unsigned cSegments,
2166 size_t cbWrite, void *pvUser,
2167 PPPDMASYNCCOMPLETIONTASK ppTask)
2168{
2169 return pDrvIns->pHlpR3->pfnAsyncCompletionEpWrite(pEndpoint, off, paSegments, cSegments, cbWrite, pvUser, ppTask);
2170}
2171# endif
2172
2173#endif /* IN_RING3 */
2174
2175#ifdef VBOX_WITH_NETSHAPER
2176# ifdef IN_RING3
2177
2178/**
2179 * @copydoc PDMDRVHLPR3::pfnNetShaperAttach
2180 */
2181DECLINLINE(int) PDMDrvHlpNetShaperAttach(PPDMDRVINS pDrvIns, const char *pcszBwGroup, PPDMNSFILTER pFilter)
2182{
2183 return pDrvIns->pHlpR3->pfnNetShaperAttach(pDrvIns, pcszBwGroup, pFilter);
2184}
2185
2186/**
2187 * @copydoc PDMDRVHLPR3::pfnNetShaperDetach
2188 */
2189DECLINLINE(int) PDMDrvHlpNetShaperDetach(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter)
2190{
2191 return pDrvIns->pHlpR3->pfnNetShaperDetach(pDrvIns, pFilter);
2192}
2193
2194# endif /* IN_RING3 */
2195
2196/**
2197 * @copydoc PDMDRVHLPR3::pfnNetShaperAllocateBandwidth
2198 */
2199DECLINLINE(bool) PDMDrvHlpNetShaperAllocateBandwidth(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter, size_t cbTransfer)
2200{
2201 return pDrvIns->CTX_SUFF(pHlp)->pfnNetShaperAllocateBandwidth(pDrvIns, pFilter, cbTransfer);
2202}
2203
2204#endif /* VBOX_WITH_NETSHAPER*/
2205
2206#ifdef IN_RING3
2207/**
2208 * @copydoc PDMDRVHLPR3::pfnCritSectInit
2209 */
2210DECLINLINE(int) PDMDrvHlpCritSectInit(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszName)
2211{
2212 return pDrvIns->pHlpR3->pfnCritSectInit(pDrvIns, pCritSect, RT_SRC_POS_ARGS, pszName);
2213}
2214#endif /* IN_RING3 */
2215
2216/**
2217 * @see PDMCritSectEnter
2218 */
2219DECLINLINE(int) PDMDrvHlpCritSectEnter(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy)
2220{
2221 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectEnter(pDrvIns, pCritSect, rcBusy);
2222}
2223
2224/**
2225 * @see PDMCritSectEnterDebug
2226 */
2227DECLINLINE(int) PDMDrvHlpCritSectEnterDebug(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, int rcBusy, RTHCUINTPTR uId, RT_SRC_POS_DECL)
2228{
2229 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectEnterDebug(pDrvIns, pCritSect, rcBusy, uId, RT_SRC_POS_ARGS);
2230}
2231
2232/**
2233 * @see PDMCritSectTryEnter
2234 */
2235DECLINLINE(int) PDMDrvHlpCritSectTryEnter(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect)
2236{
2237 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectTryEnter(pDrvIns, pCritSect);
2238}
2239
2240/**
2241 * @see PDMCritSectTryEnterDebug
2242 */
2243DECLINLINE(int) PDMDrvHlpCritSectTryEnterDebug(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL)
2244{
2245 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectTryEnterDebug(pDrvIns, pCritSect, uId, RT_SRC_POS_ARGS);
2246}
2247
2248/**
2249 * @see PDMCritSectLeave
2250 */
2251DECLINLINE(int) PDMDrvHlpCritSectLeave(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect)
2252{
2253 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectLeave(pDrvIns, pCritSect);
2254}
2255
2256/**
2257 * @see PDMCritSectIsOwner
2258 */
2259DECLINLINE(bool) PDMDrvHlpCritSectIsOwner(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect)
2260{
2261 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectIsOwner(pDrvIns, pCritSect);
2262}
2263
2264/**
2265 * @see PDMCritSectIsInitialized
2266 */
2267DECLINLINE(bool) PDMDrvHlpCritSectIsInitialized(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect)
2268{
2269 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectIsInitialized(pDrvIns, pCritSect);
2270}
2271
2272/**
2273 * @see PDMCritSectHasWaiters
2274 */
2275DECLINLINE(bool) PDMDrvHlpCritSectHasWaiters(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect)
2276{
2277 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectHasWaiters(pDrvIns, pCritSect);
2278}
2279
2280/**
2281 * @see PDMCritSectGetRecursion
2282 */
2283DECLINLINE(uint32_t) PDMDrvHlpCritSectGetRecursion(PPDMDRVINS pDrvIns, PCPDMCRITSECT pCritSect)
2284{
2285 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectGetRecursion(pDrvIns, pCritSect);
2286}
2287
2288#if defined(IN_RING3) || defined(IN_RING0)
2289/**
2290 * @see PDMHCCritSectScheduleExitEvent
2291 */
2292DECLINLINE(int) PDMDrvHlpCritSectScheduleExitEvent(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal)
2293{
2294 return pDrvIns->CTX_SUFF(pHlp)->pfnCritSectScheduleExitEvent(pDrvIns, pCritSect, hEventToSignal);
2295}
2296#endif
2297
2298/* Strict build: Remap the two enter calls to the debug versions. */
2299#ifdef VBOX_STRICT
2300# ifdef IPRT_INCLUDED_asm_h
2301# define PDMDrvHlpCritSectEnter(pDrvIns, pCritSect, rcBusy) PDMDrvHlpCritSectEnterDebug((pDrvIns), (pCritSect), (rcBusy), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
2302# define PDMDrvHlpCritSectTryEnter(pDrvIns, pCritSect) PDMDrvHlpCritSectTryEnterDebug((pDrvIns), (pCritSect), (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
2303# else
2304# define PDMDrvHlpCritSectEnter(pDrvIns, pCritSect, rcBusy) PDMDrvHlpCritSectEnterDebug((pDrvIns), (pCritSect), (rcBusy), 0, RT_SRC_POS)
2305# define PDMDrvHlpCritSectTryEnter(pDrvIns, pCritSect) PDMDrvHlpCritSectTryEnterDebug((pDrvIns), (pCritSect), 0, RT_SRC_POS)
2306# endif
2307#endif
2308
2309#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
2310
2311/**
2312 * @see PDMR3CritSectDelete
2313 */
2314DECLINLINE(int) PDMDrvHlpCritSectDelete(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect)
2315{
2316 return pDrvIns->pHlpR3->pfnCritSectDelete(pDrvIns, pCritSect);
2317}
2318
2319/**
2320 * @copydoc PDMDRVHLPR3::pfnCallR0
2321 */
2322DECLINLINE(int) PDMDrvHlpCallR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)
2323{
2324 return pDrvIns->pHlpR3->pfnCallR0(pDrvIns, uOperation, u64Arg);
2325}
2326
2327/**
2328 * @copydoc PDMDRVHLPR3::pfnBlkCacheRetain
2329 */
2330DECLINLINE(int) PDMDrvHlpBlkCacheRetain(PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
2331 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
2332 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
2333 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
2334 const char *pcszId)
2335{
2336 return pDrvIns->pHlpR3->pfnBlkCacheRetain(pDrvIns, ppBlkCache, pfnXferComplete, pfnXferEnqueue, pfnXferEnqueueDiscard, pcszId);
2337}
2338
2339/**
2340 * @copydoc PDMDRVHLPR3::pfnBlkCacheRelease
2341 */
2342DECLINLINE(void) PDMDrvHlpBlkCacheRelease(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache)
2343{
2344 pDrvIns->pHlpR3->pfnBlkCacheRelease(pBlkCache);
2345}
2346
2347/**
2348 * @copydoc PDMDRVHLPR3::pfnBlkCacheClear
2349 */
2350DECLINLINE(int) PDMDrvHlpBlkCacheClear(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache)
2351{
2352 return pDrvIns->pHlpR3->pfnBlkCacheClear(pBlkCache);
2353}
2354
2355/**
2356 * @copydoc PDMDRVHLPR3::pfnBlkCacheSuspend
2357 */
2358DECLINLINE(int) PDMDrvHlpBlkCacheSuspend(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache)
2359{
2360 return pDrvIns->pHlpR3->pfnBlkCacheSuspend(pBlkCache);
2361}
2362
2363/**
2364 * @copydoc PDMDRVHLPR3::pfnBlkCacheResume
2365 */
2366DECLINLINE(int) PDMDrvHlpBlkCacheResume(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache)
2367{
2368 return pDrvIns->pHlpR3->pfnBlkCacheResume(pBlkCache);
2369}
2370
2371/**
2372 * @copydoc PDMDRVHLPR3::pfnBlkCacheIoXferComplete
2373 */
2374DECLINLINE(void) PDMDrvHlpBlkCacheIoXferComplete(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache,
2375 PPDMBLKCACHEIOXFER hIoXfer, int rcIoXfer)
2376{
2377 pDrvIns->pHlpR3->pfnBlkCacheIoXferComplete(pBlkCache, hIoXfer, rcIoXfer);
2378}
2379
2380/**
2381 * @copydoc PDMDRVHLPR3::pfnBlkCacheRead
2382 */
2383DECLINLINE(int) PDMDrvHlpBlkCacheRead(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache, uint64_t off,
2384 PCRTSGBUF pSgBuf, size_t cbRead, void *pvUser)
2385{
2386 return pDrvIns->pHlpR3->pfnBlkCacheRead(pBlkCache, off, pSgBuf, cbRead, pvUser);
2387}
2388
2389/**
2390 * @copydoc PDMDRVHLPR3::pfnBlkCacheWrite
2391 */
2392DECLINLINE(int) PDMDrvHlpBlkCacheWrite(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache, uint64_t off,
2393 PCRTSGBUF pSgBuf, size_t cbRead, void *pvUser)
2394{
2395 return pDrvIns->pHlpR3->pfnBlkCacheWrite(pBlkCache, off, pSgBuf, cbRead, pvUser);
2396}
2397
2398/**
2399 * @copydoc PDMDRVHLPR3::pfnBlkCacheFlush
2400 */
2401DECLINLINE(int) PDMDrvHlpBlkCacheFlush(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache, void *pvUser)
2402{
2403 return pDrvIns->pHlpR3->pfnBlkCacheFlush(pBlkCache, pvUser);
2404}
2405
2406/**
2407 * @copydoc PDMDRVHLPR3::pfnBlkCacheDiscard
2408 */
2409DECLINLINE(int) PDMDrvHlpBlkCacheDiscard(PPDMDRVINS pDrvIns, PPDMBLKCACHE pBlkCache, PCRTRANGE paRanges,
2410 unsigned cRanges, void *pvUser)
2411{
2412 return pDrvIns->pHlpR3->pfnBlkCacheDiscard(pBlkCache, paRanges, cRanges, pvUser);
2413}
2414
2415/**
2416 * @copydoc PDMDRVHLPR3::pfnVMGetSuspendReason
2417 */
2418DECLINLINE(VMSUSPENDREASON) PDMDrvHlpVMGetSuspendReason(PPDMDRVINS pDrvIns)
2419{
2420 return pDrvIns->pHlpR3->pfnVMGetSuspendReason(pDrvIns);
2421}
2422
2423/**
2424 * @copydoc PDMDRVHLPR3::pfnVMGetResumeReason
2425 */
2426DECLINLINE(VMRESUMEREASON) PDMDrvHlpVMGetResumeReason(PPDMDRVINS pDrvIns)
2427{
2428 return pDrvIns->pHlpR3->pfnVMGetResumeReason(pDrvIns);
2429}
2430
2431/**
2432 * @copydoc PDMDRVHLPR3::pfnQueryGenericUserObject
2433 */
2434DECLINLINE(void *) PDMDrvHlpQueryGenericUserObject(PPDMDRVINS pDrvIns, PCRTUUID pUuid)
2435{
2436 return pDrvIns->pHlpR3->pfnQueryGenericUserObject(pDrvIns, pUuid);
2437}
2438
2439
2440/** Pointer to callbacks provided to the VBoxDriverRegister() call. */
2441typedef struct PDMDRVREGCB *PPDMDRVREGCB;
2442/** Pointer to const callbacks provided to the VBoxDriverRegister() call. */
2443typedef const struct PDMDRVREGCB *PCPDMDRVREGCB;
2444
2445/**
2446 * Callbacks for VBoxDriverRegister().
2447 */
2448typedef struct PDMDRVREGCB
2449{
2450 /** Interface version.
2451 * This is set to PDM_DRVREG_CB_VERSION. */
2452 uint32_t u32Version;
2453
2454 /**
2455 * Registers a driver with the current VM instance.
2456 *
2457 * @returns VBox status code.
2458 * @param pCallbacks Pointer to the callback table.
2459 * @param pReg Pointer to the driver registration record.
2460 * This data must be permanent and readonly.
2461 */
2462 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg));
2463} PDMDRVREGCB;
2464
2465/** Current version of the PDMDRVREGCB structure. */
2466#define PDM_DRVREG_CB_VERSION PDM_VERSION_MAKE(0xf0fa, 1, 0)
2467
2468
2469/**
2470 * The VBoxDriverRegister callback function.
2471 *
2472 * PDM will invoke this function after loading a driver module and letting
2473 * the module decide which drivers to register and how to handle conflicts.
2474 *
2475 * @returns VBox status code.
2476 * @param pCallbacks Pointer to the callback table.
2477 * @param u32Version VBox version number.
2478 */
2479typedef DECLCALLBACKTYPE(int, FNPDMVBOXDRIVERSREGISTER,(PCPDMDRVREGCB pCallbacks, uint32_t u32Version));
2480
2481VMMR3DECL(int) PDMR3DrvStaticRegistration(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback);
2482
2483#endif /* IN_RING3 */
2484
2485/** @} */
2486
2487RT_C_DECLS_END
2488
2489#endif /* !VBOX_INCLUDED_vmm_pdmdrv_h */
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