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