VirtualBox

source: vbox/trunk/include/VBox/pdmdrv.h@ 26162

Last change on this file since 26162 was 26161, checked in by vboxsync, 15 years ago

PDM: s/pDrvReg/pReg/g

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 48.8 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Drivers. (VMM)
3 */
4
5/*
6 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_pdmdrv_h
31#define ___VBox_pdmdrv_h
32
33#include <VBox/pdmqueue.h>
34#include <VBox/pdmcritsect.h>
35#include <VBox/pdmthread.h>
36#include <VBox/pdmifs.h>
37#include <VBox/pdmins.h>
38#include <VBox/pdmcommon.h>
39#include <VBox/pdmasynccompletion.h>
40#include <VBox/tm.h>
41#include <VBox/ssm.h>
42#include <VBox/cfgm.h>
43#include <VBox/dbgf.h>
44#include <VBox/mm.h>
45#include <VBox/err.h>
46#include <iprt/stdarg.h>
47
48RT_C_DECLS_BEGIN
49
50/** @defgroup grp_pdm_driver The PDM Drivers API
51 * @ingroup grp_pdm
52 * @{
53 */
54
55/** Pointer const PDM Driver API, ring-3. */
56typedef R3PTRTYPE(struct PDMDRVHLPR3 const *) PCPDMDRVHLPR3;
57/** Pointer const PDM Driver API, ring-0. */
58typedef R0PTRTYPE(struct PDMDRVHLPR0 const *) PCPDMDRVHLPR0;
59/** Pointer const PDM Driver API, raw-mode context. */
60typedef RCPTRTYPE(struct PDMDRVHLPRC const *) PCPDMDRVHLPRC;
61
62
63/**
64 * Construct a driver instance for a VM.
65 *
66 * @returns VBox status.
67 * @param pDrvIns The driver instance data. If the registration structure
68 * is needed, it can be accessed thru pDrvIns->pReg.
69 * @param pCfgHandle Configuration node handle for the driver. Use this to
70 * obtain the configuration of the driver instance. It's
71 * also found in pDrvIns->pCfgHandle as it's expected to be
72 * used frequently in this function.
73 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
74 */
75typedef DECLCALLBACK(int) FNPDMDRVCONSTRUCT(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags);
76/** Pointer to a FNPDMDRVCONSTRUCT() function. */
77typedef FNPDMDRVCONSTRUCT *PFNPDMDRVCONSTRUCT;
78
79/**
80 * Destruct a driver instance.
81 *
82 * Most VM resources are freed by the VM. This callback is provided so that
83 * any non-VM resources can be freed correctly.
84 *
85 * @param pDrvIns The driver instance data.
86 */
87typedef DECLCALLBACK(void) FNPDMDRVDESTRUCT(PPDMDRVINS pDrvIns);
88/** Pointer to a FNPDMDRVDESTRUCT() function. */
89typedef FNPDMDRVDESTRUCT *PFNPDMDRVDESTRUCT;
90
91/**
92 * Driver relocation callback.
93 *
94 * This is called when the instance data has been relocated in raw-mode context
95 * (RC). It is also called when the RC hypervisor selects changes. The driver
96 * must fixup all necessary pointers and re-query all interfaces to other RC
97 * devices and drivers.
98 *
99 * Before the RC code is executed the first time, this function will be called
100 * with a 0 delta so RC pointer calculations can be one in one place.
101 *
102 * @param pDrvIns Pointer to the driver instance.
103 * @param offDelta The relocation delta relative to the old location.
104 *
105 * @remark A relocation CANNOT fail.
106 */
107typedef DECLCALLBACK(void) FNPDMDRVRELOCATE(PPDMDRVINS pDrvIns, RTGCINTPTR offDelta);
108/** Pointer to a FNPDMDRVRELOCATE() function. */
109typedef FNPDMDRVRELOCATE *PFNPDMDRVRELOCATE;
110
111/**
112 * Driver I/O Control interface.
113 *
114 * This is used by external components, such as the COM interface, to
115 * communicate with a driver using a driver specific interface. Generally,
116 * the driver interfaces are used for this task.
117 *
118 * @returns VBox status code.
119 * @param pDrvIns Pointer to the driver instance.
120 * @param uFunction Function to perform.
121 * @param pvIn Pointer to input data.
122 * @param cbIn Size of input data.
123 * @param pvOut Pointer to output data.
124 * @param cbOut Size of output data.
125 * @param pcbOut Where to store the actual size of the output data.
126 */
127typedef DECLCALLBACK(int) FNPDMDRVIOCTL(PPDMDRVINS pDrvIns, uint32_t uFunction,
128 void *pvIn, uint32_t cbIn,
129 void *pvOut, uint32_t cbOut, uint32_t *pcbOut);
130/** Pointer to a FNPDMDRVIOCTL() function. */
131typedef FNPDMDRVIOCTL *PFNPDMDRVIOCTL;
132
133/**
134 * Power On notification.
135 *
136 * @param pDrvIns The driver instance data.
137 */
138typedef DECLCALLBACK(void) FNPDMDRVPOWERON(PPDMDRVINS pDrvIns);
139/** Pointer to a FNPDMDRVPOWERON() function. */
140typedef FNPDMDRVPOWERON *PFNPDMDRVPOWERON;
141
142/**
143 * Reset notification.
144 *
145 * @returns VBox status.
146 * @param pDrvIns The driver instance data.
147 */
148typedef DECLCALLBACK(void) FNPDMDRVRESET(PPDMDRVINS pDrvIns);
149/** Pointer to a FNPDMDRVRESET() function. */
150typedef FNPDMDRVRESET *PFNPDMDRVRESET;
151
152/**
153 * Suspend notification.
154 *
155 * @returns VBox status.
156 * @param pDrvIns The driver instance data.
157 */
158typedef DECLCALLBACK(void) FNPDMDRVSUSPEND(PPDMDRVINS pDrvIns);
159/** Pointer to a FNPDMDRVSUSPEND() function. */
160typedef FNPDMDRVSUSPEND *PFNPDMDRVSUSPEND;
161
162/**
163 * Resume notification.
164 *
165 * @returns VBox status.
166 * @param pDrvIns The driver instance data.
167 */
168typedef DECLCALLBACK(void) FNPDMDRVRESUME(PPDMDRVINS pDrvIns);
169/** Pointer to a FNPDMDRVRESUME() function. */
170typedef FNPDMDRVRESUME *PFNPDMDRVRESUME;
171
172/**
173 * Power Off notification.
174 *
175 * @param pDrvIns The driver instance data.
176 */
177typedef DECLCALLBACK(void) FNPDMDRVPOWEROFF(PPDMDRVINS pDrvIns);
178/** Pointer to a FNPDMDRVPOWEROFF() function. */
179typedef FNPDMDRVPOWEROFF *PFNPDMDRVPOWEROFF;
180
181/**
182 * Attach command.
183 *
184 * This is called to let the drive attach to a driver at runtime. This is not
185 * called during VM construction, the driver constructor have to do this by
186 * calling PDMDrvHlpAttach.
187 *
188 * This is like plugging in the keyboard or mouse after turning on the PC.
189 *
190 * @returns VBox status code.
191 * @param pDrvIns The driver instance.
192 * @param fFlags Flags, combination of the PDM_TACH_FLAGS_* \#defines.
193 */
194typedef DECLCALLBACK(int) FNPDMDRVATTACH(PPDMDRVINS pDrvIns, uint32_t fFlags);
195/** Pointer to a FNPDMDRVATTACH() function. */
196typedef FNPDMDRVATTACH *PFNPDMDRVATTACH;
197
198/**
199 * Detach notification.
200 *
201 * This is called when a driver below it in the chain is detaching itself
202 * from it. The driver should adjust it's state to reflect this.
203 *
204 * This is like ejecting a cdrom or floppy.
205 *
206 * @param pDrvIns The driver instance.
207 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
208 */
209typedef DECLCALLBACK(void) FNPDMDRVDETACH(PPDMDRVINS pDrvIns, uint32_t fFlags);
210/** Pointer to a FNPDMDRVDETACH() function. */
211typedef FNPDMDRVDETACH *PFNPDMDRVDETACH;
212
213
214
215/**
216 * PDM Driver Registration Structure.
217 *
218 * This structure is used when registering a driver from VBoxInitDrivers() (in
219 * host ring-3 context). PDM will continue use till the VM is terminated.
220 */
221typedef struct PDMDRVREG
222{
223 /** Structure version. PDM_DRVREG_VERSION defines the current version. */
224 uint32_t u32Version;
225 /** Driver name. */
226 char szDriverName[32];
227 /** Name of the raw-mode context module (no path).
228 * Only evalutated if PDM_DRVREG_FLAGS_RC is set. */
229 char szRCMod[32];
230 /** Name of the ring-0 module (no path).
231 * Only evalutated if PDM_DRVREG_FLAGS_R0 is set. */
232 char szR0Mod[32];
233 /** The description of the driver. The UTF-8 string pointed to shall, like this structure,
234 * remain unchanged from registration till VM destruction. */
235 const char *pszDescription;
236
237 /** Flags, combination of the PDM_DRVREG_FLAGS_* \#defines. */
238 uint32_t fFlags;
239 /** Driver class(es), combination of the PDM_DRVREG_CLASS_* \#defines. */
240 uint32_t fClass;
241 /** Maximum number of instances (per VM). */
242 uint32_t cMaxInstances;
243 /** Size of the instance data. */
244 uint32_t cbInstance;
245
246 /** Construct instance - required. */
247 PFNPDMDRVCONSTRUCT pfnConstruct;
248 /** Destruct instance - optional. */
249 PFNPDMDRVDESTRUCT pfnDestruct;
250 /** Relocation command - optional. */
251 PFNPDMDRVRELOCATE pfnRelocate;
252 /** I/O control - optional. */
253 PFNPDMDRVIOCTL pfnIOCtl;
254 /** Power on notification - optional. */
255 PFNPDMDRVPOWERON pfnPowerOn;
256 /** Reset notification - optional. */
257 PFNPDMDRVRESET pfnReset;
258 /** Suspend notification - optional. */
259 PFNPDMDRVSUSPEND pfnSuspend;
260 /** Resume notification - optional. */
261 PFNPDMDRVRESUME pfnResume;
262 /** Attach command - optional. */
263 PFNPDMDRVATTACH pfnAttach;
264 /** Detach notification - optional. */
265 PFNPDMDRVDETACH pfnDetach;
266 /** Power off notification - optional. */
267 PFNPDMDRVPOWEROFF pfnPowerOff;
268 /** @todo */
269 PFNRT pfnSoftReset;
270 /** Initialization safty marker. */
271 uint32_t u32VersionEnd;
272} PDMDRVREG;
273/** Pointer to a PDM Driver Structure. */
274typedef PDMDRVREG *PPDMDRVREG;
275/** Const pointer to a PDM Driver Structure. */
276typedef PDMDRVREG const *PCPDMDRVREG;
277
278/** Current DRVREG version number. */
279#define PDM_DRVREG_VERSION PDM_VERSION_MAKE(0xf0ff, 1, 0)
280
281/** PDM Driver Flags.
282 * @{ */
283/** @def PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT
284 * The bit count for the current host. */
285#if HC_ARCH_BITS == 32
286# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000001)
287#elif HC_ARCH_BITS == 64
288# define PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT UINT32_C(0x00000002)
289#else
290# error Unsupported HC_ARCH_BITS value.
291#endif
292/** The host bit count mask. */
293#define PDM_DRVREG_FLAGS_HOST_BITS_MASK UINT32_C(0x00000003)
294/** This flag is used to indicate that the driver has a RC component. */
295#define PDM_DRVREG_FLAGS_RC UINT32_C(0x00000010)
296/** This flag is used to indicate that the driver has a R0 component. */
297#define PDM_DRVREG_FLAGS_R0 UINT32_C(0x00000020)
298
299/** @} */
300
301
302/** PDM Driver Classes.
303 * @{ */
304/** Mouse input driver. */
305#define PDM_DRVREG_CLASS_MOUSE RT_BIT(0)
306/** Keyboard input driver. */
307#define PDM_DRVREG_CLASS_KEYBOARD RT_BIT(1)
308/** Display driver. */
309#define PDM_DRVREG_CLASS_DISPLAY RT_BIT(2)
310/** Network transport driver. */
311#define PDM_DRVREG_CLASS_NETWORK RT_BIT(3)
312/** Block driver. */
313#define PDM_DRVREG_CLASS_BLOCK RT_BIT(4)
314/** Media driver. */
315#define PDM_DRVREG_CLASS_MEDIA RT_BIT(5)
316/** Mountable driver. */
317#define PDM_DRVREG_CLASS_MOUNTABLE RT_BIT(6)
318/** Audio driver. */
319#define PDM_DRVREG_CLASS_AUDIO RT_BIT(7)
320/** VMMDev driver. */
321#define PDM_DRVREG_CLASS_VMMDEV RT_BIT(8)
322/** Status driver. */
323#define PDM_DRVREG_CLASS_STATUS RT_BIT(9)
324/** ACPI driver. */
325#define PDM_DRVREG_CLASS_ACPI RT_BIT(10)
326/** USB related driver. */
327#define PDM_DRVREG_CLASS_USB RT_BIT(11)
328/** ISCSI Transport related driver. */
329#define PDM_DRVREG_CLASS_ISCSITRANSPORT RT_BIT(12)
330/** Char driver. */
331#define PDM_DRVREG_CLASS_CHAR RT_BIT(13)
332/** Stream driver. */
333#define PDM_DRVREG_CLASS_STREAM RT_BIT(14)
334/** SCSI driver. */
335#define PDM_DRVREG_CLASS_SCSI RT_BIT(15)
336/** @} */
337
338
339/**
340 * PDM Driver Instance.
341 *
342 * @implements PDMIBASE
343 */
344typedef struct PDMDRVINS
345{
346 /** Structure version. PDM_DRVINS_VERSION defines the current version. */
347 uint32_t u32Version;
348 /** Driver instance number. */
349 uint32_t iInstance;
350
351 /** Pointer the PDM Driver API. */
352 RCPTRTYPE(PCPDMDRVHLPRC) pDrvHlpRC;
353 /** Pointer to driver instance data. */
354 RCPTRTYPE(void *) pvInstanceDataRC;
355
356 /** Pointer the PDM Driver API. */
357 R0PTRTYPE(PCPDMDRVHLPR0) pDrvHlpR0;
358 /** Pointer to driver instance data. */
359 R0PTRTYPE(void *) pvInstanceDataR0;
360
361 /** Pointer the PDM Driver API. */
362 R3PTRTYPE(PCPDMDRVHLPR3) pDrvHlpR3;
363 /** Pointer to driver instance data. */
364 R3PTRTYPE(void *) pvInstanceDataR3;
365
366 /** Pointer to driver registration structure. */
367 R3PTRTYPE(PCPDMDRVREG) pReg;
368 /** Configuration handle. */
369 R3PTRTYPE(PCFGMNODE) pCfgHandle;
370
371 /** Pointer to the base interface of the device/driver instance above. */
372 R3PTRTYPE(PPDMIBASE) pUpBase;
373 /** Pointer to the base interface of the driver instance below. */
374 R3PTRTYPE(PPDMIBASE) pDownBase;
375
376 /** The base interface of the driver.
377 * The driver constructor initializes this. */
378 PDMIBASE IBase;
379 /** Align the internal data more naturally. */
380 RTR3PTR R3PtrPadding;
381
382 /** Internal data. */
383 union
384 {
385#ifdef PDMDRVINSINT_DECLARED
386 PDMDRVINSINT s;
387#endif
388 uint8_t padding[HC_ARCH_BITS == 32 ? 40 + 32 : 72 + 24];
389 } Internal;
390
391 /** Driver instance data. The size of this area is defined
392 * in the PDMDRVREG::cbInstanceData field. */
393 char achInstanceData[4];
394} PDMDRVINS;
395
396/** Current DRVREG version number. */
397#define PDM_DRVINS_VERSION PDM_VERSION_MAKE(0xf0fe, 1, 0)
398
399/** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */
400#define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDRVINS, IBase)) )
401
402/**
403 * Checks the structure versions of the drive instance and driver helpers,
404 * returning if they are incompatible.
405 *
406 * Intended for the constructor.
407 *
408 * @param pDrvIns The drvice instance pointer.
409 */
410#define PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns) \
411 do \
412 { \
413 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
414 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
415 ("DrvIns=%#x mine=%#x\n", (pDrvIns)->u32Version, PDM_DRVINS_VERSION), \
416 VERR_VERSION_MISMATCH); \
417 AssertLogRelMsgReturn(PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pDrvHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
418 ("DrvHlp=%#x mine=%#x\n", (pDrvIns)->pDrvHlpR3->u32Version, PDM_DRVHLPR3_VERSION), \
419 VERR_VERSION_MISMATCH); \
420 } while (0)
421
422/**
423 * Quietly checks the structure versions of the drive instance and driver
424 * helpers, returning if they are incompatible.
425 *
426 * Intended for the destructor.
427 *
428 * @param pDrvIns The drvice instance pointer.
429 */
430#define PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns) \
431 do \
432 { \
433 PPDMDRVINS pDrvInsTypeCheck = (pDrvIns); NOREF(pDrvInsTypeCheck); \
434 if (RT_UNLIKELY( !PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->u32Version, PDM_DRVINS_VERSION) \
435 || !PDM_VERSION_ARE_COMPATIBLE((pDrvIns)->pDrvHlpR3->u32Version, PDM_DRVHLPR3_VERSION)) ) \
436 return; \
437 } while (0)
438
439
440
441
442/**
443 * USB hub registration structure.
444 */
445typedef struct PDMUSBHUBREG
446{
447 /** Structure version number. PDM_USBHUBREG_VERSION defines the current version. */
448 uint32_t u32Version;
449
450 /**
451 * Request the hub to attach of the specified device.
452 *
453 * @returns VBox status code.
454 * @param pDrvIns The hub instance.
455 * @param pUsbIns The device to attach.
456 * @param piPort Where to store the port number the device was attached to.
457 * @thread EMT.
458 */
459 DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t *piPort));
460
461 /**
462 * Request the hub to detach of the specified device.
463 *
464 * The device has previously been attached to the hub with the
465 * pfnAttachDevice call. This call is not currently expected to
466 * fail.
467 *
468 * @returns VBox status code.
469 * @param pDrvIns The hub instance.
470 * @param pUsbIns The device to detach.
471 * @param iPort The port number returned by the attach call.
472 * @thread EMT.
473 */
474 DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PPDMDRVINS pDrvIns, PPDMUSBINS pUsbIns, uint32_t iPort));
475
476 /** Counterpart to u32Version, same value. */
477 uint32_t u32TheEnd;
478} PDMUSBHUBREG;
479/** Pointer to a const USB hub registration structure. */
480typedef const PDMUSBHUBREG *PCPDMUSBHUBREG;
481
482/** Current PDMUSBHUBREG version number. */
483#define PDM_USBHUBREG_VERSION PDM_VERSION_MAKE(0xf0fd, 1, 0)
484
485
486/**
487 * USB hub helpers.
488 * This is currently just a place holder.
489 */
490typedef struct PDMUSBHUBHLP
491{
492 /** Structure version. PDM_USBHUBHLP_VERSION defines the current version. */
493 uint32_t u32Version;
494
495 /** Just a safety precaution. */
496 uint32_t u32TheEnd;
497} PDMUSBHUBHLP;
498/** Pointer to PCI helpers. */
499typedef PDMUSBHUBHLP *PPDMUSBHUBHLP;
500/** Pointer to const PCI helpers. */
501typedef const PDMUSBHUBHLP *PCPDMUSBHUBHLP;
502/** Pointer to const PCI helpers pointer. */
503typedef PCPDMUSBHUBHLP *PPCPDMUSBHUBHLP;
504
505/** Current PDMUSBHUBHLP version number. */
506#define PDM_USBHUBHLP_VERSION PDM_VERSION_MAKE(0xf0fc, 1, 0)
507
508
509#ifdef IN_RING3
510/**
511 * PDM Driver API.
512 */
513typedef struct PDMDRVHLPR3
514{
515 /** Structure version. PDM_DRVHLPR3_VERSION defines the current version. */
516 uint32_t u32Version;
517
518 /**
519 * Attaches a driver (chain) to the driver.
520 *
521 * @returns VBox status code.
522 * @param pDrvIns Driver instance.
523 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
524 * @param ppBaseInterface Where to store the pointer to the base interface.
525 */
526 DECLR3CALLBACKMEMBER(int, pfnAttach,(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface));
527
528 /**
529 * Detach the driver the drivers below us.
530 *
531 * @returns VBox status code.
532 * @param pDrvIns Driver instance.
533 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
534 */
535 DECLR3CALLBACKMEMBER(int, pfnDetach,(PPDMDRVINS pDrvIns, uint32_t fFlags));
536
537 /**
538 * Detach the driver from the driver above it and destroy this
539 * driver and all drivers below it.
540 *
541 * @returns VBox status code.
542 * @param pDrvIns Driver instance.
543 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG or 0.
544 */
545 DECLR3CALLBACKMEMBER(int, pfnDetachSelf,(PPDMDRVINS pDrvIns, uint32_t fFlags));
546
547 /**
548 * Prepare a media mount.
549 *
550 * The driver must not have anything attached to itself
551 * when calling this function as the purpose is to set up the configuration
552 * of an future attachment.
553 *
554 * @returns VBox status code
555 * @param pDrvIns Driver instance.
556 * @param pszFilename Pointer to filename. If this is NULL it assumed that the caller have
557 * constructed a configuration which can be attached to the bottom driver.
558 * @param pszCoreDriver Core driver name. NULL will cause autodetection. Ignored if pszFilanem is NULL.
559 */
560 DECLR3CALLBACKMEMBER(int, pfnMountPrepare,(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver));
561
562 /**
563 * Assert that the current thread is the emulation thread.
564 *
565 * @returns True if correct.
566 * @returns False if wrong.
567 * @param pDrvIns Driver instance.
568 * @param pszFile Filename of the assertion location.
569 * @param iLine Linenumber of the assertion location.
570 * @param pszFunction Function of the assertion location.
571 */
572 DECLR3CALLBACKMEMBER(bool, pfnAssertEMT,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
573
574 /**
575 * Assert that the current thread is NOT the emulation thread.
576 *
577 * @returns True if correct.
578 * @returns False if wrong.
579 * @param pDrvIns Driver instance.
580 * @param pszFile Filename of the assertion location.
581 * @param iLine Linenumber of the assertion location.
582 * @param pszFunction Function of the assertion location.
583 */
584 DECLR3CALLBACKMEMBER(bool, pfnAssertOther,(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction));
585
586 /**
587 * Set the VM error message
588 *
589 * @returns rc.
590 * @param pDrvIns Driver instance.
591 * @param rc VBox status code.
592 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
593 * @param pszFormat Error message format string.
594 * @param ... Error message arguments.
595 */
596 DECLR3CALLBACKMEMBER(int, pfnVMSetError,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...));
597
598 /**
599 * Set the VM error message
600 *
601 * @returns rc.
602 * @param pDrvIns Driver instance.
603 * @param rc VBox status code.
604 * @param RT_SRC_POS_DECL Use RT_SRC_POS.
605 * @param pszFormat Error message format string.
606 * @param va Error message arguments.
607 */
608 DECLR3CALLBACKMEMBER(int, pfnVMSetErrorV,(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
609
610 /**
611 * Set the VM runtime error message
612 *
613 * @returns VBox status code.
614 * @param pDrvIns Driver instance.
615 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
616 * @param pszErrorId Error ID string.
617 * @param pszFormat Error message format string.
618 * @param ... Error message arguments.
619 */
620 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeError,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...));
621
622 /**
623 * Set the VM runtime error message
624 *
625 * @returns VBox status code.
626 * @param pDrvIns Driver instance.
627 * @param fFlags The action flags. See VMSETRTERR_FLAGS_*.
628 * @param pszErrorId Error ID string.
629 * @param pszFormat Error message format string.
630 * @param va Error message arguments.
631 */
632 DECLR3CALLBACKMEMBER(int, pfnVMSetRuntimeErrorV,(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va));
633
634 /**
635 * Gets the VM state.
636 *
637 * @returns VM state.
638 * @param pDrvIns The driver instance.
639 * @thread Any thread (just keep in mind that it's volatile info).
640 */
641 DECLR3CALLBACKMEMBER(VMSTATE, pfnVMState, (PPDMDRVINS pDrvIns));
642
643 /**
644 * Checks if the VM was teleported and hasn't been fully resumed yet.
645 *
646 * @returns true / false.
647 * @param pDrvIns The driver instance.
648 * @thread Any thread.
649 */
650 DECLR3CALLBACKMEMBER(bool, pfnVMTeleportedAndNotFullyResumedYet,(PPDMDRVINS pDrvIns));
651
652 /**
653 * Create a queue.
654 *
655 * @returns VBox status code.
656 * @param pDrvIns Driver instance.
657 * @param cbItem Size a queue item.
658 * @param cItems Number of items in the queue.
659 * @param cMilliesInterval Number of milliseconds between polling the queue.
660 * If 0 then the emulation thread will be notified whenever an item arrives.
661 * @param pfnCallback The consumer function.
662 * @param pszName The queue base name. The instance number will be
663 * appended automatically.
664 * @param ppQueue Where to store the queue handle on success.
665 * @thread The emulation thread.
666 */
667 DECLR3CALLBACKMEMBER(int, pfnPDMQueueCreate,(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
668 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue));
669
670 /**
671 * Query the virtual timer frequency.
672 *
673 * @returns Frequency in Hz.
674 * @param pDrvIns Driver instance.
675 * @thread Any thread.
676 */
677 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualFreq,(PPDMDRVINS pDrvIns));
678
679 /**
680 * Query the virtual time.
681 *
682 * @returns The current virtual time.
683 * @param pDrvIns Driver instance.
684 * @thread Any thread.
685 */
686 DECLR3CALLBACKMEMBER(uint64_t, pfnTMGetVirtualTime,(PPDMDRVINS pDrvIns));
687
688 /**
689 * Creates a timer.
690 *
691 * @returns VBox status.
692 * @param pDrvIns Driver instance.
693 * @param enmClock The clock to use on this timer.
694 * @param pfnCallback Callback function.
695 * @param pvUser The user argument to the callback.
696 * @param fFlags Timer creation flags, see grp_tm_timer_flags.
697 * @param pszDesc Pointer to description string which must stay around
698 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
699 * @param ppTimer Where to store the timer on success.
700 * @thread EMT
701 */
702 DECLR3CALLBACKMEMBER(int, pfnTMTimerCreate,(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer));
703
704 /**
705 * Register a save state data unit.
706 *
707 * @returns VBox status.
708 * @param pDrvIns Driver instance.
709 * @param uVersion Data layout version number.
710 * @param cbGuess The approximate amount of data in the unit.
711 * Only for progress indicators.
712 *
713 * @param pfnLivePrep Prepare live save callback, optional.
714 * @param pfnLiveExec Execute live save callback, optional.
715 * @param pfnLiveVote Vote live save callback, optional.
716 *
717 * @param pfnSavePrep Prepare save callback, optional.
718 * @param pfnSaveExec Execute save callback, optional.
719 * @param pfnSaveDone Done save callback, optional.
720 *
721 * @param pfnLoadPrep Prepare load callback, optional.
722 * @param pfnLoadExec Execute load callback, optional.
723 * @param pfnLoadDone Done load callback, optional.
724 */
725 DECLR3CALLBACKMEMBER(int, pfnSSMRegister,(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
726 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
727 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
728 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone));
729
730 /**
731 * Deregister a save state data unit.
732 *
733 * @returns VBox status.
734 * @param pDrvIns Driver instance.
735 * @param pszName Data unit name.
736 * @param uInstance The instance identifier of the data unit.
737 * This must together with the name be unique.
738 */
739 DECLR3CALLBACKMEMBER(int, pfnSSMDeregister,(PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance));
740
741 /**
742 * Registers a statistics sample if statistics are enabled.
743 *
744 * @param pDrvIns Driver instance.
745 * @param pvSample Pointer to the sample.
746 * @param enmType Sample type. This indicates what pvSample is pointing at.
747 * @param pszName Sample name. The name is on this form "/<component>/<sample>".
748 * Further nesting is possible.
749 * @param enmUnit Sample unit.
750 * @param pszDesc Sample description.
751 */
752 DECLR3CALLBACKMEMBER(void, pfnSTAMRegister,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName,
753 STAMUNIT enmUnit, const char *pszDesc));
754
755 /**
756 * Same as pfnSTAMRegister except that the name is specified in a
757 * RTStrPrintf like fashion.
758 *
759 * @param pDrvIns Driver instance.
760 * @param pvSample Pointer to the sample.
761 * @param enmType Sample type. This indicates what pvSample is pointing at.
762 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
763 * @param enmUnit Sample unit.
764 * @param pszDesc Sample description.
765 * @param pszName The sample name format string.
766 * @param ... Arguments to the format string.
767 */
768 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterF,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
769 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...));
770
771 /**
772 * Same as pfnSTAMRegister except that the name is specified in a
773 * RTStrPrintfV like fashion.
774 *
775 * @param pDrvIns Driver instance.
776 * @param pvSample Pointer to the sample.
777 * @param enmType Sample type. This indicates what pvSample is pointing at.
778 * @param enmVisibility Visibility type specifying whether unused statistics should be visible or not.
779 * @param enmUnit Sample unit.
780 * @param pszDesc Sample description.
781 * @param pszName The sample name format string.
782 * @param args Arguments to the format string.
783 */
784 DECLR3CALLBACKMEMBER(void, pfnSTAMRegisterV,(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
785 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args));
786
787 /**
788 * Deregister a statistic item previously registered with pfnSTAMRegister,
789 * pfnSTAMRegisterF or pfnSTAMRegisterV
790 *
791 * @returns VBox status.
792 * @param pDrvIns Driver instance.
793 * @param pvSample Pointer to the sample.
794 */
795 DECLR3CALLBACKMEMBER(int, pfnSTAMDeregister,(PPDMDRVINS pDrvIns, void *pvSample));
796
797 /**
798 * Calls the HC R0 VMM entry point, in a safer but slower manner than
799 * SUPR3CallVMMR0.
800 *
801 * When entering using this call the R0 components can call into the host kernel
802 * (i.e. use the SUPR0 and RT APIs).
803 *
804 * See VMMR0Entry() for more details.
805 *
806 * @returns error code specific to uFunction.
807 * @param pDrvIns The driver instance.
808 * @param uOperation Operation to execute.
809 * This is limited to services.
810 * @param pvArg Pointer to argument structure or if cbArg is 0 just an value.
811 * @param cbArg The size of the argument. This is used to copy whatever the argument
812 * points at into a kernel buffer to avoid problems like the user page
813 * being invalidated while we're executing the call.
814 */
815 DECLR3CALLBACKMEMBER(int, pfnSUPCallVMMR0Ex,(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg));
816
817 /**
818 * Registers a USB HUB.
819 *
820 * @returns VBox status code.
821 * @param pDrvIns The driver instance.
822 * @param fVersions Indicates the kinds of USB devices that can be attached to this HUB.
823 * @param cPorts The number of ports.
824 * @param pUsbHubReg The hub callback structure that PDMUsb uses to interact with it.
825 * @param ppUsbHubHlp The helper callback structure that the hub uses to talk to PDMUsb.
826 *
827 * @thread EMT.
828 */
829 DECLR3CALLBACKMEMBER(int, pfnUSBRegisterHub,(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp));
830
831 /**
832 * Set up asynchronous handling of a suspend, reset or power off notification.
833 *
834 * This shall only be called when getting the notification. It must be called
835 * for each one.
836 *
837 * @returns VBox status code.
838 * @param pDrvIns The driver instance.
839 * @param pfnAsyncNotify The callback.
840 * @thread EMT(0)
841 */
842 DECLR3CALLBACKMEMBER(int, pfnSetAsyncNotification, (PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify));
843
844 /**
845 * Notify EMT(0) that the driver has completed the asynchronous notification
846 * handling.
847 *
848 * This can be called at any time, spurious calls will simply be ignored.
849 *
850 * @param pDrvIns The driver instance.
851 * @thread Any
852 */
853 DECLR3CALLBACKMEMBER(void, pfnAsyncNotificationCompleted, (PPDMDRVINS pDrvIns));
854
855 /**
856 * Creates a PDM thread.
857 *
858 * This differs from the RTThreadCreate() API in that PDM takes care of suspending,
859 * resuming, and destroying the thread as the VM state changes.
860 *
861 * @returns VBox status code.
862 * @param pDrvIns The driver instance.
863 * @param ppThread Where to store the thread 'handle'.
864 * @param pvUser The user argument to the thread function.
865 * @param pfnThread The thread function.
866 * @param pfnWakeup The wakup callback. This is called on the EMT thread when
867 * a state change is pending.
868 * @param cbStack See RTThreadCreate.
869 * @param enmType See RTThreadCreate.
870 * @param pszName See RTThreadCreate.
871 */
872 DECLR3CALLBACKMEMBER(int, pfnPDMThreadCreate,(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
873 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName));
874
875 /**
876 * Creates a async completion template for a driver instance.
877 *
878 * The template is used when creating new completion tasks.
879 *
880 * @returns VBox status code.
881 * @param pDrvIns The driver instance.
882 * @param ppTemplate Where to store the template pointer on success.
883 * @param pfnCompleted The completion callback routine.
884 * @param pvTemplateUser Template user argument.
885 * @param pszDesc Description.
886 */
887 DECLR3CALLBACKMEMBER(int, pfnPDMAsyncCompletionTemplateCreate,(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
888 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
889 const char *pszDesc));
890
891
892 /**
893 * Resolves the symbol for a raw-mode context interface.
894 *
895 * @returns VBox status code.
896 * @param pDrvIns The driver instance.
897 * @param pvInterface The interface structure.
898 * @param cbInterface The size of the interface structure.
899 * @param pszSymPrefix What to prefix the symbols in the list with before
900 * resolving them. This must start with 'drv' and
901 * contain the driver name.
902 * @param pszSymList List of symbols corresponding to the interface.
903 * There is generally a there is generally a define
904 * holding this list associated with the interface
905 * definition (INTERFACE_SYM_LIST). For more details
906 * see PDMR3LdrGetInterfaceSymbols.
907 * @thread EMT
908 */
909 DECLR3CALLBACKMEMBER(int, pfnPDMLdrGetRCInterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
910 const char *pszSymPrefix, const char *pszSymList));
911
912 /**
913 * Resolves the symbol for a ring-0 context interface.
914 *
915 * @returns VBox status code.
916 * @param pDrvIns The driver instance.
917 * @param pvInterface The interface structure.
918 * @param cbInterface The size of the interface structure.
919 * @param pszSymPrefix What to prefix the symbols in the list with before
920 * resolving them. This must start with 'drv' and
921 * contain the driver name.
922 * @param pszSymList List of symbols corresponding to the interface.
923 * There is generally a there is generally a define
924 * holding this list associated with the interface
925 * definition (INTERFACE_SYM_LIST). For more details
926 * see PDMR3LdrGetInterfaceSymbols.
927 * @thread EMT
928 */
929 DECLR3CALLBACKMEMBER(int, pfnPDMLdrGetR0InterfaceSymbols,(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
930 const char *pszSymPrefix, const char *pszSymList));
931 /** Just a safety precaution. */
932 uint32_t u32TheEnd;
933} PDMDRVHLPR3;
934/** Current DRVHLP version number. */
935#define PDM_DRVHLPR3_VERSION PDM_VERSION_MAKE(0xf0fb, 1, 0)
936
937
938/**
939 * @copydoc PDMDRVHLP::pfnVMSetError
940 */
941DECLINLINE(int) PDMDrvHlpVMSetError(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
942{
943 va_list va;
944 va_start(va, pszFormat);
945 pDrvIns->CTX_SUFF(pDrvHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
946 va_end(va);
947 return rc;
948}
949
950/** @def PDMDRV_SET_ERROR
951 * Set the VM error. See PDMDrvHlpVMSetError() for printf like message formatting.
952 */
953#define PDMDRV_SET_ERROR(pDrvIns, rc, pszError) \
954 PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, "%s", pszError)
955
956/**
957 * @copydoc PDMDRVHLP::pfnVMSetErrorV
958 */
959DECLINLINE(int) PDMDrvHlpVMSetErrorV(PPDMDRVINS pDrvIns, const int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
960{
961 return pDrvIns->CTX_SUFF(pDrvHlp)->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
962}
963
964
965/**
966 * @copydoc PDMDRVHLP::pfnVMSetRuntimeError
967 */
968DECLINLINE(int) PDMDrvHlpVMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
969{
970 va_list va;
971 int rc;
972 va_start(va, pszFormat);
973 rc = pDrvIns->CTX_SUFF(pDrvHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
974 va_end(va);
975 return rc;
976}
977
978/** @def PDMDRV_SET_RUNTIME_ERROR
979 * Set the VM runtime error. See PDMDrvHlpVMSetRuntimeError() for printf like message formatting.
980 */
981#define PDMDRV_SET_RUNTIME_ERROR(pDrvIns, fFlags, pszErrorId, pszError) \
982 PDMDrvHlpVMSetRuntimeError(pDrvIns, fFlags, pszErrorId, "%s", pszError)
983
984/**
985 * @copydoc PDMDRVHLP::pfnVMSetRuntimeErrorV
986 */
987DECLINLINE(int) PDMDrvHlpVMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
988{
989 return pDrvIns->CTX_SUFF(pDrvHlp)->pfnVMSetRuntimeErrorV(pDrvIns, fFlags, pszErrorId, pszFormat, va);
990}
991
992#endif /* IN_RING3 */
993
994
995/** @def PDMDRV_ASSERT_EMT
996 * Assert that the current thread is the emulation thread.
997 */
998#ifdef VBOX_STRICT
999# define PDMDRV_ASSERT_EMT(pDrvIns) pDrvIns->CTX_SUFF(pDrvHlp)->pfnAssertEMT(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1000#else
1001# define PDMDRV_ASSERT_EMT(pDrvIns) do { } while (0)
1002#endif
1003
1004/** @def PDMDRV_ASSERT_OTHER
1005 * Assert that the current thread is NOT the emulation thread.
1006 */
1007#ifdef VBOX_STRICT
1008# define PDMDRV_ASSERT_OTHER(pDrvIns) pDrvIns->CTX_SUFF(pDrvHlp)->pfnAssertOther(pDrvIns, __FILE__, __LINE__, __FUNCTION__)
1009#else
1010# define PDMDRV_ASSERT_OTHER(pDrvIns) do { } while (0)
1011#endif
1012
1013
1014#ifdef IN_RING3
1015
1016/**
1017 * @copydoc PDMDRVHLP::pfnAttach
1018 */
1019DECLINLINE(int) PDMDrvHlpAttach(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface)
1020{
1021 return pDrvIns->pDrvHlpR3->pfnAttach(pDrvIns, fFlags, ppBaseInterface);
1022}
1023
1024/**
1025 * Check that there is no driver below the us that we should attach to.
1026 *
1027 * @returns VERR_PDM_NO_ATTACHED_DRIVER if there is no driver.
1028 * @param pDrvIns The driver instance.
1029 */
1030DECLINLINE(int) PDMDrvHlpNoAttach(PPDMDRVINS pDrvIns)
1031{
1032 return pDrvIns->pDrvHlpR3->pfnAttach(pDrvIns, 0, NULL);
1033}
1034
1035/**
1036 * @copydoc PDMDRVHLP::pfnDetach
1037 */
1038DECLINLINE(int) PDMDrvHlpDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1039{
1040 return pDrvIns->pDrvHlpR3->pfnDetach(pDrvIns, fFlags);
1041}
1042
1043/**
1044 * @copydoc PDMDRVHLP::pfnDetachSelf
1045 */
1046DECLINLINE(int) PDMDrvHlpDetachSelf(PPDMDRVINS pDrvIns, uint32_t fFlags)
1047{
1048 return pDrvIns->pDrvHlpR3->pfnDetachSelf(pDrvIns, fFlags);
1049}
1050
1051/**
1052 * @copydoc PDMDRVHLP::pfnMountPrepare
1053 */
1054DECLINLINE(int) PDMDrvHlpMountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver)
1055{
1056 return pDrvIns->pDrvHlpR3->pfnMountPrepare(pDrvIns, pszFilename, pszCoreDriver);
1057}
1058
1059/**
1060 * @copydoc PDMDRVHLP::pfnVMState
1061 */
1062DECLINLINE(VMSTATE) PDMDrvHlpVMState(PPDMDRVINS pDrvIns)
1063{
1064 return pDrvIns->CTX_SUFF(pDrvHlp)->pfnVMState(pDrvIns);
1065}
1066
1067/**
1068 * @copydoc PDMDRVHLP::pfnVMTeleportedAndNotFullyResumedYet
1069 */
1070DECLINLINE(bool) PDMDrvHlpVMTeleportedAndNotFullyResumedYet(PPDMDRVINS pDrvIns)
1071{
1072 return pDrvIns->pDrvHlpR3->pfnVMTeleportedAndNotFullyResumedYet(pDrvIns);
1073}
1074
1075/**
1076 * @copydoc PDMDRVHLP::pfnPDMQueueCreate
1077 */
1078DECLINLINE(int) PDMDrvHlpPDMQueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
1079 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
1080{
1081 return pDrvIns->pDrvHlpR3->pfnPDMQueueCreate(pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue);
1082}
1083
1084/**
1085 * @copydoc PDMDRVHLP::pfnTMGetVirtualFreq
1086 */
1087DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualFreq(PPDMDRVINS pDrvIns)
1088{
1089 return pDrvIns->pDrvHlpR3->pfnTMGetVirtualFreq(pDrvIns);
1090}
1091
1092/**
1093 * @copydoc PDMDRVHLP::pfnTMGetVirtualTime
1094 */
1095DECLINLINE(uint64_t) PDMDrvHlpTMGetVirtualTime(PPDMDRVINS pDrvIns)
1096{
1097 return pDrvIns->pDrvHlpR3->pfnTMGetVirtualTime(pDrvIns);
1098}
1099
1100/**
1101 * @copydoc PDMDRVHLP::pfnTMTimerCreate
1102 */
1103DECLINLINE(int) PDMDrvHlpTMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
1104{
1105 return pDrvIns->pDrvHlpR3->pfnTMTimerCreate(pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
1106}
1107
1108/**
1109 * Register a save state data unit.
1110 *
1111 * @returns VBox status.
1112 * @param pDrvIns Driver instance.
1113 * @param uVersion Data layout version number.
1114 * @param cbGuess The approximate amount of data in the unit.
1115 * Only for progress indicators.
1116 * @param pfnSaveExec Execute save callback, optional.
1117 * @param pfnLoadExec Execute load callback, optional.
1118 */
1119DECLINLINE(int) PDMDrvHlpSSMRegister(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1120 PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVLOADEXEC pfnLoadExec)
1121{
1122 return pDrvIns->pDrvHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1123 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1124 NULL /*pfnSavePrep*/, pfnSaveExec, NULL /*pfnSaveDone*/,
1125 NULL /*pfnLoadPrep*/, pfnLoadExec, NULL /*pfnLoadDone*/);
1126}
1127
1128/**
1129 * @copydoc PDMDRVHLP::pfnSSMRegister
1130 */
1131DECLINLINE(int) PDMDrvHlpSSMRegisterEx(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1132 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1133 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1134 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
1135{
1136 return pDrvIns->pDrvHlpR3->pfnSSMRegister(pDrvIns, uVersion, cbGuess,
1137 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1138 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1139 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1140}
1141
1142/**
1143 * Register a load done callback.
1144 *
1145 * @returns VBox status.
1146 * @param pDrvIns Driver instance.
1147 * @param pfnLoadDone Done load callback, optional.
1148 */
1149DECLINLINE(int) PDMDrvHlpSSMRegisterLoadDone(PPDMDRVINS pDrvIns, PFNSSMDRVLOADDONE pfnLoadDone)
1150{
1151 return pDrvIns->pDrvHlpR3->pfnSSMRegister(pDrvIns, 0 /*uVersion*/, 0 /*cbGuess*/,
1152 NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1153 NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/,
1154 NULL /*pfnLoadPrep*/, NULL /*pfnLoadExec*/, pfnLoadDone);
1155}
1156
1157/**
1158 * @copydoc PDMDRVHLP::pfnSTAMRegister
1159 */
1160DECLINLINE(void) PDMDrvHlpSTAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
1161{
1162 pDrvIns->pDrvHlpR3->pfnSTAMRegister(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
1163}
1164
1165/**
1166 * @copydoc PDMDRVHLP::pfnSTAMRegisterF
1167 */
1168DECLINLINE(void) PDMDrvHlpSTAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
1169 const char *pszDesc, const char *pszName, ...)
1170{
1171 va_list va;
1172 va_start(va, pszName);
1173 pDrvIns->pDrvHlpR3->pfnSTAMRegisterV(pDrvIns, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, va);
1174 va_end(va);
1175}
1176
1177/**
1178 * @copydoc PDMDRVHLP::pfnSTAMDeregister
1179 */
1180DECLINLINE(int) PDMDrvHlpSTAMDeregister(PPDMDRVINS pDrvIns, void *pvSample)
1181{
1182 return pDrvIns->pDrvHlpR3->pfnSTAMDeregister(pDrvIns, pvSample);
1183}
1184
1185/**
1186 * @copydoc PDMDRVHLP::pfnSUPCallVMMR0Ex
1187 */
1188DECLINLINE(int) PDMDrvHlpSUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg)
1189{
1190 return pDrvIns->pDrvHlpR3->pfnSUPCallVMMR0Ex(pDrvIns, uOperation, pvArg, cbArg);
1191}
1192
1193/**
1194 * @copydoc PDMDRVHLP::pfnUSBRegisterHub
1195 */
1196DECLINLINE(int) PDMDrvHlpUSBRegisterHub(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp)
1197{
1198 return pDrvIns->pDrvHlpR3->pfnUSBRegisterHub(pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp);
1199}
1200
1201/**
1202 * @copydoc PDMDRVHLP::pfnSetAsyncNotification
1203 */
1204DECLINLINE(int) PDMDrvHlpSetAsyncNotification(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
1205{
1206 return pDrvIns->pDrvHlpR3->pfnSetAsyncNotification(pDrvIns, pfnAsyncNotify);
1207}
1208
1209/**
1210 * @copydoc PDMDRVHLP::pfnAsyncNotificationCompleted
1211 */
1212DECLINLINE(void) PDMDrvHlpAsyncNotificationCompleted(PPDMDRVINS pDrvIns)
1213{
1214 pDrvIns->pDrvHlpR3->pfnAsyncNotificationCompleted(pDrvIns);
1215}
1216
1217/**
1218 * @copydoc PDMDRVHLP::pfnPDMThreadCreate
1219 */
1220DECLINLINE(int) PDMDrvHlpPDMThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1221 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
1222{
1223 return pDrvIns->pDrvHlpR3->pfnPDMThreadCreate(pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
1224}
1225
1226# ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
1227/**
1228 * @copydoc PDMDRVHLP::pfnPDMAsyncCompletionTemplateCreate
1229 */
1230DECLINLINE(int) PDMDrvHlpPDMAsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1231 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser, const char *pszDesc)
1232{
1233 return pDrvIns->pDrvHlpR3->pfnPDMAsyncCompletionTemplateCreate(pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
1234}
1235# endif
1236
1237
1238/** Pointer to callbacks provided to the VBoxDriverRegister() call. */
1239typedef struct PDMDRVREGCB *PPDMDRVREGCB;
1240/** Pointer to const callbacks provided to the VBoxDriverRegister() call. */
1241typedef const struct PDMDRVREGCB *PCPDMDRVREGCB;
1242
1243/**
1244 * Callbacks for VBoxDriverRegister().
1245 */
1246typedef struct PDMDRVREGCB
1247{
1248 /** Interface version.
1249 * This is set to PDM_DRVREG_CB_VERSION. */
1250 uint32_t u32Version;
1251
1252 /**
1253 * Registers a driver with the current VM instance.
1254 *
1255 * @returns VBox status code.
1256 * @param pCallbacks Pointer to the callback table.
1257 * @param pReg Pointer to the driver registration record.
1258 * This data must be permanent and readonly.
1259 */
1260 DECLR3CALLBACKMEMBER(int, pfnRegister,(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg));
1261} PDMDRVREGCB;
1262
1263/** Current version of the PDMDRVREGCB structure. */
1264#define PDM_DRVREG_CB_VERSION PDM_VERSION_MAKE(0xf0fa, 1, 0)
1265
1266
1267/**
1268 * The VBoxDriverRegister callback function.
1269 *
1270 * PDM will invoke this function after loading a driver module and letting
1271 * the module decide which drivers to register and how to handle conflicts.
1272 *
1273 * @returns VBox status code.
1274 * @param pCallbacks Pointer to the callback table.
1275 * @param u32Version VBox version number.
1276 */
1277typedef DECLCALLBACK(int) FNPDMVBOXDRIVERSREGISTER(PCPDMDRVREGCB pCallbacks, uint32_t u32Version);
1278
1279VMMR3DECL(int) PDMR3RegisterDrivers(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback);
1280
1281#endif /* IN_RING3 */
1282
1283/** @} */
1284
1285RT_C_DECLS_END
1286
1287#endif
Note: See TracBrowser for help on using the repository browser.

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