VirtualBox

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

Last change on this file since 53328 was 53062, checked in by vboxsync, 10 years ago

USB: Integrate USB sniffer. Make it possible to specify a file to dump the traffic to when attaching a USB device with VBoxManage

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