[1] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VirtualBox Driver Interface to VMM device
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[8155] | 7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
[1] | 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
|
---|
[5999] | 12 | * General Public License (GPL) as published by the Free Software
|
---|
| 13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[8155] | 16 | *
|
---|
| 17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
| 18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
| 19 | * additional information or have any questions.
|
---|
[1] | 20 | */
|
---|
| 21 |
|
---|
| 22 | #include "VMMDev.h"
|
---|
| 23 | #include "ConsoleImpl.h"
|
---|
| 24 | #include "DisplayImpl.h"
|
---|
| 25 | #include "GuestImpl.h"
|
---|
| 26 |
|
---|
| 27 | #include "Logging.h"
|
---|
| 28 |
|
---|
[4015] | 29 | #include <VBox/pdmdrv.h>
|
---|
[1] | 30 | #include <VBox/VBoxDev.h>
|
---|
| 31 | #include <VBox/VBoxGuest.h>
|
---|
[4032] | 32 | #include <VBox/shflsvc.h>
|
---|
[1] | 33 | #include <iprt/asm.h>
|
---|
| 34 |
|
---|
[11820] | 35 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 36 | #include "hgcm/HGCM.h"
|
---|
[1080] | 37 | #include "hgcm/HGCMObjects.h"
|
---|
[12449] | 38 | #include <VBox/HostServices/VBoxCrOpenGLSvc.h>
|
---|
[1] | 39 | #endif
|
---|
| 40 |
|
---|
| 41 | //
|
---|
| 42 | // defines
|
---|
| 43 | //
|
---|
| 44 |
|
---|
[6762] | 45 | #ifdef RT_OS_OS2
|
---|
| 46 | # define VBOXSHAREDFOLDERS_DLL "VBoxSFld"
|
---|
| 47 | #else
|
---|
| 48 | # define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
|
---|
| 49 | #endif
|
---|
[1] | 50 |
|
---|
| 51 | //
|
---|
| 52 | // globals
|
---|
| 53 | //
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | /**
|
---|
| 57 | * VMMDev driver instance data.
|
---|
| 58 | */
|
---|
| 59 | typedef struct DRVMAINVMMDEV
|
---|
| 60 | {
|
---|
| 61 | /** Pointer to the VMMDev object. */
|
---|
| 62 | VMMDev *pVMMDev;
|
---|
| 63 | /** Pointer to the driver instance structure. */
|
---|
| 64 | PPDMDRVINS pDrvIns;
|
---|
| 65 | /** Pointer to the VMMDev port interface of the driver/device above us. */
|
---|
| 66 | PPDMIVMMDEVPORT pUpPort;
|
---|
| 67 | /** Our VMM device connector interface. */
|
---|
| 68 | PDMIVMMDEVCONNECTOR Connector;
|
---|
[4021] | 69 |
|
---|
[11820] | 70 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 71 | /** Pointer to the HGCM port interface of the driver/device above us. */
|
---|
| 72 | PPDMIHGCMPORT pHGCMPort;
|
---|
| 73 | /** Our HGCM connector interface. */
|
---|
| 74 | PDMIHGCMCONNECTOR HGCMConnector;
|
---|
| 75 | #endif
|
---|
| 76 | } DRVMAINVMMDEV, *PDRVMAINVMMDEV;
|
---|
| 77 |
|
---|
| 78 | /** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
|
---|
| 79 | #define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
|
---|
| 80 |
|
---|
[11820] | 81 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 82 | /** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
|
---|
| 83 | #define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
|
---|
| 84 | #endif
|
---|
| 85 |
|
---|
| 86 | //
|
---|
| 87 | // constructor / destructor
|
---|
| 88 | //
|
---|
| 89 | VMMDev::VMMDev(Console *console) : mpDrv(NULL)
|
---|
| 90 | {
|
---|
| 91 | mParent = console;
|
---|
| 92 | int rc = RTSemEventCreate(&mCredentialsEvent);
|
---|
| 93 | AssertRC(rc);
|
---|
[11820] | 94 | #ifdef VBOX_WITH_HGCM
|
---|
[1711] | 95 | rc = HGCMHostInit ();
|
---|
[1] | 96 | AssertRC(rc);
|
---|
[11409] | 97 | m_fHGCMActive = true;
|
---|
[11820] | 98 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 99 | mu32CredentialsFlags = 0;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | VMMDev::~VMMDev()
|
---|
| 103 | {
|
---|
| 104 | RTSemEventDestroy (mCredentialsEvent);
|
---|
| 105 | if (mpDrv)
|
---|
| 106 | mpDrv->pVMMDev = NULL;
|
---|
| 107 | mpDrv = NULL;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
|
---|
| 111 | {
|
---|
| 112 | Assert(mpDrv);
|
---|
| 113 | return mpDrv->pUpPort;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | //
|
---|
| 119 | // public methods
|
---|
| 120 | //
|
---|
| 121 |
|
---|
| 122 | /**
|
---|
| 123 | * Wait on event semaphore for guest credential judgement result.
|
---|
| 124 | */
|
---|
| 125 | int VMMDev::WaitCredentialsJudgement (uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
|
---|
| 126 | {
|
---|
| 127 | if (u32Timeout == 0)
|
---|
| 128 | {
|
---|
| 129 | u32Timeout = 5000;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | int rc = RTSemEventWait (mCredentialsEvent, u32Timeout);
|
---|
| 133 |
|
---|
| 134 | if (VBOX_SUCCESS (rc))
|
---|
| 135 | {
|
---|
| 136 | *pu32CredentialsFlags = mu32CredentialsFlags;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | return rc;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | int VMMDev::SetCredentialsJudgementResult (uint32_t u32Flags)
|
---|
| 143 | {
|
---|
| 144 | mu32CredentialsFlags = u32Flags;
|
---|
| 145 |
|
---|
| 146 | int rc = RTSemEventSignal (mCredentialsEvent);
|
---|
| 147 | AssertRC(rc);
|
---|
| 148 |
|
---|
| 149 | return rc;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
| 154 | * Report guest OS version.
|
---|
[8690] | 155 | * Called whenever the Additions issue a guest version report request or the VM is reset.
|
---|
[1] | 156 | *
|
---|
| 157 | * @param pInterface Pointer to this interface.
|
---|
| 158 | * @param guestInfo Pointer to guest information structure
|
---|
| 159 | * @thread The emulation thread.
|
---|
| 160 | */
|
---|
| 161 | DECLCALLBACK(void) vmmdevUpdateGuestVersion(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestInfo *guestInfo)
|
---|
| 162 | {
|
---|
| 163 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 164 |
|
---|
| 165 | Assert(guestInfo);
|
---|
| 166 | if (!guestInfo)
|
---|
| 167 | return;
|
---|
| 168 |
|
---|
| 169 | /* store that information in IGuest */
|
---|
| 170 | Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
| 171 | Assert(guest);
|
---|
| 172 | if (!guest)
|
---|
| 173 | return;
|
---|
| 174 |
|
---|
[8690] | 175 | if (guestInfo->additionsVersion != 0)
|
---|
| 176 | {
|
---|
| 177 | char version[20];
|
---|
| 178 | RTStrPrintf(version, sizeof(version), "%d", guestInfo->additionsVersion);
|
---|
| 179 | guest->setAdditionsVersion(Bstr(version), guestInfo->osType);
|
---|
[1] | 180 |
|
---|
[8690] | 181 | /*
|
---|
| 182 | * Tell the console interface about the event
|
---|
| 183 | * so that it can notify its consumers.
|
---|
| 184 | */
|
---|
| 185 | pDrv->pVMMDev->getParent()->onAdditionsStateChange();
|
---|
| 186 |
|
---|
| 187 | if (guestInfo->additionsVersion < VMMDEV_VERSION)
|
---|
| 188 | pDrv->pVMMDev->getParent()->onAdditionsOutdated();
|
---|
| 189 | }
|
---|
| 190 | else
|
---|
[1] | 191 | {
|
---|
[8690] | 192 | /*
|
---|
| 193 | * The guest additions was disabled because of a reset
|
---|
| 194 | * or driver unload.
|
---|
| 195 | */
|
---|
| 196 | guest->setAdditionsVersion (Bstr(), guestInfo->osType);
|
---|
| 197 | pDrv->pVMMDev->getParent()->onAdditionsStateChange();
|
---|
[1] | 198 | }
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | /**
|
---|
[3582] | 202 | * Update the guest additions capabilities.
|
---|
| 203 | * This is called when the guest additions capabilities change. The new capabilities
|
---|
| 204 | * are given and the connector should update its internal state.
|
---|
| 205 | *
|
---|
| 206 | * @param pInterface Pointer to this interface.
|
---|
| 207 | * @param newCapabilities New capabilities.
|
---|
| 208 | * @thread The emulation thread.
|
---|
| 209 | */
|
---|
| 210 | DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
| 211 | {
|
---|
| 212 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 213 |
|
---|
| 214 | /* store that information in IGuest */
|
---|
| 215 | Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
| 216 | Assert(guest);
|
---|
| 217 | if (!guest)
|
---|
| 218 | return;
|
---|
| 219 |
|
---|
[3911] | 220 | guest->setSupportsSeamless(BOOL (newCapabilities & VMMDEV_GUEST_SUPPORTS_SEAMLESS));
|
---|
[7409] | 221 | guest->setSupportsGraphics(BOOL (newCapabilities & VMMDEV_GUEST_SUPPORTS_GRAPHICS));
|
---|
[3582] | 222 |
|
---|
| 223 | /*
|
---|
| 224 | * Tell the console interface about the event
|
---|
| 225 | * so that it can notify its consumers.
|
---|
| 226 | */
|
---|
| 227 | pDrv->pVMMDev->getParent()->onAdditionsStateChange();
|
---|
[8690] | 228 |
|
---|
[3582] | 229 | }
|
---|
| 230 |
|
---|
| 231 | /**
|
---|
[1] | 232 | * Update the mouse capabilities.
|
---|
| 233 | * This is called when the mouse capabilities change. The new capabilities
|
---|
| 234 | * are given and the connector should update its internal state.
|
---|
| 235 | *
|
---|
| 236 | * @param pInterface Pointer to this interface.
|
---|
| 237 | * @param newCapabilities New capabilities.
|
---|
| 238 | * @thread The emulation thread.
|
---|
| 239 | */
|
---|
| 240 | DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
| 241 | {
|
---|
| 242 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 243 | /*
|
---|
| 244 | * Tell the console interface about the event
|
---|
| 245 | * so that it can notify its consumers.
|
---|
| 246 | */
|
---|
| 247 | pDrv->pVMMDev->getParent()->onMouseCapabilityChange(BOOL (newCapabilities & VMMDEV_MOUSEGUESTWANTSABS),
|
---|
| 248 | BOOL (newCapabilities & VMMDEV_MOUSEGUESTNEEDSHOSTCUR));
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | /**
|
---|
| 253 | * Update the pointer shape or visibility.
|
---|
| 254 | *
|
---|
| 255 | * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
|
---|
| 256 | * The new shape is passed as a caller allocated buffer that will be freed after returning.
|
---|
| 257 | *
|
---|
| 258 | * @param pInterface Pointer to this interface.
|
---|
| 259 | * @param fVisible Whether the pointer is visible or not.
|
---|
| 260 | * @param fAlpha Alpha channel information is present.
|
---|
| 261 | * @param xHot Horizontal coordinate of the pointer hot spot.
|
---|
| 262 | * @param yHot Vertical coordinate of the pointer hot spot.
|
---|
| 263 | * @param width Pointer width in pixels.
|
---|
| 264 | * @param height Pointer height in pixels.
|
---|
| 265 | * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
|
---|
| 266 | * @thread The emulation thread.
|
---|
| 267 | */
|
---|
| 268 | DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
| 269 | uint32_t xHot, uint32_t yHot,
|
---|
| 270 | uint32_t width, uint32_t height,
|
---|
| 271 | void *pShape)
|
---|
| 272 | {
|
---|
| 273 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 274 |
|
---|
| 275 | /* tell the console about it */
|
---|
| 276 | pDrv->pVMMDev->getParent()->onMousePointerShapeChange(fVisible, fAlpha,
|
---|
| 277 | xHot, yHot, width, height, pShape);
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
| 281 | {
|
---|
| 282 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 283 |
|
---|
| 284 | Display *display = pDrv->pVMMDev->getParent()->getDisplay();
|
---|
| 285 |
|
---|
| 286 | if (display)
|
---|
| 287 | {
|
---|
[3808] | 288 | LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
|
---|
[1] | 289 | return display->VideoAccelEnable (fEnable, pVbvaMemory);
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | return VERR_NOT_SUPPORTED;
|
---|
| 293 | }
|
---|
| 294 | DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
|
---|
| 295 | {
|
---|
| 296 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 297 |
|
---|
| 298 | Display *display = pDrv->pVMMDev->getParent()->getDisplay();
|
---|
| 299 |
|
---|
| 300 | if (display)
|
---|
| 301 | {
|
---|
[3808] | 302 | LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
|
---|
[1] | 303 | display->VideoAccelFlush ();
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 |
|
---|
| 307 | DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t width, uint32_t height,
|
---|
| 308 | uint32_t bpp, bool *fSupported)
|
---|
| 309 | {
|
---|
| 310 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 311 |
|
---|
| 312 | if (!fSupported)
|
---|
| 313 | return VERR_INVALID_PARAMETER;
|
---|
| 314 | IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
[3155] | 315 | if (framebuffer)
|
---|
| 316 | framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
|
---|
| 317 | else
|
---|
| 318 | *fSupported = true;
|
---|
[1] | 319 | return VINF_SUCCESS;
|
---|
| 320 | }
|
---|
| 321 |
|
---|
| 322 | DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
|
---|
| 323 | {
|
---|
| 324 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 325 |
|
---|
| 326 | if (!heightReduction)
|
---|
| 327 | return VERR_INVALID_PARAMETER;
|
---|
| 328 | IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
[3155] | 329 | if (framebuffer)
|
---|
| 330 | framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
|
---|
| 331 | else
|
---|
| 332 | *heightReduction = 0;
|
---|
[1] | 333 | return VINF_SUCCESS;
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
|
---|
| 337 | {
|
---|
| 338 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 339 |
|
---|
| 340 | int rc = pDrv->pVMMDev->SetCredentialsJudgementResult (u32Flags);
|
---|
| 341 |
|
---|
| 342 | return rc;
|
---|
| 343 | }
|
---|
| 344 |
|
---|
[3556] | 345 | DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
|
---|
| 346 | {
|
---|
| 347 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 348 |
|
---|
| 349 | if (!cRect)
|
---|
| 350 | return VERR_INVALID_PARAMETER;
|
---|
| 351 | IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
| 352 | if (framebuffer)
|
---|
[3577] | 353 | framebuffer->SetVisibleRegion((BYTE *)pRect, cRect);
|
---|
[3556] | 354 |
|
---|
| 355 | return VINF_SUCCESS;
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
|
---|
| 359 | {
|
---|
| 360 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 361 |
|
---|
| 362 | IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
| 363 | if (framebuffer)
|
---|
| 364 | {
|
---|
| 365 | ULONG cRect = 0;
|
---|
[3577] | 366 | framebuffer->GetVisibleRegion((BYTE *)pRect, cRect, &cRect);
|
---|
[3556] | 367 |
|
---|
| 368 | *pcRect = cRect;
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | return VINF_SUCCESS;
|
---|
| 372 | }
|
---|
| 373 |
|
---|
[4513] | 374 | /**
|
---|
| 375 | * Request the statistics interval
|
---|
| 376 | *
|
---|
| 377 | * @returns VBox status code.
|
---|
| 378 | * @param pInterface Pointer to this interface.
|
---|
| 379 | * @param pulInterval Pointer to interval in seconds
|
---|
| 380 | * @thread The emulation thread.
|
---|
| 381 | */
|
---|
| 382 | DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
|
---|
| 383 | {
|
---|
| 384 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 385 | ULONG val = 0;
|
---|
| 386 |
|
---|
| 387 | if (!pulInterval)
|
---|
| 388 | return VERR_INVALID_POINTER;
|
---|
| 389 |
|
---|
| 390 | /* store that information in IGuest */
|
---|
| 391 | Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
| 392 | Assert(guest);
|
---|
| 393 | if (!guest)
|
---|
| 394 | return VERR_INVALID_PARAMETER; /** @todo wrong error */
|
---|
| 395 |
|
---|
| 396 | guest->COMGETTER(StatisticsUpdateInterval)(&val);
|
---|
| 397 | *pulInterval = val;
|
---|
| 398 | return VINF_SUCCESS;
|
---|
| 399 | }
|
---|
| 400 |
|
---|
| 401 | /**
|
---|
| 402 | * Report new guest statistics
|
---|
| 403 | *
|
---|
| 404 | * @returns VBox status code.
|
---|
| 405 | * @param pInterface Pointer to this interface.
|
---|
| 406 | * @param pGuestStats Guest statistics
|
---|
| 407 | * @thread The emulation thread.
|
---|
| 408 | */
|
---|
| 409 | DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
|
---|
| 410 | {
|
---|
| 411 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 412 |
|
---|
| 413 | Assert(pGuestStats);
|
---|
| 414 | if (!pGuestStats)
|
---|
| 415 | return VERR_INVALID_POINTER;
|
---|
| 416 |
|
---|
| 417 | /* store that information in IGuest */
|
---|
| 418 | Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
| 419 | Assert(guest);
|
---|
| 420 | if (!guest)
|
---|
| 421 | return VERR_INVALID_PARAMETER; /** @todo wrong error */
|
---|
| 422 |
|
---|
[4570] | 423 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
[4571] | 424 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_CPULoad_Idle, pGuestStats->u32CpuLoad_Idle);
|
---|
[4513] | 425 |
|
---|
[4570] | 426 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
[4571] | 427 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_CPULoad_Kernel, pGuestStats->u32CpuLoad_Kernel);
|
---|
[4570] | 428 |
|
---|
| 429 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
[4571] | 430 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_CPULoad_User, pGuestStats->u32CpuLoad_User);
|
---|
[4570] | 431 |
|
---|
[4513] | 432 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_THREADS)
|
---|
[4571] | 433 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_Threads, pGuestStats->u32Threads);
|
---|
[4513] | 434 |
|
---|
| 435 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PROCESSES)
|
---|
[4571] | 436 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_Processes, pGuestStats->u32Processes);
|
---|
[4513] | 437 |
|
---|
[4575] | 438 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_HANDLES)
|
---|
| 439 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_Handles, pGuestStats->u32Handles);
|
---|
| 440 |
|
---|
| 441 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEMORY_LOAD)
|
---|
| 442 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemoryLoad, pGuestStats->u32MemoryLoad);
|
---|
| 443 |
|
---|
| 444 | /* Note that reported values are in pages; upper layers expect them in megabytes */
|
---|
[4576] | 445 | Assert(pGuestStats->u32PageSize == 4096);
|
---|
[4578] | 446 | if (pGuestStats->u32PageSize != 4096)
|
---|
[4576] | 447 | pGuestStats->u32PageSize = 4096;
|
---|
[4575] | 448 |
|
---|
[4513] | 449 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
[4606] | 450 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PhysMemTotal, (pGuestStats->u32PhysMemTotal + (_1M/pGuestStats->u32PageSize)-1) / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 451 |
|
---|
| 452 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
[4577] | 453 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PhysMemAvailable, pGuestStats->u32PhysMemAvail / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 454 |
|
---|
| 455 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
[4577] | 456 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PhysMemBalloon, pGuestStats->u32PhysMemBalloon / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 457 |
|
---|
[4575] | 458 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_COMMIT_TOTAL)
|
---|
[4577] | 459 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemCommitTotal, pGuestStats->u32MemCommitTotal / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 460 |
|
---|
| 461 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_TOTAL)
|
---|
[4577] | 462 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemKernelTotal, pGuestStats->u32MemKernelTotal / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 463 |
|
---|
| 464 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_PAGED)
|
---|
[4577] | 465 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemKernelPaged, pGuestStats->u32MemKernelPaged / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 466 |
|
---|
| 467 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED)
|
---|
[4577] | 468 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemKernelNonpaged, pGuestStats->u32MemKernelNonPaged / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 469 |
|
---|
| 470 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
[4577] | 471 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemSystemCache, pGuestStats->u32MemSystemCache / (_1M/pGuestStats->u32PageSize));
|
---|
[8690] | 472 |
|
---|
[4513] | 473 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
[4577] | 474 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PageFileSize, pGuestStats->u32PageFileSize / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 475 |
|
---|
[4685] | 476 | /* increase sample number */
|
---|
| 477 | ULONG sample;
|
---|
| 478 |
|
---|
| 479 | int rc = guest->GetStatistic(0, GuestStatisticType_SampleNumber, &sample);
|
---|
| 480 | if (SUCCEEDED(rc))
|
---|
| 481 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_SampleNumber, sample+1);
|
---|
| 482 |
|
---|
[4513] | 483 | return VINF_SUCCESS;
|
---|
| 484 | }
|
---|
| 485 |
|
---|
[4532] | 486 | /**
|
---|
| 487 | * Inflate or deflate the memory balloon
|
---|
| 488 | *
|
---|
| 489 | * @returns VBox status code.
|
---|
| 490 | * @param pInterface Pointer to this interface.
|
---|
| 491 | * @param fInflate Inflate or deflate
|
---|
| 492 | * @param cPages Number of physical pages (must be 256 as we allocate in 1 MB chunks)
|
---|
| 493 | * @param aPhysPage Array of physical page addresses
|
---|
| 494 | * @thread The emulation thread.
|
---|
| 495 | */
|
---|
| 496 | DECLCALLBACK(int) vmmdevChangeMemoryBalloon(PPDMIVMMDEVCONNECTOR pInterface, bool fInflate, uint32_t cPages, RTGCPHYS *aPhysPage)
|
---|
| 497 | {
|
---|
[4533] | 498 | if ( cPages != VMMDEV_MEMORY_BALLOON_CHUNK_PAGES
|
---|
[4532] | 499 | || !aPhysPage)
|
---|
| 500 | return VERR_INVALID_PARAMETER;
|
---|
| 501 |
|
---|
[4666] | 502 | Log(("vmmdevChangeMemoryBalloon @todo\n"));
|
---|
[4532] | 503 | return VINF_SUCCESS;
|
---|
| 504 | }
|
---|
| 505 |
|
---|
[11820] | 506 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 507 |
|
---|
| 508 | /* HGCM connector interface */
|
---|
| 509 |
|
---|
| 510 | static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
|
---|
| 511 | {
|
---|
[3792] | 512 | LogSunlover(("Enter\n"));
|
---|
[1681] | 513 |
|
---|
[1] | 514 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
[8690] | 515 |
|
---|
[1711] | 516 | if ( !pServiceLocation
|
---|
| 517 | || ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
|
---|
| 518 | && pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
|
---|
| 519 | {
|
---|
| 520 | return VERR_INVALID_PARAMETER;
|
---|
| 521 | }
|
---|
[1] | 522 |
|
---|
[11844] | 523 | if (!pDrv->pVMMDev->hgcmIsActive ())
|
---|
| 524 | {
|
---|
| 525 | return VERR_INVALID_STATE;
|
---|
| 526 | }
|
---|
| 527 |
|
---|
[1711] | 528 | return HGCMGuestConnect (pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
|
---|
[1] | 529 | }
|
---|
| 530 |
|
---|
| 531 | static DECLCALLBACK(int) iface_hgcmDisconnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
|
---|
| 532 | {
|
---|
[3792] | 533 | LogSunlover(("Enter\n"));
|
---|
[1681] | 534 |
|
---|
[1] | 535 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 536 |
|
---|
[11844] | 537 | if (!pDrv->pVMMDev->hgcmIsActive ())
|
---|
| 538 | {
|
---|
| 539 | return VERR_INVALID_STATE;
|
---|
| 540 | }
|
---|
| 541 |
|
---|
[1711] | 542 | return HGCMGuestDisconnect (pDrv->pHGCMPort, pCmd, u32ClientID);
|
---|
[1] | 543 | }
|
---|
| 544 |
|
---|
| 545 | static DECLCALLBACK(int) iface_hgcmCall (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
|
---|
| 546 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
| 547 | {
|
---|
[3792] | 548 | LogSunlover(("Enter\n"));
|
---|
[1681] | 549 |
|
---|
[1] | 550 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 551 |
|
---|
[11844] | 552 | if (!pDrv->pVMMDev->hgcmIsActive ())
|
---|
| 553 | {
|
---|
| 554 | return VERR_INVALID_STATE;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
[1711] | 557 | return HGCMGuestCall (pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms);
|
---|
[1] | 558 | }
|
---|
| 559 |
|
---|
[906] | 560 | /**
|
---|
| 561 | * Execute state save operation.
|
---|
| 562 | *
|
---|
| 563 | * @returns VBox status code.
|
---|
| 564 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 565 | * @param pSSM SSM operation handle.
|
---|
| 566 | */
|
---|
| 567 | static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
|
---|
| 568 | {
|
---|
[3792] | 569 | LogSunlover(("Enter\n"));
|
---|
[1711] | 570 | return HGCMHostSaveState (pSSM);
|
---|
[906] | 571 | }
|
---|
| 572 |
|
---|
| 573 |
|
---|
| 574 | /**
|
---|
| 575 | * Execute state load operation.
|
---|
| 576 | *
|
---|
| 577 | * @returns VBox status code.
|
---|
| 578 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 579 | * @param pSSM SSM operation handle.
|
---|
| 580 | * @param u32Version Data layout version.
|
---|
| 581 | */
|
---|
| 582 | static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t u32Version)
|
---|
| 583 | {
|
---|
[1681] | 584 | LogFlowFunc(("Enter\n"));
|
---|
| 585 |
|
---|
| 586 | if (u32Version != HGCM_SSM_VERSION)
|
---|
| 587 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
| 588 |
|
---|
[1711] | 589 | return HGCMHostLoadState (pSSM);
|
---|
[906] | 590 | }
|
---|
| 591 |
|
---|
[6792] | 592 | int VMMDev::hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName)
|
---|
[1] | 593 | {
|
---|
[11844] | 594 | if (!hgcmIsActive ())
|
---|
[11409] | 595 | {
|
---|
| 596 | return VERR_INVALID_STATE;
|
---|
| 597 | }
|
---|
[6792] | 598 | return HGCMHostLoad (pszServiceLibrary, pszServiceName);
|
---|
[1] | 599 | }
|
---|
| 600 |
|
---|
| 601 | int VMMDev::hgcmHostCall (const char *pszServiceName, uint32_t u32Function,
|
---|
| 602 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
| 603 | {
|
---|
[11844] | 604 | if (!hgcmIsActive ())
|
---|
[11409] | 605 | {
|
---|
| 606 | return VERR_INVALID_STATE;
|
---|
| 607 | }
|
---|
[1711] | 608 | return HGCMHostCall (pszServiceName, u32Function, cParms, paParms);
|
---|
[1] | 609 | }
|
---|
[5272] | 610 |
|
---|
| 611 | void VMMDev::hgcmShutdown (void)
|
---|
| 612 | {
|
---|
[11409] | 613 | ASMAtomicWriteBool(&m_fHGCMActive, false);
|
---|
[5272] | 614 | HGCMHostShutdown ();
|
---|
| 615 | }
|
---|
| 616 |
|
---|
[1711] | 617 | #endif /* HGCM */
|
---|
[1] | 618 |
|
---|
| 619 |
|
---|
| 620 | /**
|
---|
| 621 | * Queries an interface to the driver.
|
---|
| 622 | *
|
---|
| 623 | * @returns Pointer to interface.
|
---|
| 624 | * @returns NULL if the interface was not supported by the driver.
|
---|
| 625 | * @param pInterface Pointer to this interface structure.
|
---|
| 626 | * @param enmInterface The requested interface identification.
|
---|
| 627 | */
|
---|
| 628 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
|
---|
| 629 | {
|
---|
| 630 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
[11296] | 631 | PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 632 | switch (enmInterface)
|
---|
| 633 | {
|
---|
| 634 | case PDMINTERFACE_BASE:
|
---|
| 635 | return &pDrvIns->IBase;
|
---|
| 636 | case PDMINTERFACE_VMMDEV_CONNECTOR:
|
---|
| 637 | return &pDrv->Connector;
|
---|
[11820] | 638 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 639 | case PDMINTERFACE_HGCM_CONNECTOR:
|
---|
| 640 | return &pDrv->HGCMConnector;
|
---|
| 641 | #endif
|
---|
| 642 | default:
|
---|
| 643 | return NULL;
|
---|
| 644 | }
|
---|
| 645 | }
|
---|
| 646 |
|
---|
[4021] | 647 | /**
|
---|
[1] | 648 | * Destruct a VMMDev driver instance.
|
---|
| 649 | *
|
---|
| 650 | * @returns VBox status.
|
---|
| 651 | * @param pDrvIns The driver instance data.
|
---|
| 652 | */
|
---|
| 653 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
| 654 | {
|
---|
[11296] | 655 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 656 | LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
[11820] | 657 | #ifdef VBOX_WITH_HGCM
|
---|
[1711] | 658 | /* HGCM is shut down on the VMMDev destructor. */
|
---|
[11820] | 659 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 660 | if (pData->pVMMDev)
|
---|
| 661 | {
|
---|
| 662 | pData->pVMMDev->mpDrv = NULL;
|
---|
| 663 | }
|
---|
| 664 | }
|
---|
| 665 |
|
---|
| 666 | /**
|
---|
| 667 | * Reset notification.
|
---|
| 668 | *
|
---|
| 669 | * @returns VBox status.
|
---|
| 670 | * @param pDrvIns The driver instance data.
|
---|
| 671 | */
|
---|
| 672 | DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
|
---|
| 673 | {
|
---|
| 674 | LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
|
---|
[11820] | 675 | #ifdef VBOX_WITH_HGCM
|
---|
[1711] | 676 | HGCMHostReset ();
|
---|
[11820] | 677 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 678 | }
|
---|
| 679 |
|
---|
| 680 | /**
|
---|
| 681 | * Construct a VMMDev driver instance.
|
---|
| 682 | *
|
---|
| 683 | * @returns VBox status.
|
---|
| 684 | * @param pDrvIns The driver instance data.
|
---|
| 685 | * If the registration structure is needed, pDrvIns->pDrvReg points to it.
|
---|
| 686 | * @param pCfgHandle Configuration node handle for the driver. Use this to obtain the configuration
|
---|
| 687 | * of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
|
---|
| 688 | * iInstance it's expected to be used a bit in this function.
|
---|
| 689 | */
|
---|
| 690 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
|
---|
| 691 | {
|
---|
[11296] | 692 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 693 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
| 694 |
|
---|
| 695 | /*
|
---|
| 696 | * Validate configuration.
|
---|
| 697 | */
|
---|
[12449] | 698 | if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0OpenGLEnabled\0crOpenGLEnabled\0"))
|
---|
[1] | 699 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
| 700 | PPDMIBASE pBaseIgnore;
|
---|
| 701 | int rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBaseIgnore);
|
---|
| 702 | if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
| 703 | {
|
---|
| 704 | AssertMsgFailed(("Configuration error: Not possible to attach anything to this driver!\n"));
|
---|
| 705 | return VERR_PDM_DRVINS_NO_ATTACH;
|
---|
| 706 | }
|
---|
| 707 |
|
---|
| 708 | /*
|
---|
| 709 | * IBase.
|
---|
| 710 | */
|
---|
| 711 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
| 712 |
|
---|
| 713 | pData->Connector.pfnUpdateGuestVersion = vmmdevUpdateGuestVersion;
|
---|
[3584] | 714 | pData->Connector.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
|
---|
[1] | 715 | pData->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
|
---|
| 716 | pData->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
|
---|
| 717 | pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
| 718 | pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
| 719 | pData->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
|
---|
| 720 | pData->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
|
---|
| 721 | pData->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
|
---|
[3556] | 722 | pData->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
|
---|
| 723 | pData->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
|
---|
[4513] | 724 | pData->Connector.pfnReportStatistics = vmmdevReportStatistics;
|
---|
| 725 | pData->Connector.pfnQueryStatisticsInterval = vmmdevQueryStatisticsInterval;
|
---|
[4532] | 726 | pData->Connector.pfnChangeMemoryBalloon = vmmdevChangeMemoryBalloon;
|
---|
[1] | 727 |
|
---|
[11820] | 728 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 729 | pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
| 730 | pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
| 731 | pData->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
| 732 | #endif
|
---|
| 733 |
|
---|
| 734 | /*
|
---|
| 735 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
| 736 | */
|
---|
| 737 | pData->pUpPort = (PPDMIVMMDEVPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_VMMDEV_PORT);
|
---|
| 738 | if (!pData->pUpPort)
|
---|
| 739 | {
|
---|
| 740 | AssertMsgFailed(("Configuration error: No VMMDev port interface above!\n"));
|
---|
| 741 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
| 742 | }
|
---|
| 743 |
|
---|
[11820] | 744 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 745 | pData->pHGCMPort = (PPDMIHGCMPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HGCM_PORT);
|
---|
| 746 | if (!pData->pHGCMPort)
|
---|
| 747 | {
|
---|
| 748 | AssertMsgFailed(("Configuration error: No HGCM port interface above!\n"));
|
---|
| 749 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
| 750 | }
|
---|
| 751 | #endif
|
---|
| 752 |
|
---|
| 753 | /*
|
---|
| 754 | * Get the Console object pointer and update the mpDrv member.
|
---|
| 755 | */
|
---|
| 756 | void *pv;
|
---|
| 757 | rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
|
---|
| 758 | if (VBOX_FAILURE(rc))
|
---|
| 759 | {
|
---|
| 760 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Vrc\n", rc));
|
---|
| 761 | return rc;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
|
---|
| 765 | pData->pVMMDev->mpDrv = pData;
|
---|
| 766 |
|
---|
[11820] | 767 | #ifdef VBOX_WITH_HGCM
|
---|
[6762] | 768 | rc = pData->pVMMDev->hgcmLoadService (VBOXSHAREDFOLDERS_DLL,
|
---|
[6361] | 769 | "VBoxSharedFolders");
|
---|
[1681] | 770 | pData->pVMMDev->fSharedFolderActive = VBOX_SUCCESS(rc);
|
---|
| 771 | if (VBOX_SUCCESS(rc))
|
---|
| 772 | {
|
---|
[4032] | 773 | PPDMLED pLed;
|
---|
| 774 | PPDMILEDPORTS pLedPort;
|
---|
| 775 |
|
---|
[1681] | 776 | LogRel(("Shared Folders service loaded.\n"));
|
---|
[4032] | 777 | pLedPort = (PPDMILEDPORTS)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_LED_PORTS);
|
---|
| 778 | if (!pLedPort)
|
---|
| 779 | {
|
---|
| 780 | AssertMsgFailed(("Configuration error: No LED port interface above!\n"));
|
---|
| 781 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
| 782 | }
|
---|
| 783 | rc = pLedPort->pfnQueryStatusLed(pLedPort, 0, &pLed);
|
---|
| 784 | if (VBOX_SUCCESS(rc) && pLed)
|
---|
| 785 | {
|
---|
| 786 | VBOXHGCMSVCPARM parm;
|
---|
| 787 |
|
---|
| 788 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 789 | parm.u.pointer.addr = pLed;
|
---|
| 790 | parm.u.pointer.size = sizeof(*pLed);
|
---|
| 791 |
|
---|
| 792 | rc = HGCMHostCall("VBoxSharedFolders", SHFL_FN_SET_STATUS_LED, 1, &parm);
|
---|
| 793 | }
|
---|
| 794 | else
|
---|
| 795 | AssertMsgFailed(("pfnQueryStatusLed failed with %Vrc (pLed=%x)\n", rc, pLed));
|
---|
[1681] | 796 | }
|
---|
| 797 | else
|
---|
| 798 | {
|
---|
| 799 | LogRel(("Failed to load Shared Folders service %Vrc\n", rc));
|
---|
| 800 | }
|
---|
[3559] | 801 |
|
---|
| 802 | bool fEnabled;
|
---|
| 803 |
|
---|
| 804 | /* Check CFGM option. */
|
---|
| 805 | rc = CFGMR3QueryBool(pCfgHandle, "OpenGLEnabled", &fEnabled);
|
---|
| 806 | if ( VBOX_SUCCESS(rc)
|
---|
| 807 | && fEnabled)
|
---|
[3076] | 808 | {
|
---|
[3559] | 809 | rc = pData->pVMMDev->hgcmLoadService ("VBoxSharedOpenGL", "VBoxSharedOpenGL");
|
---|
| 810 | if (VBOX_SUCCESS(rc))
|
---|
| 811 | {
|
---|
| 812 | LogRel(("Shared OpenGL service loaded.\n"));
|
---|
| 813 | }
|
---|
| 814 | else
|
---|
| 815 | {
|
---|
| 816 | LogRel(("Failed to load Shared OpenGL service %Vrc\n", rc));
|
---|
| 817 | }
|
---|
[3076] | 818 | }
|
---|
| 819 |
|
---|
[12449] | 820 | rc = CFGMR3QueryBool(pCfgHandle, "crOpenGLEnabled", &fEnabled);
|
---|
| 821 | if ( VBOX_SUCCESS(rc) && fEnabled)
|
---|
| 822 | {
|
---|
| 823 | rc = pData->pVMMDev->hgcmLoadService ("VBoxSharedCrOpenGL", "VBoxSharedCrOpenGL");
|
---|
| 824 | if (VBOX_SUCCESS(rc))
|
---|
| 825 | {
|
---|
| 826 | LogRel(("Shared Chromium OpenGL service loaded.\n"));
|
---|
| 827 |
|
---|
| 828 | /* Setup the service. */
|
---|
| 829 | VBOXHGCMSVCPARM parm;
|
---|
| 830 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 831 |
|
---|
| 832 | //parm.u.pointer.addr = static_cast <IConsole *> (pData->pVMMDev->getParent());
|
---|
[12577] | 833 | parm.u.pointer.addr = pData->pVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
[12449] | 834 | parm.u.pointer.size = sizeof(IFramebuffer *);
|
---|
[12577] | 835 |
|
---|
| 836 | rc = HGCMHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_FRAMEBUFFER, 1, &parm);
|
---|
[12449] | 837 | if (!VBOX_SUCCESS(rc))
|
---|
[12577] | 838 | AssertMsgFailed(("SHCRGL_HOST_FN_SET_FRAMEBUFFER failed with %Vrc\n", rc));
|
---|
[12449] | 839 | }
|
---|
| 840 | else
|
---|
| 841 | {
|
---|
| 842 | LogRel(("Failed to load Shared Chromium OpenGL service %Vrc\n", rc));
|
---|
| 843 | }
|
---|
| 844 | }
|
---|
| 845 |
|
---|
[906] | 846 | pDrvIns->pDrvHlp->pfnSSMRegister(pDrvIns, "HGCM", 0, HGCM_SSM_VERSION, 4096/* bad guess */, NULL, iface_hgcmSave, NULL, NULL, iface_hgcmLoad, NULL);
|
---|
[11820] | 847 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 848 |
|
---|
| 849 | return VINF_SUCCESS;
|
---|
| 850 | }
|
---|
| 851 |
|
---|
| 852 |
|
---|
| 853 | /**
|
---|
| 854 | * VMMDevice driver registration record.
|
---|
| 855 | */
|
---|
| 856 | const PDMDRVREG VMMDev::DrvReg =
|
---|
| 857 | {
|
---|
| 858 | /* u32Version */
|
---|
| 859 | PDM_DRVREG_VERSION,
|
---|
| 860 | /* szDriverName */
|
---|
| 861 | "MainVMMDev",
|
---|
| 862 | /* pszDescription */
|
---|
| 863 | "Main VMMDev driver (Main as in the API).",
|
---|
| 864 | /* fFlags */
|
---|
| 865 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
| 866 | /* fClass. */
|
---|
| 867 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
| 868 | /* cMaxInstances */
|
---|
| 869 | ~0,
|
---|
| 870 | /* cbInstance */
|
---|
| 871 | sizeof(DRVMAINVMMDEV),
|
---|
| 872 | /* pfnConstruct */
|
---|
| 873 | VMMDev::drvConstruct,
|
---|
| 874 | /* pfnDestruct */
|
---|
| 875 | VMMDev::drvDestruct,
|
---|
| 876 | /* pfnIOCtl */
|
---|
| 877 | NULL,
|
---|
| 878 | /* pfnPowerOn */
|
---|
| 879 | NULL,
|
---|
| 880 | /* pfnReset */
|
---|
| 881 | VMMDev::drvReset,
|
---|
| 882 | /* pfnSuspend */
|
---|
| 883 | NULL,
|
---|
| 884 | /* pfnResume */
|
---|
| 885 | NULL,
|
---|
| 886 | /* pfnDetach */
|
---|
| 887 | NULL
|
---|
| 888 | };
|
---|