VirtualBox

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

Last change on this file since 40894 was 40652, checked in by vboxsync, 13 years ago

NetShaper,E1000: Basic framework and partial implementation for network shaper

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 70.4 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Drivers.
3 */
4
5/*
6 * Copyright (C) 2006-2010 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#if HC_ARCH_BITS == 64
392 /** Align the internal data more naturally. */
393 uint32_t u32Padding;
394#endif
395
396 /** Internal data. */
397 union
398 {
399#ifdef PDMDRVINSINT_DECLARED
400 PDMDRVINSINT s;
401#endif
402 uint8_t padding[HC_ARCH_BITS == 32 ? 40 + 32 : 72 + 24];
403 } Internal;
404
405 /** Driver instance data. The size of this area is defined
406 * in the PDMDRVREG::cbInstanceData field. */
407 char achInstanceData[4];
408} PDMDRVINS;
409
410/** Current DRVREG version number. */
411#define PDM_DRVINS_VERSION PDM_VERSION_MAKE(0xf0fe, 1, 0)
412
413/** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */
414#define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDRVINS, IBase)) )
415
416/** @def PDMDRVINS_2_RCPTR
417 * Converts a PDM Driver instance pointer a RC PDM Driver instance pointer.
418 */
419#define PDMDRVINS_2_RCPTR(pDrvIns) ( (RCPTRTYPE(PPDMDRVINS))((RTGCUINTPTR)(pDrvIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDRVINS, achInstanceData)) )
420
421/** @def PDMDRVINS_2_R3PTR
422 * Converts a PDM Driver instance pointer a R3 PDM Driver instance pointer.
423 */
424#define PDMDRVINS_2_R3PTR(pDrvIns) ( (R3PTRTYPE(PPDMDRVINS))((RTHCUINTPTR)(pDrvIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDRVINS, achInstanceData)) )
425
426/** @def PDMDRVINS_2_R0PTR
427 * Converts a PDM Driver instance pointer a R0 PDM Driver instance pointer.
428 */
429#define PDMDRVINS_2_R0PTR(pDrvIns) ( (R0PTRTYPE(PPDMDRVINS))((RTR0UINTPTR)(pDrvIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDRVINS, achInstanceData)) )
430
431
432
433/**
434 * Checks the structure versions of the drive instance and driver helpers,
435 * returning if they are incompatible.
436 *
437 * Intended for the constructor.
438 *
439 * @param pDrvIns Pointer to the PDM driver instance.
440 */
441#define PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns) \
442 do \
443 { \
444 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
445 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
446 ("DrvIns=%#x mine=%#x\n", (pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
447 VERR_PDM_DRVINS_VERSION_MISMATCH); \
448 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
449 ("DrvHlp=%#x mine=%#x\n", (pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
450 VERR_PDM_DRVHLPR3_VERSION_MISMATCH); \
451 } while (0)
452
453/**
454 * Quietly checks the structure versions of the drive instance and driver
455 * helpers, returning if they are incompatible.
456 *
457 * Intended for the destructor.
458 *
459 * @param pDrvIns Pointer to the PDM driver instance.
460 */
461#define PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns) \
462 do \
463 { \
464 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
465 if (RT_UNLIKELY( !PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION) \
466 || !PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pHlpR3->u32Version, PDM_DRVHLPR3_VERSION)) ) \
467 return; \
468 } while (0)
469
470/**
471 * Wrapper around CFGMR3ValidateConfig for the root config for use in the
472 * constructor - returns on failure.
473 *
474 * This should be invoked after having initialized the instance data
475 * sufficiently for the correct operation of the destructor. The destructor is
476 * always called!
477 *
478 * @param pDrvIns Pointer to the PDM driver instance.
479 * @param pszValidValues Patterns describing the valid value names. See
480 * RTStrSimplePatternMultiMatch for details on the
481 * pattern syntax.
482 * @param pszValidNodes Patterns describing the valid node (key) names.
483 * Pass empty string if no valid nodess.
484 */
485#define PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, pszValidValues, pszValidNodes) \
486 do \
487 { \
488 int rcValCfg = CFGMR3ValidateConfig((pDrvIns)->pCfg, "/", pszValidValues, pszValidNodes, \
489 (pDrvIns)->pReg->szName, (pDrvIns)->iInstance); \
490 if (RT_FAILURE(rcValCfg)) \
491 return rcValCfg; \
492 } while (0)
493
494
495
496/**
497 * USB hub registration structure.
498 */
499typedef struct PDMUSBHUBREG
500{
501 /** Structure version number. PDM_USBHUBREG_VERSION defines the current version. */
502 uint32_t u32Version;
503
504 /**
505 * Request the hub to attach of the specified device.
506 *
507 * @returns VBox status code.
508 * @param pDrvIns The hub instance.
509 * @param pUsbIns The device to attach.
510 * @param piPort Where to store the port number the device was attached to.
511 * @thread EMT.
512 */
513 DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t *piPort));
514
515 /**
516 * Request the hub to detach of the specified device.
517 *
518 * The device has previously been attached to the hub with the
519 * pfnAttachDevice call. This call is not currently expected to
520 * fail.
521 *
522 * @returns VBox status code.
523 * @param pDrvIns The hub instance.
524 * @param pUsbIns The device to detach.
525 * @param iPort The port number returned by the attach call.
526 * @thread EMT.
527 */
528 DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t iPort));
529
530 /** Counterpart to u32Version, same value. */
531 uint32_t u32TheEnd;
532} PDMUSBHUBREG;
533/** Pointer to a const USB hub registration structure. */
534typedef const PDMUSBHUBREG *PCPDMUSBHUBREG;
535
536/** Current PDMUSBHUBREG version number. */
537#define PDM_USBHUBREG_VERSION PDM_VERSION_MAKE(0xf0fd, 1, 0)
538
539
540/**
541 * USB hub helpers.
542 * This is currently just a place holder.
543 */
544typedef struct PDMUSBHUBHLP
545{
546 /** Structure version. PDM_USBHUBHLP_VERSION defines the current version. */
547 uint32_t u32Version;
548
549 /** Just a safety precaution. */
550 uint32_t u32TheEnd;
551} PDMUSBHUBHLP;
552/** Pointer to PCI helpers. */
553typedef PDMUSBHUBHLP *PPDMUSBHUBHLP;
554/** Pointer to const PCI helpers. */
555typedef const PDMUSBHUBHLP *PCPDMUSBHUBHLP;
556/** Pointer to const PCI helpers pointer. */
557typedef PCPDMUSBHUBHLP *PPCPDMUSBHUBHLP;
558
559/** Current PDMUSBHUBHLP version number. */
560#define PDM_USBHUBHLP_VERSION PDM_VERSION_MAKE(0xf0fc, 1, 0)
561
562
563/**
564 * PDM Driver API - raw-mode context variant.
565 */
566typedef struct PDMDRVHLPRC
567{
568 /** Structure version. PDM_DRVHLPRC_VERSION defines the current version. */
569 uint32_t u32Version;
570
571 /**
572 * Set the VM error message
573 *
574 * @returns rc.
575 * @param pDrvIns Driver instance.
576 * @param rc VBox status code.
577 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
578 * @param pszFormat Error message format string.
579 * @param ... Error message arguments.
580 */
581 DECLRCCALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
582
583 /**
584 * Set the VM error message
585 *
586 * @returns rc.
587 * @param pDrvIns Driver instance.
588 * @param rc VBox status code.
589 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
590 * @param pszFormat Error message format string.
591 * @param va Error message arguments.
592 */
593 DECLRCCALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
594
595 /**
596 * Set the VM runtime error message
597 *
598 * @returns VBox status code.
599 * @param pDrvIns Driver instance.
600 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
601 * @param pszErrorId Error ID string.
602 * @param pszFormat Error message format string.
603 * @param ... Error message arguments.
604 */
605 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
606
607 /**
608 * Set the VM runtime error message
609 *
610 * @returns VBox status code.
611 * @param pDrvIns Driver instance.
612 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
613 * @param pszErrorId Error ID string.
614 * @param pszFormat Error message format string.
615 * @param va Error message arguments.
616 */
617 DECLRCCALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
618
619 /**
620 * Assert that the current thread is the emulation thread.
621 *
622 * @returns True if correct.
623 * @returns False if wrong.
624 * @param pDrvIns Driver instance.
625 * @param pszFile Filename of the assertion location.
626 * @param iLine Linenumber of the assertion location.
627 * @param pszFunction Function of the assertion location.
628 */
629 DECLRCCALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
630
631 /**
632 * Assert that the current thread is NOT the emulation thread.
633 *
634 * @returns True if correct.
635 * @returns False if wrong.
636 * @param pDrvIns Driver instance.
637 * @param pszFile Filename of the assertion location.
638 * @param iLine Linenumber of the assertion location.
639 * @param pszFunction Function of the assertion location.
640 */
641 DECLRCCALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
642
643 /**
644 * Notify FTM about a checkpoint occurrence
645 *
646 * @param pDrvIns The driver instance.
647 * @param enmType Checkpoint type
648 * @thread Any
649 */
650 DECLRCCALLBACKMEMBER(int, pfnFTSetCheckpoint,(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType));
651
652 /** Just a safety precaution. */
653 uint32_t u32TheEnd;
654} PDMDRVHLPRC;
655/** Current PDMDRVHLPRC version number. */
656#define PDM_DRVHLPRC_VERSION PDM_VERSION_MAKE(0xf0f9, 2, 0)
657
658
659/**
660 * PDM Driver API, ring-0 context.
661 */
662typedef struct PDMDRVHLPR0
663{
664 /** Structure version. PDM_DRVHLPR0_VERSION defines the current version. */
665 uint32_t u32Version;
666
667 /**
668 * Set the VM error message
669 *
670 * @returns rc.
671 * @param pDrvIns Driver instance.
672 * @param rc VBox status code.
673 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
674 * @param pszFormat Error message format string.
675 * @param ... Error message arguments.
676 */
677 DECLR0CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
678
679 /**
680 * Set the VM error message
681 *
682 * @returns rc.
683 * @param pDrvIns Driver instance.
684 * @param rc VBox status code.
685 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
686 * @param pszFormat Error message format string.
687 * @param va Error message arguments.
688 */
689 DECLR0CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
690
691 /**
692 * Set the VM runtime error message
693 *
694 * @returns VBox status code.
695 * @param pDrvIns Driver instance.
696 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
697 * @param pszErrorId Error ID string.
698 * @param pszFormat Error message format string.
699 * @param ... Error message arguments.
700 */
701 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
702
703 /**
704 * Set the VM runtime error message
705 *
706 * @returns VBox status code.
707 * @param pDrvIns Driver instance.
708 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
709 * @param pszErrorId Error ID string.
710 * @param pszFormat Error message format string.
711 * @param va Error message arguments.
712 */
713 DECLR0CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
714
715 /**
716 * Assert that the current thread is the emulation thread.
717 *
718 * @returns True if correct.
719 * @returns False if wrong.
720 * @param pDrvIns Driver instance.
721 * @param pszFile Filename of the assertion location.
722 * @param iLine Linenumber of the assertion location.
723 * @param pszFunction Function of the assertion location.
724 */
725 DECLR0CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
726
727 /**
728 * Assert that the current thread is NOT 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, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
738
739 /**
740 * Notify FTM about a checkpoint occurrence
741 *
742 * @param pDrvIns The driver instance.
743 * @param enmType Checkpoint type
744 * @thread Any
745 */
746 DECLR0CALLBACKMEMBER(int, pfnFTSetCheckpoint,(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType));
747
748 /** Just a safety precaution. */
749 uint32_t u32TheEnd;
750} PDMDRVHLPR0;
751/** Current DRVHLP version number. */
752#define PDM_DRVHLPR0_VERSION PDM_VERSION_MAKE(0xf0f8, 2, 0)
753
754
755#ifdef IN_RING3
756
757/**
758 * PDM Driver API.
759 */
760typedef struct PDMDRVHLPR3
761{
762 /** Structure version. PDM_DRVHLPR3_VERSION defines the current version. */
763 uint32_t u32Version;
764
765 /**
766 * Attaches a driver (chain) to the driver.
767 *
768 * @returns VBox status code.
769 * @param pDrvIns Driver instance.
770 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
771 * @param ppBaseInterface Where to store the pointer to the base interface.
772 */
773 DECLR3CALLBACKMEMBER(int, pfnAttach,(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface));
774
775 /**
776 * Detach the driver the drivers below us.
777 *
778 * @returns VBox status code.
779 * @param pDrvIns Driver instance.
780 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
781 */
782 DECLR3CALLBACKMEMBER(int, pfnDetach,(PPDMDRVINS pDrvIns, uint32_t fFlags));
783
784 /**
785 * Detach the driver from the driver above it and destroy this
786 * driver and all drivers below it.
787 *
788 * @returns VBox status code.
789 * @param pDrvIns Driver instance.
790 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
791 */
792 DECLR3CALLBACKMEMBER(int, pfnDetachSelf,(PPDMDRVINS pDrvIns, uint32_t fFlags));
793
794 /**
795 * Prepare a media mount.
796 *
797 * The driver must not have anything attached to itself
798 * when calling this function as the purpose is to set up the configuration
799 * of an future attachment.
800 *
801 * @returns VBox status code
802 * @param pDrvIns Driver instance.
803 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
804 * constructed a configuration which can be attached to the bottom driver.
805 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
806 */
807 DECLR3CALLBACKMEMBER(int, pfnMountPrepare,(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver));
808
809 /**
810 * Assert that the current thread is the emulation thread.
811 *
812 * @returns True if correct.
813 * @returns False if wrong.
814 * @param pDrvIns Driver instance.
815 * @param pszFile Filename of the assertion location.
816 * @param iLine Linenumber of the assertion location.
817 * @param pszFunction Function of the assertion location.
818 */
819 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
820
821 /**
822 * Assert that the current thread is NOT 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, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
832
833 /**
834 * Set the VM error message
835 *
836 * @returns rc.
837 * @param pDrvIns Driver instance.
838 * @param rc VBox status code.
839 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
840 * @param pszFormat Error message format string.
841 * @param ... Error message arguments.
842 */
843 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
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 RT_SRC_POS_DECL Use RT_SRC_POS.
852 * @param pszFormat Error message format string.
853 * @param va Error message arguments.
854 */
855 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
856
857 /**
858 * Set the VM runtime error message
859 *
860 * @returns VBox status code.
861 * @param pDrvIns Driver instance.
862 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
863 * @param pszErrorId Error ID string.
864 * @param pszFormat Error message format string.
865 * @param ... Error message arguments.
866 */
867 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
868
869 /**
870 * Set the VM runtime error message
871 *
872 * @returns VBox status code.
873 * @param pDrvIns Driver instance.
874 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
875 * @param pszErrorId Error ID string.
876 * @param pszFormat Error message format string.
877 * @param va Error message arguments.
878 */
879 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
880
881 /**
882 * Gets the VM state.
883 *
884 * @returns VM state.
885 * @param pDrvIns The driver instance.
886 * @thread Any thread (just keep in mind that it's volatile info).
887 */
888 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDRVINS pDrvIns));
889
890 /**
891 * Checks if the VM was teleported and hasn't been fully resumed yet.
892 *
893 * @returns true / false.
894 * @param pDrvIns The driver instance.
895 * @thread Any thread.
896 */
897 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDRVINS pDrvIns));
898
899 /**
900 * Gets the support driver session.
901 *
902 * This is intended for working using the semaphore API.
903 *
904 * @returns Support driver session handle.
905 * @param pDrvIns The driver instance.
906 */
907 DECLR3CALLBACKMEMBER(PSUPDRVSESSION, pfnGetSupDrvSession,(PPDMDRVINS pDrvIns));
908
909 /**
910 * Create a queue.
911 *
912 * @returns VBox status code.
913 * @param pDrvIns Driver instance.
914 * @param cbItem Size a queue item.
915 * @param cItems Number of items in the queue.
916 * @param cMilliesInterval Number of milliseconds between polling the queue.
917 * If 0 then the emulation thread will be notified whenever an item arrives.
918 * @param pfnCallback The consumer function.
919 * @param pszName The queue base name. The instance number will be
920 * appended automatically.
921 * @param ppQueue Where to store the queue handle on success.
922 * @thread The emulation thread.
923 */
924 DECLR3CALLBACKMEMBER(int, pfnQueueCreate,(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
925 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue));
926
927 /**
928 * Query the virtual timer frequency.
929 *
930 * @returns Frequency in Hz.
931 * @param pDrvIns Driver instance.
932 * @thread Any thread.
933 */
934 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMDRVINS pDrvIns));
935
936 /**
937 * Query the virtual time.
938 *
939 * @returns The current virtual time.
940 * @param pDrvIns Driver instance.
941 * @thread Any thread.
942 */
943 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMDRVINS pDrvIns));
944
945 /**
946 * Creates a timer.
947 *
948 * @returns VBox status.
949 * @param pDrvIns Driver instance.
950 * @param enmClock The clock to use on this timer.
951 * @param pfnCallback Callback function.
952 * @param pvUser The user argument to the callback.
953 * @param fFlags Timer creation flags, see grp_tm_timer_flags.
954 * @param pszDesc Pointer to description string which must stay around
955 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
956 * @param ppTimer Where to store the timer on success.
957 * @thread EMT
958 */
959 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
960
961 /**
962 * Register a save state data unit.
963 *
964 * @returns VBox status.
965 * @param pDrvIns Driver instance.
966 * @param uVersion Data layout version number.
967 * @param cbGuess The approximate amount of data in the unit.
968 * Only for progress indicators.
969 *
970 * @param pfnLivePrep Prepare live save callback, optional.
971 * @param pfnLiveExec Execute live save callback, optional.
972 * @param pfnLiveVote Vote live save callback, optional.
973 *
974 * @param pfnSavePrep Prepare save callback, optional.
975 * @param pfnSaveExec Execute save callback, optional.
976 * @param pfnSaveDone Done save callback, optional.
977 *
978 * @param pfnLoadPrep Prepare load callback, optional.
979 * @param pfnLoadExec Execute load callback, optional.
980 * @param pfnLoadDone Done load callback, optional.
981 */
982 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
983 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
984 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
985 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone));
986
987 /**
988 * Deregister a save state data unit.
989 *
990 * @returns VBox status.
991 * @param pDrvIns Driver instance.
992 * @param pszName Data unit name.
993 * @param uInstance The instance identifier of the data unit.
994 * This must together with the name be unique.
995 */
996 DECLR3CALLBACKMEMBER(int, pfnSSMDeregister,(PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance));
997
998 /**
999 * Register an info handler with DBGF.
1000 *
1001 * @returns VBox status code.
1002 * @param pDrvIns Driver instance.
1003 * @param pszName Data unit name.
1004 * @param pszDesc The description of the info and any arguments
1005 * the handler may take.
1006 * @param pfnHandler The handler function to be called to display the
1007 * info.
1008 */
1009 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoRegister,(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler));
1010
1011 /**
1012 * Deregister an info handler from DBGF.
1013 *
1014 * @returns VBox status code.
1015 * @param pDrvIns Driver instance.
1016 * @param pszName Data unit name.
1017 */
1018 DECLR3CALLBACKMEMBER(int, pfnDBGFInfoDeregister,(PPDMDRVINS pDrvIns, const char *pszName));
1019
1020 /**
1021 * Registers a statistics sample if statistics are enabled.
1022 *
1023 * @param pDrvIns Driver instance.
1024 * @param pvSample Pointer to the sample.
1025 * @param enmType Sample type. This indicates what pvSample is pointing at.
1026 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
1027 * Further nesting is possible.
1028 * @param enmUnit Sample unit.
1029 * @param pszDesc Sample description.
1030 */
1031 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName,
1032 STAMUNIT enmUnit, const char *pszDesc));
1033
1034 /**
1035 * Same as pfnSTAMRegister except that the name is specified in a
1036 * RTStrPrintf like fashion.
1037 *
1038 * @param pDrvIns Driver instance.
1039 * @param pvSample Pointer to the sample.
1040 * @param enmType Sample type. This indicates what pvSample is pointing at.
1041 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
1042 * @param enmUnit Sample unit.
1043 * @param pszDesc Sample description.
1044 * @param pszName The sample name format string.
1045 * @param ... Arguments to the format string.
1046 */
1047 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1048 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
1049
1050 /**
1051 * Same as pfnSTAMRegister except that the name is specified in a
1052 * RTStrPrintfV 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 args Arguments to the format string.
1062 */
1063 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1064 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
1065
1066 /**
1067 * Deregister a statistic item previously registered with pfnSTAMRegister,
1068 * pfnSTAMRegisterF or pfnSTAMRegisterV
1069 *
1070 * @returns VBox status.
1071 * @param pDrvIns Driver instance.
1072 * @param pvSample Pointer to the sample.
1073 */
1074 DECLR3CALLBACKMEMBER(int, pfnSTAMDeregister,(PPDMDRVINS pDrvIns, void *pvSample));
1075
1076 /**
1077 * Calls the HC R0 VMM entry point, in a safer but slower manner than
1078 * SUPR3CallVMMR0.
1079 *
1080 * When entering using this call the R0 components can call into the host kernel
1081 * (i.e. use the SUPR0 and RT APIs).
1082 *
1083 * See VMMR0Entry() for more details.
1084 *
1085 * @returns error code specific to uFunction.
1086 * @param pDrvIns The driver instance.
1087 * @param uOperation Operation to execute.
1088 * This is limited to services.
1089 * @param pvArg Pointer to argument structure or if cbArg is 0 just an value.
1090 * @param cbArg The size of the argument. This is used to copy whatever the argument
1091 * points at into a kernel buffer to avoid problems like the user page
1092 * being invalidated while we're executing the call.
1093 */
1094 DECLR3CALLBACKMEMBER(int, pfnSUPCallVMMR0Ex,(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg));
1095
1096 /**
1097 * Registers a USB HUB.
1098 *
1099 * @returns VBox status code.
1100 * @param pDrvIns The driver instance.
1101 * @param fVersions Indicates the kinds of USB devices that can be attached to this HUB.
1102 * @param cPorts The number of ports.
1103 * @param pUsbHubReg The hub callback structure that PDMUsb uses to interact with it.
1104 * @param ppUsbHubHlp The helper callback structure that the hub uses to talk to PDMUsb.
1105 *
1106 * @thread EMT.
1107 */
1108 DECLR3CALLBACKMEMBER(int, pfnUSBRegisterHub,(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp));
1109
1110 /**
1111 * Set up asynchronous handling of a suspend, reset or power off notification.
1112 *
1113 * This shall only be called when getting the notification. It must be called
1114 * for each one.
1115 *
1116 * @returns VBox status code.
1117 * @param pDrvIns The driver instance.
1118 * @param pfnAsyncNotify The callback.
1119 * @thread EMT(0)
1120 */
1121 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify));
1122
1123 /**
1124 * Notify EMT(0) that the driver has completed the asynchronous notification
1125 * handling.
1126 *
1127 * This can be called at any time, spurious calls will simply be ignored.
1128 *
1129 * @param pDrvIns The driver instance.
1130 * @thread Any
1131 */
1132 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDRVINS pDrvIns));
1133
1134 /**
1135 * Creates a PDM thread.
1136 *
1137 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
1138 * resuming, and destroying the thread as the VM state changes.
1139 *
1140 * @returns VBox status code.
1141 * @param pDrvIns The driver instance.
1142 * @param ppThread Where to store the thread 'handle'.
1143 * @param pvUser The user argument to the thread function.
1144 * @param pfnThread The thread function.
1145 * @param pfnWakeup The wakup callback. This is called on the EMT thread when
1146 * a state change is pending.
1147 * @param cbStack See RTThreadCreate.
1148 * @param enmType See RTThreadCreate.
1149 * @param pszName See RTThreadCreate.
1150 */
1151 DECLR3CALLBACKMEMBER(int, pfnThreadCreate,(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1152 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
1153
1154 /**
1155 * Creates an async completion template for a driver instance.
1156 *
1157 * The template is used when creating new completion tasks.
1158 *
1159 * @returns VBox status code.
1160 * @param pDrvIns The driver instance.
1161 * @param ppTemplate Where to store the template pointer on success.
1162 * @param pfnCompleted The completion callback routine.
1163 * @param pvTemplateUser Template user argument.
1164 * @param pszDesc Description.
1165 */
1166 DECLR3CALLBACKMEMBER(int, pfnAsyncCompletionTemplateCreate,(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1167 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
1168 const char *pszDesc));
1169
1170#ifdef VBOX_WITH_NETSHAPER
1171 /**
1172 * Attaches network filter driver to a bandwidth group.
1173 *
1174 * @returns VBox status code.
1175 * @param pDrvIns The driver instance.
1176 * @param pcszBwGroup Name of the bandwidth group to attach to.
1177 * @param pFilter Pointer to the filter we attach.
1178 */
1179 DECLR3CALLBACKMEMBER(int, pfnNetShaperAttach,(PPDMDRVINS pDrvIns, const char *pszBwGroup,
1180 PPDMNSFILTER pFilter));
1181
1182
1183 /**
1184 * Detaches network filter driver to a bandwidth group.
1185 *
1186 * @returns VBox status code.
1187 * @param pDrvIns The driver instance.
1188 * @param pFilter Pointer to the filter we attach.
1189 */
1190 DECLR3CALLBACKMEMBER(int, pfnNetShaperDetach,(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter));
1191#endif /* VBOX_WITH_NETSHAPER */
1192
1193
1194 /**
1195 * Resolves the symbol for a raw-mode context interface.
1196 *
1197 * @returns VBox status code.
1198 * @param pDrvIns The driver instance.
1199 * @param pvInterface The interface structure.
1200 * @param cbInterface The size of the interface structure.
1201 * @param pszSymPrefix What to prefix the symbols in the list with before
1202 * resolving them. This must start with 'drv' and
1203 * contain the driver name.
1204 * @param pszSymList List of symbols corresponding to the interface.
1205 * There is generally a there is generally a define
1206 * holding this list associated with the interface
1207 * definition (INTERFACE_SYM_LIST). For more details
1208 * see PDMR3LdrGetInterfaceSymbols.
1209 * @thread EMT
1210 */
1211 DECLR3CALLBACKMEMBER(int, pfnLdrGetRCInterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1212 const char *pszSymPrefix, const char *pszSymList));
1213
1214 /**
1215 * Resolves the symbol for a ring-0 context interface.
1216 *
1217 * @returns VBox status code.
1218 * @param pDrvIns The driver instance.
1219 * @param pvInterface The interface structure.
1220 * @param cbInterface The size of the interface structure.
1221 * @param pszSymPrefix What to prefix the symbols in the list with before
1222 * resolving them. This must start with 'drv' and
1223 * contain the driver name.
1224 * @param pszSymList List of symbols corresponding to the interface.
1225 * There is generally a there is generally a define
1226 * holding this list associated with the interface
1227 * definition (INTERFACE_SYM_LIST). For more details
1228 * see PDMR3LdrGetInterfaceSymbols.
1229 * @thread EMT
1230 */
1231 DECLR3CALLBACKMEMBER(int, pfnLdrGetR0InterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1232 const char *pszSymPrefix, const char *pszSymList));
1233 /**
1234 * Initializes a PDM critical section.
1235 *
1236 * The PDM critical sections are derived from the IPRT critical sections, but
1237 * works in both RC and R0 as well as R3.
1238 *
1239 * @returns VBox status code.
1240 * @param pDrvIns The driver instance.
1241 * @param pCritSect Pointer to the critical section.
1242 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
1243 * @param pszName The base name of the critical section. Will be
1244 * mangeled with the instance number. For
1245 * statistics and lock validation.
1246 * @param va Arguments for the format string.
1247 * @thread EMT
1248 */
1249 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect,
1250 RT_SRC_POS_DECL, const char *pszName));
1251
1252 /**
1253 * Call the ring-0 request handler routine of the driver.
1254 *
1255 * For this to work, the driver must be ring-0 enabled and export a request
1256 * handler function. The name of the function must be the driver name in the
1257 * PDMDRVREG struct prefixed with 'drvR0' and suffixed with 'ReqHandler'.
1258 * The driver name will be capitalized. It shall take the exact same
1259 * arguments as this function and be declared using PDMBOTHCBDECL. See
1260 * FNPDMDRVREQHANDLERR0.
1261 *
1262 * @returns VBox status code.
1263 * @retval VERR_SYMBOL_NOT_FOUND if the driver doesn't export the required
1264 * handler function.
1265 * @retval VERR_ACCESS_DENIED if the driver isn't ring-0 capable.
1266 *
1267 * @param pDrvIns The driver instance.
1268 * @param uOperation The operation to perform.
1269 * @param u64Arg 64-bit integer argument.
1270 * @thread Any
1271 */
1272 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg));
1273
1274 /**
1275 * Notify FTM about a checkpoint occurrence
1276 *
1277 * @param pDrvIns The driver instance.
1278 * @param enmType Checkpoint type
1279 * @thread Any
1280 */
1281 DECLR3CALLBACKMEMBER(int, pfnFTSetCheckpoint,(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType));
1282
1283 /**
1284 * Creates a block cache for a driver driver instance.
1285 *
1286 * @returns VBox status code.
1287 * @param pDrvIns The driver instance.
1288 * @param ppBlkCache Where to store the handle to the block cache.
1289 * @param pfnXferComplete The I/O transfer complete callback.
1290 * @param pfnXferEnqueue The I/O request enqueue callback.
1291 * @param pcszId Unique ID used to identify the user.
1292 */
1293 DECLR3CALLBACKMEMBER(int, pfnBlkCacheRetain, (PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
1294 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
1295 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
1296 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
1297 const char *pcszId));
1298
1299 /** Just a safety precaution. */
1300 uint32_t u32TheEnd;
1301} PDMDRVHLPR3;
1302/** Current DRVHLP version number. */
1303#define PDM_DRVHLPR3_VERSION PDM_VERSION_MAKE(0xf0fb, 2, 0)
1304
1305#endif /* IN_RING3 */
1306
1307
1308/**
1309 * @copydoc PDMDRVHLP::pfnVMSetError
1310 */
1311DECLINLINE(int) PDMDrvHlpVMSetError(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
1312{
1313 va_list va;
1314 va_start(va, pszFormat);
1315 pDrvIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1316 va_end(va);
1317 return rc;
1318}
1319
1320/** @def PDMDRV_SET_ERROR
1321 * Set the VM error. See PDMDrvHlpVMSetError() for printf like message formatting.
1322 */
1323#define PDMDRV_SET_ERROR(pDrvIns, rc, pszError) \
1324 PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, "%s", pszError)
1325
1326/**
1327 * @copydoc PDMDRVHLP::pfnVMSetErrorV
1328 */
1329DECLINLINE(int) PDMDrvHlpVMSetErrorV(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
1330{
1331 return pDrvIns->CTX_SUFF(pHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
1332}
1333
1334
1335/**
1336 * @copydoc PDMDRVHLP::pfnVMSetRuntimeError
1337 */
1338DECLINLINE(int) PDMDrvHlpVMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
1339{
1340 va_list va;
1341 int rc;
1342 va_start(va, pszFormat);
1343 rc = pDrvIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
1344 va_end(va);
1345 return rc;
1346}
1347
1348/** @def PDMDRV_SET_RUNTIME_ERROR
1349 * Set the VM runtime error. See PDMDrvHlpVMSetRuntimeError() for printf like message formatting.
1350 */
1351#define PDMDRV_SET_RUNTIME_ERROR(pDrvIns, fFlags, pszErrorId, pszError) \
1352 PDMDrvHlpVMSetRuntimeError(pDrvIns, fFlags, pszErrorId, "%s", pszError)
1353
1354/**
1355 * @copydoc PDMDRVHLP::pfnVMSetRuntimeErrorV
1356 */
1357DECLINLINE(int) PDMDrvHlpVMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
1358{
1359 return pDrvIns->CTX_SUFF(pHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
1360}
1361
1362
1363
1364/** @def PDMDRV_ASSERT_EMT
1365 * Assert that the current thread is the emulation thread.
1366 */
1367#ifdef VBOX_STRICT
1368# define PDMDRV_ASSERT_EMT(pDrvIns) pDrvIns->CTX_SUFF(pHlp)->pfnAssertEMT(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1369#else
1370# define PDMDRV_ASSERT_EMT(pDrvIns) do { } while (0)
1371#endif
1372
1373/** @def PDMDRV_ASSERT_OTHER
1374 * Assert that the current thread is NOT the emulation thread.
1375 */
1376#ifdef VBOX_STRICT
1377# define PDMDRV_ASSERT_OTHER(pDrvIns) pDrvIns->CTX_SUFF(pHlp)->pfnAssertOther(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1378#else
1379# define PDMDRV_ASSERT_OTHER(pDrvIns) do { } while (0)
1380#endif
1381
1382/**
1383 * @copydoc PDMDRVHLP::pfnFTSetCheckpoint
1384 */
1385DECLINLINE(int) PDMDrvHlpFTSetCheckpoint(PPDMDRVINS pDrvIns, FTMCHECKPOINTTYPE enmType)
1386{
1387 return pDrvIns->CTX_SUFF(pHlp)->pfnFTSetCheckpoint(pDrvIns, enmType);
1388}
1389
1390
1391#ifdef IN_RING3
1392
1393/**
1394 * @copydoc PDMDRVHLP::pfnAttach
1395 */
1396DECLINLINE(int) PDMDrvHlpAttach(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface)
1397{
1398 return pDrvIns->pHlpR3->pfnAttach(pDrvIns, fFlags, ppBaseInterface);
1399}
1400
1401/**
1402 * Check that there is no driver below the us that we should attach to.
1403 *
1404 * @returns VERR_PDM_NO_ATTACHED_DRIVER if there is no driver.
1405 * @param pDrvIns The driver instance.
1406 */
1407DECLINLINE(int) PDMDrvHlpNoAttach(PPDMDRVINS pDrvIns)
1408{
1409 return pDrvIns->pHlpR3->pfnAttach(pDrvIns, 0, NULL);
1410}
1411
1412/**
1413 * @copydoc PDMDRVHLP::pfnDetach
1414 */
1415DECLINLINE(int) PDMDrvHlpDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1416{
1417 return pDrvIns->pHlpR3->pfnDetach(pDrvIns, fFlags);
1418}
1419
1420/**
1421 * @copydoc PDMDRVHLP::pfnDetachSelf
1422 */
1423DECLINLINE(int) PDMDrvHlpDetachSelf(PPDMDRVINS pDrvIns, uint32_t fFlags)
1424{
1425 return pDrvIns->pHlpR3->pfnDetachSelf(pDrvIns, fFlags);
1426}
1427
1428/**
1429 * @copydoc PDMDRVHLP::pfnMountPrepare
1430 */
1431DECLINLINE(int) PDMDrvHlpMountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver)
1432{
1433 return pDrvIns->pHlpR3->pfnMountPrepare(pDrvIns, pszFilename, pszCoreDriver);
1434}
1435
1436/**
1437 * @copydoc PDMDRVHLP::pfnVMState
1438 */
1439DECLINLINE(VMSTATE) PDMDrvHlpVMState(PPDMDRVINS pDrvIns)
1440{
1441 return pDrvIns->CTX_SUFF(pHlp)->pfnVMState(pDrvIns);
1442}
1443
1444/**
1445 * @copydoc PDMDRVHLP::pfnVMTeleportedAndNotFullyResumedYet
1446 */
1447DECLINLINE(bool) PDMDrvHlpVMTeleportedAndNotFullyResumedYet(PPDMDRVINS pDrvIns)
1448{
1449 return pDrvIns->pHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDrvIns);
1450}
1451
1452/**
1453 * @copydoc PDMDRVHLP::pfnGetSupDrvSession
1454 */
1455DECLINLINE(PSUPDRVSESSION) PDMDrvHlpGetSupDrvSession(PPDMDRVINS pDrvIns)
1456{
1457 return pDrvIns->pHlpR3->pfnGetSupDrvSession(pDrvIns);
1458}
1459
1460/**
1461 * @copydoc PDMDRVHLP::pfnQueueCreate
1462 */
1463DECLINLINE(int) PDMDrvHlpQueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
1464 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
1465{
1466 return pDrvIns->pHlpR3->pfnQueueCreate(pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue);
1467}
1468
1469/**
1470 * @copydoc PDMDRVHLP::pfnTMGetVirtualFreq
1471 */
1472DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualFreq(PPDMDRVINS pDrvIns)
1473{
1474 return pDrvIns->pHlpR3->pfnTMGetVirtualFreq(pDrvIns);
1475}
1476
1477/**
1478 * @copydoc PDMDRVHLP::pfnTMGetVirtualTime
1479 */
1480DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualTime(PPDMDRVINS pDrvIns)
1481{
1482 return pDrvIns->pHlpR3->pfnTMGetVirtualTime(pDrvIns);
1483}
1484
1485/**
1486 * @copydoc PDMDRVHLP::pfnTMTimerCreate
1487 */
1488DECLINLINE(int) PDMDrvHlpTMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
1489{
1490 return pDrvIns->pHlpR3->pfnTMTimerCreate(pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
1491}
1492
1493/**
1494 * Register a save state data unit.
1495 *
1496 * @returns VBox status.
1497 * @param pDrvIns Driver instance.
1498 * @param uVersion Data layout version number.
1499 * @param cbGuess The approximate amount of data in the unit.
1500 * Only for progress indicators.
1501 * @param pfnSaveExec Execute save callback, optional.
1502 * @param pfnLoadExec Execute load callback, optional.
1503 */
1504DECLINLINE(int) PDMDrvHlpSSMRegister(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1505 PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVLOADEXEC pfnLoadExec)
1506{
1507 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1508 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1509 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
1510 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
1511}
1512
1513/**
1514 * @copydoc PDMDRVHLP::pfnSSMRegister
1515 */
1516DECLINLINE(int) PDMDrvHlpSSMRegisterEx(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1517 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1518 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1519 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
1520{
1521 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1522 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1523 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1524 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1525}
1526
1527/**
1528 * Register a load done callback.
1529 *
1530 * @returns VBox status.
1531 * @param pDrvIns Driver instance.
1532 * @param pfnLoadDone Done load callback, optional.
1533 */
1534DECLINLINE(int) PDMDrvHlpSSMRegisterLoadDone(PPDMDRVINS pDrvIns, PFNSSMDRVLOADDONE pfnLoadDone)
1535{
1536 return pDrvIns->pHlpR3->pfnSSMRegister(pDrvIns, 0 /*uVersion*/, 0 /*cbGuess*/,
1537 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1538 NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/,
1539 NULL /*pfnLoadPrep*/, NULL /*pfnLoadExec*/, pfnLoadDone);
1540}
1541
1542/**
1543 * @copydoc PDMDRVHLP::pfnDBGFInfoRegister
1544 */
1545DECLINLINE(int) PDMDrvHlpDBGFInfoRegister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1546{
1547 return pDrvIns->pHlpR3->pfnDBGFInfoRegister(pDrvIns, pszName, pszDesc, pfnHandler);
1548}
1549
1550/**
1551 * @copydoc PDMDRVHLP::pfnDBGFInfoDeregister
1552 */
1553DECLINLINE(int) PDMDrvHlpDBGFInfoDeregister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1554{
1555 return pDrvIns->pHlpR3->pfnDBGFInfoRegister(pDrvIns, pszName, pszDesc, pfnHandler);
1556}
1557
1558/**
1559 * @copydoc PDMDRVHLP::pfnSTAMRegister
1560 */
1561DECLINLINE(void) PDMDrvHlpSTAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1562{
1563 pDrvIns->pHlpR3->pfnSTAMRegister(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
1564}
1565
1566/**
1567 * @copydoc PDMDRVHLP::pfnSTAMRegisterF
1568 */
1569DECLINLINE(void) PDMDrvHlpSTAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
1570 const char *pszDesc, const char *pszName, ...)
1571{
1572 va_list va;
1573 va_start(va, pszName);
1574 pDrvIns->pHlpR3->pfnSTAMRegisterV(pDrvIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
1575 va_end(va);
1576}
1577
1578/**
1579 * Convenience wrapper that registers counter which is always visible.
1580 *
1581 * @param pDrvIns The driver instance.
1582 * @param pCounter Pointer to the counter variable.
1583 * @param pszName The name of the sample. This is prefixed with
1584 * "/Drivers/<drivername>-<instance no>/".
1585 * @param enmUnit The unit.
1586 * @param pszDesc The description.
1587 */
1588DECLINLINE(void) PDMDrvHlpSTAMRegCounterEx(PPDMDRVINS pDrvIns, PSTAMCOUNTER pCounter, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1589{
1590 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pCounter, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1591 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1592}
1593
1594/**
1595 * Convenience wrapper that registers counter which is always visible and has
1596 * the STAMUNIT_COUNT unit.
1597 *
1598 * @param pDrvIns The driver instance.
1599 * @param pCounter Pointer to the counter variable.
1600 * @param pszName The name of the sample. This is prefixed with
1601 * "/Drivers/<drivername>-<instance no>/".
1602 * @param pszDesc The description.
1603 */
1604DECLINLINE(void) PDMDrvHlpSTAMRegCounter(PPDMDRVINS pDrvIns, PSTAMCOUNTER pCounter, const char *pszName, const char *pszDesc)
1605{
1606 PDMDrvHlpSTAMRegCounterEx(pDrvIns, pCounter, pszName, STAMUNIT_COUNT, pszDesc);
1607}
1608
1609/**
1610 * Convenience wrapper that registers profiling sample which is always visible.
1611 *
1612 * @param pDrvIns The driver instance.
1613 * @param pProfile Pointer to the profiling variable.
1614 * @param pszName The name of the sample. This is prefixed with
1615 * "/Drivers/<drivername>-<instance no>/".
1616 * @param enmUnit The unit.
1617 * @param pszDesc The description.
1618 */
1619DECLINLINE(void) PDMDrvHlpSTAMRegProfileEx(PPDMDRVINS pDrvIns, PSTAMPROFILE pProfile, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1620{
1621 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pProfile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1622 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1623}
1624
1625/**
1626 * Convenience wrapper that registers profiling sample which is always visible
1627 * hand counts ticks per call (STAMUNIT_TICKS_PER_CALL).
1628 *
1629 * @param pDrvIns The driver instance.
1630 * @param pProfile Pointer to the profiling variable.
1631 * @param pszName The name of the sample. This is prefixed with
1632 * "/Drivers/<drivername>-<instance no>/".
1633 * @param pszDesc The description.
1634 */
1635DECLINLINE(void) PDMDrvHlpSTAMRegProfile(PPDMDRVINS pDrvIns, PSTAMPROFILE pProfile, const char *pszName, const char *pszDesc)
1636{
1637 PDMDrvHlpSTAMRegProfileEx(pDrvIns, pProfile, pszName, STAMUNIT_TICKS_PER_CALL, pszDesc);
1638}
1639
1640/**
1641 * Convenience wrapper that registers an advanced profiling sample which is
1642 * always visible.
1643 *
1644 * @param pDrvIns The driver instance.
1645 * @param pProfile Pointer to the profiling variable.
1646 * @param enmUnit The unit.
1647 * @param pszName The name of the sample. This is prefixed with
1648 * "/Drivers/<drivername>-<instance no>/".
1649 * @param pszDesc The description.
1650 */
1651DECLINLINE(void) PDMDrvHlpSTAMRegProfileAdvEx(PPDMDRVINS pDrvIns, PSTAMPROFILEADV pProfile, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1652{
1653 pDrvIns->pHlpR3->pfnSTAMRegisterF(pDrvIns, pProfile, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, enmUnit, pszDesc,
1654 "/Drivers/%s-%u/%s", pDrvIns->pReg->szName, pDrvIns->iInstance, pszName);
1655}
1656
1657/**
1658 * Convenience wrapper that registers an advanced profiling sample which is
1659 * always visible.
1660 *
1661 * @param pDrvIns The driver instance.
1662 * @param pProfile Pointer to the profiling variable.
1663 * @param pszName The name of the sample. This is prefixed with
1664 * "/Drivers/<drivername>-<instance no>/".
1665 * @param pszDesc The description.
1666 */
1667DECLINLINE(void) PDMDrvHlpSTAMRegProfileAdv(PPDMDRVINS pDrvIns, PSTAMPROFILEADV pProfile, const char *pszName, const char *pszDesc)
1668{
1669 PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, pProfile, pszName, STAMUNIT_TICKS_PER_CALL, pszDesc);
1670}
1671
1672/**
1673 * @copydoc PDMDRVHLP::pfnSTAMDeregister
1674 */
1675DECLINLINE(int) PDMDrvHlpSTAMDeregister(PPDMDRVINS pDrvIns, void *pvSample)
1676{
1677 return pDrvIns->pHlpR3->pfnSTAMDeregister(pDrvIns, pvSample);
1678}
1679
1680/**
1681 * @copydoc PDMDRVHLP::pfnSUPCallVMMR0Ex
1682 */
1683DECLINLINE(int) PDMDrvHlpSUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg)
1684{
1685 return pDrvIns->pHlpR3->pfnSUPCallVMMR0Ex(pDrvIns, uOperation, pvArg, cbArg);
1686}
1687
1688/**
1689 * @copydoc PDMDRVHLP::pfnUSBRegisterHub
1690 */
1691DECLINLINE(int) PDMDrvHlpUSBRegisterHub(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp)
1692{
1693 return pDrvIns->pHlpR3->pfnUSBRegisterHub(pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp);
1694}
1695
1696/**
1697 * @copydoc PDMDRVHLP::pfnSetAsyncNotification
1698 */
1699DECLINLINE(int) PDMDrvHlpSetAsyncNotification(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
1700{
1701 return pDrvIns->pHlpR3->pfnSetAsyncNotification(pDrvIns, pfnAsyncNotify);
1702}
1703
1704/**
1705 * @copydoc PDMDRVHLP::pfnAsyncNotificationCompleted
1706 */
1707DECLINLINE(void) PDMDrvHlpAsyncNotificationCompleted(PPDMDRVINS pDrvIns)
1708{
1709 pDrvIns->pHlpR3->pfnAsyncNotificationCompleted(pDrvIns);
1710}
1711
1712/**
1713 * @copydoc PDMDRVHLP::pfnThreadCreate
1714 */
1715DECLINLINE(int) PDMDrvHlpThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1716 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
1717{
1718 return pDrvIns->pHlpR3->pfnThreadCreate(pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
1719}
1720
1721# ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
1722/**
1723 * @copydoc PDMDRVHLP::pfnAsyncCompletionTemplateCreate
1724 */
1725DECLINLINE(int) PDMDrvHlpAsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1726 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc)
1727{
1728 return pDrvIns->pHlpR3->pfnAsyncCompletionTemplateCreate(pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
1729}
1730# endif
1731
1732# ifdef VBOX_WITH_NETSHAPER
1733/**
1734 * @copydoc PDMDRVHLP::pfnNetShaperAttach
1735 */
1736DECLINLINE(int) PDMDrvHlpNetShaperAttach(PPDMDRVINS pDrvIns, const char *pcszBwGroup, PPDMNSFILTER pFilter)
1737{
1738 return pDrvIns->pHlpR3->pfnNetShaperAttach(pDrvIns, pcszBwGroup, pFilter);
1739}
1740
1741/**
1742 * @copydoc PDMDRVHLP::pfnNetShaperDetach
1743 */
1744DECLINLINE(int) PDMDrvHlpNetShaperDetach(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter)
1745{
1746 return pDrvIns->pHlpR3->pfnNetShaperDetach(pDrvIns, pFilter);
1747}
1748# endif
1749
1750/**
1751 * @copydoc PDMDRVHLP::pfnCritSectInit
1752 */
1753DECLINLINE(int) PDMDrvHlpCritSectInit(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszName)
1754{
1755 return pDrvIns->pHlpR3->pfnCritSectInit(pDrvIns, pCritSect, RT_SRC_POS_ARGS, pszName);
1756}
1757
1758/**
1759 * @copydoc PDMDRVHLP::pfnCallR0
1760 */
1761DECLINLINE(int) PDMDrvHlpCallR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)
1762{
1763 return pDrvIns->pHlpR3->pfnCallR0(pDrvIns, uOperation, u64Arg);
1764}
1765
1766/**
1767 * @copydoc PDMDRVHLP::pfnBlkCacheRetain
1768 */
1769DECLINLINE(int) PDMDrvHlpBlkCacheRetain(PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
1770 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
1771 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
1772 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
1773 const char *pcszId)
1774{
1775 return pDrvIns->pHlpR3->pfnBlkCacheRetain(pDrvIns, ppBlkCache, pfnXferComplete, pfnXferEnqueue, pfnXferEnqueueDiscard, pcszId);
1776}
1777
1778/** Pointer to callbacks provided to the VBoxDriverRegister() call. */
1779typedef struct PDMDRVREGCB *PPDMDRVREGCB;
1780/** Pointer to const callbacks provided to the VBoxDriverRegister() call. */
1781typedef const struct PDMDRVREGCB *PCPDMDRVREGCB;
1782
1783/**
1784 * Callbacks for VBoxDriverRegister().
1785 */
1786typedef struct PDMDRVREGCB
1787{
1788 /** Interface version.
1789 * This is set to PDM_DRVREG_CB_VERSION. */
1790 uint32_t u32Version;
1791
1792 /**
1793 * Registers a driver with the current VM instance.
1794 *
1795 * @returns VBox status code.
1796 * @param pCallbacks Pointer to the callback table.
1797 * @param pReg Pointer to the driver registration record.
1798 * This data must be permanent and readonly.
1799 */
1800 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg));
1801} PDMDRVREGCB;
1802
1803/** Current version of the PDMDRVREGCB structure. */
1804#define PDM_DRVREG_CB_VERSION PDM_VERSION_MAKE(0xf0fa, 1, 0)
1805
1806
1807/**
1808 * The VBoxDriverRegister callback function.
1809 *
1810 * PDM will invoke this function after loading a driver module and letting
1811 * the module decide which drivers to register and how to handle conflicts.
1812 *
1813 * @returns VBox status code.
1814 * @param pCallbacks Pointer to the callback table.
1815 * @param u32Version VBox version number.
1816 */
1817typedef DECLCALLBACK(int) FNPDMVBOXDRIVERSREGISTER(PCPDMDRVREGCB pCallbacks, uint32_t u32Version);
1818
1819VMMR3DECL(int) PDMR3DrvStaticRegistration(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback);
1820
1821#endif /* IN_RING3 */
1822
1823/** @} */
1824
1825RT_C_DECLS_END
1826
1827#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