VirtualBox

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

Last change on this file since 1995 was 1354, checked in by vboxsync, 18 years ago

Make it possible to move shared libs from /opt/VirtualBox-xxx to /usr/lib as required for Mandriva packages. Make it possible to move runtime modules to /usr/lib/virtualbox.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 36.8 KB
Line 
1/* $Id: PDMDriver.cpp 1354 2007-03-09 09:39:20Z vboxsync $ */
2/** @file
3 * PDM - Pluggable Device and Driver Manager, Driver parts.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_PDM_DRIVER
27#include "PDMInternal.h"
28#include <VBox/pdm.h>
29#include <VBox/mm.h>
30#include <VBox/cfgm.h>
31#include <VBox/vmm.h>
32#include <VBox/sup.h>
33#include <VBox/vm.h>
34#include <VBox/version.h>
35#include <VBox/err.h>
36
37#include <VBox/log.h>
38#include <iprt/assert.h>
39#include <iprt/thread.h>
40#include <iprt/string.h>
41#include <iprt/asm.h>
42#include <iprt/alloc.h>
43#include <iprt/path.h>
44
45
46/*******************************************************************************
47* Structures and Typedefs *
48*******************************************************************************/
49/**
50 * Internal callback structure pointer.
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} PDMDRVREGCBINT, *PPDMDRVREGCBINT;
63typedef const PDMDRVREGCBINT *PCPDMDRVREGCBINT;
64
65
66/*******************************************************************************
67* Internal Functions *
68*******************************************************************************/
69/** @name Driver Helpers
70 * @{
71 */
72static DECLCALLBACK(int) pdmR3DrvHlp_Attach(PPDMDRVINS pDrvIns, PPDMIBASE *ppBaseInterface);
73static DECLCALLBACK(int) pdmR3DrvHlp_Detach(PPDMDRVINS pDrvIns);
74static DECLCALLBACK(int) pdmR3DrvHlp_DetachSelf(PPDMDRVINS pDrvIns);
75static DECLCALLBACK(int) pdmR3DrvHlp_MountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver);
76static DECLCALLBACK(int) pdmR3DrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
77static DECLCALLBACK(int) pdmR3DrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
78static DECLCALLBACK(bool) pdmR3DrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction);
79static DECLCALLBACK(bool) pdmR3DrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction);
80static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue);
81static DECLCALLBACK(int) pdmR3DrvHlp_PDMPollerRegister(PPDMDRVINS pDrvIns, PFNPDMDRVPOLLER pfnPoller);
82static DECLCALLBACK(uint64_t) pdmR3DrvHlp_TMGetVirtualFreq(PPDMDRVINS pDrvIns);
83static DECLCALLBACK(uint64_t) pdmR3DrvHlp_TMGetVirtualTime(PPDMDRVINS pDrvIns);
84static DECLCALLBACK(int) pdmR3DrvHlp_TMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer);
85static DECLCALLBACK(int) pdmR3DrvHlp_SSMRegister(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
86 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
87 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone);
88static DECLCALLBACK(int) pdmR3DrvHlp_SSMDeregister(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance);
89static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc);
90static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...);
91static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterV(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args);
92static DECLCALLBACK(int) pdmR3DrvHlp_SUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg);
93
94/** @def PDMDRV_ASSERT_DRVINS
95 * Asserts the validity of the driver instance.
96 */
97#ifdef VBOX_STRICT
98# define PDMDRV_ASSERT_DRVINS(pDrvIns) do { Assert(pDrvIns); Assert(pDrvIns->u32Version == PDM_DRVINS_VERSION); Assert(pDrvIns->pvInstanceData == (void *)&pDrvIns->achInstanceData[0]); } while (0)
99#else
100# define PDMDRV_ASSERT_DRVINS(pDrvIns) do { } while (0)
101#endif
102/** @} */
103
104static DECLCALLBACK(int) pdmR3DrvRegister(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pDrvReg);
105static int pdmR3DrvLoad(PVM pVM, PPDMDRVREGCBINT pRegCB, const char *pszFilename, const char *pszName);
106
107
108/*******************************************************************************
109* Global Variables *
110*******************************************************************************/
111/**
112 * The driver helper structure.
113 */
114const PDMDRVHLP g_pdmR3DrvHlp =
115{
116 PDM_DRVHLP_VERSION,
117 pdmR3DrvHlp_Attach,
118 pdmR3DrvHlp_Detach,
119 pdmR3DrvHlp_DetachSelf,
120 pdmR3DrvHlp_MountPrepare,
121 pdmR3DrvHlp_AssertEMT,
122 pdmR3DrvHlp_AssertOther,
123 pdmR3DrvHlp_VMSetError,
124 pdmR3DrvHlp_VMSetErrorV,
125 pdmR3DrvHlp_PDMQueueCreate,
126 pdmR3DrvHlp_PDMPollerRegister,
127 pdmR3DrvHlp_TMGetVirtualFreq,
128 pdmR3DrvHlp_TMGetVirtualTime,
129 pdmR3DrvHlp_TMTimerCreate,
130 pdmR3DrvHlp_SSMRegister,
131 pdmR3DrvHlp_SSMDeregister,
132 pdmR3DrvHlp_STAMRegister,
133 pdmR3DrvHlp_STAMRegisterF,
134 pdmR3DrvHlp_STAMRegisterV,
135 pdmR3DrvHlp_SUPCallVMMR0Ex,
136 0 /* the end */
137};
138
139
140/**
141 * Register external drivers
142 *
143 * @returns VBox status code.
144 * @param pVM The VM to operate on.
145 * @param pfnCallback Driver registration callback
146 */
147PDMR3DECL(int) PDMR3RegisterDrivers(PVM pVM, FNPDMVBOXDRIVERSREGISTER pfnCallback)
148{
149 /*
150 * The registration callbacks.
151 */
152 PDMDRVREGCBINT RegCB;
153 RegCB.Core.u32Version = PDM_DRVREG_CB_VERSION;
154 RegCB.Core.pfnRegister = pdmR3DrvRegister;
155 RegCB.pVM = pVM;
156
157 int rc = pfnCallback(&RegCB.Core, VBOX_VERSION);
158 if (VBOX_FAILURE(rc))
159 AssertMsgFailed(("VBoxDriversRegister failed with rc=%Vrc\n"));
160
161 return rc;
162}
163
164/**
165 * This function will initialize the drivers for this VM instance.
166 *
167 * First of all this mean loading the builtin drivers and letting them
168 * register themselves. Beyond that any additional driver modules are
169 * loaded and called for registration.
170 *
171 * @returns VBox status code.
172 * @param pVM VM Handle.
173 */
174int pdmR3DrvInit(PVM pVM)
175{
176 LogFlow(("pdmR3DrvInit:\n"));
177
178 AssertRelease(!(RT_OFFSETOF(PDMDRVINS, achInstanceData) & 15));
179 PPDMDRVINS pDrvInsAssert;
180 AssertRelease(sizeof(pDrvInsAssert->Internal.s) <= sizeof(pDrvInsAssert->Internal.padding));
181
182 /*
183 * The registration callbacks.
184 */
185 PDMDRVREGCBINT RegCB;
186 RegCB.Core.u32Version = PDM_DRVREG_CB_VERSION;
187 RegCB.Core.pfnRegister = pdmR3DrvRegister;
188 RegCB.pVM = pVM;
189
190 /*
191 * Load the builtin module
192 */
193 PCFGMNODE pDriversNode = CFGMR3GetChild(CFGMR3GetRoot(pVM), "PDM/Drivers");
194 bool fLoadBuiltin;
195 int rc = CFGMR3QueryBool(pDriversNode, "LoadBuiltin", &fLoadBuiltin);
196 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
197 fLoadBuiltin = true;
198 else if (VBOX_FAILURE(rc))
199 {
200 AssertMsgFailed(("Configuration error: Querying boolean \"LoadBuiltin\" failed with %Vrc\n", rc));
201 return rc;
202 }
203 if (fLoadBuiltin)
204 {
205 /* make filename */
206 char *pszFilename = pdmR3FileR3("VBoxDD", /*fShared=*/true);
207 if (!pszFilename)
208 return VERR_NO_TMP_MEMORY;
209 rc = pdmR3DrvLoad(pVM, &RegCB, pszFilename, "VBoxDD");
210 RTMemTmpFree(pszFilename);
211 if (VBOX_FAILURE(rc))
212 return rc;
213 }
214
215 /*
216 * Load additional driver modules.
217 */
218 for (PCFGMNODE pCur = CFGMR3GetFirstChild(pDriversNode); pCur; pCur = CFGMR3GetNextChild(pCur))
219 {
220 /*
221 * Get the name and path.
222 */
223 char szName[PDMMOD_NAME_LEN];
224 rc = CFGMR3GetName(pCur, &szName[0], sizeof(szName));
225 if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
226 {
227 AssertMsgFailed(("configuration error: The module name is too long, cchName=%d.\n", CFGMR3GetNameLen(pCur)));
228 return VERR_PDM_MODULE_NAME_TOO_LONG;
229 }
230 else if (VBOX_FAILURE(rc))
231 {
232 AssertMsgFailed(("CFGMR3GetName -> %Vrc.\n", rc));
233 return rc;
234 }
235
236 /* the path is optional, if no path the module name + path is used. */
237 char szFilename[RTPATH_MAX];
238 rc = CFGMR3QueryString(pCur, "Path", &szFilename[0], sizeof(szFilename));
239 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT)
240 strcpy(szFilename, szName);
241 else if (VBOX_FAILURE(rc))
242 {
243 AssertMsgFailed(("configuration error: Failure to query the module path, rc=%Vrc.\n", rc));
244 return rc;
245 }
246
247 /* prepend path? */
248 if (!RTPathHavePath(szFilename))
249 {
250 char *psz = pdmR3FileR3(szFilename);
251 if (!psz)
252 return VERR_NO_TMP_MEMORY;
253 size_t cch = strlen(psz) + 1;
254 if (cch > sizeof(szFilename))
255 {
256 RTMemTmpFree(psz);
257 AssertMsgFailed(("Filename too long! cch=%d '%s'\n", cch, psz));
258 return VERR_FILENAME_TOO_LONG;
259 }
260 memcpy(szFilename, psz, cch);
261 RTMemTmpFree(psz);
262 }
263
264 /*
265 * Load the module and register it's drivers.
266 */
267 rc = pdmR3DrvLoad(pVM, &RegCB, szFilename, szName);
268 if (VBOX_FAILURE(rc))
269 return rc;
270 }
271
272 LogFlow(("pdmR3DrvInit: returns VINF_SUCCESS\n"));
273 return VINF_SUCCESS;
274}
275
276
277/**
278 * Loads one driver module and call the registration entry point.
279 *
280 * @returns VBox status code.
281 * @param pVM VM handle.
282 * @param pRegCB The registration callback stuff.
283 * @param pszFilename Module filename.
284 * @param pszName Module name.
285 */
286static int pdmR3DrvLoad(PVM pVM, PPDMDRVREGCBINT pRegCB, const char *pszFilename, const char *pszName)
287{
288 /*
289 * Load it.
290 */
291 int rc = pdmR3LoadR3(pVM, pszFilename, pszName);
292 if (VBOX_SUCCESS(rc))
293 {
294 /*
295 * Get the registration export and call it.
296 */
297 FNPDMVBOXDRIVERSREGISTER *pfnVBoxDriversRegister;
298 rc = PDMR3GetSymbolR3(pVM, pszName, "VBoxDriversRegister", (void **)&pfnVBoxDriversRegister);
299 if (VBOX_SUCCESS(rc))
300 {
301 Log(("PDM: Calling VBoxDriversRegister (%p) of %s (%s)\n", pfnVBoxDriversRegister, pszName, pszFilename));
302 rc = pfnVBoxDriversRegister(&pRegCB->Core, VBOX_VERSION);
303 if (VBOX_SUCCESS(rc))
304 Log(("PDM: Successfully loaded driver module %s (%s).\n", pszName, pszFilename));
305 else
306 AssertMsgFailed(("VBoxDriversRegister failed with rc=%Vrc\n"));
307 }
308 else
309 {
310 AssertMsgFailed(("Failed to locate 'VBoxDriversRegister' in %s (%s) rc=%Vrc\n", pszName, pszFilename, rc));
311 if (rc == VERR_SYMBOL_NOT_FOUND)
312 rc = VERR_PDM_NO_REGISTRATION_EXPORT;
313 }
314 }
315 else
316 AssertMsgFailed(("Failed to load %s (%s) rc=%Vrc!\n", pszName, pszFilename, rc));
317 return rc;
318}
319
320
321/** @copydoc PDMDRVREGCB::pfnRegister */
322static DECLCALLBACK(int) pdmR3DrvRegister(PCPDMDRVREGCB pCallbacks, PCPDMDRVREG pDrvReg)
323{
324 /*
325 * Validate the registration structure.
326 */
327 Assert(pDrvReg);
328 if (pDrvReg->u32Version != PDM_DRVREG_VERSION)
329 {
330 AssertMsgFailed(("Unknown struct version %#x!\n", pDrvReg->u32Version));
331 return VERR_PDM_UNKNOWN_DRVREG_VERSION;
332 }
333 if ( !pDrvReg->szDriverName[0]
334 || strlen(pDrvReg->szDriverName) >= sizeof(pDrvReg->szDriverName))
335 {
336 AssertMsgFailed(("Invalid name '%s'\n", pDrvReg->szDriverName));
337 return VERR_PDM_INVALID_DRIVER_REGISTRATION;
338 }
339 if ((pDrvReg->fFlags & PDM_DRVREG_FLAGS_HOST_BITS_MASK) != PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT)
340 {
341 AssertMsgFailed(("Invalid host bits flags! fFlags=%#x (Driver %s)\n", pDrvReg->fFlags, pDrvReg->szDriverName));
342 return VERR_PDM_INVALID_DRIVER_HOST_BITS;
343 }
344 if (pDrvReg->cMaxInstances <= 0)
345 {
346 AssertMsgFailed(("Max instances %u! (Driver %s)\n", pDrvReg->cMaxInstances, pDrvReg->szDriverName));
347 return VERR_PDM_INVALID_DRIVER_REGISTRATION;
348 }
349 if (pDrvReg->cbInstance > _1M)
350 {
351 AssertMsgFailed(("Instance size above 1MB, %d bytes! (Driver %s)\n", pDrvReg->cbInstance, pDrvReg->szDriverName));
352 return VERR_PDM_INVALID_DRIVER_REGISTRATION;
353 }
354 if (!pDrvReg->pfnConstruct)
355 {
356 AssertMsgFailed(("No constructore! (Driver %s)\n", pDrvReg->szDriverName));
357 return VERR_PDM_INVALID_DRIVER_REGISTRATION;
358 }
359
360 /*
361 * Check for duplicate and find FIFO entry at the same time.
362 */
363 PCPDMDRVREGCBINT pRegCB = (PCPDMDRVREGCBINT)pCallbacks;
364 PPDMDRV pDrvPrev = NULL;
365 PPDMDRV pDrv = pRegCB->pVM->pdm.s.pDrvs;
366 for (; pDrv; pDrvPrev = pDrv, pDrv = pDrv->pNext)
367 {
368 if (!strcmp(pDrv->pDrvReg->szDriverName, pDrvReg->szDriverName))
369 {
370 AssertMsgFailed(("Driver '%s' already exists\n", pDrvReg->szDriverName));
371 return VERR_PDM_DRIVER_NAME_CLASH;
372 }
373 }
374
375 /*
376 * Allocate new driver structure and insert it into the list.
377 */
378 pDrv = (PPDMDRV)MMR3HeapAlloc(pRegCB->pVM, MM_TAG_PDM_DRIVER, sizeof(*pDrv));
379 if (pDrv)
380 {
381 pDrv->pNext = NULL;
382 pDrv->cInstances = 0;
383 pDrv->pDrvReg = pDrvReg;
384
385 if (pDrvPrev)
386 pDrvPrev->pNext = pDrv;
387 else
388 pRegCB->pVM->pdm.s.pDrvs = pDrv;
389 Log(("PDM: Registered driver '%s'\n", pDrvReg->szDriverName));
390 return VINF_SUCCESS;
391 }
392 return VERR_NO_MEMORY;
393}
394
395
396/**
397 * Lookups a driver structure by name.
398 * @internal
399 */
400PPDMDRV pdmR3DrvLookup(PVM pVM, const char *pszName)
401{
402 for (PPDMDRV pDrv = pVM->pdm.s.pDrvs; pDrv; pDrv = pDrv->pNext)
403 if (!strcmp(pDrv->pDrvReg->szDriverName, pszName))
404 return pDrv;
405 return NULL;
406}
407
408
409/**
410 * Detaches a driver from whatever it's attached to.
411 * This will of course lead to the destruction of the driver and all drivers below it in the chain.
412 *
413 * @returns VINF_SUCCESS
414 * @param pDrvIns The driver instance to detach.
415 */
416int pdmR3DrvDetach(PPDMDRVINS pDrvIns)
417{
418 PDMDRV_ASSERT_DRVINS(pDrvIns);
419 LogFlow(("pdmR3DrvDetach: pDrvIns=%p '%s'/%d\n", pDrvIns, pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));
420 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
421
422 /*
423 * Check that we're not doing this recursively, that could have unwanted sideeffects!
424 */
425 if (pDrvIns->Internal.s.fDetaching)
426 {
427 AssertMsgFailed(("Recursive detach! '%s'/%d\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));
428 return VINF_SUCCESS;
429 }
430
431 /*
432 * Check that we actually can detach this instance.
433 * The requirement is that the driver/device above have a detach method.
434 */
435 if (pDrvIns->Internal.s.pUp
436 ? !pDrvIns->Internal.s.pUp->pDrvReg->pfnDetach
437 : !pDrvIns->Internal.s.pLun->pDevIns->pDevReg->pfnDetach)
438 {
439 AssertMsgFailed(("Cannot detach driver instance because the driver/device above doesn't support it!\n"));
440 return VERR_PDM_DRIVER_DETACH_NOT_POSSIBLE;
441 }
442
443 /*
444 * Detach the bottom most driver until we've detached pDrvIns.
445 */
446 pDrvIns->Internal.s.fDetaching = true;
447 PPDMDRVINS pCur;
448 do
449 {
450 /* find the driver to detach. */
451 pCur = pDrvIns;
452 while (pCur->Internal.s.pDown)
453 pCur = pCur->Internal.s.pDown;
454 LogFlow(("pdmR3DrvDetach: pCur=%p '%s'/%d\n", pCur, pCur->pDrvReg->szDriverName, pCur->iInstance));
455
456 /*
457 * Unlink it and notify parent.
458 */
459 pCur->Internal.s.fDetaching = true;
460 if (pCur->Internal.s.pUp)
461 {
462 /* driver parent */
463 PPDMDRVINS pParent = pCur->Internal.s.pUp;
464 pCur->Internal.s.pUp = NULL;
465 pParent->Internal.s.pDown = NULL;
466
467 if (pParent->pDrvReg->pfnDetach)
468 pParent->pDrvReg->pfnDetach(pParent);
469
470 pParent->pDownBase = NULL;
471 }
472 else
473 {
474 /* device parent */
475 PPDMLUN pLun = pCur->Internal.s.pLun;
476 pLun->pTop = NULL;
477 if (pLun->pDevIns->pDevReg->pfnDetach)
478 pLun->pDevIns->pDevReg->pfnDetach(pLun->pDevIns, pLun->iLun);
479 }
480
481 /*
482 * Call destructor.
483 */
484 pCur->pUpBase = NULL;
485 if (pCur->pDrvReg->pfnDestruct)
486 pCur->pDrvReg->pfnDestruct(pCur);
487
488 /*
489 * Free all resources allocated by the driver.
490 */
491 /* Queues. */
492 int rc = PDMR3QueueDestroyDriver(pCur->Internal.s.pVM, pCur);
493 AssertRC(rc);
494 /* Timers. */
495 rc = TMR3TimerDestroyDriver(pCur->Internal.s.pVM, pCur);
496 AssertRC(rc);
497 /* SSM data units */
498 rc = SSMR3DeregisterDriver(pCur->Internal.s.pVM, pCur, NULL, 0);
499 AssertRC(rc);
500 /* Finally, the driver it self. */
501 ASMMemFill32(pCur, RT_OFFSETOF(PDMDRVINS, achInstanceData[pCur->pDrvReg->cbInstance]), 0xdeadd0d0);
502 MMR3HeapFree(pCur);
503
504 } while (pCur != pDrvIns);
505
506 return VINF_SUCCESS;
507}
508
509
510/** @copydoc PDMDRVHLP::pfnAttach */
511static DECLCALLBACK(int) pdmR3DrvHlp_Attach(PPDMDRVINS pDrvIns, PPDMIBASE *ppBaseInterface)
512{
513 PDMDRV_ASSERT_DRVINS(pDrvIns);
514 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
515 LogFlow(("pdmR3DrvHlp_Attach: caller='%s'/%d:\n",
516 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));
517
518 /*
519 * Check that there isn't anything attached already.
520 */
521 int rc;
522 if (!pDrvIns->Internal.s.pDown)
523 {
524 /*
525 * Get the attached driver configuration.
526 */
527 PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver");
528 if (pNode)
529 {
530 char *pszName;
531 rc = CFGMR3QueryStringAlloc(pNode, "Driver", &pszName);
532 if (VBOX_SUCCESS(rc))
533 {
534 /*
535 * Find the driver and allocate instance data.
536 */
537 PVM pVM = pDrvIns->Internal.s.pVM;
538 PPDMDRV pDrv = pdmR3DrvLookup(pVM, pszName);
539 if (pDrv)
540 {
541 /* config node */
542 PCFGMNODE pConfigNode = CFGMR3GetChild(pNode, "Config");
543 if (!pConfigNode)
544 rc = CFGMR3InsertNode(pNode, "Config", &pConfigNode);
545 if (VBOX_SUCCESS(rc))
546 {
547 CFGMR3SetRestrictedRoot(pConfigNode);
548
549 size_t cb = RT_OFFSETOF(PDMDRVINS, achInstanceData[pDrv->pDrvReg->cbInstance]);
550 cb = RT_ALIGN_Z(cb, 16);
551 PPDMDRVINS pNew = (PPDMDRVINS)MMR3HeapAllocZ(pVM, MM_TAG_PDM_DRIVER, cb);
552 if (pNew)
553 {
554 /*
555 * Initialize the instance structure (declaration order).
556 */
557 pNew->u32Version = PDM_DRVINS_VERSION;
558 pNew->Internal.s.pUp = pDrvIns;
559 pNew->Internal.s.pDown = NULL;
560 pNew->Internal.s.pLun = pDrvIns->Internal.s.pLun;
561 pNew->Internal.s.pDrv = pDrv;
562 pNew->Internal.s.pVM = pVM;
563 pNew->Internal.s.fDetaching = false;
564 pNew->Internal.s.pCfgHandle = pNode;
565 pNew->pDrvHlp = &g_pdmR3DrvHlp;
566 pNew->pDrvReg = pDrv->pDrvReg;
567 pNew->pCfgHandle = pConfigNode;
568 pNew->iInstance = pDrv->cInstances++;
569 pNew->pUpBase = &pDrvIns->IBase; /* This ain't safe, you can calc the pDrvIns of the up/down driver! */
570 pNew->pDownBase = NULL;
571 pNew->IBase.pfnQueryInterface = NULL;
572 pNew->pvInstanceData = &pNew->achInstanceData[0];
573
574 /*
575 * Hook it onto the chain and call the constructor.
576 */
577 pDrvIns->Internal.s.pDown = pNew;
578 Log(("PDM: Constructing driver '%s' instance %d...\n", pNew->pDrvReg->szDriverName, pNew->iInstance));
579 rc = pDrv->pDrvReg->pfnConstruct(pNew, pNew->pCfgHandle);
580 if (VBOX_SUCCESS(rc))
581 {
582 *ppBaseInterface = &pNew->IBase;
583 rc = VINF_SUCCESS;
584 }
585 else
586 {
587 /*
588 * Unlink and free the data.
589 */
590 pDrvIns->Internal.s.pDown = NULL;
591 ASMMemFill32(pNew, cb, 0xdeadd0d0);
592 MMR3HeapFree(pNew);
593 pDrv->cInstances--;
594 }
595 }
596 else
597 {
598 AssertMsgFailed(("Failed to allocate %d bytes for instantiating driver '%s'\n", cb, pszName));
599 rc = VERR_NO_MEMORY;
600 }
601 }
602 else
603 AssertMsgFailed(("Failed to create Config node! rc=%Vrc\n", rc));
604 }
605 else
606 {
607 AssertMsgFailed(("Driver '%s' wasn't found!\n", pszName));
608 rc = VERR_PDM_DRIVER_NOT_FOUND;
609 }
610 MMR3HeapFree(pszName);
611 }
612 else
613 {
614 AssertMsgFailed(("Query for string value of \"Driver\" -> %Vrc\n", rc));
615 if (rc == VERR_CFGM_VALUE_NOT_FOUND)
616 rc = VERR_PDM_CFG_MISSING_DRIVER_NAME;
617 }
618 }
619 else
620 rc = VERR_PDM_NO_ATTACHED_DRIVER;
621 }
622 else
623 {
624 AssertMsgFailed(("Already got a driver attached. The driver should keep track of such things!\n"));
625 rc = VERR_PDM_DRIVER_ALREADY_ATTACHED;
626 }
627
628 LogFlow(("pdmR3DrvHlp_Attach: caller='%s'/%d: return %Vrc\n",
629 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
630 return rc;
631}
632
633
634/** @copydoc PDMDRVHLP::pfnDetach */
635static DECLCALLBACK(int) pdmR3DrvHlp_Detach(PPDMDRVINS pDrvIns)
636{
637 PDMDRV_ASSERT_DRVINS(pDrvIns);
638 LogFlow(("pdmR3DrvHlp_Detach: caller='%s'/%d:\n",
639 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));
640 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
641
642 /*
643 * Anything attached?
644 */
645 int rc;
646 if (pDrvIns->Internal.s.pDown)
647 {
648 rc = pdmR3DrvDetach(pDrvIns->Internal.s.pDown);
649 }
650 else
651 {
652 AssertMsgFailed(("Nothing attached!\n"));
653 rc = VERR_PDM_NO_DRIVER_ATTACHED;
654 }
655
656 LogFlow(("pdmR3DrvHlp_Detach: caller='%s'/%d: returns %Vrc\n",
657 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
658 return rc;
659}
660
661
662/** @copydoc PDMDRVHLP::pfnDetachSelf */
663static DECLCALLBACK(int) pdmR3DrvHlp_DetachSelf(PPDMDRVINS pDrvIns)
664{
665 PDMDRV_ASSERT_DRVINS(pDrvIns);
666 LogFlow(("pdmR3DrvHlp_DetachSelf: caller='%s'/%d:\n",
667 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance));
668 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
669
670 int rc = pdmR3DrvDetach(pDrvIns);
671
672 LogFlow(("pdmR3DrvHlp_Detach: returns %Vrc\n", rc)); /* pDrvIns is freed by now. */
673 return rc;
674}
675
676
677/** @copydoc PDMDRVHLP::pfnMountPrepare */
678static DECLCALLBACK(int) pdmR3DrvHlp_MountPrepare(PPDMDRVINS pDrvIns, const char *pszFilename, const char *pszCoreDriver)
679{
680 PDMDRV_ASSERT_DRVINS(pDrvIns);
681 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n",
682 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszFilename, pszFilename, pszCoreDriver, pszCoreDriver));
683 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
684
685 /*
686 * Do the caller have anything attached below itself?
687 */
688 if (pDrvIns->Internal.s.pDown)
689 {
690 AssertMsgFailed(("Cannot prepare a mount when something's attached to you!\n"));
691 return VERR_PDM_DRIVER_ALREADY_ATTACHED;
692 }
693
694 /*
695 * We're asked to prepare, so we'll start off by nuking the
696 * attached configuration tree.
697 */
698 PCFGMNODE pNode = CFGMR3GetChild(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver");
699 if (pNode)
700 CFGMR3RemoveNode(pNode);
701
702 /*
703 * If there is no core driver, we'll have to probe for it.
704 */
705 if (!pszCoreDriver)
706 {
707 /** @todo implement image probing. */
708 AssertReleaseMsgFailed(("Not implemented!\n"));
709 return VERR_NOT_IMPLEMENTED;
710 }
711
712 /*
713 * Construct the basic attached driver configuration.
714 */
715 int rc = CFGMR3InsertNode(pDrvIns->Internal.s.pCfgHandle, "AttachedDriver", &pNode);
716 if (VBOX_SUCCESS(rc))
717 {
718 rc = CFGMR3InsertString(pNode, "Driver", pszCoreDriver);
719 if (VBOX_SUCCESS(rc))
720 {
721 PCFGMNODE pCfg;
722 rc = CFGMR3InsertNode(pNode, "Config", &pCfg);
723 if (VBOX_SUCCESS(rc))
724 {
725 rc = CFGMR3InsertString(pCfg, "Path", pszFilename);
726 if (VBOX_SUCCESS(rc))
727 {
728 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: returns %Vrc (Driver=%s)\n",
729 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, pszCoreDriver));
730 return rc;
731 }
732 else
733 AssertMsgFailed(("Path string insert failed, rc=%Vrc\n", rc));
734 }
735 else
736 AssertMsgFailed(("Config node failed, rc=%Vrc\n", rc));
737 }
738 else
739 AssertMsgFailed(("Driver string insert failed, rc=%Vrc\n", rc));
740 CFGMR3RemoveNode(pNode);
741 }
742 else
743 AssertMsgFailed(("AttachedDriver node insert failed, rc=%Vrc\n", rc));
744
745 LogFlow(("pdmR3DrvHlp_MountPrepare: caller='%s'/%d: returns %Vrc\n",
746 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
747 return rc;
748}
749
750
751/** @copydoc PDMDRVHLP::pfnAssertEMT */
752static DECLCALLBACK(bool) pdmR3DrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
753{
754 PDMDRV_ASSERT_DRVINS(pDrvIns);
755 if (VM_IS_EMT(pDrvIns->Internal.s.pVM))
756 return true;
757
758 char szMsg[100];
759 RTStrPrintf(szMsg, sizeof(szMsg), "AssertEMT '%s'/%d\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance);
760 AssertMsg1(szMsg, iLine, pszFile, pszFunction);
761 AssertBreakpoint();
762 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
763 return false;
764}
765
766
767/** @copydoc PDMDRVHLP::pfnAssertOther */
768static DECLCALLBACK(bool) pdmR3DrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
769{
770 PDMDRV_ASSERT_DRVINS(pDrvIns);
771 if (!VM_IS_EMT(pDrvIns->Internal.s.pVM))
772 return true;
773
774 char szMsg[100];
775 RTStrPrintf(szMsg, sizeof(szMsg), "AssertOther '%s'/%d\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance);
776 AssertMsg1(szMsg, iLine, pszFile, pszFunction);
777 AssertBreakpoint();
778 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
779 return false;
780}
781
782
783/** @copydoc PDMDRVHLP::pfnVMSetError */
784static DECLCALLBACK(int) pdmR3DrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
785{
786 PDMDRV_ASSERT_DRVINS(pDrvIns);
787 va_list args;
788 va_start(args, pszFormat);
789 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVM, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
790 va_end(args);
791 return rc;
792}
793
794
795/** @copydoc PDMDRVHLP::pfnVMSetErrorV */
796static DECLCALLBACK(int) pdmR3DrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
797{
798 PDMDRV_ASSERT_DRVINS(pDrvIns);
799 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVM, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
800 return rc;
801}
802
803
804/** @copydoc PDMDRVHLP::pfnPDMQueueCreate */
805static DECLCALLBACK(int) pdmR3DrvHlp_PDMQueueCreate(PPDMDRVINS pDrvIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval, PFNPDMQUEUEDRV pfnCallback, PPDMQUEUE *ppQueue)
806{
807 PDMDRV_ASSERT_DRVINS(pDrvIns);
808 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%d cItems=%d cMilliesInterval=%d pfnCallback=%p ppQueue=%p\n",
809 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue, ppQueue));
810 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
811
812 int rc = PDMR3QueueCreateDriver(pDrvIns->Internal.s.pVM, pDrvIns, cbItem, cItems, cMilliesInterval, pfnCallback, ppQueue);
813
814 LogFlow(("pdmR3DrvHlp_PDMQueueCreate: caller='%s'/%d: returns %Vrc *ppQueue=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, *ppQueue));
815 return rc;
816}
817
818
819
820/** @copydoc PDMDRVHLP::pfnPDMPollerRegister */
821static DECLCALLBACK(int) pdmR3DrvHlp_PDMPollerRegister(PPDMDRVINS pDrvIns, PFNPDMDRVPOLLER pfnPoller)
822{
823 PDMDRV_ASSERT_DRVINS(pDrvIns);
824 LogFlow(("pdmR3DrvHlp_PDMPollerRegister: caller='%s'/%d: pfnPoller=%p\n",
825 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pfnPoller));
826 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
827
828 int rc = VINF_SUCCESS;
829 PVM pVM = pDrvIns->Internal.s.pVM;
830 if (pVM->pdm.s.cPollers < ELEMENTS(pVM->pdm.s.apfnPollers))
831 {
832 pVM->pdm.s.apfnPollers[pVM->pdm.s.cPollers] = pfnPoller;
833 pVM->pdm.s.aDrvInsPollers[pVM->pdm.s.cPollers] = pDrvIns;
834 pVM->pdm.s.cPollers++;
835 if (pVM->pdm.s.cPollers == 1)
836 TMTimerSetMillies(pVM->pdm.s.pTimerPollers, 5);
837 }
838 else
839 {
840 AssertMsgFailed(("Too many pollers!\n"));
841 rc = VERR_INTERNAL_ERROR;
842 }
843
844 LogFlow(("pdmR3DrvHlp_PDMPollerRegister: caller='%s'/%d: returns %Vrc\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
845 return rc;
846}
847
848
849/** @copydoc PDMDRVHLP::pfnTMGetVirtualFreq */
850static DECLCALLBACK(uint64_t) pdmR3DrvHlp_TMGetVirtualFreq(PPDMDRVINS pDrvIns)
851{
852 PDMDRV_ASSERT_DRVINS(pDrvIns);
853
854 return TMVirtualGetFreq(pDrvIns->Internal.s.pVM);
855}
856
857
858/** @copydoc PDMDRVHLP::pfnTMGetVirtualTime */
859static DECLCALLBACK(uint64_t) pdmR3DrvHlp_TMGetVirtualTime(PPDMDRVINS pDrvIns)
860{
861 PDMDRV_ASSERT_DRVINS(pDrvIns);
862
863 return TMVirtualGet(pDrvIns->Internal.s.pVM);
864}
865
866/** @copydoc PDMDRVHLP::pfnTMTimerCreate */
867static DECLCALLBACK(int) pdmR3DrvHlp_TMTimerCreate(PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer)
868{
869 PDMDRV_ASSERT_DRVINS(pDrvIns);
870 LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pszDesc=%p:{%s} ppTimer=%p\n",
871 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, enmClock, pfnCallback, pszDesc, pszDesc, ppTimer));
872
873 int rc = TMR3TimerCreateDriver(pDrvIns->Internal.s.pVM, pDrvIns, enmClock, pfnCallback, pszDesc, ppTimer);
874
875 LogFlow(("pdmR3DrvHlp_TMTimerCreate: caller='%s'/%d: returns %Vrc *ppTimer=%p\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc, *ppTimer));
876 return rc;
877}
878
879
880
881/** @copydoc PDMDRVHLP::pfnSSMRegister */
882static DECLCALLBACK(int) pdmR3DrvHlp_SSMRegister(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance, uint32_t u32Version, size_t cbGuess,
883 PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
884 PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
885{
886 PDMDRV_ASSERT_DRVINS(pDrvIns);
887 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
888 LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x u32Version=#x cbGuess=%#x pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoaddone=%p\n",
889 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszName, pszName, u32Instance, u32Version, cbGuess, pfnSavePrep, pfnSaveExec, pfnSaveDone, pfnLoadPrep, pfnLoadExec, pfnLoadDone));
890
891 int rc = SSMR3RegisterDriver(pDrvIns->Internal.s.pVM, pDrvIns, pszName, u32Instance, u32Version, cbGuess,
892 pfnSavePrep, pfnSaveExec, pfnSaveDone,
893 pfnLoadPrep, pfnLoadExec, pfnLoadDone);
894
895 LogFlow(("pdmR3DrvHlp_SSMRegister: caller='%s'/%d: returns %Vrc\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
896 return rc;
897}
898
899
900/** @copydoc PDMDRVHLP::pfnSSMDeregister */
901static DECLCALLBACK(int) pdmR3DrvHlp_SSMDeregister(PPDMDRVINS pDrvIns, const char *pszName, uint32_t u32Instance)
902{
903 PDMDRV_ASSERT_DRVINS(pDrvIns);
904 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
905 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: pszName=%p:{%s} u32Instance=%#x\n",
906 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, pszName, pszName, u32Instance));
907
908 int rc = SSMR3DeregisterDriver(pDrvIns->Internal.s.pVM, pDrvIns, pszName, u32Instance);
909
910 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: returns %Vrc\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
911 return rc;
912}
913
914
915/** @copydoc PDMDRVHLP::pfnSTAMRegister */
916static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegister(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, const char *pszName, STAMUNIT enmUnit, const char *pszDesc)
917{
918 PDMDRV_ASSERT_DRVINS(pDrvIns);
919 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
920
921 STAM_REG(pDrvIns->Internal.s.pVM, pvSample, enmType, pszName, enmUnit, pszDesc);
922 /** @todo track the samples so they can be dumped & deregistered when the driver instance is destroyed.
923 * For now we just have to be careful not to use this call for drivers which can be unloaded. */
924}
925
926
927/** @copydoc PDMDRVHLP::pfnSTAMRegisterF */
928static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterF(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
929 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, ...)
930{
931 PDMDRV_ASSERT_DRVINS(pDrvIns);
932 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
933
934 va_list args;
935 va_start(args, pszName);
936 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
937 va_end(args);
938 AssertRC(rc);
939}
940
941
942/** @copydoc PDMDRVHLP::pfnSTAMRegisterV */
943static DECLCALLBACK(void) pdmR3DrvHlp_STAMRegisterV(PPDMDRVINS pDrvIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
944 STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args)
945{
946 PDMDRV_ASSERT_DRVINS(pDrvIns);
947 VM_ASSERT_EMT(pDrvIns->Internal.s.pVM);
948
949 int rc = STAMR3RegisterV(pDrvIns->Internal.s.pVM, pvSample, enmType, enmVisibility, enmUnit, pszDesc, pszName, args);
950 AssertRC(rc);
951}
952
953
954/** @copydoc PDMDRVHLP::pfnSUPCallVMMR0Ex */
955static DECLCALLBACK(int) pdmR3DrvHlp_SUPCallVMMR0Ex(PPDMDRVINS pDrvIns, unsigned uOperation, void *pvArg, unsigned cbArg)
956{
957 PDMDRV_ASSERT_DRVINS(pDrvIns);
958 LogFlow(("pdmR3DrvHlp_SSMCallVMMR0Ex: caller='%s'/%d: uOperation=%u pvArg=%p cbArg=%d\n",
959 pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, uOperation, pvArg, cbArg));
960 int rc;
961 if ( uOperation >= VMMR0_DO_SRV_START
962 && uOperation < VMMR0_DO_SRV_END)
963 rc = SUPCallVMMR0Ex(pDrvIns->Internal.s.pVM->pVMR0, uOperation, pvArg, cbArg);
964 else
965 {
966 AssertMsgFailed(("Invalid uOperation=%u\n", uOperation));
967 rc = VERR_INVALID_PARAMETER;
968 }
969
970 LogFlow(("pdmR3DrvHlp_SSMDeregister: caller='%s'/%d: returns %Vrc\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc));
971 return rc;
972}
973
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