VirtualBox

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

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

Main: IGuest::seamlessSupport => supportsSeamless.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.1 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/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 = 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/**
474 * Destruct a VMMDev driver instance.
475 *
476 * @returns VBox status.
477 * @param pDrvIns The driver instance data.
478 */
479DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
480{
481 PDRVMAINVMMDEV pData = PDMINS2DATA(pDrvIns, PDRVMAINVMMDEV);
482 LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
483#ifdef VBOX_HGCM
484 /* HGCM is shut down on the VMMDev destructor. */
485#endif /* VBOX_HGCM */
486 if (pData->pVMMDev)
487 {
488 pData->pVMMDev->mpDrv = NULL;
489 }
490}
491
492/**
493 * Reset notification.
494 *
495 * @returns VBox status.
496 * @param pDrvIns The driver instance data.
497 */
498DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
499{
500 LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
501#ifdef VBOX_HGCM
502 HGCMHostReset ();
503#endif /* VBOX_HGCM */
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\0OpenGLEnabled\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.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
541 pData->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
542 pData->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
543 pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
544 pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
545 pData->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
546 pData->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
547 pData->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
548 pData->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
549 pData->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
550
551
552#ifdef VBOX_HGCM
553 pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
554 pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
555 pData->HGCMConnector.pfnCall = iface_hgcmCall;
556#endif
557
558 /*
559 * Get the IVMMDevPort interface of the above driver/device.
560 */
561 pData->pUpPort = (PPDMIVMMDEVPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_VMMDEV_PORT);
562 if (!pData->pUpPort)
563 {
564 AssertMsgFailed(("Configuration error: No VMMDev port interface above!\n"));
565 return VERR_PDM_MISSING_INTERFACE_ABOVE;
566 }
567
568#ifdef VBOX_HGCM
569 pData->pHGCMPort = (PPDMIHGCMPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HGCM_PORT);
570 if (!pData->pHGCMPort)
571 {
572 AssertMsgFailed(("Configuration error: No HGCM port interface above!\n"));
573 return VERR_PDM_MISSING_INTERFACE_ABOVE;
574 }
575#endif
576
577 /*
578 * Get the Console object pointer and update the mpDrv member.
579 */
580 void *pv;
581 rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
582 if (VBOX_FAILURE(rc))
583 {
584 AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Vrc\n", rc));
585 return rc;
586 }
587
588 pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
589 pData->pVMMDev->mpDrv = pData;
590
591#ifdef VBOX_HGCM
592 rc = pData->pVMMDev->hgcmLoadService ("VBoxSharedFolders", "VBoxSharedFolders");
593 pData->pVMMDev->fSharedFolderActive = VBOX_SUCCESS(rc);
594 if (VBOX_SUCCESS(rc))
595 {
596 LogRel(("Shared Folders service loaded.\n"));
597 }
598 else
599 {
600 LogRel(("Failed to load Shared Folders service %Vrc\n", rc));
601 }
602
603 bool fEnabled;
604
605 /* Check CFGM option. */
606 rc = CFGMR3QueryBool(pCfgHandle, "OpenGLEnabled", &fEnabled);
607 if ( VBOX_SUCCESS(rc)
608 && fEnabled)
609 {
610 rc = pData->pVMMDev->hgcmLoadService ("VBoxSharedOpenGL", "VBoxSharedOpenGL");
611 if (VBOX_SUCCESS(rc))
612 {
613 LogRel(("Shared OpenGL service loaded.\n"));
614 }
615 else
616 {
617 LogRel(("Failed to load Shared OpenGL service %Vrc\n", rc));
618 }
619 }
620
621 pDrvIns->pDrvHlp->pfnSSMRegister(pDrvIns, "HGCM", 0, HGCM_SSM_VERSION, 4096/* bad guess */, NULL, iface_hgcmSave, NULL, NULL, iface_hgcmLoad, NULL);
622#endif /* VBOX_HGCM */
623
624 return VINF_SUCCESS;
625}
626
627
628/**
629 * VMMDevice driver registration record.
630 */
631const PDMDRVREG VMMDev::DrvReg =
632{
633 /* u32Version */
634 PDM_DRVREG_VERSION,
635 /* szDriverName */
636 "MainVMMDev",
637 /* pszDescription */
638 "Main VMMDev driver (Main as in the API).",
639 /* fFlags */
640 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
641 /* fClass. */
642 PDM_DRVREG_CLASS_VMMDEV,
643 /* cMaxInstances */
644 ~0,
645 /* cbInstance */
646 sizeof(DRVMAINVMMDEV),
647 /* pfnConstruct */
648 VMMDev::drvConstruct,
649 /* pfnDestruct */
650 VMMDev::drvDestruct,
651 /* pfnIOCtl */
652 NULL,
653 /* pfnPowerOn */
654 NULL,
655 /* pfnReset */
656 VMMDev::drvReset,
657 /* pfnSuspend */
658 NULL,
659 /* pfnResume */
660 NULL,
661 /* pfnDetach */
662 NULL
663};
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