VirtualBox

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

Last change on this file since 50653 was 48980, checked in by vboxsync, 11 years ago

PDM,USB: Add methods to detach and attach drivers to USB devices during runtime, add fFlags parameter to pfnDriver{Detach|Attach} to indicate whether this is a hotplug event or not, use a preconfigured UUID during device instantiation to make removing the device during runtime possible

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

© 2023 Oracle
ContactPrivacy policyTerms of Use