VirtualBox

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

Last change on this file since 76402 was 76401, checked in by vboxsync, 6 years ago

pdmdrv.h: header indent and ring-3-ness. bugref:9344

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 73.9 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Drivers.
3 */
4
5/*
6 * Copyright (C) 2006-2017 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_vmm_pdmdrv_h
27#define ___VBox_vmm_pdmdrv_h
28
29#include <VBox/vmm/pdmqueue.h>
30#include <VBox/vmm/pdmcritsect.h>
31#include <VBox/vmm/pdmifs.h>
32#include <VBox/vmm/pdmins.h>
33#include <VBox/vmm/pdmcommon.h>
34#ifdef IN_RING3
35# include <VBox/vmm/pdmthread.h>
36# include <VBox/vmm/pdmasynccompletion.h>
37# include <VBox/vmm/pdmblkcache.h>
38#endif
39#ifdef VBOX_WITH_NETSHAPER
40# include <VBox/vmm/pdmnetshaper.h>
41#endif
42#include <VBox/vmm/tm.h>
43#include <VBox/vmm/ssm.h>
44#include <VBox/vmm/cfgm.h>
45#include <VBox/vmm/dbgf.h>
46#include <VBox/vmm/mm.h>
47#include <VBox/vmm/ftm.h>
48#include <VBox/err.h>
49#include <iprt/stdarg.h>
50
51
52RT_C_DECLS_BEGIN
53
54/** @defgroup grp_pdm_driver The PDM Drivers API
55 * @ingroup grp_pdm
56 * @{
57 */
58
59/** Pointer const PDM Driver API, ring-3. */
60typedef R3PTRTYPE(struct PDMDRVHLPR3 const *) PCPDMDRVHLPR3;
61/** Pointer const PDM Driver API, ring-0. */
62typedef R0PTRTYPE(struct PDMDRVHLPR0 const *) PCPDMDRVHLPR0;
63/** Pointer const PDM Driver API, raw-mode context. */
64typedef RCPTRTYPE(struct PDMDRVHLPRC const *) PCPDMDRVHLPRC;
65
66
67/**
68 * Construct a driver instance for a VM.
69 *
70 * @returns VBox status.
71 * @param pDrvIns The driver instance data. If the registration structure
72 * is needed, it can be accessed thru pDrvIns->pReg.
73 * @param pCfg Configuration node handle for the driver. This is
74 * expected to be in high demand in the constructor and is
75 * therefore passed as an argument. When using it at other
76 * times, it can be accessed via pDrvIns->pCfg.
77 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
78 */
79typedef DECLCALLBACK(int) FNPDMDRVCONSTRUCT(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
80/** Pointer to a FNPDMDRVCONSTRUCT() function. */
81typedef FNPDMDRVCONSTRUCT *PFNPDMDRVCONSTRUCT;
82
83/**
84 * Destruct a driver instance.
85 *
86 * Most VM resources are freed by the VM. This callback is provided so that
87 * any non-VM resources can be freed correctly.
88 *
89 * @param pDrvIns The driver instance data.
90 */
91typedef DECLCALLBACK(void) FNPDMDRVDESTRUCT(PPDMDRVINS pDrvIns);
92/** Pointer to a FNPDMDRVDESTRUCT() function. */
93typedef FNPDMDRVDESTRUCT *PFNPDMDRVDESTRUCT;
94
95/**
96 * Driver relocation callback.
97 *
98 * This is called when the instance data has been relocated in raw-mode context
99 * (RC). It is also called when the RC hypervisor selects changes. The driver
100 * must fixup all necessary pointers and re-query all interfaces to other RC
101 * devices and drivers.
102 *
103 * Before the RC code is executed the first time, this function will be called
104 * with a 0 delta so RC pointer calculations can be one in one place.
105 *
106 * @param pDrvIns Pointer to the driver instance.
107 * @param offDelta The relocation delta relative to the old location.
108 *
109 * @remark A relocation CANNOT fail.
110 */
111typedef DECLCALLBACK(void) FNPDMDRVRELOCATE(PPDMDRVINS pDrvIns, RTGCINTPTR offDelta);
112/** Pointer to a FNPDMDRVRELOCATE() function. */
113typedef FNPDMDRVRELOCATE *PFNPDMDRVRELOCATE;
114
115/**
116 * Driver I/O Control interface.
117 *
118 * This is used by external components, such as the COM interface, to
119 * communicate with a driver using a driver specific interface. Generally,
120 * the driver interfaces are used for this task.
121 *
122 * @returns VBox status code.
123 * @param pDrvIns Pointer to the driver instance.
124 * @param uFunction Function to perform.
125 * @param pvIn Pointer to input data.
126 * @param cbIn Size of input data.
127 * @param pvOut Pointer to output data.
128 * @param cbOut Size of output data.
129 * @param pcbOut Where to store the actual size of the output data.
130 */
131typedef DECLCALLBACK(int) FNPDMDRVIOCTL(PPDMDRVINS pDrvIns, uint32_t uFunction,
132 void *pvIn, uint32_t cbIn,
133 void *pvOut, uint32_t cbOut, uint32_t *pcbOut);
134/** Pointer to a FNPDMDRVIOCTL() function. */
135typedef FNPDMDRVIOCTL *PFNPDMDRVIOCTL;
136
137/**
138 * Power On notification.
139 *
140 * @param pDrvIns The driver instance data.
141 */
142typedef DECLCALLBACK(void) FNPDMDRVPOWERON(PPDMDRVINS pDrvIns);
143/** Pointer to a FNPDMDRVPOWERON() function. */
144typedef FNPDMDRVPOWERON *PFNPDMDRVPOWERON;
145
146/**
147 * Reset notification.
148 *
149 * @returns VBox status.
150 * @param pDrvIns The driver instance data.
151 */
152typedef DECLCALLBACK(void) FNPDMDRVRESET(PPDMDRVINS pDrvIns);
153/** Pointer to a FNPDMDRVRESET() function. */
154typedef FNPDMDRVRESET *PFNPDMDRVRESET;
155
156/**
157 * Suspend notification.
158 *
159 * @returns VBox status.
160 * @param pDrvIns The driver instance data.
161 */
162typedef DECLCALLBACK(void) FNPDMDRVSUSPEND(PPDMDRVINS pDrvIns);
163/** Pointer to a FNPDMDRVSUSPEND() function. */
164typedef FNPDMDRVSUSPEND *PFNPDMDRVSUSPEND;
165
166/**
167 * Resume notification.
168 *
169 * @returns VBox status.
170 * @param pDrvIns The driver instance data.
171 */
172typedef DECLCALLBACK(void) FNPDMDRVRESUME(PPDMDRVINS pDrvIns);
173/** Pointer to a FNPDMDRVRESUME() function. */
174typedef FNPDMDRVRESUME *PFNPDMDRVRESUME;
175
176/**
177 * Power Off notification.
178 *
179 * This is always called when VMR3PowerOff is called.
180 * There will be no callback when hot plugging devices or when replumbing the driver
181 * stack.
182 *
183 * @param pDrvIns The driver instance data.
184 */
185typedef DECLCALLBACK(void) FNPDMDRVPOWEROFF(PPDMDRVINS pDrvIns);
186/** Pointer to a FNPDMDRVPOWEROFF() function. */
187typedef FNPDMDRVPOWEROFF *PFNPDMDRVPOWEROFF;
188
189/**
190 * Attach command.
191 *
192 * This is called to let the driver attach to a driver at runtime. This is not
193 * called during VM construction, the driver constructor have to do this by
194 * calling PDMDrvHlpAttach.
195 *
196 * This is like plugging in the keyboard or mouse after turning on the PC.
197 *
198 * @returns VBox status code.
199 * @param pDrvIns The driver instance.
200 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
201 */
202typedef DECLCALLBACK(int) FNPDMDRVATTACH(PPDMDRVINS pDrvIns, uint32_t fFlags);
203/** Pointer to a FNPDMDRVATTACH() function. */
204typedef FNPDMDRVATTACH *PFNPDMDRVATTACH;
205
206/**
207 * Detach notification.
208 *
209 * This is called when a driver below it in the chain is detaching itself
210 * from it. The driver should adjust it's state to reflect this.
211 *
212 * This is like ejecting a cdrom or floppy.
213 *
214 * @param pDrvIns The driver instance.
215 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
216 */
217typedef DECLCALLBACK(void) FNPDMDRVDETACH(PPDMDRVINS pDrvIns, uint32_t fFlags);
218/** Pointer to a FNPDMDRVDETACH() function. */
219typedef FNPDMDRVDETACH *PFNPDMDRVDETACH;
220
221
222
223/**
224 * PDM Driver Registration Structure.
225 *
226 * This structure is used when registering a driver from VBoxInitDrivers() (in
227 * host ring-3 context). PDM will continue use till the VM is terminated.
228 */
229typedef struct PDMDRVREG
230{
231 /** Structure version. PDM_DRVREG_VERSION defines the current version. */
232 uint32_t u32Version;
233 /** Driver name. */
234 char szName[32];
235 /** Name of the raw-mode context module (no path).
236 * Only evalutated if PDM_DRVREG_FLAGS_RC is set. */
237 char szRCMod[32];
238 /** Name of the ring-0 module (no path).
239 * Only evalutated if PDM_DRVREG_FLAGS_R0 is set. */
240 char szR0Mod[32];
241 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
242 * remain unchanged from registration till VM destruction. */
243 const char *pszDescription;
244
245 /** Flags, combination of the PDM_DRVREG_FLAGS_* \#defines. */
246 uint32_t fFlags;
247 /** Driver class(es), combination of the PDM_DRVREG_CLASS_* \#defines. */
248 uint32_t fClass;
249 /** Maximum number of instances (per VM). */
250 uint32_t cMaxInstances;
251 /** Size of the instance data. */
252 uint32_t cbInstance;
253
254 /** Construct instance - required. */
255 PFNPDMDRVCONSTRUCT pfnConstruct;
256 /** Destruct instance - optional. */
257 PFNPDMDRVDESTRUCT pfnDestruct;
258 /** Relocation command - optional. */
259 PFNPDMDRVRELOCATE pfnRelocate;
260 /** I/O control - optional. */
261 PFNPDMDRVIOCTL pfnIOCtl;
262 /** Power on notification - optional. */
263 PFNPDMDRVPOWERON pfnPowerOn;
264 /** Reset notification - optional. */
265 PFNPDMDRVRESET pfnReset;
266 /** Suspend notification - optional. */
267 PFNPDMDRVSUSPEND pfnSuspend;
268 /** Resume notification - optional. */
269 PFNPDMDRVRESUME pfnResume;
270 /** Attach command - optional. */
271 PFNPDMDRVATTACH pfnAttach;
272 /** Detach notification - optional. */
273 PFNPDMDRVDETACH pfnDetach;
274 /** Power off notification - optional. */
275 PFNPDMDRVPOWEROFF pfnPowerOff;
276 /** @todo */
277 PFNRT pfnSoftReset;
278 /** Initialization safty marker. */
279 uint32_t u32VersionEnd;
280} PDMDRVREG;
281/** Pointer to a PDM Driver Structure. */
282typedef PDMDRVREG *PPDMDRVREG;
283/** Const pointer to a PDM Driver Structure. */
284typedef PDMDRVREG const *PCPDMDRVREG;
285
286/** Current DRVREG version number. */
287#define PDM_DRVREG_VERSION PDM_VERSION_MAKE(0xf0ff, 1, 0)
288
289/** PDM Driver Flags.
290 * @{ */
291/** @def PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT
292 * The bit count for the current host. */
293#if HC_ARCH_BITS == 32
294# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000001)
295#elif HC_ARCH_BITS == 64
296# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000002)
297#else
298# error Unsupported HC_ARCH_BITS value.
299#endif
300/** The host bit count mask. */
301#define PDM_DRVREG_FLAGS_HOST_BITS_MASK UINT32_C(0x00000003)
302/** This flag is used to indicate that the driver has a RC component. */
303#define PDM_DRVREG_FLAGS_RC UINT32_C(0x00000010)
304/** This flag is used to indicate that the driver has a R0 component. */
305#define PDM_DRVREG_FLAGS_R0 UINT32_C(0x00000020)
306
307/** @} */
308
309
310/** PDM Driver Classes.
311 * @{ */
312/** Mouse input driver. */
313#define PDM_DRVREG_CLASS_MOUSE RT_BIT(0)
314/** Keyboard input driver. */
315#define PDM_DRVREG_CLASS_KEYBOARD RT_BIT(1)
316/** Display driver. */
317#define PDM_DRVREG_CLASS_DISPLAY RT_BIT(2)
318/** Network transport driver. */
319#define PDM_DRVREG_CLASS_NETWORK RT_BIT(3)
320/** Block driver. */
321#define PDM_DRVREG_CLASS_BLOCK RT_BIT(4)
322/** Media driver. */
323#define PDM_DRVREG_CLASS_MEDIA RT_BIT(5)
324/** Mountable driver. */
325#define PDM_DRVREG_CLASS_MOUNTABLE RT_BIT(6)
326/** Audio driver. */
327#define PDM_DRVREG_CLASS_AUDIO RT_BIT(7)
328/** VMMDev driver. */
329#define PDM_DRVREG_CLASS_VMMDEV RT_BIT(8)
330/** Status driver. */
331#define PDM_DRVREG_CLASS_STATUS RT_BIT(9)
332/** ACPI driver. */
333#define PDM_DRVREG_CLASS_ACPI RT_BIT(10)
334/** USB related driver. */
335#define PDM_DRVREG_CLASS_USB RT_BIT(11)
336/** ISCSI Transport related driver. */
337#define PDM_DRVREG_CLASS_ISCSITRANSPORT RT_BIT(12)
338/** Char driver. */
339#define PDM_DRVREG_CLASS_CHAR RT_BIT(13)
340/** Stream driver. */
341#define PDM_DRVREG_CLASS_STREAM RT_BIT(14)
342/** SCSI driver. */
343#define PDM_DRVREG_CLASS_SCSI RT_BIT(15)
344/** Generic raw PCI device driver. */
345#define PDM_DRVREG_CLASS_PCIRAW RT_BIT(16)
346/** @} */
347
348
349/**
350 * PDM Driver Instance.
351 *
352 * @implements PDMIBASE
353 */
354typedef struct PDMDRVINS
355{
356 /** Structure version. PDM_DRVINS_VERSION defines the current version. */
357 uint32_t u32Version;
358 /** Driver instance number. */
359 uint32_t iInstance;
360
361 /** Pointer the PDM Driver API. */
362 RCPTRTYPE(PCPDMDRVHLPRC) pHlpRC;
363 /** Pointer to driver instance data. */
364 RCPTRTYPE(void *) pvInstanceDataRC;
365
366 /** Pointer the PDM Driver API. */
367 R0PTRTYPE(PCPDMDRVHLPR0) pHlpR0;
368 /** Pointer to driver instance data. */
369 R0PTRTYPE(void *) pvInstanceDataR0;
370
371 /** Pointer the PDM Driver API. */
372 R3PTRTYPE(PCPDMDRVHLPR3) pHlpR3;
373 /** Pointer to driver instance data. */
374 R3PTRTYPE(void *) pvInstanceDataR3;
375
376 /** Pointer to driver registration structure. */
377 R3PTRTYPE(PCPDMDRVREG) pReg;
378 /** Configuration handle. */
379 R3PTRTYPE(PCFGMNODE) pCfg;
380
381 /** Pointer to the base interface of the device/driver instance above. */
382 R3PTRTYPE(PPDMIBASE) pUpBase;
383 /** Pointer to the base interface of the driver instance below. */
384 R3PTRTYPE(PPDMIBASE) pDownBase;
385
386 /** The base interface of the driver.
387 * The driver constructor initializes this. */
388 PDMIBASE IBase;
389
390 /** Tracing indicator. */
391 uint32_t fTracing;
392 /** The tracing ID of this device. */
393 uint32_t idTracing;
394#if HC_ARCH_BITS == 32
395 /** Align the internal data more naturally. */
396 uint32_t au32Padding[HC_ARCH_BITS == 32 ? 7 : 0];
397#endif
398
399 /** Internal data. */
400 union
401 {
402#ifdef PDMDRVINSINT_DECLARED
403 PDMDRVINSINT s;
404#endif
405 uint8_t padding[HC_ARCH_BITS == 32 ? 40 + 32 : 72 + 24];
406 } Internal;
407
408 /** Driver instance data. The size of this area is defined
409 * in the PDMDRVREG::cbInstanceData field. */
410 char achInstanceData[4];
411} PDMDRVINS;
412
413/** Current DRVREG version number. */
414#define PDM_DRVINS_VERSION PDM_VERSION_MAKE(0xf0fe, 2, 0)
415
416/** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */
417#define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_UOFFSETOF(PDMDRVINS, IBase)) )
418
419/** @def PDMDRVINS_2_RCPTR
420 * Converts a PDM Driver instance pointer a RC PDM Driver instance pointer.
421 */
422#define PDMDRVINS_2_RCPTR(pDrvIns) ( (RCPTRTYPE(PPDMDRVINS))((RTRCUINTPTR)(pDrvIns)->pvInstanceDataRC - (RTRCUINTPTR)RT_UOFFSETOF(PDMDRVINS, achInstanceData)) )
423
424/** @def PDMDRVINS_2_R3PTR
425 * Converts a PDM Driver instance pointer a R3 PDM Driver instance pointer.
426 */
427#define PDMDRVINS_2_R3PTR(pDrvIns) ( (R3PTRTYPE(PPDMDRVINS))((RTHCUINTPTR)(pDrvIns)->pvInstanceDataR3 - RT_UOFFSETOF(PDMDRVINS, achInstanceData)) )
428
429/** @def PDMDRVINS_2_R0PTR
430 * Converts a PDM Driver instance pointer a R0 PDM Driver instance pointer.
431 */
432#define PDMDRVINS_2_R0PTR(pDrvIns) ( (R0PTRTYPE(PPDMDRVINS))((RTR0UINTPTR)(pDrvIns)->pvInstanceDataR0 - RT_UOFFSETOF(PDMDRVINS, achInstanceData)) )
433
434
435
436/**
437 * Checks the structure versions of the drive instance and driver helpers,
438 * returning if they are incompatible.
439 *
440 * Intended for the constructor.
441 *
442 * @param pDrvIns Pointer to the PDM driver instance.
443 */
444#define PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns) \
445 do \
446 { \
447 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
448 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
449 ("DrvIns=%#x mine=%#x\n", (pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
450 VERR_PDM_DRVINS_VERSION_MISMATCH); \
451 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
452 ("DrvHlp=%#x mine=%#x\n", (pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
453 VERR_PDM_DRVHLPR3_VERSION_MISMATCH); \
454 } while (0)
455
456/**
457 * Quietly checks the structure versions of the drive instance and driver
458 * helpers, returning if they are incompatible.
459 *
460 * Intended for the destructor.
461 *
462 * @param pDrvIns Pointer to the PDM driver instance.
463 */
464#define PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns) \
465 do \
466 { \
467 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
468 if (RT_LIKELY( PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION) \
469 && PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION)) ) \
470 { /* likely */ } else return; \
471 } while (0)
472
473/**
474 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
475 * constructor - returns on failure.
476 *
477 * This should be invoked after having initialized the instance data
478 * sufficiently for the correct operation of the destructor. The destructor is
479 * always called!
480 *
481 * @param pDrvIns Pointer to the PDM driver instance.
482 * @param pszValidValues Patterns describing the valid value names. See
483 * RTStrSimplePatternMultiMatch for details on the
484 * pattern syntax.
485 * @param pszValidNodes Patterns describing the valid node (key) names.
486 * Pass empty string if no valid nodess.
487 */
488#define PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, pszValidValues, pszValidNodes) \
489 do \
490 { \
491 int rcValCfg = CFGMR3ValidateConfig((pDrvIns)->pCfg, "/", pszValidValues, pszValidNodes, \
492 (pDrvIns)->pReg->szName, (pDrvIns)->iInstance); \
493 if (RT_SUCCESS(rcValCfg)) \
494 { /* likely */ } else return rcValCfg; \
495 } while (0)
496
497
498
499/**
500 * USB hub registration structure.
501 */
502typedef struct PDMUSBHUBREG
503{
504 /** Structure version number. PDM_USBHUBREG_VERSION defines the current version. */
505 uint32_t u32Version;
506
507 /**
508 * Request the hub to attach of the specified device.
509 *
510 * @returns VBox status code.
511 * @param pDrvIns The hub instance.
512 * @param pUsbIns The device to attach.
513 * @param pszCaptureFilename Path to the file for USB traffic capturing, optional.
514 * @param piPort Where to store the port number the device was attached to.
515 * @thread EMT.
516 */
517 DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, const char *pszCaptureFilename, uint32_t *piPort));
518
519 /**
520 * Request the hub to detach of the specified device.
521 *
522 * The device has previously been attached to the hub with the
523 * pfnAttachDevice call. This call is not currently expected to
524 * fail.
525 *
526 * @returns VBox status code.
527 * @param pDrvIns The hub instance.
528 * @param pUsbIns The device to detach.
529 * @param iPort The port number returned by the attach call.
530 * @thread EMT.
531 */
532 DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t iPort));
533
534 /** Counterpart to u32Version, same value. */
535 uint32_t u32TheEnd;
536} PDMUSBHUBREG;
537/** Pointer to a const USB hub registration structure. */
538typedef const PDMUSBHUBREG *PCPDMUSBHUBREG;
539
540/** Current PDMUSBHUBREG version number. */
541#define PDM_USBHUBREG_VERSION PDM_VERSION_MAKE(0xf0fd, 2, 0)
542
543
544/**
545 * USB hub helpers.
546 * This is currently just a place holder.
547 */
548typedef struct PDMUSBHUBHLP
549{
550 /** Structure version. PDM_USBHUBHLP_VERSION defines the current version. */
551 uint32_t u32Version;
552
553 /** Just a safety precaution. */
554 uint32_t u32TheEnd;
555} PDMUSBHUBHLP;
556/** Pointer to PCI helpers. */
557typedef PDMUSBHUBHLP *PPDMUSBHUBHLP;
558/** Pointer to const PCI helpers. */
559typedef const PDMUSBHUBHLP *PCPDMUSBHUBHLP;
560/** Pointer to const PCI helpers pointer. */
561typedef PCPDMUSBHUBHLP *PPCPDMUSBHUBHLP;
562
563/** Current PDMUSBHUBHLP version number. */
564#define PDM_USBHUBHLP_VERSION PDM_VERSION_MAKE(0xf0fc, 1, 0)
565
566
567/**
568 * PDM Driver API - raw-mode context variant.
569 */
570typedef struct PDMDRVHLPRC
571{
572 /** Structure version. PDM_DRVHLPRC_VERSION defines the current version. */
573 uint32_t u32Version;
574
575 /**
576 * Set the VM error message
577 *
578 * @returns rc.
579 * @param pDrvIns Driver instance.
580 * @param rc VBox status code.
581 * @param SRC_POS Use RT_SRC_POS.
582 * @param pszFormat Error message format string.
583 * @param ... Error message arguments.
584 */
585 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
586 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
587
588 /**
589 * Set the VM error message
590 *
591 * @returns rc.
592 * @param pDrvIns Driver instance.
593 * @param rc VBox status code.
594 * @param SRC_POS Use RT_SRC_POS.
595 * @param pszFormat Error message format string.
596 * @param va Error message arguments.
597 */
598 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
599 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
600
601 /**
602 * Set the VM runtime error message
603 *
604 * @returns VBox status code.
605 * @param pDrvIns Driver instance.
606 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
607 * @param pszErrorId Error ID string.
608 * @param pszFormat Error message format string.
609 * @param ... Error message arguments.
610 */
611 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
612 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
613
614 /**
615 * Set the VM runtime error message
616 *
617 * @returns VBox status code.
618 * @param pDrvIns Driver instance.
619 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
620 * @param pszErrorId Error ID string.
621 * @param pszFormat Error message format string.
622 * @param va Error message arguments.
623 */
624 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
625 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
626
627 /**
628 * Assert that the current thread is the emulation thread.
629 *
630 * @returns True if correct.
631 * @returns False if wrong.
632 * @param pDrvIns Driver instance.
633 * @param pszFile Filename of the assertion location.
634 * @param iLine Linenumber of the assertion location.
635 * @param pszFunction Function of the assertion location.
636 */
637 DECLRCCALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
638
639 /**
640 * Assert that the current thread is NOT the emulation thread.
641 *
642 * @returns True if correct.
643 * @returns False if wrong.
644 * @param pDrvIns Driver instance.
645 * @param pszFile Filename of the assertion location.
646 * @param iLine Linenumber of the assertion location.
647 * @param pszFunction Function of the assertion location.
648 */
649 DECLRCCALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
650
651 /**
652 * Notify FTM about a checkpoint occurrence
653 *
654 * @param pDrvIns The driver instance.
655 * @param enmType Checkpoint type
656 * @thread Any
657 */
658 DECLRCCALLBACKMEMBER(int, pfnFTSetCheckpoint,(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType));
659
660 /** Just a safety precaution. */
661 uint32_t u32TheEnd;
662} PDMDRVHLPRC;
663/** Current PDMDRVHLPRC version number. */
664#define PDM_DRVHLPRC_VERSION PDM_VERSION_MAKE(0xf0f9, 2, 0)
665
666
667/**
668 * PDM Driver API, ring-0 context.
669 */
670typedef struct PDMDRVHLPR0
671{
672 /** Structure version. PDM_DRVHLPR0_VERSION defines the current version. */
673 uint32_t u32Version;
674
675 /**
676 * Set the VM error message
677 *
678 * @returns rc.
679 * @param pDrvIns Driver instance.
680 * @param rc VBox status code.
681 * @param SRC_POS Use RT_SRC_POS.
682 * @param pszFormat Error message format string.
683 * @param ... Error message arguments.
684 */
685 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
686 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
687
688 /**
689 * Set the VM error message
690 *
691 * @returns rc.
692 * @param pDrvIns Driver instance.
693 * @param rc VBox status code.
694 * @param SRC_POS Use RT_SRC_POS.
695 * @param pszFormat Error message format string.
696 * @param va Error message arguments.
697 */
698 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
699 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
700
701 /**
702 * Set the VM runtime error message
703 *
704 * @returns VBox status code.
705 * @param pDrvIns Driver instance.
706 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
707 * @param pszErrorId Error ID string.
708 * @param pszFormat Error message format string.
709 * @param ... Error message arguments.
710 */
711 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
712 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
713
714 /**
715 * Set the VM runtime error message
716 *
717 * @returns VBox status code.
718 * @param pDrvIns Driver instance.
719 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
720 * @param pszErrorId Error ID string.
721 * @param pszFormat Error message format string.
722 * @param va Error message arguments.
723 */
724 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
725 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
726
727 /**
728 * Assert that the current thread is the emulation thread.
729 *
730 * @returns True if correct.
731 * @returns False if wrong.
732 * @param pDrvIns Driver instance.
733 * @param pszFile Filename of the assertion location.
734 * @param iLine Linenumber of the assertion location.
735 * @param pszFunction Function of the assertion location.
736 */
737 DECLR0CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
738
739 /**
740 * Assert that the current thread is NOT the emulation thread.
741 *
742 * @returns True if correct.
743 * @returns False if wrong.
744 * @param pDrvIns Driver instance.
745 * @param pszFile Filename of the assertion location.
746 * @param iLine Linenumber of the assertion location.
747 * @param pszFunction Function of the assertion location.
748 */
749 DECLR0CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
750
751 /**
752 * Notify FTM about a checkpoint occurrence
753 *
754 * @param pDrvIns The driver instance.
755 * @param enmType Checkpoint type
756 * @thread Any
757 */
758 DECLR0CALLBACKMEMBER(int, pfnFTSetCheckpoint,(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType));
759
760 /** Just a safety precaution. */
761 uint32_t u32TheEnd;
762} PDMDRVHLPR0;
763/** Current DRVHLP version number. */
764#define PDM_DRVHLPR0_VERSION PDM_VERSION_MAKE(0xf0f8, 2, 0)
765
766
767#ifdef IN_RING3
768
769/**
770 * PDM Driver API.
771 */
772typedef struct PDMDRVHLPR3
773{
774 /** Structure version. PDM_DRVHLPR3_VERSION defines the current version. */
775 uint32_t u32Version;
776
777 /**
778 * Attaches a driver (chain) to the driver.
779 *
780 * @returns VBox status code.
781 * @param pDrvIns Driver instance.
782 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
783 * @param ppBaseInterface Where to store the pointer to the base interface.
784 */
785 DECLR3CALLBACKMEMBER(int, pfnAttach,(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface));
786
787 /**
788 * Detach the driver the drivers below us.
789 *
790 * @returns VBox status code.
791 * @param pDrvIns Driver instance.
792 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
793 */
794 DECLR3CALLBACKMEMBER(int, pfnDetach,(PPDMDRVINS pDrvIns, uint32_t fFlags));
795
796 /**
797 * Detach the driver from the driver above it and destroy this
798 * driver and all drivers below it.
799 *
800 * @returns VBox status code.
801 * @param pDrvIns Driver instance.
802 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
803 */
804 DECLR3CALLBACKMEMBER(int, pfnDetachSelf,(PPDMDRVINS pDrvIns, uint32_t fFlags));
805
806 /**
807 * Prepare a media mount.
808 *
809 * The driver must not have anything attached to itself
810 * when calling this function as the purpose is to set up the configuration
811 * of an future attachment.
812 *
813 * @returns VBox status code
814 * @param pDrvIns Driver instance.
815 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
816 * constructed a configuration which can be attached to the bottom driver.
817 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
818 */
819 DECLR3CALLBACKMEMBER(int, pfnMountPrepare,(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver));
820
821 /**
822 * Assert that the current thread is the emulation thread.
823 *
824 * @returns True if correct.
825 * @returns False if wrong.
826 * @param pDrvIns Driver instance.
827 * @param pszFile Filename of the assertion location.
828 * @param iLine Linenumber of the assertion location.
829 * @param pszFunction Function of the assertion location.
830 */
831 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
832
833 /**
834 * Assert that the current thread is NOT the emulation thread.
835 *
836 * @returns True if correct.
837 * @returns False if wrong.
838 * @param pDrvIns Driver instance.
839 * @param pszFile Filename of the assertion location.
840 * @param iLine Linenumber of the assertion location.
841 * @param pszFunction Function of the assertion location.
842 */
843 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
844
845 /**
846 * Set the VM error message
847 *
848 * @returns rc.
849 * @param pDrvIns Driver instance.
850 * @param rc VBox status code.
851 * @param SRC_POS Use RT_SRC_POS.
852 * @param pszFormat Error message format string.
853 * @param ... Error message arguments.
854 */
855 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
856 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7));
857
858 /**
859 * Set the VM error message
860 *
861 * @returns rc.
862 * @param pDrvIns Driver instance.
863 * @param rc VBox status code.
864 * @param SRC_POS Use RT_SRC_POS.
865 * @param pszFormat Error message format string.
866 * @param va Error message arguments.
867 */
868 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL,
869 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(6, 0));
870
871 /**
872 * Set the VM runtime error message
873 *
874 * @returns VBox status code.
875 * @param pDrvIns Driver instance.
876 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
877 * @param pszErrorId Error ID string.
878 * @param pszFormat Error message format string.
879 * @param ... Error message arguments.
880 */
881 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
882 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5));
883
884 /**
885 * Set the VM runtime error message
886 *
887 * @returns VBox status code.
888 * @param pDrvIns Driver instance.
889 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
890 * @param pszErrorId Error ID string.
891 * @param pszFormat Error message format string.
892 * @param va Error message arguments.
893 */
894 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
895 const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(4, 0));
896
897 /**
898 * Gets the VM state.
899 *
900 * @returns VM state.
901 * @param pDrvIns The driver instance.
902 * @thread Any thread (just keep in mind that it's volatile info).
903 */
904 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDRVINS pDrvIns));
905
906 /**
907 * Checks if the VM was teleported and hasn't been fully resumed yet.
908 *
909 * @returns true / false.
910 * @param pDrvIns The driver instance.
911 * @thread Any thread.
912 */
913 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDRVINS pDrvIns));
914
915 /**
916 * Gets the support driver session.
917 *
918 * This is intended for working using the semaphore API.
919 *
920 * @returns Support driver session handle.
921 * @param pDrvIns The driver instance.
922 */
923 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDRVINS pDrvIns));
924
925 /**
926 * Create a queue.
927 *
928 * @returns VBox status code.
929 * @param pDrvIns Driver instance.
930 * @param cbItem Size a queue item.
931 * @param cItems Number of items in the queue.
932 * @param cMilliesInterval Number of milliseconds between polling the queue.
933 * If 0 then the emulation thread will be notified whenever an item arrives.
934 * @param pfnCallback The consumer function.
935 * @param pszName The queue base name. The instance number will be
936 * appended automatically.
937 * @param ppQueue Where to store the queue handle on success.
938 * @thread The emulation thread.
939 */
940 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
941 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue));
942
943 /**
944 * Query the virtual timer frequency.
945 *
946 * @returns Frequency in Hz.
947 * @param pDrvIns Driver instance.
948 * @thread Any thread.
949 */
950 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMDRVINS pDrvIns));
951
952 /**
953 * Query the virtual time.
954 *
955 * @returns The current virtual time.
956 * @param pDrvIns Driver instance.
957 * @thread Any thread.
958 */
959 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMDRVINS pDrvIns));
960
961 /**
962 * Creates a timer.
963 *
964 * @returns VBox status.
965 * @param pDrvIns Driver instance.
966 * @param enmClock The clock to use on this timer.
967 * @param pfnCallback Callback function.
968 * @param pvUser The user argument to the callback.
969 * @param fFlags Timer creation flags, see grp_tm_timer_flags.
970 * @param pszDesc Pointer to description string which must stay around
971 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
972 * @param ppTimer Where to store the timer on success.
973 * @thread EMT
974 */
975 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
976
977 /**
978 * Register a save state data unit.
979 *
980 * @returns VBox status.
981 * @param pDrvIns Driver instance.
982 * @param uVersion Data layout version number.
983 * @param cbGuess The approximate amount of data in the unit.
984 * Only for progress indicators.
985 *
986 * @param pfnLivePrep Prepare live save callback, optional.
987 * @param pfnLiveExec Execute live save callback, optional.
988 * @param pfnLiveVote Vote live save callback, optional.
989 *
990 * @param pfnSavePrep Prepare save callback, optional.
991 * @param pfnSaveExec Execute save callback, optional.
992 * @param pfnSaveDone Done save callback, optional.
993 *
994 * @param pfnLoadPrep Prepare load callback, optional.
995 * @param pfnLoadExec Execute load callback, optional.
996 * @param pfnLoadDone Done load callback, optional.
997 */
998 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
999 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1000 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1001 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone));
1002
1003 /**
1004 * Deregister a save state data unit.
1005 *
1006 * @returns VBox status.
1007 * @param pDrvIns Driver instance.
1008 * @param pszName Data unit name.
1009 * @param uInstance The instance identifier of the data unit.
1010 * This must together with the name be unique.
1011 */
1012 DECLR3CALLBACKMEMBER(int, pfnSSMDeregister,(PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance));
1013
1014 /**
1015 * Register an info handler with DBGF.
1016 *
1017 * @returns VBox status code.
1018 * @param pDrvIns Driver instance.
1019 * @param pszName Data unit name.
1020 * @param pszDesc The description of the info and any arguments
1021 * the handler may take.
1022 * @param pfnHandler The handler function to be called to display the
1023 * info.
1024 */
1025 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler));
1026
1027 /**
1028 * Deregister an info handler from DBGF.
1029 *
1030 * @returns VBox status code.
1031 * @param pDrvIns Driver instance.
1032 * @param pszName Data unit name.
1033 */
1034 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoDeregister,(PPDMDRVINS pDrvIns, const char *pszName));
1035
1036 /**
1037 * Registers a statistics sample if statistics are enabled.
1038 *
1039 * @param pDrvIns Driver instance.
1040 * @param pvSample Pointer to the sample.
1041 * @param enmType Sample type. This indicates what pvSample is pointing at.
1042 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
1043 * Further nesting is possible.
1044 * @param enmUnit Sample unit.
1045 * @param pszDesc Sample description.
1046 */
1047 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName,
1048 STAMUNIT enmUnit, const char *pszDesc));
1049
1050 /**
1051 * Same as pfnSTAMRegister except that the name is specified in a
1052 * RTStrPrintf like fashion.
1053 *
1054 * @param pDrvIns Driver instance.
1055 * @param pvSample Pointer to the sample.
1056 * @param enmType Sample type. This indicates what pvSample is pointing at.
1057 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
1058 * @param enmUnit Sample unit.
1059 * @param pszDesc Sample description.
1060 * @param pszName The sample name format string.
1061 * @param ... Arguments to the format string.
1062 */
1063 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1064 STAMUNIT enmUnit, const char *pszDesc,
1065 const char *pszName, ...) RT_IPRT_FORMAT_ATTR(7, 8));
1066
1067 /**
1068 * Same as pfnSTAMRegister except that the name is specified in a
1069 * RTStrPrintfV like fashion.
1070 *
1071 * @param pDrvIns Driver instance.
1072 * @param pvSample Pointer to the sample.
1073 * @param enmType Sample type. This indicates what pvSample is pointing at.
1074 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
1075 * @param enmUnit Sample unit.
1076 * @param pszDesc Sample description.
1077 * @param pszName The sample name format string.
1078 * @param args Arguments to the format string.
1079 */
1080 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1081 STAMUNIT enmUnit, const char *pszDesc,
1082 const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0));
1083
1084 /**
1085 * Deregister a statistic item previously registered with pfnSTAMRegister,
1086 * pfnSTAMRegisterF or pfnSTAMRegisterV
1087 *
1088 * @returns VBox status.
1089 * @param pDrvIns Driver instance.
1090 * @param pvSample Pointer to the sample.
1091 */
1092 DECLR3CALLBACKMEMBER(int, pfnSTAMDeregister,(PPDMDRVINS pDrvIns, void *pvSample));
1093
1094 /**
1095 * Calls the HC R0 VMM entry point, in a safer but slower manner than
1096 * SUPR3CallVMMR0.
1097 *
1098 * When entering using this call the R0 components can call into the host kernel
1099 * (i.e. use the SUPR0 and RT APIs).
1100 *
1101 * See VMMR0Entry() for more details.
1102 *
1103 * @returns error code specific to uFunction.
1104 * @param pDrvIns The driver instance.
1105 * @param uOperation Operation to execute.
1106 * This is limited to services.
1107 * @param pvArg Pointer to argument structure or if cbArg is 0 just an value.
1108 * @param cbArg The size of the argument. This is used to copy whatever the argument
1109 * points at into a kernel buffer to avoid problems like the user page
1110 * being invalidated while we're executing the call.
1111 */
1112 DECLR3CALLBACKMEMBER(int, pfnSUPCallVMMR0Ex,(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg));
1113
1114 /**
1115 * Registers a USB HUB.
1116 *
1117 * @returns VBox status code.
1118 * @param pDrvIns The driver instance.
1119 * @param fVersions Indicates the kinds of USB devices that can be attached to this HUB.
1120 * @param cPorts The number of ports.
1121 * @param pUsbHubReg The hub callback structure that PDMUsb uses to interact with it.
1122 * @param ppUsbHubHlp The helper callback structure that the hub uses to talk to PDMUsb.
1123 *
1124 * @thread EMT.
1125 */
1126 DECLR3CALLBACKMEMBER(int, pfnUSBRegisterHub,(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp));
1127
1128 /**
1129 * Set up asynchronous handling of a suspend, reset or power off notification.
1130 *
1131 * This shall only be called when getting the notification. It must be called
1132 * for each one.
1133 *
1134 * @returns VBox status code.
1135 * @param pDrvIns The driver instance.
1136 * @param pfnAsyncNotify The callback.
1137 * @thread EMT(0)
1138 */
1139 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify));
1140
1141 /**
1142 * Notify EMT(0) that the driver has completed the asynchronous notification
1143 * handling.
1144 *
1145 * This can be called at any time, spurious calls will simply be ignored.
1146 *
1147 * @param pDrvIns The driver instance.
1148 * @thread Any
1149 */
1150 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDRVINS pDrvIns));
1151
1152 /**
1153 * Creates a PDM thread.
1154 *
1155 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
1156 * resuming, and destroying the thread as the VM state changes.
1157 *
1158 * @returns VBox status code.
1159 * @param pDrvIns The driver instance.
1160 * @param ppThread Where to store the thread 'handle'.
1161 * @param pvUser The user argument to the thread function.
1162 * @param pfnThread The thread function.
1163 * @param pfnWakeup The wakup callback. This is called on the EMT thread when
1164 * a state change is pending.
1165 * @param cbStack See RTThreadCreate.
1166 * @param enmType See RTThreadCreate.
1167 * @param pszName See RTThreadCreate.
1168 */
1169 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1170 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
1171
1172 /**
1173 * Creates an async completion template for a driver instance.
1174 *
1175 * The template is used when creating new completion tasks.
1176 *
1177 * @returns VBox status code.
1178 * @param pDrvIns The driver instance.
1179 * @param ppTemplate Where to store the template pointer on success.
1180 * @param pfnCompleted The completion callback routine.
1181 * @param pvTemplateUser Template user argument.
1182 * @param pszDesc Description.
1183 */
1184 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionTemplateCreate,(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1185 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
1186 const char *pszDesc));
1187
1188#ifdef VBOX_WITH_NETSHAPER
1189 /**
1190 * Attaches network filter driver to a bandwidth group.
1191 *
1192 * @returns VBox status code.
1193 * @param pDrvIns The driver instance.
1194 * @param pcszBwGroup Name of the bandwidth group to attach to.
1195 * @param pFilter Pointer to the filter we attach.
1196 */
1197 DECLR3CALLBACKMEMBER(int, pfnNetShaperAttach,(PPDMDRVINS pDrvIns, const char *pszBwGroup,
1198 PPDMNSFILTER pFilter));
1199
1200
1201 /**
1202 * Detaches network filter driver to a bandwidth group.
1203 *
1204 * @returns VBox status code.
1205 * @param pDrvIns The driver instance.
1206 * @param pFilter Pointer to the filter we attach.
1207 */
1208 DECLR3CALLBACKMEMBER(int, pfnNetShaperDetach,(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter));
1209#endif /* VBOX_WITH_NETSHAPER */
1210
1211
1212 /**
1213 * Resolves the symbol for a raw-mode context interface.
1214 *
1215 * @returns VBox status code.
1216 * @param pDrvIns The driver instance.
1217 * @param pvInterface The interface structure.
1218 * @param cbInterface The size of the interface structure.
1219 * @param pszSymPrefix What to prefix the symbols in the list with before
1220 * resolving them. This must start with 'drv' and
1221 * contain the driver name.
1222 * @param pszSymList List of symbols corresponding to the interface.
1223 * There is generally a there is generally a define
1224 * holding this list associated with the interface
1225 * definition (INTERFACE_SYM_LIST). For more details
1226 * see PDMR3LdrGetInterfaceSymbols.
1227 * @thread EMT
1228 */
1229 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1230 const char *pszSymPrefix, const char *pszSymList));
1231
1232 /**
1233 * Resolves the symbol for a ring-0 context interface.
1234 *
1235 * @returns VBox status code.
1236 * @param pDrvIns The driver instance.
1237 * @param pvInterface The interface structure.
1238 * @param cbInterface The size of the interface structure.
1239 * @param pszSymPrefix What to prefix the symbols in the list with before
1240 * resolving them. This must start with 'drv' and
1241 * contain the driver name.
1242 * @param pszSymList List of symbols corresponding to the interface.
1243 * There is generally a there is generally a define
1244 * holding this list associated with the interface
1245 * definition (INTERFACE_SYM_LIST). For more details
1246 * see PDMR3LdrGetInterfaceSymbols.
1247 * @thread EMT
1248 */
1249 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1250 const char *pszSymPrefix, const char *pszSymList));
1251 /**
1252 * Initializes a PDM critical section.
1253 *
1254 * The PDM critical sections are derived from the IPRT critical sections, but
1255 * works in both RC and R0 as well as R3.
1256 *
1257 * @returns VBox status code.
1258 * @param pDrvIns The driver instance.
1259 * @param pCritSect Pointer to the critical section.
1260 * @param SRC_POS Use RT_SRC_POS.
1261 * @param pszName The base name of the critical section. Will be
1262 * mangeled with the instance number. For
1263 * statistics and lock validation.
1264 * @thread EMT
1265 */
1266 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszName));
1267
1268 /**
1269 * Call the ring-0 request handler routine of the driver.
1270 *
1271 * For this to work, the driver must be ring-0 enabled and export a request
1272 * handler function. The name of the function must be the driver name in the
1273 * PDMDRVREG struct prefixed with 'drvR0' and suffixed with 'ReqHandler'.
1274 * The driver name will be capitalized. It shall take the exact same
1275 * arguments as this function and be declared using PDMBOTHCBDECL. See
1276 * FNPDMDRVREQHANDLERR0.
1277 *
1278 * @returns VBox status code.
1279 * @retval VERR_SYMBOL_NOT_FOUND if the driver doesn't export the required
1280 * handler function.
1281 * @retval VERR_ACCESS_DENIED if the driver isn't ring-0 capable.
1282 *
1283 * @param pDrvIns The driver instance.
1284 * @param uOperation The operation to perform.
1285 * @param u64Arg 64-bit integer argument.
1286 * @thread Any
1287 */
1288 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg));
1289
1290 /**
1291 * Notify FTM about a checkpoint occurrence
1292 *
1293 * @param pDrvIns The driver instance.
1294 * @param enmType Checkpoint type
1295 * @thread Any
1296 */
1297 DECLR3CALLBACKMEMBER(int, pfnFTSetCheckpoint,(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType));
1298
1299 /**
1300 * Creates a block cache for a driver driver instance.
1301 *
1302 * @returns VBox status code.
1303 * @param pDrvIns The driver instance.
1304 * @param ppBlkCache Where to store the handle to the block cache.
1305 * @param pfnXferComplete The I/O transfer complete callback.
1306 * @param pfnXferEnqueue The I/O request enqueue callback.
1307 * @param pfnXferEnqueueDiscard The discard request enqueue callback.
1308 * @param pcszId Unique ID used to identify the user.
1309 */
1310 DECLR3CALLBACKMEMBER(int, pfnBlkCacheRetain, (PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
1311 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
1312 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
1313 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
1314 const char *pcszId));
1315 /**
1316 * Gets the reason for the most recent VM suspend.
1317 *
1318 * @returns The suspend reason. VMSUSPENDREASON_INVALID is returned if no
1319 * suspend has been made or if the pDrvIns is invalid.
1320 * @param pDrvIns The driver instance.
1321 */
1322 DECLR3CALLBACKMEMBER(VMSUSPENDREASON, pfnVMGetSuspendReason,(PPDMDRVINS pDrvIns));
1323
1324 /**
1325 * Gets the reason for the most recent VM resume.
1326 *
1327 * @returns The resume reason. VMRESUMEREASON_INVALID is returned if no
1328 * resume has been made or if the pDrvIns is invalid.
1329 * @param pDrvIns The driver instance.
1330 */
1331 DECLR3CALLBACKMEMBER(VMRESUMEREASON, pfnVMGetResumeReason,(PPDMDRVINS pDrvIns));
1332
1333 /** @name Space reserved for minor interface changes.
1334 * @{ */
1335 DECLR3CALLBACKMEMBER(void, pfnReserved0,(PPDMDRVINS pDrvIns));
1336 DECLR3CALLBACKMEMBER(void, pfnReserved1,(PPDMDRVINS pDrvIns));
1337 DECLR3CALLBACKMEMBER(void, pfnReserved2,(PPDMDRVINS pDrvIns));
1338 DECLR3CALLBACKMEMBER(void, pfnReserved3,(PPDMDRVINS pDrvIns));
1339 DECLR3CALLBACKMEMBER(void, pfnReserved4,(PPDMDRVINS pDrvIns));
1340 DECLR3CALLBACKMEMBER(void, pfnReserved5,(PPDMDRVINS pDrvIns));
1341 DECLR3CALLBACKMEMBER(void, pfnReserved6,(PPDMDRVINS pDrvIns));
1342 DECLR3CALLBACKMEMBER(void, pfnReserved7,(PPDMDRVINS pDrvIns));
1343 DECLR3CALLBACKMEMBER(void, pfnReserved8,(PPDMDRVINS pDrvIns));
1344 DECLR3CALLBACKMEMBER(void, pfnReserved9,(PPDMDRVINS pDrvIns));
1345 /** @} */
1346
1347 /** Just a safety precaution. */
1348 uint32_t u32TheEnd;
1349} PDMDRVHLPR3;
1350/** Current DRVHLP version number. */
1351#define PDM_DRVHLPR3_VERSION PDM_VERSION_MAKE(0xf0fb, 3, 0)
1352
1353#endif /* IN_RING3 */
1354
1355
1356/**
1357 * @copydoc PDMDRVHLPR3::pfnVMSetError
1358 */
1359DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 7) PDMDrvHlpVMSetError(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL,
1360 const char *pszFormat, ...)
1361{
1362 va_list va;
1363 va_start(va, pszFormat);
1364 pDrvIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1365 va_end(va);
1366 return rc;
1367}
1368
1369/** @def PDMDRV_SET_ERROR
1370 * Set the VM error. See PDMDrvHlpVMSetError() for printf like message formatting.
1371 */
1372#define PDMDRV_SET_ERROR(pDrvIns, rc, pszError) \
1373 PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, "%s", pszError)
1374
1375/**
1376 * @copydoc PDMDRVHLPR3::pfnVMSetErrorV
1377 */
1378DECLINLINE(int) RT_IPRT_FORMAT_ATTR(6, 0) PDMDrvHlpVMSetErrorV(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL,
1379 const char *pszFormat, va_list va)
1380{
1381 return pDrvIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1382}
1383
1384
1385/**
1386 * @copydoc PDMDRVHLPR3::pfnVMSetRuntimeError
1387 */
1388DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 5) PDMDrvHlpVMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
1389 const char *pszFormat, ...)
1390{
1391 va_list va;
1392 int rc;
1393 va_start(va, pszFormat);
1394 rc = pDrvIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
1395 va_end(va);
1396 return rc;
1397}
1398
1399/** @def PDMDRV_SET_RUNTIME_ERROR
1400 * Set the VM runtime error. See PDMDrvHlpVMSetRuntimeError() for printf like message formatting.
1401 */
1402#define PDMDRV_SET_RUNTIME_ERROR(pDrvIns, fFlags, pszErrorId, pszError) \
1403 PDMDrvHlpVMSetRuntimeError(pDrvIns, fFlags, pszErrorId, "%s", pszError)
1404
1405/**
1406 * @copydoc PDMDRVHLPR3::pfnVMSetRuntimeErrorV
1407 */
1408DECLINLINE(int) RT_IPRT_FORMAT_ATTR(4, 0) PDMDrvHlpVMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags,
1409 const char *pszErrorId, const char *pszFormat, va_list va)
1410{
1411 return pDrvIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
1412}
1413
1414
1415
1416/** @def PDMDRV_ASSERT_EMT
1417 * Assert that the current thread is the emulation thread.
1418 */
1419#ifdef VBOX_STRICT
1420# define PDMDRV_ASSERT_EMT(pDrvIns) pDrvIns->CTX_SUFF(pHlp)->pfnAssertEMT(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1421#else
1422# define PDMDRV_ASSERT_EMT(pDrvIns) do { } while (0)
1423#endif
1424
1425/** @def PDMDRV_ASSERT_OTHER
1426 * Assert that the current thread is NOT the emulation thread.
1427 */
1428#ifdef VBOX_STRICT
1429# define PDMDRV_ASSERT_OTHER(pDrvIns) pDrvIns->CTX_SUFF(pHlp)->pfnAssertOther(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1430#else
1431# define PDMDRV_ASSERT_OTHER(pDrvIns) do { } while (0)
1432#endif
1433
1434/**
1435 * @copydoc PDMDRVHLPR3::pfnFTSetCheckpoint
1436 */
1437DECLINLINE(int) PDMDrvHlpFTSetCheckpoint(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType)
1438{
1439 return pDrvIns->CTX_SUFF(pHlp)->pfnFTSetCheckpoint(pDrvIns, enmType);
1440}
1441
1442
1443#ifdef IN_RING3
1444
1445/**
1446 * @copydoc PDMDRVHLPR3::pfnAttach
1447 */
1448DECLINLINE(int) PDMDrvHlpAttach(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface)
1449{
1450 return pDrvIns->pHlpR3->pfnAttach(pDrvIns, fFlags, ppBaseInterface);
1451}
1452
1453/**
1454 * Check that there is no driver below the us that we should attach to.
1455 *
1456 * @returns VERR_PDM_NO_ATTACHED_DRIVER if there is no driver.
1457 * @param pDrvIns The driver instance.
1458 */
1459DECLINLINE(int) PDMDrvHlpNoAttach(PPDMDRVINS pDrvIns)
1460{
1461 return pDrvIns->pHlpR3->pfnAttach(pDrvIns, 0, NULL);
1462}
1463
1464/**
1465 * @copydoc PDMDRVHLPR3::pfnDetach
1466 */
1467DECLINLINE(int) PDMDrvHlpDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1468{
1469 return pDrvIns->pHlpR3->pfnDetach(pDrvIns, fFlags);
1470}
1471
1472/**
1473 * @copydoc PDMDRVHLPR3::pfnDetachSelf
1474 */
1475DECLINLINE(int) PDMDrvHlpDetachSelf(PPDMDRVINS pDrvIns, uint32_t fFlags)
1476{
1477 return pDrvIns->pHlpR3->pfnDetachSelf(pDrvIns, fFlags);
1478}
1479
1480/**
1481 * @copydoc PDMDRVHLPR3::pfnMountPrepare
1482 */
1483DECLINLINE(int) PDMDrvHlpMountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver)
1484{
1485 return pDrvIns->pHlpR3->pfnMountPrepare(pDrvIns, pszFilename, pszCoreDriver);
1486}
1487
1488/**
1489 * @copydoc PDMDRVHLPR3::pfnVMState
1490 */
1491DECLINLINE(VMSTATE) PDMDrvHlpVMState(PPDMDRVINS pDrvIns)
1492{
1493 return pDrvIns->CTX_SUFF(pHlp)->pfnVMState(pDrvIns);
1494}
1495
1496/**
1497 * @copydoc PDMDRVHLPR3::pfnVMTeleportedAndNotFullyResumedYet
1498 */
1499DECLINLINE(bool) PDMDrvHlpVMTeleportedAndNotFullyResumedYet(PPDMDRVINS pDrvIns)
1500{
1501 return pDrvIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDrvIns);
1502}
1503
1504/**
1505 * @copydoc PDMDRVHLPR3::pfnGetSupDrvSession
1506 */
1507DECLINLINE(PSUPDRVSESSION) PDMDrvHlpGetSupDrvSession(PPDMDRVINS pDrvIns)
1508{
1509 return pDrvIns->pHlpR3->pfnGetSupDrvSession(pDrvIns);
1510}
1511
1512/**
1513 * @copydoc PDMDRVHLPR3::pfnQueueCreate
1514 */
1515DECLINLINE(int) PDMDrvHlpQueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
1516 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
1517{
1518 return pDrvIns->pHlpR3->pfnQueueCreate(pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue);
1519}
1520
1521/**
1522 * @copydoc PDMDRVHLPR3::pfnTMGetVirtualFreq
1523 */
1524DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualFreq(PPDMDRVINS pDrvIns)
1525{
1526 return pDrvIns->pHlpR3->pfnTMGetVirtualFreq(pDrvIns);
1527}
1528
1529/**
1530 * @copydoc PDMDRVHLPR3::pfnTMGetVirtualTime
1531 */
1532DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualTime(PPDMDRVINS pDrvIns)
1533{
1534 return pDrvIns->pHlpR3->pfnTMGetVirtualTime(pDrvIns);
1535}
1536
1537/**
1538 * @copydoc PDMDRVHLPR3::pfnTMTimerCreate
1539 */
1540DECLINLINE(int) PDMDrvHlpTMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
1541{
1542 return pDrvIns->pHlpR3->pfnTMTimerCreate(pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
1543}
1544
1545/**
1546 * Register a save state data unit.
1547 *
1548 * @returns VBox status.
1549 * @param pDrvIns Driver instance.
1550 * @param uVersion Data layout version number.
1551 * @param cbGuess The approximate amount of data in the unit.
1552 * Only for progress indicators.
1553 * @param pfnSaveExec Execute save callback, optional.
1554 * @param pfnLoadExec Execute load callback, optional.
1555 */
1556DECLINLINE(int) PDMDrvHlpSSMRegister(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1557 PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVLOADEXEC pfnLoadExec)
1558{
1559 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1560 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1561 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
1562 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
1563}
1564
1565/**
1566 * @copydoc PDMDRVHLPR3::pfnSSMRegister
1567 */
1568DECLINLINE(int) PDMDrvHlpSSMRegisterEx(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1569 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1570 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1571 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
1572{
1573 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1574 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1575 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1576 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1577}
1578
1579/**
1580 * Register a load done callback.
1581 *
1582 * @returns VBox status.
1583 * @param pDrvIns Driver instance.
1584 * @param pfnLoadDone Done load callback, optional.
1585 */
1586DECLINLINE(int) PDMDrvHlpSSMRegisterLoadDone(PPDMDRVINS pDrvIns, PFNSSMDRVLOADDONE pfnLoadDone)
1587{
1588 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, 0 /*uVersion*/, 0 /*cbGuess*/,
1589 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1590 NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/,
1591 NULL /*pfnLoadPrep*/, NULL /*pfnLoadExec*/, pfnLoadDone);
1592}
1593
1594/**
1595 * @copydoc PDMDRVHLPR3::pfnDBGFInfoRegister
1596 */
1597DECLINLINE(int) PDMDrvHlpDBGFInfoRegister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1598{
1599 return pDrvIns->pHlpR3->pfnDBGFInfoRegister(pDrvIns, pszName, pszDesc, pfnHandler);
1600}
1601
1602/**
1603 * @copydoc PDMDRVHLPR3::pfnDBGFInfoRegister
1604 */
1605DECLINLINE(int) PDMDrvHlpDBGFInfoDeregister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1606{
1607 return pDrvIns->pHlpR3->pfnDBGFInfoRegister(pDrvIns, pszName, pszDesc, pfnHandler);
1608}
1609
1610/**
1611 * @copydoc PDMDRVHLPR3::pfnSTAMRegister
1612 */
1613DECLINLINE(void) PDMDrvHlpSTAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1614{
1615 pDrvIns->pHlpR3->pfnSTAMRegister(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
1616}
1617
1618/**
1619 * @copydoc PDMDRVHLPR3::pfnSTAMRegisterF
1620 */
1621DECLINLINE(void) RT_IPRT_FORMAT_ATTR(7, 8) PDMDrvHlpSTAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType,
1622 STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
1623 const char *pszDesc, const char *pszName, ...)
1624{
1625 va_list va;
1626 va_start(va, pszName);
1627 pDrvIns->pHlpR3->pfnSTAMRegisterV(pDrvIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
1628 va_end(va);
1629}
1630
1631/**
1632 * Convenience wrapper that registers counter which is always visible.
1633 *
1634 * @param pDrvIns The driver instance.
1635 * @param pCounter Pointer to the counter variable.
1636 * @param pszName The name of the sample. This is prefixed with
1637 * "/Drivers/<drivername>-<instance no>/".
1638 * @param enmUnit The unit.
1639 * @param pszDesc The description.
1640 */
1641DECLINLINE(void) PDMDrvHlpSTAMRegCounterEx(PPDMDRVINS pDrvIns, PSTAMCOUNTER pCounter, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1642{
1643 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pCounter, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1644 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1645}
1646
1647/**
1648 * Convenience wrapper that registers counter which is always visible and has
1649 * the STAMUNIT_COUNT unit.
1650 *
1651 * @param pDrvIns The driver instance.
1652 * @param pCounter Pointer to the counter variable.
1653 * @param pszName The name of the sample. This is prefixed with
1654 * "/Drivers/<drivername>-<instance no>/".
1655 * @param pszDesc The description.
1656 */
1657DECLINLINE(void) PDMDrvHlpSTAMRegCounter(PPDMDRVINS pDrvIns, PSTAMCOUNTER pCounter, const char *pszName, const char *pszDesc)
1658{
1659 PDMDrvHlpSTAMRegCounterEx(pDrvIns, pCounter, pszName, STAMUNIT_COUNT, pszDesc);
1660}
1661
1662/**
1663 * Convenience wrapper that registers profiling sample which is always visible.
1664 *
1665 * @param pDrvIns The driver instance.
1666 * @param pProfile Pointer to the profiling variable.
1667 * @param pszName The name of the sample. This is prefixed with
1668 * "/Drivers/<drivername>-<instance no>/".
1669 * @param enmUnit The unit.
1670 * @param pszDesc The description.
1671 */
1672DECLINLINE(void) PDMDrvHlpSTAMRegProfileEx(PPDMDRVINS pDrvIns, PSTAMPROFILE pProfile, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1673{
1674 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pProfile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1675 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1676}
1677
1678/**
1679 * Convenience wrapper that registers profiling sample which is always visible
1680 * hand counts ticks per call (STAMUNIT_TICKS_PER_CALL).
1681 *
1682 * @param pDrvIns The driver instance.
1683 * @param pProfile Pointer to the profiling variable.
1684 * @param pszName The name of the sample. This is prefixed with
1685 * "/Drivers/<drivername>-<instance no>/".
1686 * @param pszDesc The description.
1687 */
1688DECLINLINE(void) PDMDrvHlpSTAMRegProfile(PPDMDRVINS pDrvIns, PSTAMPROFILE pProfile, const char *pszName, const char *pszDesc)
1689{
1690 PDMDrvHlpSTAMRegProfileEx(pDrvIns, pProfile, pszName, STAMUNIT_TICKS_PER_CALL, pszDesc);
1691}
1692
1693/**
1694 * Convenience wrapper that registers an advanced profiling sample which is
1695 * always visible.
1696 *
1697 * @param pDrvIns The driver instance.
1698 * @param pProfile Pointer to the profiling variable.
1699 * @param enmUnit The unit.
1700 * @param pszName The name of the sample. This is prefixed with
1701 * "/Drivers/<drivername>-<instance no>/".
1702 * @param pszDesc The description.
1703 */
1704DECLINLINE(void) PDMDrvHlpSTAMRegProfileAdvEx(PPDMDRVINS pDrvIns, PSTAMPROFILEADV pProfile, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1705{
1706 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pProfile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1707 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1708}
1709
1710/**
1711 * Convenience wrapper that registers an advanced profiling sample which is
1712 * always visible.
1713 *
1714 * @param pDrvIns The driver instance.
1715 * @param pProfile Pointer to the profiling variable.
1716 * @param pszName The name of the sample. This is prefixed with
1717 * "/Drivers/<drivername>-<instance no>/".
1718 * @param pszDesc The description.
1719 */
1720DECLINLINE(void) PDMDrvHlpSTAMRegProfileAdv(PPDMDRVINS pDrvIns, PSTAMPROFILEADV pProfile, const char *pszName, const char *pszDesc)
1721{
1722 PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, pProfile, pszName, STAMUNIT_TICKS_PER_CALL, pszDesc);
1723}
1724
1725/**
1726 * @copydoc PDMDRVHLPR3::pfnSTAMDeregister
1727 */
1728DECLINLINE(int) PDMDrvHlpSTAMDeregister(PPDMDRVINS pDrvIns, void *pvSample)
1729{
1730 return pDrvIns->pHlpR3->pfnSTAMDeregister(pDrvIns, pvSample);
1731}
1732
1733/**
1734 * @copydoc PDMDRVHLPR3::pfnSUPCallVMMR0Ex
1735 */
1736DECLINLINE(int) PDMDrvHlpSUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg)
1737{
1738 return pDrvIns->pHlpR3->pfnSUPCallVMMR0Ex(pDrvIns, uOperation, pvArg, cbArg);
1739}
1740
1741/**
1742 * @copydoc PDMDRVHLPR3::pfnUSBRegisterHub
1743 */
1744DECLINLINE(int) PDMDrvHlpUSBRegisterHub(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp)
1745{
1746 return pDrvIns->pHlpR3->pfnUSBRegisterHub(pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp);
1747}
1748
1749/**
1750 * @copydoc PDMDRVHLPR3::pfnSetAsyncNotification
1751 */
1752DECLINLINE(int) PDMDrvHlpSetAsyncNotification(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
1753{
1754 return pDrvIns->pHlpR3->pfnSetAsyncNotification(pDrvIns, pfnAsyncNotify);
1755}
1756
1757/**
1758 * @copydoc PDMDRVHLPR3::pfnAsyncNotificationCompleted
1759 */
1760DECLINLINE(void) PDMDrvHlpAsyncNotificationCompleted(PPDMDRVINS pDrvIns)
1761{
1762 pDrvIns->pHlpR3->pfnAsyncNotificationCompleted(pDrvIns);
1763}
1764
1765/**
1766 * @copydoc PDMDRVHLPR3::pfnThreadCreate
1767 */
1768DECLINLINE(int) PDMDrvHlpThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1769 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
1770{
1771 return pDrvIns->pHlpR3->pfnThreadCreate(pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
1772}
1773
1774# ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
1775/**
1776 * @copydoc PDMDRVHLPR3::pfnAsyncCompletionTemplateCreate
1777 */
1778DECLINLINE(int) PDMDrvHlpAsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1779 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc)
1780{
1781 return pDrvIns->pHlpR3->pfnAsyncCompletionTemplateCreate(pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
1782}
1783# endif
1784
1785# ifdef VBOX_WITH_NETSHAPER
1786/**
1787 * @copydoc PDMDRVHLPR3::pfnNetShaperAttach
1788 */
1789DECLINLINE(int) PDMDrvHlpNetShaperAttach(PPDMDRVINS pDrvIns, const char *pcszBwGroup, PPDMNSFILTER pFilter)
1790{
1791 return pDrvIns->pHlpR3->pfnNetShaperAttach(pDrvIns, pcszBwGroup, pFilter);
1792}
1793
1794/**
1795 * @copydoc PDMDRVHLPR3::pfnNetShaperDetach
1796 */
1797DECLINLINE(int) PDMDrvHlpNetShaperDetach(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter)
1798{
1799 return pDrvIns->pHlpR3->pfnNetShaperDetach(pDrvIns, pFilter);
1800}
1801# endif
1802
1803/**
1804 * @copydoc PDMDRVHLPR3::pfnCritSectInit
1805 */
1806DECLINLINE(int) PDMDrvHlpCritSectInit(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszName)
1807{
1808 return pDrvIns->pHlpR3->pfnCritSectInit(pDrvIns, pCritSect, RT_SRC_POS_ARGS, pszName);
1809}
1810
1811/**
1812 * @copydoc PDMDRVHLPR3::pfnCallR0
1813 */
1814DECLINLINE(int) PDMDrvHlpCallR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)
1815{
1816 return pDrvIns->pHlpR3->pfnCallR0(pDrvIns, uOperation, u64Arg);
1817}
1818
1819/**
1820 * @copydoc PDMDRVHLPR3::pfnBlkCacheRetain
1821 */
1822DECLINLINE(int) PDMDrvHlpBlkCacheRetain(PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
1823 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
1824 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
1825 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
1826 const char *pcszId)
1827{
1828 return pDrvIns->pHlpR3->pfnBlkCacheRetain(pDrvIns, ppBlkCache, pfnXferComplete, pfnXferEnqueue, pfnXferEnqueueDiscard, pcszId);
1829}
1830
1831/**
1832 * @copydoc PDMDRVHLPR3::pfnVMGetSuspendReason
1833 */
1834DECLINLINE(VMSUSPENDREASON) PDMDrvHlpVMGetSuspendReason(PPDMDRVINS pDrvIns)
1835{
1836 return pDrvIns->pHlpR3->pfnVMGetSuspendReason(pDrvIns);
1837}
1838
1839/**
1840 * @copydoc PDMDRVHLPR3::pfnVMGetResumeReason
1841 */
1842DECLINLINE(VMRESUMEREASON) PDMDrvHlpVMGetResumeReason(PPDMDRVINS pDrvIns)
1843{
1844 return pDrvIns->pHlpR3->pfnVMGetResumeReason(pDrvIns);
1845}
1846
1847
1848/** Pointer to callbacks provided to the VBoxDriverRegister() call. */
1849typedef struct PDMDRVREGCB *PPDMDRVREGCB;
1850/** Pointer to const callbacks provided to the VBoxDriverRegister() call. */
1851typedef const struct PDMDRVREGCB *PCPDMDRVREGCB;
1852
1853/**
1854 * Callbacks for VBoxDriverRegister().
1855 */
1856typedef struct PDMDRVREGCB
1857{
1858 /** Interface version.
1859 * This is set to PDM_DRVREG_CB_VERSION. */
1860 uint32_t u32Version;
1861
1862 /**
1863 * Registers a driver with the current VM instance.
1864 *
1865 * @returns VBox status code.
1866 * @param pCallbacks Pointer to the callback table.
1867 * @param pReg Pointer to the driver registration record.
1868 * This data must be permanent and readonly.
1869 */
1870 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg));
1871} PDMDRVREGCB;
1872
1873/** Current version of the PDMDRVREGCB structure. */
1874#define PDM_DRVREG_CB_VERSION PDM_VERSION_MAKE(0xf0fa, 1, 0)
1875
1876
1877/**
1878 * The VBoxDriverRegister callback function.
1879 *
1880 * PDM will invoke this function after loading a driver module and letting
1881 * the module decide which drivers to register and how to handle conflicts.
1882 *
1883 * @returns VBox status code.
1884 * @param pCallbacks Pointer to the callback table.
1885 * @param u32Version VBox version number.
1886 */
1887typedef DECLCALLBACK(int) FNPDMVBOXDRIVERSREGISTER(PCPDMDRVREGCB pCallbacks, uint32_t u32Version);
1888
1889VMMR3DECL(int) PDMR3DrvStaticRegistration(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback);
1890
1891#endif /* IN_RING3 */
1892
1893/** @} */
1894
1895RT_C_DECLS_END
1896
1897#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette