VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp@ 82968

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 74.0 KB
Line 
1/* $Id: PDMDriver.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * PDM - Pluggable Device and Driver Manager, Driver parts.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_PDM_DRIVER
23#include "PDMInternal.h"
24#include <VBox/vmm/pdm.h>
25#include <VBox/vmm/mm.h>
26#include <VBox/vmm/cfgm.h>
27#include <VBox/vmm/hm.h>
28#include <VBox/vmm/vmm.h>
29#include <VBox/sup.h>
30#include <VBox/vmm/vmcc.h>
31
32#include <VBox/version.h>
33#include <VBox/err.h>
34
35#include <VBox/log.h>
36#include <iprt/assert.h>
37#include <iprt/asm.h>
38#include <iprt/ctype.h>
39#include <iprt/mem.h>
40#include <iprt/thread.h>
41#include <iprt/path.h>
42#include <iprt/string.h>
43
44
45/*********************************************************************************************************************************
46* Structures and Typedefs *
47*********************************************************************************************************************************/
48/**
49 * Internal callback structure pointer.
50 *
51 * The main purpose is to define the extra data we associate
52 * with PDMDRVREGCB so we can find the VM instance and so on.
53 */
54typedef struct PDMDRVREGCBINT
55{
56 /** The callback structure. */
57 PDMDRVREGCB Core;
58 /** A bit of padding. */
59 uint32_t u32[4];
60 /** VM Handle. */
61 PVM pVM;
62 /** Pointer to the configuration node the registrations should be
63 * associated with. Can be NULL. */
64 PCFGMNODE pCfgNode;
65} PDMDRVREGCBINT, *PPDMDRVREGCBINT;
66typedef const PDMDRVREGCBINT *PCPDMDRVREGCBINT;
67
68
69/*********************************************************************************************************************************
70* Internal Functions *
71*********************************************************************************************************************************/
72static DECLCALLBACK(int) pdmR3DrvRegister(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg);
73static int pdmR3DrvLoad(PVM pVM, PPDMDRVREGCBINT pRegCB, const char *pszFilename, const char *pszName);
74
75
76/**
77 * Register drivers in a statically linked environment.
78 *
79 * @returns VBox status code.
80 * @param pVM The cross context VM structure.
81 * @param pfnCallback Driver registration callback
82 */
83VMMR3DECL(int) PDMR3DrvStaticRegistration(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback)
84{
85 /*
86 * The registration callbacks.
87 */
88 PDMDRVREGCBINT RegCB;
89 RegCB.Core.u32Version = PDM_DRVREG_CB_VERSION;
90 RegCB.Core.pfnRegister = pdmR3DrvRegister;
91 RegCB.pVM = pVM;
92 RegCB.pCfgNode = NULL;
93
94 int rc = pfnCallback(&RegCB.Core, VBOX_VERSION);
95 if (RT_FAILURE(rc))
96 AssertMsgFailed(("VBoxDriversRegister failed with rc=%Rrc\n", rc));
97
98 return rc;
99}
100
101
102/**
103 * This function will initialize the drivers for this VM instance.
104 *
105 * First of all this mean loading the builtin drivers and letting them
106 * register themselves. Beyond that any additional driver modules are
107 * loaded and called for registration.
108 *
109 * @returns VBox status code.
110 * @param pVM The cross context VM structure.
111 */
112int pdmR3DrvInit(PVM pVM)
113{
114 LogFlow(("pdmR3DrvInit:\n"));
115
116 AssertRelease(!(RT_UOFFSETOF(PDMDRVINS, achInstanceData) & 15));
117 PPDMDRVINS pDrvInsAssert; NOREF(pDrvInsAssert);
118 AssertCompile(sizeof(pDrvInsAssert->Internal.s) <= sizeof(pDrvInsAssert->Internal.padding));
119 AssertRelease(sizeof(pDrvInsAssert->Internal.s) <= sizeof(pDrvInsAssert->Internal.padding));
120
121 /*
122 * The registration callbacks.
123 */
124 PDMDRVREGCBINT RegCB;
125 RegCB.Core.u32Version = PDM_DRVREG_CB_VERSION;
126 RegCB.Core.pfnRegister = pdmR3DrvRegister;
127 RegCB.pVM = pVM;
128 RegCB.pCfgNode = NULL;
129
130 /*
131 * Load the builtin module
132 */
133 PCFGMNODE pDriversNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "PDM/Drivers");
134 bool fLoadBuiltin;
135 int rc = CFGMR3QueryBool(pDriversNode, "LoadBuiltin", &fLoadBuiltin);
136 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
137 fLoadBuiltin = true;
138 else if (RT_FAILURE(rc))
139 {
140 AssertMsgFailed(("Configuration error: Querying boolean \"LoadBuiltin\" failed with %Rrc\n", rc));
141 return rc;
142 }
143 if (fLoadBuiltin)
144 {
145 /* make filename */
146 char *pszFilename = pdmR3FileR3("VBoxDD", true /*fShared*/);
147 if (!pszFilename)
148 return VERR_NO_TMP_MEMORY;
149 rc = pdmR3DrvLoad(pVM, &RegCB, pszFilename, "VBoxDD");
150 RTMemTmpFree(pszFilename);
151 if (RT_FAILURE(rc))
152 return rc;
153 }
154
155 /*
156 * Load additional driver modules.
157 */
158 for (PCFGMNODE pCur = CFGMR3GetFirstChild(pDriversNode); pCur; pCur = CFGMR3GetNextChild(pCur))
159 {
160 /*
161 * Get the name and path.
162 */
163 char szName[PDMMOD_NAME_LEN];
164 rc = CFGMR3GetName(pCur, &szName[0], sizeof(szName));
165 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
166 {
167 AssertMsgFailed(("configuration error: The module name is too long, cchName=%zu.\n", CFGMR3GetNameLen(pCur)));
168 return VERR_PDM_MODULE_NAME_TOO_LONG;
169 }
170 else if (RT_FAILURE(rc))
171 {
172 AssertMsgFailed(("CFGMR3GetName -> %Rrc.\n", rc));
173 return rc;
174 }
175
176 /* the path is optional, if no path the module name + path is used. */
177 char szFilename[RTPATH_MAX];
178 rc = CFGMR3QueryString(pCur, "Path", &szFilename[0], sizeof(szFilename));
179 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
180 strcpy(szFilename, szName);
181 else if (RT_FAILURE(rc))
182 {
183 AssertMsgFailed(("configuration error: Failure to query the module path, rc=%Rrc.\n", rc));
184 return rc;
185 }
186
187 /* prepend path? */
188 if (!RTPathHavePath(szFilename))
189 {
190 char *psz = pdmR3FileR3(szFilename, false /*fShared*/);
191 if (!psz)
192 return VERR_NO_TMP_MEMORY;
193 size_t cch = strlen(psz) + 1;
194 if (cch > sizeof(szFilename))
195 {
196 RTMemTmpFree(psz);
197 AssertMsgFailed(("Filename too long! cch=%d '%s'\n", cch, psz));
198 return VERR_FILENAME_TOO_LONG;
199 }
200 memcpy(szFilename, psz, cch);
201 RTMemTmpFree(psz);
202 }
203
204 /*
205 * Load the module and register it's drivers.
206 */
207 RegCB.pCfgNode = pCur;
208 rc = pdmR3DrvLoad(pVM, &RegCB, szFilename, szName);
209 if (RT_FAILURE(rc))
210 return rc;
211 }
212
213 LogFlow(("pdmR3DrvInit: returns VINF_SUCCESS\n"));
214 return VINF_SUCCESS;
215}
216
217
218/**
219 * Loads one driver module and call the registration entry point.
220 *
221 * @returns VBox status code.
222 * @param pVM The cross context VM structure.
223 * @param pRegCB The registration callback stuff.
224 * @param pszFilename Module filename.
225 * @param pszName Module name.
226 */
227static int pdmR3DrvLoad(PVM pVM, PPDMDRVREGCBINT pRegCB, const char *pszFilename, const char *pszName)
228{
229 /*
230 * Load it.
231 */
232 int rc = pdmR3LoadR3U(pVM->pUVM, pszFilename, pszName);
233 if (RT_SUCCESS(rc))
234 {
235 /*
236 * Get the registration export and call it.
237 */
238 FNPDMVBOXDRIVERSREGISTER *pfnVBoxDriversRegister;
239 rc = PDMR3LdrGetSymbolR3(pVM, pszName, "VBoxDriversRegister", (void **)&pfnVBoxDriversRegister);
240 if (RT_SUCCESS(rc))
241 {
242 Log(("PDM: Calling VBoxDriversRegister (%p) of %s (%s)\n", pfnVBoxDriversRegister, pszName, pszFilename));
243 rc = pfnVBoxDriversRegister(&pRegCB->Core, VBOX_VERSION);
244 if (RT_SUCCESS(rc))
245 Log(("PDM: Successfully loaded driver module %s (%s).\n", pszName, pszFilename));
246 else
247 AssertMsgFailed(("VBoxDriversRegister failed with rc=%Rrc\n", rc));
248 }
249 else
250 {
251 AssertMsgFailed(("Failed to locate 'VBoxDriversRegister' in %s (%s) rc=%Rrc\n", pszName, pszFilename, rc));
252 if (rc == VERR_SYMBOL_NOT_FOUND)
253 rc = VERR_PDM_NO_REGISTRATION_EXPORT;
254 }
255 }
256 else
257 AssertMsgFailed(("Failed to load %s (%s) rc=%Rrc!\n", pszName, pszFilename, rc));
258 return rc;
259}
260
261
262/** @interface_method_impl{PDMDRVREGCB,pfnRegister} */
263static DECLCALLBACK(int) pdmR3DrvRegister(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pReg)
264{
265 /*
266 * Validate the registration structure.
267 */
268 AssertPtrReturn(pReg, VERR_INVALID_POINTER);
269 AssertMsgReturn(pReg->u32Version == PDM_DRVREG_VERSION,
270 ("%#x\n", pReg->u32Version),
271 VERR_PDM_UNKNOWN_DRVREG_VERSION);
272 AssertReturn(pReg->szName[0], VERR_PDM_INVALID_DRIVER_REGISTRATION);
273 AssertMsgReturn(RTStrEnd(pReg->szName, sizeof(pReg->szName)),
274 ("%.*s\n", sizeof(pReg->szName), pReg->szName),
275 VERR_PDM_INVALID_DRIVER_REGISTRATION);
276 AssertMsgReturn(pdmR3IsValidName(pReg->szName), ("%.*s\n", sizeof(pReg->szName), pReg->szName),
277 VERR_PDM_INVALID_DRIVER_REGISTRATION);
278 AssertMsgReturn( !(pReg->fFlags & PDM_DRVREG_FLAGS_R0)
279 || ( pReg->szR0Mod[0]
280 && RTStrEnd(pReg->szR0Mod, sizeof(pReg->szR0Mod))),
281 ("%s: %.*s\n", pReg->szName, sizeof(pReg->szR0Mod), pReg->szR0Mod),
282 VERR_PDM_INVALID_DRIVER_REGISTRATION);
283 AssertMsgReturn( !(pReg->fFlags & PDM_DRVREG_FLAGS_RC)
284 || ( pReg->szRCMod[0]
285 && RTStrEnd(pReg->szRCMod, sizeof(pReg->szRCMod))),
286 ("%s: %.*s\n", pReg->szName, sizeof(pReg->szRCMod), pReg->szRCMod),
287 VERR_PDM_INVALID_DRIVER_REGISTRATION);
288 AssertMsgReturn(VALID_PTR(pReg->pszDescription),
289 ("%s: %p\n", pReg->szName, pReg->pszDescription),
290 VERR_PDM_INVALID_DRIVER_REGISTRATION);
291 AssertMsgReturn(!(pReg->fFlags & ~(PDM_DRVREG_FLAGS_HOST_BITS_MASK | PDM_DRVREG_FLAGS_R0 | PDM_DRVREG_FLAGS_RC)),
292 ("%s: %#x\n", pReg->szName, pReg->fFlags),
293 VERR_PDM_INVALID_DRIVER_REGISTRATION);
294 AssertMsgReturn((pReg->fFlags & PDM_DRVREG_FLAGS_HOST_BITS_MASK) == PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
295 ("%s: %#x\n", pReg->szName, pReg->fFlags),
296 VERR_PDM_INVALID_DRIVER_HOST_BITS);
297 AssertMsgReturn(pReg->cMaxInstances > 0,
298 ("%s: %#x\n", pReg->szName, pReg->cMaxInstances),
299 VERR_PDM_INVALID_DRIVER_REGISTRATION);
300 AssertMsgReturn(pReg->cbInstance <= _1M,
301 ("%s: %#x\n", pReg->szName, pReg->cbInstance),
302 VERR_PDM_INVALID_DRIVER_REGISTRATION);
303 AssertMsgReturn(VALID_PTR(pReg->pfnConstruct),
304 ("%s: %p\n", pReg->szName, pReg->pfnConstruct),
305 VERR_PDM_INVALID_DRIVER_REGISTRATION);
306 AssertMsgReturn(VALID_PTR(pReg->pfnRelocate) || !(pReg->fFlags & PDM_DRVREG_FLAGS_RC),
307 ("%s: %#x\n", pReg->szName, pReg->cbInstance),
308 VERR_PDM_INVALID_DRIVER_REGISTRATION);
309 AssertMsgReturn(pReg->pfnSoftReset == NULL,
310 ("%s: %p\n", pReg->szName, pReg->pfnSoftReset),
311 VERR_PDM_INVALID_DRIVER_REGISTRATION);
312 AssertMsgReturn(pReg->u32VersionEnd == PDM_DRVREG_VERSION,
313 ("%s: %#x\n", pReg->szName, pReg->u32VersionEnd),
314 VERR_PDM_INVALID_DRIVER_REGISTRATION);
315
316 /*
317 * Check for duplicate and find FIFO entry at the same time.
318 */
319 PCPDMDRVREGCBINT pRegCB = (PCPDMDRVREGCBINT)pCallbacks;
320 PPDMDRV pDrvPrev = NULL;
321 PPDMDRV pDrv = pRegCB->pVM->pdm.s.pDrvs;
322 for (; pDrv; pDrvPrev = pDrv, pDrv = pDrv->pNext)
323 {
324 if (!strcmp(pDrv->pReg->szName, pReg->szName))
325 {
326 AssertMsgFailed(("Driver '%s' already exists\n", pReg->szName));
327 return VERR_PDM_DRIVER_NAME_CLASH;
328 }
329 }
330
331 /*
332 * Allocate new driver structure and insert it into the list.
333 */
334 int rc;
335 pDrv = (PPDMDRV)MMR3HeapAlloc(pRegCB->pVM, MM_TAG_PDM_DRIVER, sizeof(*pDrv));
336 if (pDrv)
337 {
338 pDrv->pNext = NULL;
339 pDrv->cInstances = 0;
340 pDrv->iNextInstance = 0;
341 pDrv->pReg = pReg;
342 rc = CFGMR3QueryStringAllocDef( pRegCB->pCfgNode, "RCSearchPath", &pDrv->pszRCSearchPath, NULL);
343 if (RT_SUCCESS(rc))
344 rc = CFGMR3QueryStringAllocDef(pRegCB->pCfgNode, "R0SearchPath", &pDrv->pszR0SearchPath, NULL);
345 if (RT_SUCCESS(rc))
346 {
347 if (pDrvPrev)
348 pDrvPrev->pNext = pDrv;
349 else
350 pRegCB->pVM->pdm.s.pDrvs = pDrv;
351 Log(("PDM: Registered driver '%s'\n", pReg->szName));
352 return VINF_SUCCESS;
353 }
354 MMR3HeapFree(pDrv);
355 }
356 else
357 rc = VERR_NO_MEMORY;
358 return rc;
359}
360
361
362/**
363 * Lookups a driver structure by name.
364 * @internal
365 */
366PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName)
367{
368 for (PPDMDRV pDrv = pVM->pdm.s.pDrvs; pDrv; pDrv = pDrv->pNext)
369 if (!strcmp(pDrv->pReg->szName, pszName))
370 return pDrv;
371 return NULL;
372}
373
374
375/**
376 * Transforms the driver chain as it's being instantiated.
377 *
378 * Worker for pdmR3DrvInstantiate.
379 *
380 * @returns VBox status code.
381 * @param pVM The cross context VM structure.
382 * @param pDrvAbove The driver above, NULL if top.
383 * @param pLun The LUN.
384 * @param ppNode The AttachedDriver node, replaced if any
385 * morphing took place.
386 */
387static int pdmR3DrvMaybeTransformChain(PVM pVM, PPDMDRVINS pDrvAbove, PPDMLUN pLun, PCFGMNODE *ppNode)
388{
389 /*
390 * The typical state of affairs is that there are no injections.
391 */
392 PCFGMNODE pCurTrans = CFGMR3GetFirstChild(CFGMR3GetChild(CFGMR3GetRoot(pVM), "PDM/DriverTransformations"));
393 if (!pCurTrans)
394 return VINF_SUCCESS;
395
396 /*
397 * Gather the attributes used in the matching process.
398 */
399 const char *pszDevice = pLun->pDevIns
400 ? pLun->pDevIns->Internal.s.pDevR3->pReg->szName
401 : pLun->pUsbIns->Internal.s.pUsbDev->pReg->szName;
402 char szLun[32];
403 RTStrPrintf(szLun, sizeof(szLun), "%u", pLun->iLun);
404 const char *pszAbove = pDrvAbove ? pDrvAbove->Internal.s.pDrv->pReg->szName : "<top>";
405 char *pszThisDrv;
406 int rc = CFGMR3QueryStringAlloc(*ppNode, "Driver", &pszThisDrv);
407 AssertMsgRCReturn(rc, ("Query for string value of \"Driver\" -> %Rrc\n", rc),
408 rc == VERR_CFGM_VALUE_NOT_FOUND ? VERR_PDM_CFG_MISSING_DRIVER_NAME : rc);
409
410 uint64_t uInjectTransformationAbove = 0;
411 if (pDrvAbove)
412 {
413 rc = CFGMR3QueryIntegerDef(CFGMR3GetParent(*ppNode), "InjectTransformationPtr", &uInjectTransformationAbove, 0);
414 AssertLogRelRCReturn(rc, rc);
415 }
416
417
418 /*
419 * Enumerate possible driver chain transformations.
420 */
421 unsigned cTransformations = 0;
422 for (; pCurTrans != NULL; pCurTrans = CFGMR3GetNextChild(pCurTrans))
423 {
424 char szCurTransNm[256];
425 rc = CFGMR3GetName(pCurTrans, szCurTransNm, sizeof(szCurTransNm));
426 AssertLogRelRCReturn(rc, rc);
427
428 /** @cfgm{/PDM/DriverTransformations/&lt;name&gt;/Device,string,*}
429 * One or more simple wildcard patters separated by '|' for matching
430 * the devices this transformation rule applies to. */
431 char *pszMultiPat;
432 rc = CFGMR3QueryStringAllocDef(pCurTrans, "Device", &pszMultiPat, "*");
433 AssertLogRelRCReturn(rc, rc);
434 bool fMatch = RTStrSimplePatternMultiMatch(pszMultiPat, RTSTR_MAX, pszDevice, RTSTR_MAX, NULL);
435 MMR3HeapFree(pszMultiPat);
436 if (!fMatch)
437 continue;
438
439 /** @cfgm{/PDM/DriverTransformations/&lt;name&gt;/LUN,string,*}
440 * One or more simple wildcard patters separated by '|' for matching
441 * the LUNs this transformation rule applies to. */
442 rc = CFGMR3QueryStringAllocDef(pCurTrans, "LUN", &pszMultiPat, "*");
443 AssertLogRelRCReturn(rc, rc);
444 fMatch = RTStrSimplePatternMultiMatch(pszMultiPat, RTSTR_MAX, szLun, RTSTR_MAX, NULL);
445 MMR3HeapFree(pszMultiPat);
446 if (!fMatch)
447 continue;
448
449 /** @cfgm{/PDM/DriverTransformations/&lt;name&gt;/BelowDriver,string,*}
450 * One or more simple wildcard patters separated by '|' for matching the
451 * drivers the transformation should be applied below. This means, that
452 * when the drivers matched here attached another driver below them, the
453 * transformation will be applied. To represent the device, '&lt;top&gt;'
454 * is used. */
455 rc = CFGMR3QueryStringAllocDef(pCurTrans, "BelowDriver", &pszMultiPat, "*");
456 AssertLogRelRCReturn(rc, rc);
457 fMatch = RTStrSimplePatternMultiMatch(pszMultiPat, RTSTR_MAX, pszAbove, RTSTR_MAX, NULL);
458 MMR3HeapFree(pszMultiPat);
459 if (!fMatch)
460 continue;
461
462 /** @cfgm{/PDM/DriverTransformations/&lt;name&gt;/AboveDriver,string,*}
463 * One or more simple wildcard patters separated by '|' for matching the
464 * drivers the transformation should be applie above or at (depending on
465 * the action). The value being matched against here is the driver that
466 * is in the process of being attached, so for mergeconfig actions this is
467 * usually what you need to match on. */
468 rc = CFGMR3QueryStringAlloc(pCurTrans, "AboveDriver", &pszMultiPat);
469 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
470 rc = VINF_SUCCESS;
471 else
472 {
473 AssertLogRelRCReturn(rc, rc);
474 fMatch = RTStrSimplePatternMultiMatch(pszMultiPat, RTSTR_MAX, pszThisDrv, RTSTR_MAX, NULL);
475 MMR3HeapFree(pszMultiPat);
476 if (!fMatch)
477 continue;
478 if (uInjectTransformationAbove == (uintptr_t)pCurTrans)
479 continue;
480 }
481
482 /*
483 * We've got a match! Now, what are we supposed to do?
484 */
485 /** @cfgm{/PDM/DriverTransformations/&lt;name&gt;/Action,string,inject}
486 * The action that the transformation takes. Possible values are:
487 * - inject
488 * - mergeconfig: This merges and the content of the 'Config' key under the
489 * transformation into the driver's own 'Config' key, replacing any
490 * duplicates.
491 * - remove
492 * - removetree
493 * - replace
494 * - replacetree
495 */
496 char szAction[16];
497 rc = CFGMR3QueryStringDef(pCurTrans, "Action", szAction, sizeof(szAction), "inject");
498 AssertLogRelRCReturn(rc, rc);
499 AssertLogRelMsgReturn( !strcmp(szAction, "inject")
500 || !strcmp(szAction, "mergeconfig")
501 || !strcmp(szAction, "remove")
502 || !strcmp(szAction, "removetree")
503 || !strcmp(szAction, "replace")
504 || !strcmp(szAction, "replacetree")
505 ,
506 ("Action='%s', valid values are 'inject', 'mergeconfig', 'replace', 'replacetree', 'remove', 'removetree'.\n", szAction),
507 VERR_PDM_MISCONFIGURED_DRV_TRANSFORMATION);
508 LogRel(("PDMDriver: Applying '%s' to '%s'::[%s]...'%s': %s\n", szCurTransNm, pszDevice, szLun, pszThisDrv, szAction));
509 CFGMR3Dump(*ppNode);
510 CFGMR3Dump(pCurTrans);
511
512 /* Get the attached driver to inject. */
513 PCFGMNODE pTransAttDrv = NULL;
514 if (!strcmp(szAction, "inject") || !strcmp(szAction, "replace") || !strcmp(szAction, "replacetree"))
515 {
516 pTransAttDrv = CFGMR3GetChild(pCurTrans, "AttachedDriver");
517 AssertLogRelMsgReturn(pTransAttDrv,
518 ("An %s transformation requires an AttachedDriver child node!\n", szAction),
519 VERR_PDM_MISCONFIGURED_DRV_TRANSFORMATION);
520 }
521
522
523 /*
524 * Remove the node.
525 */
526 if (!strcmp(szAction, "remove") || !strcmp(szAction, "removetree"))
527 {
528 PCFGMNODE pBelowThis = CFGMR3GetChild(*ppNode, "AttachedDriver");
529 if (!pBelowThis || !strcmp(szAction, "removetree"))
530 {
531 CFGMR3RemoveNode(*ppNode);
532 *ppNode = NULL;
533 }
534 else
535 {
536 PCFGMNODE pBelowThisCopy;
537 rc = CFGMR3DuplicateSubTree(pBelowThis, &pBelowThisCopy);
538 AssertLogRelRCReturn(rc, rc);
539
540 rc = CFGMR3ReplaceSubTree(*ppNode, pBelowThisCopy);
541 AssertLogRelRCReturnStmt(rc, CFGMR3RemoveNode(pBelowThis), rc);
542 }
543 }
544 /*
545 * Replace the driver about to be instantiated.
546 */
547 else if (!strcmp(szAction, "replace") || !strcmp(szAction, "replacetree"))
548 {
549 PCFGMNODE pTransCopy;
550 rc = CFGMR3DuplicateSubTree(pTransAttDrv, &pTransCopy);
551 AssertLogRelRCReturn(rc, rc);
552
553 PCFGMNODE pBelowThis = CFGMR3GetChild(*ppNode, "AttachedDriver");
554 if (!pBelowThis || !strcmp(szAction, "replacetree"))
555 rc = VINF_SUCCESS;
556 else
557 {
558 PCFGMNODE pBelowThisCopy;
559 rc = CFGMR3DuplicateSubTree(pBelowThis, &pBelowThisCopy);
560 if (RT_SUCCESS(rc))
561 {
562 rc = CFGMR3InsertSubTree(pTransCopy, "AttachedDriver", pBelowThisCopy, NULL);
563 AssertLogRelRC(rc);
564 if (RT_FAILURE(rc))
565 CFGMR3RemoveNode(pBelowThisCopy);
566 }
567 }
568 if (RT_SUCCESS(rc))
569 rc = CFGMR3ReplaceSubTree(*ppNode, pTransCopy);
570 if (RT_FAILURE(rc))
571 CFGMR3RemoveNode(pTransCopy);
572 }
573 /*
574 * Inject a driver before the driver about to be instantiated.
575 */
576 else if (!strcmp(szAction, "inject"))
577 {
578 PCFGMNODE pTransCopy;
579 rc = CFGMR3DuplicateSubTree(pTransAttDrv, &pTransCopy);
580 AssertLogRelRCReturn(rc, rc);
581
582 PCFGMNODE pThisCopy;
583 rc = CFGMR3DuplicateSubTree(*ppNode, &pThisCopy);
584 if (RT_SUCCESS(rc))
585 {
586 rc = CFGMR3InsertSubTree(pTransCopy, "AttachedDriver", pThisCopy, NULL);
587 if (RT_SUCCESS(rc))
588 {
589 rc = CFGMR3InsertInteger(pTransCopy, "InjectTransformationPtr", (uintptr_t)pCurTrans);
590 AssertLogRelRC(rc);
591 rc = CFGMR3InsertString(pTransCopy, "InjectTransformationNm", szCurTransNm);
592 AssertLogRelRC(rc);
593 if (RT_SUCCESS(rc))
594 rc = CFGMR3ReplaceSubTree(*ppNode, pTransCopy);
595 }
596 else
597 {
598 AssertLogRelRC(rc);
599 CFGMR3RemoveNode(pThisCopy);
600 }
601 }
602 if (RT_FAILURE(rc))
603 CFGMR3RemoveNode(pTransCopy);
604 }
605 /*
606 * Merge the Config node of the transformation with the one of the
607 * current driver.
608 */
609 else if (!strcmp(szAction, "mergeconfig"))
610 {
611 PCFGMNODE pTransConfig = CFGMR3GetChild(pCurTrans, "Config");
612 AssertLogRelReturn(pTransConfig, VERR_PDM_MISCONFIGURED_DRV_TRANSFORMATION);
613
614 PCFGMNODE pDrvConfig = CFGMR3GetChild(*ppNode, "Config");
615 if (*ppNode)
616 CFGMR3InsertNode(*ppNode, "Config", &pDrvConfig);
617 AssertLogRelReturn(pDrvConfig, VERR_PDM_CANNOT_TRANSFORM_REMOVED_DRIVER);
618
619 rc = CFGMR3CopyTree(pDrvConfig, pTransConfig, CFGM_COPY_FLAGS_REPLACE_VALUES | CFGM_COPY_FLAGS_MERGE_KEYS);
620 AssertLogRelRCReturn(rc, rc);
621 }
622 else
623 AssertFailed();
624
625 cTransformations++;
626 if (*ppNode)
627 CFGMR3Dump(*ppNode);
628 else
629 LogRel(("PDMDriver: The transformation removed the driver.\n"));
630 }
631
632 /*
633 * Note what happened in the release log.
634 */
635 if (cTransformations > 0)
636 LogRel(("PDMDriver: Transformations done. Applied %u driver transformations.\n", cTransformations));
637
638 return rc;
639}
640
641
642/**
643 * Instantiate a driver.
644 *
645 * @returns VBox status code, including informational statuses.
646 *
647 * @param pVM The cross context VM structure.
648 * @param pNode The CFGM node for the driver.
649 * @param pBaseInterface The base interface.
650 * @param pDrvAbove The driver above it. NULL if it's the top-most
651 * driver.
652 * @param pLun The LUN the driver is being attached to. NULL
653 * if we're instantiating a driver chain before
654 * attaching it - untested.
655 * @param ppBaseInterface Where to return the pointer to the base
656 * interface of the newly created driver.
657 *
658 * @remarks Recursive calls to this function is normal as the drivers will
659 * attach to anything below them during the pfnContruct call.
660 *
661 * @todo Need to extend this interface a bit so that the driver
662 * transformation feature can attach drivers to unconfigured LUNs and
663 * at the end of chains.
664 */
665int pdmR3DrvInstantiate(PVM pVM, PCFGMNODE pNode, PPDMIBASE pBaseInterface, PPDMDRVINS pDrvAbove,
666 PPDMLUN pLun, PPDMIBASE *ppBaseInterface)
667{
668 Assert(!pDrvAbove || !pDrvAbove->Internal.s.pDown);
669 Assert(!pDrvAbove || !pDrvAbove->pDownBase);
670
671 Assert(pBaseInterface->pfnQueryInterface(pBaseInterface, PDMIBASE_IID) == pBaseInterface);
672
673 /*
674 * Do driver chain injections
675 */
676 int rc = pdmR3DrvMaybeTransformChain(pVM, pDrvAbove, pLun, &pNode);
677 if (RT_FAILURE(rc))
678 return rc;
679 if (!pNode)
680 return VERR_PDM_NO_ATTACHED_DRIVER;
681
682 /*
683 * Find the driver.
684 */
685 char *pszName;
686 rc = CFGMR3QueryStringAlloc(pNode, "Driver", &pszName);
687 if (RT_SUCCESS(rc))
688 {
689 PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName);
690 if ( pDrv
691 && pDrv->cInstances < pDrv->pReg->cMaxInstances)
692 {
693 /* config node */
694 PCFGMNODE pConfigNode = CFGMR3GetChild(pNode, "Config");
695 if (!pConfigNode)
696 rc = CFGMR3InsertNode(pNode, "Config", &pConfigNode);
697 if (RT_SUCCESS(rc))
698 {
699 CFGMR3SetRestrictedRoot(pConfigNode);
700
701 /*
702 * Allocate the driver instance.
703 */
704 size_t cb = RT_UOFFSETOF_DYN(PDMDRVINS, achInstanceData[pDrv->pReg->cbInstance]);
705 cb = RT_ALIGN_Z(cb, 16);
706 bool const fHyperHeap = !!(pDrv->pReg->fFlags & (PDM_DRVREG_FLAGS_R0 | PDM_DRVREG_FLAGS_RC));
707 PPDMDRVINS pNew;
708 if (fHyperHeap)
709 rc = MMHyperAlloc(pVM, cb, 64, MM_TAG_PDM_DRIVER, (void **)&pNew);
710 else
711 rc = MMR3HeapAllocZEx(pVM, MM_TAG_PDM_DRIVER, cb, (void **)&pNew);
712 if (RT_SUCCESS(rc))
713 {
714 /*
715 * Initialize the instance structure (declaration order).
716 */
717 pNew->u32Version = PDM_DRVINS_VERSION;
718 pNew->iInstance = pDrv->iNextInstance;
719 pNew->Internal.s.pUp = pDrvAbove ? pDrvAbove : NULL;
720 //pNew->Internal.s.pDown = NULL;
721 pNew->Internal.s.pLun = pLun;
722 pNew->Internal.s.pDrv = pDrv;
723 pNew->Internal.s.pVMR3 = pVM;
724 pNew->Internal.s.pVMR0 = pDrv->pReg->fFlags & PDM_DRVREG_FLAGS_R0 ? pVM->pVMR0ForCall : NIL_RTR0PTR;
725 pNew->Internal.s.pVMRC = pDrv->pReg->fFlags & PDM_DRVREG_FLAGS_RC ? pVM->pVMRC : NIL_RTRCPTR;
726 //pNew->Internal.s.fDetaching = false;
727 pNew->Internal.s.fVMSuspended = true; /** @todo should be 'false', if driver is attached at runtime. */
728 //pNew->Internal.s.fVMReset = false;
729 pNew->Internal.s.fHyperHeap = fHyperHeap;
730 //pNew->Internal.s.pfnAsyncNotify = NULL;
731 pNew->Internal.s.pCfgHandle = pNode;
732 pNew->pReg = pDrv->pReg;
733 pNew->pCfg = pConfigNode;
734 pNew->pUpBase = pBaseInterface;
735 Assert(!pDrvAbove || pBaseInterface == &pDrvAbove->IBase);
736 //pNew->pDownBase = NULL;
737 //pNew->IBase.pfnQueryInterface = NULL;
738 //pNew->fTracing = 0;
739 pNew->idTracing = ++pVM->pdm.s.idTracingOther;
740 pNew->pHlpR3 = &g_pdmR3DrvHlp;
741 pNew->pvInstanceDataR3 = &pNew->achInstanceData[0];
742 if (pDrv->pReg->fFlags & PDM_DRVREG_FLAGS_R0)
743 {
744 pNew->pvInstanceDataR0 = MMHyperR3ToR0(pVM, &pNew->achInstanceData[0]);
745 rc = PDMR3LdrGetSymbolR0(pVM, NULL, "g_pdmR0DrvHlp", &pNew->pHlpR0);
746 AssertReleaseRCReturn(rc, rc);
747 }
748 if ( (pDrv->pReg->fFlags & PDM_DRVREG_FLAGS_RC)
749 && VM_IS_RAW_MODE_ENABLED(pVM))
750 {
751 pNew->pvInstanceDataR0 = MMHyperR3ToRC(pVM, &pNew->achInstanceData[0]);
752 rc = PDMR3LdrGetSymbolRC(pVM, NULL, "g_pdmRCDrvHlp", &pNew->pHlpRC);
753 AssertReleaseRCReturn(rc, rc);
754 }
755
756 pDrv->iNextInstance++;
757 pDrv->cInstances++;
758
759 /*
760 * Link with it with the driver above / LUN.
761 */
762 if (pDrvAbove)
763 {
764 pDrvAbove->pDownBase = &pNew->IBase;
765 pDrvAbove->Internal.s.pDown = pNew;
766 }
767 else if (pLun)
768 pLun->pTop = pNew;
769 if (pLun)
770 pLun->pBottom = pNew;
771
772 /*
773 * Invoke the constructor.
774 */
775 rc = pDrv->pReg->pfnConstruct(pNew, pNew->pCfg, 0 /*fFlags*/);
776 if (RT_SUCCESS(rc))
777 {
778 AssertPtr(pNew->IBase.pfnQueryInterface);
779 Assert(pNew->IBase.pfnQueryInterface(&pNew->IBase, PDMIBASE_IID) == &pNew->IBase);
780
781 /* Success! */
782 *ppBaseInterface = &pNew->IBase;
783 if (pLun)
784 Log(("PDM: Attached driver %p:'%s'/%d to LUN#%d on device '%s'/%d, pDrvAbove=%p:'%s'/%d\n",
785 pNew, pDrv->pReg->szName, pNew->iInstance,
786 pLun->iLun,
787 pLun->pDevIns ? pLun->pDevIns->pReg->szName : pLun->pUsbIns->pReg->szName,
788 pLun->pDevIns ? pLun->pDevIns->iInstance : pLun->pUsbIns->iInstance,
789 pDrvAbove, pDrvAbove ? pDrvAbove->pReg->szName : "", pDrvAbove ? pDrvAbove->iInstance : UINT32_MAX));
790 else
791 Log(("PDM: Attached driver %p:'%s'/%d, pDrvAbove=%p:'%s'/%d\n",
792 pNew, pDrv->pReg->szName, pNew->iInstance,
793 pDrvAbove, pDrvAbove ? pDrvAbove->pReg->szName : "", pDrvAbove ? pDrvAbove->iInstance : UINT32_MAX));
794 }
795 else
796 {
797 pdmR3DrvDestroyChain(pNew, PDM_TACH_FLAGS_NO_CALLBACKS);
798 if (rc == VERR_VERSION_MISMATCH)
799 rc = VERR_PDM_DRIVER_VERSION_MISMATCH;
800 }
801 }
802 else
803 AssertMsgFailed(("Failed to allocate %d bytes for instantiating driver '%s'! rc=%Rrc\n", cb, pszName, rc));
804 }
805 else
806 AssertMsgFailed(("Failed to create Config node! rc=%Rrc\n", rc));
807 }
808 else if (pDrv)
809 {
810 AssertMsgFailed(("Too many instances of driver '%s', max is %u\n", pszName, pDrv->pReg->cMaxInstances));
811 rc = VERR_PDM_TOO_MANY_DRIVER_INSTANCES;
812 }
813 else
814 {
815 AssertMsgFailed(("Driver '%s' wasn't found!\n", pszName));
816 rc = VERR_PDM_DRIVER_NOT_FOUND;
817 }
818 MMR3HeapFree(pszName);
819 }
820 else
821 {
822 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
823 rc = VERR_PDM_CFG_MISSING_DRIVER_NAME;
824 else
825 AssertMsgFailed(("Query for string value of \"Driver\" -> %Rrc\n", rc));
826 }
827 return rc;
828}
829
830
831/**
832 * Detaches a driver from whatever it's attached to.
833 * This will of course lead to the destruction of the driver and all drivers below it in the chain.
834 *
835 * @returns VINF_SUCCESS
836 * @param pDrvIns The driver instance to detach.
837 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
838 */
839int pdmR3DrvDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
840{
841 PDMDRV_ASSERT_DRVINS(pDrvIns);
842 LogFlow(("pdmR3DrvDetach: pDrvIns=%p '%s'/%d\n", pDrvIns, pDrvIns->pReg->szName, pDrvIns->iInstance));
843 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
844
845 /*
846 * Check that we're not doing this recursively, that could have unwanted sideeffects!
847 */
848 if (pDrvIns->Internal.s.fDetaching)
849 {
850 AssertMsgFailed(("Recursive detach! '%s'/%d\n", pDrvIns->pReg->szName, pDrvIns->iInstance));
851 return VINF_SUCCESS;
852 }
853
854 /*
855 * Check that we actually can detach this instance.
856 * The requirement is that the driver/device above has a detach method.
857 */
858 if ( pDrvIns->Internal.s.pUp
859 ? !pDrvIns->Internal.s.pUp->pReg->pfnDetach
860 : pDrvIns->Internal.s.pLun->pDevIns
861 ? !pDrvIns->Internal.s.pLun->pDevIns->pReg->pfnDetach
862 : !pDrvIns->Internal.s.pLun->pUsbIns->pReg->pfnDriverDetach
863 )
864 {
865 AssertMsgFailed(("Cannot detach driver instance because the driver/device above doesn't support it!\n"));
866 return VERR_PDM_DRIVER_DETACH_NOT_POSSIBLE;
867 }
868
869 /*
870 * Join paths with pdmR3DrvDestroyChain.
871 */
872 pdmR3DrvDestroyChain(pDrvIns, fFlags);
873 return VINF_SUCCESS;
874}
875
876
877/**
878 * Destroys a driver chain starting with the specified driver.
879 *
880 * This is used when unplugging a device at run time.
881 *
882 * @param pDrvIns Pointer to the driver instance to start with.
883 * @param fFlags PDM_TACH_FLAGS_NOT_HOT_PLUG, PDM_TACH_FLAGS_NO_CALLBACKS
884 * or 0.
885 */
886void pdmR3DrvDestroyChain(PPDMDRVINS pDrvIns, uint32_t fFlags)
887{
888 PVM pVM = pDrvIns->Internal.s.pVMR3;
889 VM_ASSERT_EMT(pVM);
890
891 /*
892 * Detach the bottommost driver until we've detached pDrvIns.
893 */
894 pDrvIns->Internal.s.fDetaching = true;
895 PPDMDRVINS pCur;
896 do
897 {
898 /* find the driver to detach. */
899 pCur = pDrvIns;
900 while (pCur->Internal.s.pDown)
901 pCur = pCur->Internal.s.pDown;
902 LogFlow(("pdmR3DrvDestroyChain: pCur=%p '%s'/%d\n", pCur, pCur->pReg->szName, pCur->iInstance));
903
904 /*
905 * Unlink it and notify parent.
906 */
907 pCur->Internal.s.fDetaching = true;
908
909 PPDMLUN pLun = pCur->Internal.s.pLun;
910 Assert(pLun->pBottom == pCur);
911 pLun->pBottom = pCur->Internal.s.pUp;
912
913 if (pCur->Internal.s.pUp)
914 {
915 /* driver parent */
916 PPDMDRVINS pParent = pCur->Internal.s.pUp;
917 pCur->Internal.s.pUp = NULL;
918 pParent->Internal.s.pDown = NULL;
919
920 if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pParent->pReg->pfnDetach)
921 pParent->pReg->pfnDetach(pParent, fFlags);
922
923 pParent->pDownBase = NULL;
924 }
925 else
926 {
927 /* device parent */
928 Assert(pLun->pTop == pCur);
929 pLun->pTop = NULL;
930 if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS))
931 {
932 if (pLun->pDevIns)
933 {
934 if (pLun->pDevIns->pReg->pfnDetach)
935 {
936 PDMCritSectEnter(pLun->pDevIns->pCritSectRoR3, VERR_IGNORED);
937 pLun->pDevIns->pReg->pfnDetach(pLun->pDevIns, pLun->iLun, fFlags);
938 PDMCritSectLeave(pLun->pDevIns->pCritSectRoR3);
939 }
940 }
941 else
942 {
943 if (pLun->pUsbIns->pReg->pfnDriverDetach)
944 {
945 /** @todo USB device locking? */
946 pLun->pUsbIns->pReg->pfnDriverDetach(pLun->pUsbIns, pLun->iLun, fFlags);
947 }
948 }
949 }
950 }
951
952 /*
953 * Call destructor.
954 */
955 pCur->pUpBase = NULL;
956 if (pCur->pReg->pfnDestruct)
957 pCur->pReg->pfnDestruct(pCur);
958 pCur->Internal.s.pDrv->cInstances--;
959
960 /*
961 * Free all resources allocated by the driver.
962 */
963 /* Queues. */
964 int rc = PDMR3QueueDestroyDriver(pVM, pCur);
965 AssertRC(rc);
966
967 /* Timers. */
968 rc = TMR3TimerDestroyDriver(pVM, pCur);
969 AssertRC(rc);
970
971 /* SSM data units. */
972 rc = SSMR3DeregisterDriver(pVM, pCur, NULL, 0);
973 AssertRC(rc);
974
975 /* PDM threads. */
976 rc = pdmR3ThreadDestroyDriver(pVM, pCur);
977 AssertRC(rc);
978
979 /* Info handlers. */
980 rc = DBGFR3InfoDeregisterDriver(pVM, pCur, NULL);
981 AssertRC(rc);
982
983 /* PDM critsects. */
984 rc = pdmR3CritSectBothDeleteDriver(pVM, pCur);
985 AssertRC(rc);
986
987 /* Block caches. */
988 PDMR3BlkCacheReleaseDriver(pVM, pCur);
989
990#ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
991 /* Completion templates.*/
992 pdmR3AsyncCompletionTemplateDestroyDriver(pVM, pCur);
993#endif
994
995 /* Finally, the driver it self. */
996 bool fHyperHeap = pCur->Internal.s.fHyperHeap;
997 ASMMemFill32(pCur, RT_UOFFSETOF_DYN(PDMDRVINS, achInstanceData[pCur->pReg->cbInstance]), 0xdeadd0d0);
998 if (fHyperHeap)
999 MMHyperFree(pVM, pCur);
1000 else
1001 MMR3HeapFree(pCur);
1002
1003 } while (pCur != pDrvIns);
1004}
1005
1006
1007
1008
1009/** @name Driver Helpers
1010 * @{
1011 */
1012
1013/** @interface_method_impl{PDMDRVHLPR3,pfnAttach} */
1014static DECLCALLBACK(int) pdmR3DrvHlp_Attach(PPDMDRVINS pDrvIns, uint32_t fFlags, PPDMIBASE *ppBaseInterface)
1015{
1016 PDMDRV_ASSERT_DRVINS(pDrvIns);
1017 PVM pVM = pDrvIns->Internal.s.pVMR3;
1018 VM_ASSERT_EMT(pVM);
1019 LogFlow(("pdmR3DrvHlp_Attach: caller='%s'/%d: fFlags=%#x\n", pDrvIns->pReg->szName, pDrvIns->iInstance, fFlags));
1020 Assert(!(fFlags & ~(PDM_TACH_FLAGS_NOT_HOT_PLUG)));
1021 RT_NOREF_PV(fFlags);
1022
1023 /*
1024 * Check that there isn't anything attached already.
1025 */
1026 int rc;
1027 if (!pDrvIns->Internal.s.pDown)
1028 {
1029 Assert(pDrvIns->Internal.s.pLun->pBottom == pDrvIns);
1030
1031 /*
1032 * Get the attached driver configuration.
1033 */
1034 PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver");
1035 if (pNode)
1036 rc = pdmR3DrvInstantiate(pVM, pNode, &pDrvIns->IBase, pDrvIns, pDrvIns->Internal.s.pLun, ppBaseInterface);
1037 else
1038 rc = VERR_PDM_NO_ATTACHED_DRIVER;
1039 }
1040 else
1041 {
1042 AssertMsgFailed(("Already got a driver attached. The driver should keep track of such things!\n"));
1043 rc = VERR_PDM_DRIVER_ALREADY_ATTACHED;
1044 }
1045
1046 LogFlow(("pdmR3DrvHlp_Attach: caller='%s'/%d: return %Rrc\n",
1047 pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1048 return rc;
1049}
1050
1051
1052/** @interface_method_impl{PDMDRVHLPR3,pfnDetach} */
1053static DECLCALLBACK(int) pdmR3DrvHlp_Detach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1054{
1055 PDMDRV_ASSERT_DRVINS(pDrvIns);
1056 LogFlow(("pdmR3DrvHlp_Detach: caller='%s'/%d: fFlags=%#x\n",
1057 pDrvIns->pReg->szName, pDrvIns->iInstance, fFlags));
1058 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1059
1060 /*
1061 * Anything attached?
1062 */
1063 int rc;
1064 if (pDrvIns->Internal.s.pDown)
1065 rc = pdmR3DrvDetach(pDrvIns->Internal.s.pDown, fFlags);
1066 else
1067 {
1068 AssertMsgFailed(("Nothing attached!\n"));
1069 rc = VERR_PDM_NO_DRIVER_ATTACHED;
1070 }
1071
1072 LogFlow(("pdmR3DrvHlp_Detach: caller='%s'/%d: returns %Rrc\n",
1073 pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1074 return rc;
1075}
1076
1077
1078/** @interface_method_impl{PDMDRVHLPR3,pfnDetachSelf} */
1079static DECLCALLBACK(int) pdmR3DrvHlp_DetachSelf(PPDMDRVINS pDrvIns, uint32_t fFlags)
1080{
1081 PDMDRV_ASSERT_DRVINS(pDrvIns);
1082 LogFlow(("pdmR3DrvHlp_DetachSelf: caller='%s'/%d: fFlags=%#x\n",
1083 pDrvIns->pReg->szName, pDrvIns->iInstance, fFlags));
1084 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1085
1086 int rc = pdmR3DrvDetach(pDrvIns, fFlags);
1087
1088 LogFlow(("pdmR3DrvHlp_Detach: returns %Rrc\n", rc)); /* pDrvIns is freed by now. */
1089 return rc;
1090}
1091
1092
1093/** @interface_method_impl{PDMDRVHLPR3,pfnMountPrepare} */
1094static DECLCALLBACK(int) pdmR3DrvHlp_MountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver)
1095{
1096 PDMDRV_ASSERT_DRVINS(pDrvIns);
1097 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n",
1098 pDrvIns->pReg->szName, pDrvIns->iInstance, pszFilename, pszFilename, pszCoreDriver, pszCoreDriver));
1099 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1100
1101 /*
1102 * Do the caller have anything attached below itself?
1103 */
1104 if (pDrvIns->Internal.s.pDown)
1105 {
1106 AssertMsgFailed(("Cannot prepare a mount when something's attached to you!\n"));
1107 return VERR_PDM_DRIVER_ALREADY_ATTACHED;
1108 }
1109
1110 /*
1111 * We're asked to prepare, so we'll start off by nuking the
1112 * attached configuration tree.
1113 */
1114 PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver");
1115 if (pNode)
1116 CFGMR3RemoveNode(pNode);
1117
1118 /*
1119 * If there is no core driver, we'll have to probe for it.
1120 */
1121 if (!pszCoreDriver)
1122 {
1123 /** @todo implement image probing. */
1124 AssertReleaseMsgFailed(("Not implemented!\n"));
1125 return VERR_NOT_IMPLEMENTED;
1126 }
1127
1128 /*
1129 * Construct the basic attached driver configuration.
1130 */
1131 int rc = CFGMR3InsertNode(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver", &pNode);
1132 if (RT_SUCCESS(rc))
1133 {
1134 rc = CFGMR3InsertString(pNode, "Driver", pszCoreDriver);
1135 if (RT_SUCCESS(rc))
1136 {
1137 PCFGMNODE pCfg;
1138 rc = CFGMR3InsertNode(pNode, "Config", &pCfg);
1139 if (RT_SUCCESS(rc))
1140 {
1141 rc = CFGMR3InsertString(pCfg, "Path", pszFilename);
1142 if (RT_SUCCESS(rc))
1143 {
1144 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: returns %Rrc (Driver=%s)\n",
1145 pDrvIns->pReg->szName, pDrvIns->iInstance, rc, pszCoreDriver));
1146 return rc;
1147 }
1148 else
1149 AssertMsgFailed(("Path string insert failed, rc=%Rrc\n", rc));
1150 }
1151 else
1152 AssertMsgFailed(("Config node failed, rc=%Rrc\n", rc));
1153 }
1154 else
1155 AssertMsgFailed(("Driver string insert failed, rc=%Rrc\n", rc));
1156 CFGMR3RemoveNode(pNode);
1157 }
1158 else
1159 AssertMsgFailed(("AttachedDriver node insert failed, rc=%Rrc\n", rc));
1160
1161 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: returns %Rrc\n",
1162 pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1163 return rc;
1164}
1165
1166
1167/** @interface_method_impl{PDMDRVHLPR3,pfnAssertEMT} */
1168static DECLCALLBACK(bool) pdmR3DrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
1169{
1170 PDMDRV_ASSERT_DRVINS(pDrvIns);
1171 if (VM_IS_EMT(pDrvIns->Internal.s.pVMR3))
1172 return true;
1173
1174 char szMsg[100];
1175 RTStrPrintf(szMsg, sizeof(szMsg), "AssertEMT '%s'/%d\n", pDrvIns->pReg->szName, pDrvIns->iInstance);
1176 RTAssertMsg1Weak(szMsg, iLine, pszFile, pszFunction);
1177 AssertBreakpoint();
1178 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1179 return false;
1180}
1181
1182
1183/** @interface_method_impl{PDMDRVHLPR3,pfnAssertOther} */
1184static DECLCALLBACK(bool) pdmR3DrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
1185{
1186 PDMDRV_ASSERT_DRVINS(pDrvIns);
1187 if (!VM_IS_EMT(pDrvIns->Internal.s.pVMR3))
1188 return true;
1189
1190 char szMsg[100];
1191 RTStrPrintf(szMsg, sizeof(szMsg), "AssertOther '%s'/%d\n", pDrvIns->pReg->szName, pDrvIns->iInstance);
1192 RTAssertMsg1Weak(szMsg, iLine, pszFile, pszFunction);
1193 AssertBreakpoint();
1194 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1195 return false;
1196}
1197
1198
1199/** @interface_method_impl{PDMDRVHLPR3,pfnVMSetError} */
1200static DECLCALLBACK(int) pdmR3DrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
1201{
1202 PDMDRV_ASSERT_DRVINS(pDrvIns);
1203 va_list args;
1204 va_start(args, pszFormat);
1205 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR3, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
1206 va_end(args);
1207 return rc;
1208}
1209
1210
1211/** @interface_method_impl{PDMDRVHLPR3,pfnVMSetErrorV} */
1212static DECLCALLBACK(int) pdmR3DrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
1213{
1214 PDMDRV_ASSERT_DRVINS(pDrvIns);
1215 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR3, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
1216 return rc;
1217}
1218
1219
1220/** @interface_method_impl{PDMDRVHLPR3,pfnVMSetRuntimeError} */
1221static DECLCALLBACK(int) pdmR3DrvHlp_VMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, ...)
1222{
1223 PDMDRV_ASSERT_DRVINS(pDrvIns);
1224 va_list args;
1225 va_start(args, pszFormat);
1226 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR3, fFlags, pszErrorId, pszFormat, args);
1227 va_end(args);
1228 return rc;
1229}
1230
1231
1232/** @interface_method_impl{PDMDRVHLPR3,pfnVMSetRuntimeErrorV} */
1233static DECLCALLBACK(int) pdmR3DrvHlp_VMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
1234{
1235 PDMDRV_ASSERT_DRVINS(pDrvIns);
1236 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR3, fFlags, pszErrorId, pszFormat, va);
1237 return rc;
1238}
1239
1240
1241/** @interface_method_impl{PDMDRVHLPR3,pfnVMState} */
1242static DECLCALLBACK(VMSTATE) pdmR3DrvHlp_VMState(PPDMDRVINS pDrvIns)
1243{
1244 PDMDRV_ASSERT_DRVINS(pDrvIns);
1245
1246 VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVMR3);
1247
1248 LogFlow(("pdmR3DrvHlp_VMState: caller='%s'/%d: returns %d (%s)\n", pDrvIns->pReg->szName, pDrvIns->iInstance,
1249 enmVMState, VMR3GetStateName(enmVMState)));
1250 return enmVMState;
1251}
1252
1253
1254/** @interface_method_impl{PDMDRVHLPR3,pfnVMTeleportedAndNotFullyResumedYet} */
1255static DECLCALLBACK(bool) pdmR3DrvHlp_VMTeleportedAndNotFullyResumedYet(PPDMDRVINS pDrvIns)
1256{
1257 PDMDRV_ASSERT_DRVINS(pDrvIns);
1258
1259 bool fRc = VMR3TeleportedAndNotFullyResumedYet(pDrvIns->Internal.s.pVMR3);
1260
1261 LogFlow(("pdmR3DrvHlp_VMState: caller='%s'/%d: returns %RTbool)\n", pDrvIns->pReg->szName, pDrvIns->iInstance,
1262 fRc));
1263 return fRc;
1264}
1265
1266
1267/** @interface_method_impl{PDMDRVHLPR3,pfnGetSupDrvSession} */
1268static DECLCALLBACK(PSUPDRVSESSION) pdmR3DrvHlp_GetSupDrvSession(PPDMDRVINS pDrvIns)
1269{
1270 PDMDRV_ASSERT_DRVINS(pDrvIns);
1271
1272 PSUPDRVSESSION pSession = pDrvIns->Internal.s.pVMR3->pSession;
1273 LogFlow(("pdmR3DrvHlp_GetSupDrvSession: caller='%s'/%d: returns %p)\n", pDrvIns->pReg->szName, pDrvIns->iInstance,
1274 pSession));
1275 return pSession;
1276}
1277
1278
1279/** @interface_method_impl{PDMDRVHLPR3,pfnQueueCreate} */
1280static DECLCALLBACK(int) pdmR3DrvHlp_QueueCreate(PPDMDRVINS pDrvIns, uint32_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
1281 PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue)
1282{
1283 PDMDRV_ASSERT_DRVINS(pDrvIns);
1284 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p pszName=%p:{%s} ppQueue=%p\n",
1285 pDrvIns->pReg->szName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, pszName, ppQueue));
1286 PVM pVM = pDrvIns->Internal.s.pVMR3;
1287 VM_ASSERT_EMT(pVM);
1288
1289 if (pDrvIns->iInstance > 0)
1290 {
1291 pszName = MMR3HeapAPrintf(pVM, MM_TAG_PDM_DRIVER_DESC, "%s_%u", pszName, pDrvIns->iInstance);
1292 AssertLogRelReturn(pszName, VERR_NO_MEMORY);
1293 }
1294
1295 int rc = PDMR3QueueCreateDriver(pVM, pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, ppQueue);
1296
1297 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc, *ppQueue));
1298 return rc;
1299}
1300
1301
1302/** @interface_method_impl{PDMDRVHLPR3,pfnTMGetVirtualFreq} */
1303static DECLCALLBACK(uint64_t) pdmR3DrvHlp_TMGetVirtualFreq(PPDMDRVINS pDrvIns)
1304{
1305 PDMDRV_ASSERT_DRVINS(pDrvIns);
1306
1307 return TMVirtualGetFreq(pDrvIns->Internal.s.pVMR3);
1308}
1309
1310
1311/** @interface_method_impl{PDMDRVHLPR3,pfnTMGetVirtualTime} */
1312static DECLCALLBACK(uint64_t) pdmR3DrvHlp_TMGetVirtualTime(PPDMDRVINS pDrvIns)
1313{
1314 PDMDRV_ASSERT_DRVINS(pDrvIns);
1315
1316 return TMVirtualGet(pDrvIns->Internal.s.pVMR3);
1317}
1318
1319
1320/** @interface_method_impl{PDMDRVHLPR3,pfnTMTimerCreate} */
1321static DECLCALLBACK(int) pdmR3DrvHlp_TMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
1322{
1323 PDMDRV_ASSERT_DRVINS(pDrvIns);
1324 LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} ppTimer=%p\n",
1325 pDrvIns->pReg->szName, pDrvIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer));
1326
1327 int rc = TMR3TimerCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer);
1328
1329 LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc *ppTimer=%p\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc, *ppTimer));
1330 return rc;
1331}
1332
1333
1334
1335/** @interface_method_impl{PDMDRVHLPR3,pfnSSMRegister} */
1336static DECLCALLBACK(int) pdmR3DrvHlp_SSMRegister(PPDMDRVINS pDrvIns, uint32_t uVersion, size_t cbGuess,
1337 PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
1338 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
1339 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
1340{
1341 PDMDRV_ASSERT_DRVINS(pDrvIns);
1342 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1343 LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: uVersion=%#x cbGuess=%#x \n"
1344 " pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
1345 pDrvIns->pReg->szName, pDrvIns->iInstance, uVersion, cbGuess,
1346 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1347 pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
1348
1349 int rc = SSMR3RegisterDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, pDrvIns->pReg->szName, pDrvIns->iInstance,
1350 uVersion, cbGuess,
1351 pfnLivePrep, pfnLiveExec, pfnLiveVote,
1352 pfnSavePrep, pfnSaveExec, pfnSaveDone,
1353 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
1354
1355 LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1356 return rc;
1357}
1358
1359
1360/** @interface_method_impl{PDMDRVHLPR3,pfnSSMDeregister} */
1361static DECLCALLBACK(int) pdmR3DrvHlp_SSMDeregister(PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance)
1362{
1363 PDMDRV_ASSERT_DRVINS(pDrvIns);
1364 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1365 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: pszName=%p:{%s} uInstance=%#x\n",
1366 pDrvIns->pReg->szName, pDrvIns->iInstance, pszName, pszName, uInstance));
1367
1368 int rc = SSMR3DeregisterDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, pszName, uInstance);
1369
1370 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1371 return rc;
1372}
1373
1374
1375/** @interface_method_impl{PDMDRVHLPR3,pfnDBGFInfoRegister} */
1376static DECLCALLBACK(int) pdmR3DrvHlp_DBGFInfoRegister(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler)
1377{
1378 PDMDRV_ASSERT_DRVINS(pDrvIns);
1379 LogFlow(("pdmR3DrvHlp_DBGFInfoRegister: caller='%s'/%d: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p\n",
1380 pDrvIns->pReg->szName, pDrvIns->iInstance, pszName, pszName, pszDesc, pszDesc, pfnHandler));
1381
1382 int rc = DBGFR3InfoRegisterDriver(pDrvIns->Internal.s.pVMR3, pszName, pszDesc, pfnHandler, pDrvIns);
1383
1384 LogFlow(("pdmR3DrvHlp_DBGFInfoRegister: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1385 return rc;
1386}
1387
1388
1389/** @interface_method_impl{PDMDRVHLPR3,pfnDBGFInfoRegisterArgv} */
1390static DECLCALLBACK(int) pdmR3DrvHlp_DBGFInfoRegisterArgv(PPDMDRVINS pDrvIns, const char *pszName, const char *pszDesc, PFNDBGFINFOARGVDRV pfnHandler)
1391{
1392 PDMDRV_ASSERT_DRVINS(pDrvIns);
1393 LogFlow(("pdmR3DrvHlp_DBGFInfoRegisterArgv: caller='%s'/%d: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p\n",
1394 pDrvIns->pReg->szName, pDrvIns->iInstance, pszName, pszName, pszDesc, pszDesc, pfnHandler));
1395
1396 int rc = DBGFR3InfoRegisterDriverArgv(pDrvIns->Internal.s.pVMR3, pszName, pszDesc, pfnHandler, pDrvIns);
1397
1398 LogFlow(("pdmR3DrvHlp_DBGFInfoRegisterArgv: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1399 return rc;
1400}
1401
1402
1403/** @interface_method_impl{PDMDRVHLPR3,pfnDBGFInfoDeregister} */
1404static DECLCALLBACK(int) pdmR3DrvHlp_DBGFInfoDeregister(PPDMDRVINS pDrvIns, const char *pszName)
1405{
1406 PDMDRV_ASSERT_DRVINS(pDrvIns);
1407 LogFlow(("pdmR3DrvHlp_DBGFInfoDeregister: caller='%s'/%d: pszName=%p:{%s}\n",
1408 pDrvIns->pReg->szName, pDrvIns->iInstance, pszName, pszName));
1409
1410 int rc = DBGFR3InfoDeregisterDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, pszName);
1411
1412 LogFlow(("pdmR3DrvHlp_DBGFInfoDeregister: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1413
1414 return rc;
1415}
1416
1417
1418/** @interface_method_impl{PDMDRVHLPR3,pfnSTAMRegister} */
1419static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName,
1420 STAMUNIT enmUnit, const char *pszDesc)
1421{
1422 PDMDRV_ASSERT_DRVINS(pDrvIns);
1423 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1424
1425 STAM_REG(pDrvIns->Internal.s.pVMR3, pvSample, enmType, pszName, enmUnit, pszDesc);
1426 RT_NOREF6(pDrvIns, pvSample, enmType, pszName, enmUnit, pszDesc);
1427 /** @todo track the samples so they can be dumped & deregistered when the driver instance is destroyed.
1428 * For now we just have to be careful not to use this call for drivers which can be unloaded. */
1429}
1430
1431
1432/** @interface_method_impl{PDMDRVHLPR3,pfnSTAMRegisterF} */
1433static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1434 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
1435{
1436 PDMDRV_ASSERT_DRVINS(pDrvIns);
1437 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1438
1439 va_list args;
1440 va_start(args, pszName);
1441 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVMR3, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
1442 va_end(args);
1443 AssertRC(rc);
1444}
1445
1446
1447/** @interface_method_impl{PDMDRVHLPR3,pfnSTAMRegisterV} */
1448static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterV(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
1449 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args)
1450{
1451 PDMDRV_ASSERT_DRVINS(pDrvIns);
1452 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1453
1454 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVMR3, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
1455 AssertRC(rc);
1456}
1457
1458
1459/** @interface_method_impl{PDMDRVHLPR3,pfnSTAMDeregister} */
1460static DECLCALLBACK(int) pdmR3DrvHlp_STAMDeregister(PPDMDRVINS pDrvIns, void *pvSample)
1461{
1462 PDMDRV_ASSERT_DRVINS(pDrvIns);
1463 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1464
1465 return STAMR3DeregisterByAddr(pDrvIns->Internal.s.pVMR3->pUVM, pvSample);
1466}
1467
1468
1469/** @interface_method_impl{PDMDRVHLPR3,pfnSUPCallVMMR0Ex} */
1470static DECLCALLBACK(int) pdmR3DrvHlp_SUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg)
1471{
1472 PDMDRV_ASSERT_DRVINS(pDrvIns);
1473 LogFlow(("pdmR3DrvHlp_SSMCallVMMR0Ex: caller='%s'/%d: uOperation=%u pvArg=%p cbArg=%d\n",
1474 pDrvIns->pReg->szName, pDrvIns->iInstance, uOperation, pvArg, cbArg));
1475 RT_NOREF_PV(cbArg);
1476
1477 int rc;
1478 if ( uOperation >= VMMR0_DO_SRV_START
1479 && uOperation < VMMR0_DO_SRV_END)
1480 rc = SUPR3CallVMMR0Ex(VMCC_GET_VMR0_FOR_CALL(pDrvIns->Internal.s.pVMR3), NIL_VMCPUID, uOperation, 0, (PSUPVMMR0REQHDR)pvArg);
1481 else
1482 {
1483 AssertMsgFailed(("Invalid uOperation=%u\n", uOperation));
1484 rc = VERR_INVALID_PARAMETER;
1485 }
1486
1487 LogFlow(("pdmR3DrvHlp_SUPCallVMMR0Ex: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1488 return rc;
1489}
1490
1491
1492/** @interface_method_impl{PDMDRVHLPR3,pfnUSBRegisterHub} */
1493static DECLCALLBACK(int) pdmR3DrvHlp_USBRegisterHub(PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp)
1494{
1495 PDMDRV_ASSERT_DRVINS(pDrvIns);
1496 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1497 LogFlow(("pdmR3DrvHlp_USBRegisterHub: caller='%s'/%d: fVersions=%#x cPorts=%#x pUsbHubReg=%p ppUsbHubHlp=%p\n",
1498 pDrvIns->pReg->szName, pDrvIns->iInstance, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp));
1499
1500#ifdef VBOX_WITH_USB
1501 int rc = pdmR3UsbRegisterHub(pDrvIns->Internal.s.pVMR3, pDrvIns, fVersions, cPorts, pUsbHubReg, ppUsbHubHlp);
1502#else
1503 int rc = VERR_NOT_SUPPORTED;
1504#endif
1505
1506 LogFlow(("pdmR3DrvHlp_USBRegisterHub: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1507 return rc;
1508}
1509
1510
1511/** @interface_method_impl{PDMDRVHLPR3,pfnSetAsyncNotification} */
1512static DECLCALLBACK(int) pdmR3DrvHlp_SetAsyncNotification(PPDMDRVINS pDrvIns, PFNPDMDRVASYNCNOTIFY pfnAsyncNotify)
1513{
1514 PDMDRV_ASSERT_DRVINS(pDrvIns);
1515 VM_ASSERT_EMT0(pDrvIns->Internal.s.pVMR3);
1516 LogFlow(("pdmR3DrvHlp_SetAsyncNotification: caller='%s'/%d: pfnAsyncNotify=%p\n", pDrvIns->pReg->szName, pDrvIns->iInstance, pfnAsyncNotify));
1517
1518 int rc = VINF_SUCCESS;
1519 AssertStmt(pfnAsyncNotify, rc = VERR_INVALID_PARAMETER);
1520 AssertStmt(!pDrvIns->Internal.s.pfnAsyncNotify, rc = VERR_WRONG_ORDER);
1521 AssertStmt(pDrvIns->Internal.s.fVMSuspended || pDrvIns->Internal.s.fVMReset, rc = VERR_WRONG_ORDER);
1522 VMSTATE enmVMState = VMR3GetState(pDrvIns->Internal.s.pVMR3);
1523 AssertStmt( enmVMState == VMSTATE_SUSPENDING
1524 || enmVMState == VMSTATE_SUSPENDING_EXT_LS
1525 || enmVMState == VMSTATE_SUSPENDING_LS
1526 || enmVMState == VMSTATE_RESETTING
1527 || enmVMState == VMSTATE_RESETTING_LS
1528 || enmVMState == VMSTATE_POWERING_OFF
1529 || enmVMState == VMSTATE_POWERING_OFF_LS,
1530 rc = VERR_INVALID_STATE);
1531
1532 if (RT_SUCCESS(rc))
1533 pDrvIns->Internal.s.pfnAsyncNotify = pfnAsyncNotify;
1534
1535 LogFlow(("pdmR3DrvHlp_SetAsyncNotification: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, pDrvIns->iInstance, rc));
1536 return rc;
1537}
1538
1539
1540/** @interface_method_impl{PDMDRVHLPR3,pfnAsyncNotificationCompleted} */
1541static DECLCALLBACK(void) pdmR3DrvHlp_AsyncNotificationCompleted(PPDMDRVINS pDrvIns)
1542{
1543 PDMDRV_ASSERT_DRVINS(pDrvIns);
1544 PVM pVM = pDrvIns->Internal.s.pVMR3;
1545
1546 VMSTATE enmVMState = VMR3GetState(pVM);
1547 if ( enmVMState == VMSTATE_SUSPENDING
1548 || enmVMState == VMSTATE_SUSPENDING_EXT_LS
1549 || enmVMState == VMSTATE_SUSPENDING_LS
1550 || enmVMState == VMSTATE_RESETTING
1551 || enmVMState == VMSTATE_RESETTING_LS
1552 || enmVMState == VMSTATE_POWERING_OFF
1553 || enmVMState == VMSTATE_POWERING_OFF_LS)
1554 {
1555 LogFlow(("pdmR3DrvHlp_AsyncNotificationCompleted: caller='%s'/%d:\n", pDrvIns->pReg->szName, pDrvIns->iInstance));
1556 VMR3AsyncPdmNotificationWakeupU(pVM->pUVM);
1557 }
1558 else
1559 LogFlow(("pdmR3DrvHlp_AsyncNotificationCompleted: caller='%s'/%d: enmVMState=%d\n", pDrvIns->pReg->szName, pDrvIns->iInstance, enmVMState));
1560}
1561
1562
1563/** @interface_method_impl{PDMDRVHLPR3,pfnThreadCreate} */
1564static DECLCALLBACK(int) pdmR3DrvHlp_ThreadCreate(PPDMDRVINS pDrvIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDRV pfnThread,
1565 PFNPDMTHREADWAKEUPDRV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName)
1566{
1567 PDMDRV_ASSERT_DRVINS(pDrvIns);
1568 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1569 LogFlow(("pdmR3DrvHlp_ThreadCreate: caller='%s'/%d: ppThread=%p pvUser=%p pfnThread=%p pfnWakeup=%p cbStack=%#zx enmType=%d pszName=%p:{%s}\n",
1570 pDrvIns->pReg->szName, pDrvIns->iInstance, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName, pszName));
1571
1572 int rc = pdmR3ThreadCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppThread, pvUser, pfnThread, pfnWakeup, cbStack, enmType, pszName);
1573
1574 LogFlow(("pdmR3DrvHlp_ThreadCreate: caller='%s'/%d: returns %Rrc *ppThread=%RTthrd\n", pDrvIns->pReg->szName, pDrvIns->iInstance,
1575 rc, *ppThread));
1576 return rc;
1577}
1578
1579
1580/** @interface_method_impl{PDMDRVHLPR3,pfnAsyncCompletionTemplateCreate} */
1581static DECLCALLBACK(int) pdmR3DrvHlp_AsyncCompletionTemplateCreate(PPDMDRVINS pDrvIns, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
1582 PFNPDMASYNCCOMPLETEDRV pfnCompleted, void *pvTemplateUser,
1583 const char *pszDesc)
1584{
1585 PDMDRV_ASSERT_DRVINS(pDrvIns);
1586 LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: ppTemplate=%p pfnCompleted=%p pszDesc=%p:{%s}\n",
1587 pDrvIns->pReg->szName, pDrvIns->iInstance, ppTemplate, pfnCompleted, pszDesc, pszDesc));
1588
1589 int rc = pdmR3AsyncCompletionTemplateCreateDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppTemplate, pfnCompleted, pvTemplateUser, pszDesc);
1590
1591 LogFlow(("pdmR3DrvHlp_AsyncCompletionTemplateCreate: caller='%s'/%d: returns %Rrc *ppThread=%p\n", pDrvIns->pReg->szName,
1592 pDrvIns->iInstance, rc, *ppTemplate));
1593 return rc;
1594}
1595
1596
1597#ifdef VBOX_WITH_NETSHAPER
1598/** @interface_method_impl{PDMDRVHLPR3,pfnNetShaperAttach} */
1599static DECLCALLBACK(int) pdmR3DrvHlp_NetShaperAttach(PPDMDRVINS pDrvIns, const char *pszBwGroup, PPDMNSFILTER pFilter)
1600{
1601 PDMDRV_ASSERT_DRVINS(pDrvIns);
1602 LogFlow(("pdmR3DrvHlp_NetShaperAttach: caller='%s'/%d: pFilter=%p pszBwGroup=%p:{%s}\n",
1603 pDrvIns->pReg->szName, pDrvIns->iInstance, pFilter, pszBwGroup, pszBwGroup));
1604
1605 int rc = PDMR3NsAttach(pDrvIns->Internal.s.pVMR3->pUVM, pDrvIns, pszBwGroup, pFilter);
1606
1607 LogFlow(("pdmR3DrvHlp_NetShaperAttach: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
1608 pDrvIns->iInstance, rc));
1609 return rc;
1610}
1611
1612
1613/** @interface_method_impl{PDMDRVHLPR3,pfnNetShaperDetach} */
1614static DECLCALLBACK(int) pdmR3DrvHlp_NetShaperDetach(PPDMDRVINS pDrvIns, PPDMNSFILTER pFilter)
1615{
1616 PDMDRV_ASSERT_DRVINS(pDrvIns);
1617 LogFlow(("pdmR3DrvHlp_NetShaperDetach: caller='%s'/%d: pFilter=%p\n",
1618 pDrvIns->pReg->szName, pDrvIns->iInstance, pFilter));
1619
1620 int rc = PDMR3NsDetach(pDrvIns->Internal.s.pVMR3->pUVM, pDrvIns, pFilter);
1621
1622 LogFlow(("pdmR3DrvHlp_NetShaperDetach: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
1623 pDrvIns->iInstance, rc));
1624 return rc;
1625}
1626#endif /* VBOX_WITH_NETSHAPER */
1627
1628
1629/** @interface_method_impl{PDMDRVHLPR3,pfnLdrGetRCInterfaceSymbols} */
1630static DECLCALLBACK(int) pdmR3DrvHlp_LdrGetRCInterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1631 const char *pszSymPrefix, const char *pszSymList)
1632{
1633 PDMDRV_ASSERT_DRVINS(pDrvIns);
1634 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1635 LogFlow(("pdmR3DrvHlp_LdrGetRCInterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",
1636 pDrvIns->pReg->szName, pDrvIns->iInstance, pvInterface, cbInterface, pszSymPrefix, pszSymPrefix, pszSymList, pszSymList));
1637
1638 int rc;
1639 if ( strncmp(pszSymPrefix, "drv", 3) == 0
1640 && RTStrIStr(pszSymPrefix + 3, pDrvIns->pReg->szName) != NULL)
1641 {
1642 if (pDrvIns->pReg->fFlags & PDM_DRVREG_FLAGS_RC)
1643 rc = PDMR3LdrGetInterfaceSymbols(pDrvIns->Internal.s.pVMR3,
1644 pvInterface, cbInterface,
1645 pDrvIns->pReg->szRCMod, pDrvIns->Internal.s.pDrv->pszRCSearchPath,
1646 pszSymPrefix, pszSymList,
1647 false /*fRing0OrRC*/);
1648 else
1649 {
1650 AssertMsgFailed(("Not a raw-mode enabled driver\n"));
1651 rc = VERR_PERMISSION_DENIED;
1652 }
1653 }
1654 else
1655 {
1656 AssertMsgFailed(("Invalid prefix '%s' for '%s'; must start with 'drv' and contain the driver name!\n",
1657 pszSymPrefix, pDrvIns->pReg->szName));
1658 rc = VERR_INVALID_NAME;
1659 }
1660
1661 LogFlow(("pdmR3DrvHlp_LdrGetRCInterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
1662 pDrvIns->iInstance, rc));
1663 return rc;
1664}
1665
1666
1667/** @interface_method_impl{PDMDRVHLPR3,pfnLdrGetR0InterfaceSymbols} */
1668static DECLCALLBACK(int) pdmR3DrvHlp_LdrGetR0InterfaceSymbols(PPDMDRVINS pDrvIns, void *pvInterface, size_t cbInterface,
1669 const char *pszSymPrefix, const char *pszSymList)
1670{
1671 PDMDRV_ASSERT_DRVINS(pDrvIns);
1672 VM_ASSERT_EMT(pDrvIns->Internal.s.pVMR3);
1673 LogFlow(("pdmR3DrvHlp_LdrGetR0InterfaceSymbols: caller='%s'/%d: pvInterface=%p cbInterface=%zu pszSymPrefix=%p:{%s} pszSymList=%p:{%s}\n",
1674 pDrvIns->pReg->szName, pDrvIns->iInstance, pvInterface, cbInterface, pszSymPrefix, pszSymPrefix, pszSymList, pszSymList));
1675
1676 int rc;
1677 if ( strncmp(pszSymPrefix, "drv", 3) == 0
1678 && RTStrIStr(pszSymPrefix + 3, pDrvIns->pReg->szName) != NULL)
1679 {
1680 if (pDrvIns->pReg->fFlags & PDM_DRVREG_FLAGS_R0)
1681 rc = PDMR3LdrGetInterfaceSymbols(pDrvIns->Internal.s.pVMR3,
1682 pvInterface, cbInterface,
1683 pDrvIns->pReg->szR0Mod, pDrvIns->Internal.s.pDrv->pszR0SearchPath,
1684 pszSymPrefix, pszSymList,
1685 true /*fRing0OrRC*/);
1686 else
1687 {
1688 AssertMsgFailed(("Not a ring-0 enabled driver\n"));
1689 rc = VERR_PERMISSION_DENIED;
1690 }
1691 }
1692 else
1693 {
1694 AssertMsgFailed(("Invalid prefix '%s' for '%s'; must start with 'drv' and contain the driver name!\n",
1695 pszSymPrefix, pDrvIns->pReg->szName));
1696 rc = VERR_INVALID_NAME;
1697 }
1698
1699 LogFlow(("pdmR3DrvHlp_LdrGetR0InterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
1700 pDrvIns->iInstance, rc));
1701 return rc;
1702}
1703
1704
1705/** @interface_method_impl{PDMDRVHLPR3,pfnCritSectInit} */
1706static DECLCALLBACK(int) pdmR3DrvHlp_CritSectInit(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect,
1707 RT_SRC_POS_DECL, const char *pszName)
1708{
1709 PDMDRV_ASSERT_DRVINS(pDrvIns);
1710 PVM pVM = pDrvIns->Internal.s.pVMR3;
1711 VM_ASSERT_EMT(pVM);
1712 LogFlow(("pdmR3DrvHlp_CritSectInit: caller='%s'/%d: pCritSect=%p pszName=%s\n",
1713 pDrvIns->pReg->szName, pDrvIns->iInstance, pCritSect, pszName));
1714
1715 int rc = pdmR3CritSectInitDriver(pVM, pDrvIns, pCritSect, RT_SRC_POS_ARGS, "%s_%u", pszName, pDrvIns->iInstance);
1716
1717 LogFlow(("pdmR3DrvHlp_CritSectInit: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
1718 pDrvIns->iInstance, rc));
1719 return rc;
1720}
1721
1722
1723/** @interface_method_impl{PDMDRVHLPR3,pfnCallR0} */
1724static DECLCALLBACK(int) pdmR3DrvHlp_CallR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)
1725{
1726 PDMDRV_ASSERT_DRVINS(pDrvIns);
1727 PVM pVM = pDrvIns->Internal.s.pVMR3;
1728 LogFlow(("pdmR3DrvHlp_CallR0: caller='%s'/%d: uOperation=%#x u64Arg=%#RX64\n",
1729 pDrvIns->pReg->szName, pDrvIns->iInstance, uOperation, u64Arg));
1730
1731 /*
1732 * Lazy resolve the ring-0 entry point.
1733 */
1734 int rc = VINF_SUCCESS;
1735 PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0 = pDrvIns->Internal.s.pfnReqHandlerR0;
1736 if (RT_UNLIKELY(pfnReqHandlerR0 == NIL_RTR0PTR))
1737 {
1738 if (pDrvIns->pReg->fFlags & PDM_DRVREG_FLAGS_R0)
1739 {
1740 char szSymbol[ sizeof("drvR0") + sizeof(pDrvIns->pReg->szName) + sizeof("ReqHandler")];
1741 strcat(strcat(strcpy(szSymbol, "drvR0"), pDrvIns->pReg->szName), "ReqHandler");
1742 szSymbol[sizeof("drvR0") - 1] = RT_C_TO_UPPER(szSymbol[sizeof("drvR0") - 1]);
1743
1744 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDrvIns->pReg->szR0Mod, pDrvIns->Internal.s.pDrv->pszR0SearchPath, szSymbol,
1745 &pfnReqHandlerR0);
1746 if (RT_SUCCESS(rc))
1747 pDrvIns->Internal.s.pfnReqHandlerR0 = pfnReqHandlerR0;
1748 else
1749 pfnReqHandlerR0 = NIL_RTR0PTR;
1750 }
1751 else
1752 rc = VERR_ACCESS_DENIED;
1753 }
1754 if (RT_LIKELY(pfnReqHandlerR0 != NIL_RTR0PTR))
1755 {
1756 /*
1757 * Make the ring-0 call.
1758 */
1759 PDMDRIVERCALLREQHANDLERREQ Req;
1760 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
1761 Req.Hdr.cbReq = sizeof(Req);
1762 Req.pDrvInsR0 = PDMDRVINS_2_R0PTR(pDrvIns);
1763 Req.uOperation = uOperation;
1764 Req.u32Alignment = 0;
1765 Req.u64Arg = u64Arg;
1766 rc = SUPR3CallVMMR0Ex(VMCC_GET_VMR0_FOR_CALL(pVM), NIL_VMCPUID, VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER, 0, &Req.Hdr);
1767 }
1768
1769 LogFlow(("pdmR3DrvHlp_CallR0: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName,
1770 pDrvIns->iInstance, rc));
1771 return rc;
1772}
1773
1774
1775/** @interface_method_impl{PDMDRVHLPR3,pfnBlkCacheRetain} */
1776static DECLCALLBACK(int) pdmR3DrvHlp_BlkCacheRetain(PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
1777 PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
1778 PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
1779 PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
1780 const char *pcszId)
1781{
1782 PDMDRV_ASSERT_DRVINS(pDrvIns);
1783 return PDMR3BlkCacheRetainDriver(pDrvIns->Internal.s.pVMR3, pDrvIns, ppBlkCache,
1784 pfnXferComplete, pfnXferEnqueue, pfnXferEnqueueDiscard, pcszId);
1785}
1786
1787
1788
1789/** @interface_method_impl{PDMDRVHLPR3,pfnVMGetSuspendReason} */
1790static DECLCALLBACK(VMSUSPENDREASON) pdmR3DrvHlp_VMGetSuspendReason(PPDMDRVINS pDrvIns)
1791{
1792 PDMDRV_ASSERT_DRVINS(pDrvIns);
1793 PVM pVM = pDrvIns->Internal.s.pVMR3;
1794 VM_ASSERT_EMT(pVM);
1795 VMSUSPENDREASON enmReason = VMR3GetSuspendReason(pVM->pUVM);
1796 LogFlow(("pdmR3DrvHlp_VMGetSuspendReason: caller='%s'/%d: returns %d\n",
1797 pDrvIns->pReg->szName, pDrvIns->iInstance, enmReason));
1798 return enmReason;
1799}
1800
1801
1802/** @interface_method_impl{PDMDRVHLPR3,pfnVMGetResumeReason} */
1803static DECLCALLBACK(VMRESUMEREASON) pdmR3DrvHlp_VMGetResumeReason(PPDMDRVINS pDrvIns)
1804{
1805 PDMDRV_ASSERT_DRVINS(pDrvIns);
1806 PVM pVM = pDrvIns->Internal.s.pVMR3;
1807 VM_ASSERT_EMT(pVM);
1808 VMRESUMEREASON enmReason = VMR3GetResumeReason(pVM->pUVM);
1809 LogFlow(("pdmR3DrvHlp_VMGetResumeReason: caller='%s'/%d: returns %d\n",
1810 pDrvIns->pReg->szName, pDrvIns->iInstance, enmReason));
1811 return enmReason;
1812}
1813
1814
1815/**
1816 * The driver helper structure.
1817 */
1818const PDMDRVHLPR3 g_pdmR3DrvHlp =
1819{
1820 PDM_DRVHLPR3_VERSION,
1821 pdmR3DrvHlp_Attach,
1822 pdmR3DrvHlp_Detach,
1823 pdmR3DrvHlp_DetachSelf,
1824 pdmR3DrvHlp_MountPrepare,
1825 pdmR3DrvHlp_AssertEMT,
1826 pdmR3DrvHlp_AssertOther,
1827 pdmR3DrvHlp_VMSetError,
1828 pdmR3DrvHlp_VMSetErrorV,
1829 pdmR3DrvHlp_VMSetRuntimeError,
1830 pdmR3DrvHlp_VMSetRuntimeErrorV,
1831 pdmR3DrvHlp_VMState,
1832 pdmR3DrvHlp_VMTeleportedAndNotFullyResumedYet,
1833 pdmR3DrvHlp_GetSupDrvSession,
1834 pdmR3DrvHlp_QueueCreate,
1835 pdmR3DrvHlp_TMGetVirtualFreq,
1836 pdmR3DrvHlp_TMGetVirtualTime,
1837 pdmR3DrvHlp_TMTimerCreate,
1838 pdmR3DrvHlp_SSMRegister,
1839 pdmR3DrvHlp_SSMDeregister,
1840 pdmR3DrvHlp_DBGFInfoRegister,
1841 pdmR3DrvHlp_DBGFInfoRegisterArgv,
1842 pdmR3DrvHlp_DBGFInfoDeregister,
1843 pdmR3DrvHlp_STAMRegister,
1844 pdmR3DrvHlp_STAMRegisterF,
1845 pdmR3DrvHlp_STAMRegisterV,
1846 pdmR3DrvHlp_STAMDeregister,
1847 pdmR3DrvHlp_SUPCallVMMR0Ex,
1848 pdmR3DrvHlp_USBRegisterHub,
1849 pdmR3DrvHlp_SetAsyncNotification,
1850 pdmR3DrvHlp_AsyncNotificationCompleted,
1851 pdmR3DrvHlp_ThreadCreate,
1852 pdmR3DrvHlp_AsyncCompletionTemplateCreate,
1853#ifdef VBOX_WITH_NETSHAPER
1854 pdmR3DrvHlp_NetShaperAttach,
1855 pdmR3DrvHlp_NetShaperDetach,
1856#endif /* VBOX_WITH_NETSHAPER */
1857 pdmR3DrvHlp_LdrGetRCInterfaceSymbols,
1858 pdmR3DrvHlp_LdrGetR0InterfaceSymbols,
1859 pdmR3DrvHlp_CritSectInit,
1860 pdmR3DrvHlp_CallR0,
1861 pdmR3DrvHlp_BlkCacheRetain,
1862 pdmR3DrvHlp_VMGetSuspendReason,
1863 pdmR3DrvHlp_VMGetResumeReason,
1864 NULL,
1865 NULL,
1866 NULL,
1867 NULL,
1868 NULL,
1869 NULL,
1870 NULL,
1871 NULL,
1872 NULL,
1873 NULL,
1874 PDM_DRVHLPR3_VERSION /* u32TheEnd */
1875};
1876
1877/** @} */
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