VirtualBox

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

Last change on this file since 97262 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

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