VirtualBox

source: vbox/trunk/src/VBox/Main/VMMDevInterface.cpp@ 1158

Last change on this file since 1158 was 1080, checked in by vboxsync, 18 years ago
  • Support for save and restore added for shared folders.
  • Object type checking added
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.5 KB
Line 
1/** @file
2 *
3 * VirtualBox Driver Interface to VMM device
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#include "VMMDev.h"
23#include "ConsoleImpl.h"
24#include "DisplayImpl.h"
25#include "GuestImpl.h"
26
27#include "Logging.h"
28
29#include <VBox/pdm.h>
30#include <VBox/VBoxDev.h>
31#include <VBox/VBoxGuest.h>
32#include <VBox/cfgm.h>
33#include <VBox/err.h>
34#include <iprt/asm.h>
35
36#ifdef VBOX_HGCM
37#include "hgcm/HGCM.h"
38#include "hgcm/HGCMObjects.h"
39#endif
40
41//
42// defines
43//
44
45
46//
47// globals
48//
49
50
51/**
52 * VMMDev driver instance data.
53 */
54typedef struct DRVMAINVMMDEV
55{
56 /** Pointer to the VMMDev object. */
57 VMMDev *pVMMDev;
58 /** Pointer to the driver instance structure. */
59 PPDMDRVINS pDrvIns;
60 /** Pointer to the VMMDev port interface of the driver/device above us. */
61 PPDMIVMMDEVPORT pUpPort;
62 /** Our VMM device connector interface. */
63 PDMIVMMDEVCONNECTOR Connector;
64#ifdef VBOX_HGCM
65 /** Pointer to the HGCM port interface of the driver/device above us. */
66 PPDMIHGCMPORT pHGCMPort;
67 /** Our HGCM connector interface. */
68 PDMIHGCMCONNECTOR HGCMConnector;
69#endif
70} DRVMAINVMMDEV, *PDRVMAINVMMDEV;
71
72/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
73#define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
74
75#ifdef VBOX_HGCM
76/** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
77#define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
78#endif
79
80//
81// constructor / destructor
82//
83VMMDev::VMMDev(Console *console) : mpDrv(NULL)
84{
85 mParent = console;
86 int rc = RTSemEventCreate(&mCredentialsEvent);
87 AssertRC(rc);
88#ifdef VBOX_HGCM
89 rc = hgcmInit ();
90 AssertRC(rc);
91#endif /* VBOX_HGCM */
92 mu32CredentialsFlags = 0;
93}
94
95VMMDev::~VMMDev()
96{
97 RTSemEventDestroy (mCredentialsEvent);
98 if (mpDrv)
99 mpDrv->pVMMDev = NULL;
100 mpDrv = NULL;
101}
102
103PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
104{
105 Assert(mpDrv);
106 return mpDrv->pUpPort;
107}
108
109
110
111//
112// public methods
113//
114
115/**
116 * Wait on event semaphore for guest credential judgement result.
117 */
118int VMMDev::WaitCredentialsJudgement (uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
119{
120 if (u32Timeout == 0)
121 {
122 u32Timeout = 5000;
123 }
124
125 int rc = RTSemEventWait (mCredentialsEvent, u32Timeout);
126
127 if (VBOX_SUCCESS (rc))
128 {
129 *pu32CredentialsFlags = mu32CredentialsFlags;
130 }
131
132 return rc;
133}
134
135int VMMDev::SetCredentialsJudgementResult (uint32_t u32Flags)
136{
137 mu32CredentialsFlags = u32Flags;
138
139 int rc = RTSemEventSignal (mCredentialsEvent);
140 AssertRC(rc);
141
142 return rc;
143}
144
145
146/**
147 * Report guest OS version.
148 * Called whenever the Additions issue a guest version report request.
149 *
150 * @param pInterface Pointer to this interface.
151 * @param guestInfo Pointer to guest information structure
152 * @thread The emulation thread.
153 */
154DECLCALLBACK(void) vmmdevUpdateGuestVersion(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestInfo *guestInfo)
155{
156 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
157
158 Assert(guestInfo);
159 if (!guestInfo)
160 return;
161
162 /* store that information in IGuest */
163 Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
164 Assert(guest);
165 if (!guest)
166 return;
167
168 char version[20];
169 sprintf(version, "%d", guestInfo->additionsVersion);
170 guest->setAdditionsVersion(Bstr(version));
171
172 /*
173 * Tell the console interface about the event
174 * so that it can notify its consumers.
175 */
176 pDrv->pVMMDev->getParent()->onAdditionsStateChange();
177
178 if (guestInfo->additionsVersion < VMMDEV_VERSION)
179 {
180 pDrv->pVMMDev->getParent()->onAdditionsOutdated();
181 }
182}
183
184/**
185 * Update the mouse capabilities.
186 * This is called when the mouse capabilities change. The new capabilities
187 * are given and the connector should update its internal state.
188 *
189 * @param pInterface Pointer to this interface.
190 * @param newCapabilities New capabilities.
191 * @thread The emulation thread.
192 */
193DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
194{
195 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
196 /*
197 * Tell the console interface about the event
198 * so that it can notify its consumers.
199 */
200 pDrv->pVMMDev->getParent()->onMouseCapabilityChange(BOOL (newCapabilities & VMMDEV_MOUSEGUESTWANTSABS),
201 BOOL (newCapabilities & VMMDEV_MOUSEGUESTNEEDSHOSTCUR));
202}
203
204
205/**
206 * Update the pointer shape or visibility.
207 *
208 * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
209 * The new shape is passed as a caller allocated buffer that will be freed after returning.
210 *
211 * @param pInterface Pointer to this interface.
212 * @param fVisible Whether the pointer is visible or not.
213 * @param fAlpha Alpha channel information is present.
214 * @param xHot Horizontal coordinate of the pointer hot spot.
215 * @param yHot Vertical coordinate of the pointer hot spot.
216 * @param width Pointer width in pixels.
217 * @param height Pointer height in pixels.
218 * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
219 * @thread The emulation thread.
220 */
221DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
222 uint32_t xHot, uint32_t yHot,
223 uint32_t width, uint32_t height,
224 void *pShape)
225{
226 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
227
228 /* tell the console about it */
229 pDrv->pVMMDev->getParent()->onMousePointerShapeChange(fVisible, fAlpha,
230 xHot, yHot, width, height, pShape);
231}
232
233DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
234{
235 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
236
237 Display *display = pDrv->pVMMDev->getParent()->getDisplay();
238
239 if (display)
240 {
241 LogFlow(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
242 return display->VideoAccelEnable (fEnable, pVbvaMemory);
243 }
244
245 return VERR_NOT_SUPPORTED;
246}
247DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
248{
249 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
250
251 Display *display = pDrv->pVMMDev->getParent()->getDisplay();
252
253 if (display)
254 {
255 LogFlow(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
256 display->VideoAccelFlush ();
257 }
258}
259
260DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t width, uint32_t height,
261 uint32_t bpp, bool *fSupported)
262{
263 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
264
265 if (!fSupported)
266 return VERR_INVALID_PARAMETER;
267 IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
268 Assert(framebuffer);
269 framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
270 return VINF_SUCCESS;
271}
272
273DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
274{
275 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
276
277 if (!heightReduction)
278 return VERR_INVALID_PARAMETER;
279 IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
280 Assert(framebuffer);
281 framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
282 return VINF_SUCCESS;
283}
284
285DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
286{
287 PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
288
289 int rc = pDrv->pVMMDev->SetCredentialsJudgementResult (u32Flags);
290
291 return rc;
292}
293
294#ifdef VBOX_HGCM
295
296/* HGCM connector interface */
297
298static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
299{
300 PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
301
302 return hgcmConnectInternal (pDrv->pHGCMPort, pCmd, pServiceLocation, pu32ClientID, false);
303}
304
305static DECLCALLBACK(int) iface_hgcmDisconnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
306{
307 PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
308
309 return hgcmDisconnectInternal (pDrv->pHGCMPort, pCmd, u32ClientID, false);
310}
311
312static DECLCALLBACK(int) iface_hgcmCall (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
313 uint32_t cParms, PVBOXHGCMSVCPARM paParms)
314{
315 PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
316
317 return hgcmGuestCallInternal (pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms, false);
318}
319
320/**
321 * Execute state save operation.
322 *
323 * @returns VBox status code.
324 * @param pDrvIns Driver instance of the driver which registered the data unit.
325 * @param pSSM SSM operation handle.
326 */
327static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
328{
329 PDRVMAINVMMDEV pDrv = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
330
331 /* Save the current handle count and restore afterwards to avoid client id conflicts. */
332 int rc = SSMR3PutU32(pSSM, hgcmObjQueryHandleCount());
333 AssertRCReturn(rc, rc);
334
335 return hgcmSaveStateInternal (pDrv->pVMMDev->mSharedFolderClientId, pSSM);
336}
337
338
339/**
340 * Execute state load operation.
341 *
342 * @returns VBox status code.
343 * @param pDrvIns Driver instance of the driver which registered the data unit.
344 * @param pSSM SSM operation handle.
345 * @param u32Version Data layout version.
346 */
347static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t u32Version)
348{
349 PDRVMAINVMMDEV pDrv = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
350 uint32_t u32HandleCount;
351
352 if (u32Version != HGCM_SSM_VERSION)
353 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
354
355 /* Save the current handle count and restore afterwards to avoid client id conflicts. */
356 int rc = SSMR3GetU32(pSSM, &u32HandleCount);
357 AssertRCReturn(rc, rc);
358 hgcmObjSetHandleCount(u32HandleCount);
359
360 /* Unload all HGCM services to refresh client ids. */
361 /** @todo shared clipboard too! */
362 /** @todo need other solution! */
363 if (pDrv->pVMMDev->mSharedFolderClientId)
364 {
365 uint64_t dummy = 0;
366 PVBOXHGCMCMD cmd = (PVBOXHGCMCMD)&dummy;
367
368 pDrv->pVMMDev->hgcmDisconnect(cmd, pDrv->pVMMDev->getShFlClientId());
369
370 /* Reload Shared Folder HGCM service */
371 HGCMSERVICELOCATION loc;
372
373 cmd = (PVBOXHGCMCMD)&dummy;
374
375 Log(("Connect to Shared Folders service\n"));
376 pDrv->pVMMDev->mSharedFolderClientId = 0;
377 loc.type = VMMDevHGCMLoc_LocalHost;
378 strcpy(loc.u.host.achName, "VBoxSharedFolders");
379 int rc = pDrv->pVMMDev->hgcmConnect(cmd, &loc, &pDrv->pVMMDev->mSharedFolderClientId);
380 if (rc != VINF_SUCCESS)
381 {
382 AssertMsgFailed(("hgcmConnect returned %Vrc\n", rc));
383 }
384 }
385
386 return hgcmLoadStateInternal (pDrv->pVMMDev->mSharedFolderClientId, pSSM);
387}
388
389int VMMDev::hgcmLoadService (const char *pszServiceName, const char *pszServiceLibrary)
390{
391 return hgcmLoadInternal (pszServiceName, pszServiceLibrary);
392}
393
394int VMMDev::hgcmConnect (PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
395{
396 return hgcmConnectInternal (mpDrv->pHGCMPort, pCmd, pServiceLocation, pu32ClientID, true);
397}
398
399int VMMDev::hgcmDisconnect (PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
400{
401 return hgcmDisconnectInternal (mpDrv->pHGCMPort, pCmd, u32ClientID, true);
402}
403
404int VMMDev::hgcmHostCall (const char *pszServiceName, uint32_t u32Function,
405 uint32_t cParms, PVBOXHGCMSVCPARM paParms)
406{
407 return hgcmHostCallInternal (pszServiceName, u32Function, cParms, paParms);
408}
409
410#endif
411
412
413/**
414 * Queries an interface to the driver.
415 *
416 * @returns Pointer to interface.
417 * @returns NULL if the interface was not supported by the driver.
418 * @param pInterface Pointer to this interface structure.
419 * @param enmInterface The requested interface identification.
420 */
421DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
422{
423 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
424 PDRVMAINVMMDEV pDrv = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
425 switch (enmInterface)
426 {
427 case PDMINTERFACE_BASE:
428 return &pDrvIns->IBase;
429 case PDMINTERFACE_VMMDEV_CONNECTOR:
430 return &pDrv->Connector;
431#ifdef VBOX_HGCM
432 case PDMINTERFACE_HGCM_CONNECTOR:
433 return &pDrv->HGCMConnector;
434#endif
435 default:
436 return NULL;
437 }
438}
439
440
441/**
442 * Destruct a VMMDev driver instance.
443 *
444 * @returns VBox status.
445 * @param pDrvIns The driver instance data.
446 */
447DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
448{
449 PDRVMAINVMMDEV pData = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
450 LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
451#ifdef VBOX_HGCM
452 /* Unload Shared Folder HGCM service */
453 if (pData->pVMMDev->mSharedFolderClientId)
454 {
455 uint64_t dummy = 0;
456 PVBOXHGCMCMD cmd = (PVBOXHGCMCMD)&dummy;
457
458 pData->pVMMDev->hgcmDisconnect(cmd, pData->pVMMDev->getShFlClientId());
459 }
460
461 /// @todo hgcmShutdown
462#endif
463 if (pData->pVMMDev)
464 {
465 pData->pVMMDev->mpDrv = NULL;
466 }
467}
468
469/**
470 * Reset notification.
471 *
472 * @returns VBox status.
473 * @param pDrvIns The driver instance data.
474 */
475DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
476{
477 PDRVMAINVMMDEV pData = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
478 LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
479#ifdef VBOX_HGCM
480 /* Unload Shared Folder HGCM service */
481 if (pData->pVMMDev->mSharedFolderClientId)
482 {
483 uint64_t dummy = 0;
484 PVBOXHGCMCMD cmd = (PVBOXHGCMCMD)&dummy;
485
486 pData->pVMMDev->hgcmDisconnect(cmd, pData->pVMMDev->getShFlClientId());
487
488 /* Reload Shared Folder HGCM service */
489 HGCMSERVICELOCATION loc;
490
491 cmd = (PVBOXHGCMCMD)&dummy;
492
493 Log(("Connect to Shared Folders service\n"));
494 pData->pVMMDev->mSharedFolderClientId = 0;
495 loc.type = VMMDevHGCMLoc_LocalHost;
496 strcpy(loc.u.host.achName, "VBoxSharedFolders");
497 int rc = pData->pVMMDev->hgcmConnect(cmd, &loc, &pData->pVMMDev->mSharedFolderClientId);
498 if (rc != VINF_SUCCESS)
499 {
500 AssertMsgFailed(("hgcmConnect returned %Vrc\n", rc));
501 }
502 }
503#endif
504}
505
506/**
507 * Construct a VMMDev driver instance.
508 *
509 * @returns VBox status.
510 * @param pDrvIns The driver instance data.
511 * If the registration structure is needed, pDrvIns->pDrvReg points to it.
512 * @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
513 * of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
514 * iInstance it's expected to be used a bit in this function.
515 */
516DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
517{
518 PDRVMAINVMMDEV pData = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
519 LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
520
521 /*
522 * Validate configuration.
523 */
524 if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
525 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
526 PPDMIBASE pBaseIgnore;
527 int rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBaseIgnore);
528 if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
529 {
530 AssertMsgFailed(("Configuration error: Not possible to attach anything to this driver!\n"));
531 return VERR_PDM_DRVINS_NO_ATTACH;
532 }
533
534 /*
535 * IBase.
536 */
537 pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
538
539 pData->Connector.pfnUpdateGuestVersion = vmmdevUpdateGuestVersion;
540 pData->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
541 pData->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
542 pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
543 pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
544 pData->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
545 pData->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
546 pData->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
547
548#ifdef VBOX_HGCM
549 pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
550 pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
551 pData->HGCMConnector.pfnCall = iface_hgcmCall;
552#endif
553
554 /*
555 * Get the IVMMDevPort interface of the above driver/device.
556 */
557 pData->pUpPort = (PPDMIVMMDEVPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_VMMDEV_PORT);
558 if (!pData->pUpPort)
559 {
560 AssertMsgFailed(("Configuration error: No VMMDev port interface above!\n"));
561 return VERR_PDM_MISSING_INTERFACE_ABOVE;
562 }
563
564#ifdef VBOX_HGCM
565 pData->pHGCMPort = (PPDMIHGCMPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HGCM_PORT);
566 if (!pData->pHGCMPort)
567 {
568 AssertMsgFailed(("Configuration error: No HGCM port interface above!\n"));
569 return VERR_PDM_MISSING_INTERFACE_ABOVE;
570 }
571#endif
572
573 /*
574 * Get the Console object pointer and update the mpDrv member.
575 */
576 void *pv;
577 rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
578 if (VBOX_FAILURE(rc))
579 {
580 AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Vrc\n", rc));
581 return rc;
582 }
583
584 pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
585 pData->pVMMDev->mpDrv = pData;
586
587#ifdef VBOX_HGCM
588
589 /* Load Shared Folder HGCM service */
590 HGCMSERVICELOCATION loc;
591 uint64_t dummy = 0;
592 PVBOXHGCMCMD pCmd = (PVBOXHGCMCMD)&dummy;
593
594 Log(("Connect to Shared Folders service\n"));
595 pData->pVMMDev->mSharedFolderClientId = 0;
596
597 rc = pData->pVMMDev->hgcmLoadService ("VBoxSharedFolders", "VBoxSharedFolders");
598
599 if (rc == VINF_SUCCESS)
600 {
601 loc.type = VMMDevHGCMLoc_LocalHost;
602 strcpy(loc.u.host.achName, "VBoxSharedFolders");
603 rc = pData->pVMMDev->hgcmConnect(pCmd, &loc, &pData->pVMMDev->mSharedFolderClientId);
604 }
605
606 if (rc != VINF_SUCCESS)
607 {
608 Log(("hgcmConnect returned %Vrc, shared folders are unavailable!!!\n", rc));
609
610 /* This is not a fatal error; the shared folder dll can e.g. be missing */
611 rc = VINF_SUCCESS;
612 pData->pVMMDev->mSharedFolderClientId = 0;
613 }
614 pDrvIns->pDrvHlp->pfnSSMRegister(pDrvIns, "HGCM", 0, HGCM_SSM_VERSION, 4096/* bad guess */, NULL, iface_hgcmSave, NULL, NULL, iface_hgcmLoad, NULL);
615#endif
616
617 return VINF_SUCCESS;
618}
619
620
621/**
622 * VMMDevice driver registration record.
623 */
624const PDMDRVREG VMMDev::DrvReg =
625{
626 /* u32Version */
627 PDM_DRVREG_VERSION,
628 /* szDriverName */
629 "MainVMMDev",
630 /* pszDescription */
631 "Main VMMDev driver (Main as in the API).",
632 /* fFlags */
633 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
634 /* fClass. */
635 PDM_DRVREG_CLASS_VMMDEV,
636 /* cMaxInstances */
637 ~0,
638 /* cbInstance */
639 sizeof(DRVMAINVMMDEV),
640 /* pfnConstruct */
641 VMMDev::drvConstruct,
642 /* pfnDestruct */
643 VMMDev::drvDestruct,
644 /* pfnIOCtl */
645 NULL,
646 /* pfnPowerOn */
647 NULL,
648 /* pfnReset */
649 VMMDev::drvReset,
650 /* pfnSuspend */
651 NULL,
652 /* pfnResume */
653 NULL,
654 /* pfnDetach */
655 NULL
656};
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