VirtualBox

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

Last change on this file since 4032 was 4032, checked in by vboxsync, 17 years ago

Implemented shared folder status light

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