VirtualBox

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

Last change on this file since 104931 was 101620, checked in by vboxsync, 13 months ago

Devices/Gpio: Add virtual GPIO button driver to simulate button presses using GPIO, for passing power/sleep button requests to the guest, bugref:10538 [fix]

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

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