VirtualBox

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

Last change on this file since 76468 was 76404, checked in by vboxsync, 6 years ago

VBox/vmm/pdmnetshaper.h,pdmdev.h: Don't include err.h and assert.h in the former, and don't include the former from the latter. bugref:9344

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

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