[1] | 1 | /** @file
|
---|
[21227] | 2 | * VirtualBox Driver Interface to VMM device.
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[8155] | 6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
[1] | 7 | *
|
---|
| 8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
[5999] | 11 | * General Public License (GPL) as published by the Free Software
|
---|
| 12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[8155] | 15 | *
|
---|
| 16 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
| 17 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
| 18 | * additional information or have any questions.
|
---|
[1] | 19 | */
|
---|
| 20 |
|
---|
| 21 | #include "VMMDev.h"
|
---|
| 22 | #include "ConsoleImpl.h"
|
---|
| 23 | #include "DisplayImpl.h"
|
---|
| 24 | #include "GuestImpl.h"
|
---|
| 25 |
|
---|
| 26 | #include "Logging.h"
|
---|
| 27 |
|
---|
[4015] | 28 | #include <VBox/pdmdrv.h>
|
---|
[21219] | 29 | #include <VBox/VMMDev.h>
|
---|
[4032] | 30 | #include <VBox/shflsvc.h>
|
---|
[1] | 31 | #include <iprt/asm.h>
|
---|
| 32 |
|
---|
[11820] | 33 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 34 | #include "hgcm/HGCM.h"
|
---|
[1080] | 35 | #include "hgcm/HGCMObjects.h"
|
---|
[18637] | 36 | # if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
|
---|
| 37 | # include <VBox/HostServices/VBoxCrOpenGLSvc.h>
|
---|
| 38 | # endif
|
---|
[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 |
|
---|
[21878] | 134 | if (RT_SUCCESS(rc))
|
---|
[1] | 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 | */
|
---|
[21226] | 247 | pDrv->pVMMDev->getParent()->onMouseCapabilityChange(BOOL (newCapabilities & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE),
|
---|
| 248 | BOOL (newCapabilities & VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR));
|
---|
[1] | 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)
|
---|
[18637] | 353 | {
|
---|
[3577] | 354 | framebuffer->SetVisibleRegion((BYTE *)pRect, cRect);
|
---|
[18637] | 355 | #if defined(RT_OS_DARWIN) && defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
| 356 | {
|
---|
| 357 | BOOL is3denabled;
|
---|
[3556] | 358 |
|
---|
[18637] | 359 | pDrv->pVMMDev->getParent()->machine()->COMGETTER(Accelerate3DEnabled)(&is3denabled);
|
---|
| 360 |
|
---|
| 361 | if (is3denabled)
|
---|
| 362 | {
|
---|
| 363 | VBOXHGCMSVCPARM parms[2];
|
---|
| 364 |
|
---|
| 365 | parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 366 | parms[0].u.pointer.addr = pRect;
|
---|
| 367 | parms[0].u.pointer.size = 0; /* We don't actually care. */
|
---|
| 368 | parms[1].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
| 369 | parms[1].u.uint32 = cRect;
|
---|
| 370 |
|
---|
| 371 | int rc = pDrv->pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_SET_VISIBLE_REGION, 2, &parms[0]);
|
---|
| 372 | return rc;
|
---|
| 373 | }
|
---|
| 374 | }
|
---|
| 375 | #endif
|
---|
| 376 | }
|
---|
| 377 |
|
---|
[3556] | 378 | return VINF_SUCCESS;
|
---|
| 379 | }
|
---|
| 380 |
|
---|
| 381 | DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
|
---|
| 382 | {
|
---|
| 383 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 384 |
|
---|
| 385 | IFramebuffer *framebuffer = pDrv->pVMMDev->getParent()->getDisplay()->getFramebuffer();
|
---|
| 386 | if (framebuffer)
|
---|
| 387 | {
|
---|
| 388 | ULONG cRect = 0;
|
---|
[3577] | 389 | framebuffer->GetVisibleRegion((BYTE *)pRect, cRect, &cRect);
|
---|
[3556] | 390 |
|
---|
| 391 | *pcRect = cRect;
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | return VINF_SUCCESS;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
[4513] | 397 | /**
|
---|
| 398 | * Request the statistics interval
|
---|
| 399 | *
|
---|
| 400 | * @returns VBox status code.
|
---|
| 401 | * @param pInterface Pointer to this interface.
|
---|
| 402 | * @param pulInterval Pointer to interval in seconds
|
---|
| 403 | * @thread The emulation thread.
|
---|
| 404 | */
|
---|
| 405 | DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
|
---|
| 406 | {
|
---|
| 407 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 408 | ULONG val = 0;
|
---|
| 409 |
|
---|
| 410 | if (!pulInterval)
|
---|
| 411 | return VERR_INVALID_POINTER;
|
---|
| 412 |
|
---|
| 413 | /* store that information in IGuest */
|
---|
| 414 | Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
| 415 | Assert(guest);
|
---|
| 416 | if (!guest)
|
---|
| 417 | return VERR_INVALID_PARAMETER; /** @todo wrong error */
|
---|
| 418 |
|
---|
| 419 | guest->COMGETTER(StatisticsUpdateInterval)(&val);
|
---|
| 420 | *pulInterval = val;
|
---|
| 421 | return VINF_SUCCESS;
|
---|
| 422 | }
|
---|
| 423 |
|
---|
| 424 | /**
|
---|
| 425 | * Report new guest statistics
|
---|
| 426 | *
|
---|
| 427 | * @returns VBox status code.
|
---|
| 428 | * @param pInterface Pointer to this interface.
|
---|
| 429 | * @param pGuestStats Guest statistics
|
---|
| 430 | * @thread The emulation thread.
|
---|
| 431 | */
|
---|
| 432 | DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
|
---|
| 433 | {
|
---|
| 434 | PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 435 |
|
---|
| 436 | Assert(pGuestStats);
|
---|
| 437 | if (!pGuestStats)
|
---|
| 438 | return VERR_INVALID_POINTER;
|
---|
| 439 |
|
---|
| 440 | /* store that information in IGuest */
|
---|
| 441 | Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
|
---|
| 442 | Assert(guest);
|
---|
| 443 | if (!guest)
|
---|
| 444 | return VERR_INVALID_PARAMETER; /** @todo wrong error */
|
---|
| 445 |
|
---|
[4570] | 446 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
[4571] | 447 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_CPULoad_Idle, pGuestStats->u32CpuLoad_Idle);
|
---|
[4513] | 448 |
|
---|
[4570] | 449 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
[4571] | 450 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_CPULoad_Kernel, pGuestStats->u32CpuLoad_Kernel);
|
---|
[4570] | 451 |
|
---|
| 452 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
[4571] | 453 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_CPULoad_User, pGuestStats->u32CpuLoad_User);
|
---|
[4570] | 454 |
|
---|
[4513] | 455 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_THREADS)
|
---|
[4571] | 456 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_Threads, pGuestStats->u32Threads);
|
---|
[4513] | 457 |
|
---|
| 458 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PROCESSES)
|
---|
[4571] | 459 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_Processes, pGuestStats->u32Processes);
|
---|
[4513] | 460 |
|
---|
[4575] | 461 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_HANDLES)
|
---|
| 462 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_Handles, pGuestStats->u32Handles);
|
---|
| 463 |
|
---|
| 464 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEMORY_LOAD)
|
---|
| 465 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemoryLoad, pGuestStats->u32MemoryLoad);
|
---|
| 466 |
|
---|
| 467 | /* Note that reported values are in pages; upper layers expect them in megabytes */
|
---|
[4576] | 468 | Assert(pGuestStats->u32PageSize == 4096);
|
---|
[4578] | 469 | if (pGuestStats->u32PageSize != 4096)
|
---|
[4576] | 470 | pGuestStats->u32PageSize = 4096;
|
---|
[4575] | 471 |
|
---|
[4513] | 472 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
[4606] | 473 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PhysMemTotal, (pGuestStats->u32PhysMemTotal + (_1M/pGuestStats->u32PageSize)-1) / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 474 |
|
---|
| 475 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
[4577] | 476 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PhysMemAvailable, pGuestStats->u32PhysMemAvail / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 477 |
|
---|
| 478 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
[4577] | 479 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PhysMemBalloon, pGuestStats->u32PhysMemBalloon / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 480 |
|
---|
[4575] | 481 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_COMMIT_TOTAL)
|
---|
[4577] | 482 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemCommitTotal, pGuestStats->u32MemCommitTotal / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 483 |
|
---|
| 484 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_TOTAL)
|
---|
[4577] | 485 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemKernelTotal, pGuestStats->u32MemKernelTotal / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 486 |
|
---|
| 487 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_PAGED)
|
---|
[4577] | 488 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemKernelPaged, pGuestStats->u32MemKernelPaged / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 489 |
|
---|
| 490 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED)
|
---|
[4577] | 491 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemKernelNonpaged, pGuestStats->u32MemKernelNonPaged / (_1M/pGuestStats->u32PageSize));
|
---|
[4575] | 492 |
|
---|
| 493 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
[4577] | 494 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_MemSystemCache, pGuestStats->u32MemSystemCache / (_1M/pGuestStats->u32PageSize));
|
---|
[8690] | 495 |
|
---|
[4513] | 496 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
[4577] | 497 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_PageFileSize, pGuestStats->u32PageFileSize / (_1M/pGuestStats->u32PageSize));
|
---|
[4513] | 498 |
|
---|
[4685] | 499 | /* increase sample number */
|
---|
| 500 | ULONG sample;
|
---|
| 501 |
|
---|
| 502 | int rc = guest->GetStatistic(0, GuestStatisticType_SampleNumber, &sample);
|
---|
| 503 | if (SUCCEEDED(rc))
|
---|
| 504 | guest->SetStatistic(pGuestStats->u32CpuId, GuestStatisticType_SampleNumber, sample+1);
|
---|
| 505 |
|
---|
[4513] | 506 | return VINF_SUCCESS;
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[4532] | 509 | /**
|
---|
| 510 | * Inflate or deflate the memory balloon
|
---|
| 511 | *
|
---|
| 512 | * @returns VBox status code.
|
---|
| 513 | * @param pInterface Pointer to this interface.
|
---|
| 514 | * @param fInflate Inflate or deflate
|
---|
| 515 | * @param cPages Number of physical pages (must be 256 as we allocate in 1 MB chunks)
|
---|
| 516 | * @param aPhysPage Array of physical page addresses
|
---|
| 517 | * @thread The emulation thread.
|
---|
| 518 | */
|
---|
| 519 | DECLCALLBACK(int) vmmdevChangeMemoryBalloon(PPDMIVMMDEVCONNECTOR pInterface, bool fInflate, uint32_t cPages, RTGCPHYS *aPhysPage)
|
---|
| 520 | {
|
---|
[4533] | 521 | if ( cPages != VMMDEV_MEMORY_BALLOON_CHUNK_PAGES
|
---|
[4532] | 522 | || !aPhysPage)
|
---|
| 523 | return VERR_INVALID_PARAMETER;
|
---|
| 524 |
|
---|
[4666] | 525 | Log(("vmmdevChangeMemoryBalloon @todo\n"));
|
---|
[4532] | 526 | return VINF_SUCCESS;
|
---|
| 527 | }
|
---|
| 528 |
|
---|
[11820] | 529 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 530 |
|
---|
| 531 | /* HGCM connector interface */
|
---|
| 532 |
|
---|
| 533 | static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
|
---|
| 534 | {
|
---|
[3792] | 535 | LogSunlover(("Enter\n"));
|
---|
[1681] | 536 |
|
---|
[1] | 537 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
[8690] | 538 |
|
---|
[1711] | 539 | if ( !pServiceLocation
|
---|
| 540 | || ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
|
---|
| 541 | && pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
|
---|
| 542 | {
|
---|
| 543 | return VERR_INVALID_PARAMETER;
|
---|
| 544 | }
|
---|
[1] | 545 |
|
---|
[11844] | 546 | if (!pDrv->pVMMDev->hgcmIsActive ())
|
---|
| 547 | {
|
---|
| 548 | return VERR_INVALID_STATE;
|
---|
| 549 | }
|
---|
| 550 |
|
---|
[1711] | 551 | return HGCMGuestConnect (pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
|
---|
[1] | 552 | }
|
---|
| 553 |
|
---|
| 554 | static DECLCALLBACK(int) iface_hgcmDisconnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
|
---|
| 555 | {
|
---|
[3792] | 556 | LogSunlover(("Enter\n"));
|
---|
[1681] | 557 |
|
---|
[1] | 558 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 559 |
|
---|
[11844] | 560 | if (!pDrv->pVMMDev->hgcmIsActive ())
|
---|
| 561 | {
|
---|
| 562 | return VERR_INVALID_STATE;
|
---|
| 563 | }
|
---|
| 564 |
|
---|
[1711] | 565 | return HGCMGuestDisconnect (pDrv->pHGCMPort, pCmd, u32ClientID);
|
---|
[1] | 566 | }
|
---|
| 567 |
|
---|
| 568 | static DECLCALLBACK(int) iface_hgcmCall (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
|
---|
| 569 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
| 570 | {
|
---|
[3792] | 571 | LogSunlover(("Enter\n"));
|
---|
[1681] | 572 |
|
---|
[1] | 573 | PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
|
---|
| 574 |
|
---|
[11844] | 575 | if (!pDrv->pVMMDev->hgcmIsActive ())
|
---|
| 576 | {
|
---|
| 577 | return VERR_INVALID_STATE;
|
---|
| 578 | }
|
---|
| 579 |
|
---|
[1711] | 580 | return HGCMGuestCall (pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms);
|
---|
[1] | 581 | }
|
---|
| 582 |
|
---|
[906] | 583 | /**
|
---|
| 584 | * Execute state save operation.
|
---|
| 585 | *
|
---|
| 586 | * @returns VBox status code.
|
---|
| 587 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 588 | * @param pSSM SSM operation handle.
|
---|
| 589 | */
|
---|
| 590 | static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
|
---|
| 591 | {
|
---|
[3792] | 592 | LogSunlover(("Enter\n"));
|
---|
[1711] | 593 | return HGCMHostSaveState (pSSM);
|
---|
[906] | 594 | }
|
---|
| 595 |
|
---|
| 596 |
|
---|
| 597 | /**
|
---|
| 598 | * Execute state load operation.
|
---|
| 599 | *
|
---|
| 600 | * @returns VBox status code.
|
---|
| 601 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 602 | * @param pSSM SSM operation handle.
|
---|
[22480] | 603 | * @param uVersion Data layout version.
|
---|
[22793] | 604 | * @param uPass The data pass.
|
---|
[906] | 605 | */
|
---|
[22793] | 606 | static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
[906] | 607 | {
|
---|
[1681] | 608 | LogFlowFunc(("Enter\n"));
|
---|
| 609 |
|
---|
[22480] | 610 | if (uVersion != HGCM_SSM_VERSION)
|
---|
[1681] | 611 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
[22793] | 612 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
[1681] | 613 |
|
---|
[1711] | 614 | return HGCMHostLoadState (pSSM);
|
---|
[906] | 615 | }
|
---|
| 616 |
|
---|
[6792] | 617 | int VMMDev::hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName)
|
---|
[1] | 618 | {
|
---|
[11844] | 619 | if (!hgcmIsActive ())
|
---|
[11409] | 620 | {
|
---|
| 621 | return VERR_INVALID_STATE;
|
---|
| 622 | }
|
---|
[6792] | 623 | return HGCMHostLoad (pszServiceLibrary, pszServiceName);
|
---|
[1] | 624 | }
|
---|
| 625 |
|
---|
| 626 | int VMMDev::hgcmHostCall (const char *pszServiceName, uint32_t u32Function,
|
---|
| 627 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
| 628 | {
|
---|
[11844] | 629 | if (!hgcmIsActive ())
|
---|
[11409] | 630 | {
|
---|
| 631 | return VERR_INVALID_STATE;
|
---|
| 632 | }
|
---|
[1711] | 633 | return HGCMHostCall (pszServiceName, u32Function, cParms, paParms);
|
---|
[1] | 634 | }
|
---|
[5272] | 635 |
|
---|
| 636 | void VMMDev::hgcmShutdown (void)
|
---|
| 637 | {
|
---|
[11409] | 638 | ASMAtomicWriteBool(&m_fHGCMActive, false);
|
---|
[5272] | 639 | HGCMHostShutdown ();
|
---|
| 640 | }
|
---|
| 641 |
|
---|
[1711] | 642 | #endif /* HGCM */
|
---|
[1] | 643 |
|
---|
| 644 |
|
---|
| 645 | /**
|
---|
| 646 | * Queries an interface to the driver.
|
---|
| 647 | *
|
---|
| 648 | * @returns Pointer to interface.
|
---|
| 649 | * @returns NULL if the interface was not supported by the driver.
|
---|
| 650 | * @param pInterface Pointer to this interface structure.
|
---|
| 651 | * @param enmInterface The requested interface identification.
|
---|
| 652 | */
|
---|
| 653 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
|
---|
| 654 | {
|
---|
| 655 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
[11296] | 656 | PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 657 | switch (enmInterface)
|
---|
| 658 | {
|
---|
| 659 | case PDMINTERFACE_BASE:
|
---|
| 660 | return &pDrvIns->IBase;
|
---|
| 661 | case PDMINTERFACE_VMMDEV_CONNECTOR:
|
---|
| 662 | return &pDrv->Connector;
|
---|
[11820] | 663 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 664 | case PDMINTERFACE_HGCM_CONNECTOR:
|
---|
| 665 | return &pDrv->HGCMConnector;
|
---|
| 666 | #endif
|
---|
| 667 | default:
|
---|
| 668 | return NULL;
|
---|
| 669 | }
|
---|
| 670 | }
|
---|
| 671 |
|
---|
[4021] | 672 | /**
|
---|
[1] | 673 | * Destruct a VMMDev driver instance.
|
---|
| 674 | *
|
---|
| 675 | * @returns VBox status.
|
---|
| 676 | * @param pDrvIns The driver instance data.
|
---|
| 677 | */
|
---|
| 678 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
| 679 | {
|
---|
[11296] | 680 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 681 | LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
[11820] | 682 | #ifdef VBOX_WITH_HGCM
|
---|
[1711] | 683 | /* HGCM is shut down on the VMMDev destructor. */
|
---|
[11820] | 684 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 685 | if (pData->pVMMDev)
|
---|
| 686 | {
|
---|
| 687 | pData->pVMMDev->mpDrv = NULL;
|
---|
| 688 | }
|
---|
| 689 | }
|
---|
| 690 |
|
---|
| 691 | /**
|
---|
| 692 | * Reset notification.
|
---|
| 693 | *
|
---|
| 694 | * @returns VBox status.
|
---|
| 695 | * @param pDrvIns The driver instance data.
|
---|
| 696 | */
|
---|
| 697 | DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
|
---|
| 698 | {
|
---|
| 699 | LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
|
---|
[11820] | 700 | #ifdef VBOX_WITH_HGCM
|
---|
[1711] | 701 | HGCMHostReset ();
|
---|
[11820] | 702 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 703 | }
|
---|
| 704 |
|
---|
| 705 | /**
|
---|
| 706 | * Construct a VMMDev driver instance.
|
---|
| 707 | *
|
---|
[22277] | 708 | * @copydoc FNPDMDRVCONSTRUCT
|
---|
[1] | 709 | */
|
---|
[22277] | 710 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
|
---|
[1] | 711 | {
|
---|
[11296] | 712 | PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 713 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
| 714 |
|
---|
| 715 | /*
|
---|
| 716 | * Validate configuration.
|
---|
| 717 | */
|
---|
[16468] | 718 | if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
|
---|
[1] | 719 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
[22480] | 720 | AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
|
---|
[22277] | 721 | ("Configuration error: Not possible to attach anything to this driver!\n"),
|
---|
| 722 | VERR_PDM_DRVINS_NO_ATTACH);
|
---|
[16468] | 723 |
|
---|
[1] | 724 | /*
|
---|
| 725 | * IBase.
|
---|
| 726 | */
|
---|
| 727 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
| 728 |
|
---|
| 729 | pData->Connector.pfnUpdateGuestVersion = vmmdevUpdateGuestVersion;
|
---|
[3584] | 730 | pData->Connector.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
|
---|
[1] | 731 | pData->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
|
---|
| 732 | pData->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
|
---|
| 733 | pData->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
| 734 | pData->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
| 735 | pData->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
|
---|
| 736 | pData->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
|
---|
| 737 | pData->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
|
---|
[3556] | 738 | pData->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
|
---|
| 739 | pData->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
|
---|
[4513] | 740 | pData->Connector.pfnReportStatistics = vmmdevReportStatistics;
|
---|
| 741 | pData->Connector.pfnQueryStatisticsInterval = vmmdevQueryStatisticsInterval;
|
---|
[4532] | 742 | pData->Connector.pfnChangeMemoryBalloon = vmmdevChangeMemoryBalloon;
|
---|
[1] | 743 |
|
---|
[11820] | 744 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 745 | pData->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
| 746 | pData->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
| 747 | pData->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
| 748 | #endif
|
---|
| 749 |
|
---|
| 750 | /*
|
---|
| 751 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
| 752 | */
|
---|
| 753 | pData->pUpPort = (PPDMIVMMDEVPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_VMMDEV_PORT);
|
---|
| 754 | if (!pData->pUpPort)
|
---|
| 755 | {
|
---|
| 756 | AssertMsgFailed(("Configuration error: No VMMDev port interface above!\n"));
|
---|
| 757 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
| 758 | }
|
---|
| 759 |
|
---|
[11820] | 760 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 761 | pData->pHGCMPort = (PPDMIHGCMPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_HGCM_PORT);
|
---|
| 762 | if (!pData->pHGCMPort)
|
---|
| 763 | {
|
---|
| 764 | AssertMsgFailed(("Configuration error: No HGCM port interface above!\n"));
|
---|
| 765 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
| 766 | }
|
---|
| 767 | #endif
|
---|
| 768 |
|
---|
| 769 | /*
|
---|
| 770 | * Get the Console object pointer and update the mpDrv member.
|
---|
| 771 | */
|
---|
| 772 | void *pv;
|
---|
[22277] | 773 | int rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
|
---|
[13835] | 774 | if (RT_FAILURE(rc))
|
---|
[1] | 775 | {
|
---|
[13837] | 776 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
|
---|
[1] | 777 | return rc;
|
---|
| 778 | }
|
---|
| 779 |
|
---|
| 780 | pData->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
|
---|
| 781 | pData->pVMMDev->mpDrv = pData;
|
---|
| 782 |
|
---|
[11820] | 783 | #ifdef VBOX_WITH_HGCM
|
---|
[6762] | 784 | rc = pData->pVMMDev->hgcmLoadService (VBOXSHAREDFOLDERS_DLL,
|
---|
[6361] | 785 | "VBoxSharedFolders");
|
---|
[13835] | 786 | pData->pVMMDev->fSharedFolderActive = RT_SUCCESS(rc);
|
---|
| 787 | if (RT_SUCCESS(rc))
|
---|
[1681] | 788 | {
|
---|
[4032] | 789 | PPDMLED pLed;
|
---|
| 790 | PPDMILEDPORTS pLedPort;
|
---|
| 791 |
|
---|
[1681] | 792 | LogRel(("Shared Folders service loaded.\n"));
|
---|
[4032] | 793 | pLedPort = (PPDMILEDPORTS)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_LED_PORTS);
|
---|
| 794 | if (!pLedPort)
|
---|
| 795 | {
|
---|
| 796 | AssertMsgFailed(("Configuration error: No LED port interface above!\n"));
|
---|
| 797 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
| 798 | }
|
---|
| 799 | rc = pLedPort->pfnQueryStatusLed(pLedPort, 0, &pLed);
|
---|
[13835] | 800 | if (RT_SUCCESS(rc) && pLed)
|
---|
[4032] | 801 | {
|
---|
| 802 | VBOXHGCMSVCPARM parm;
|
---|
| 803 |
|
---|
| 804 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 805 | parm.u.pointer.addr = pLed;
|
---|
| 806 | parm.u.pointer.size = sizeof(*pLed);
|
---|
| 807 |
|
---|
| 808 | rc = HGCMHostCall("VBoxSharedFolders", SHFL_FN_SET_STATUS_LED, 1, &parm);
|
---|
| 809 | }
|
---|
| 810 | else
|
---|
[13837] | 811 | AssertMsgFailed(("pfnQueryStatusLed failed with %Rrc (pLed=%x)\n", rc, pLed));
|
---|
[1681] | 812 | }
|
---|
| 813 | else
|
---|
[13837] | 814 | LogRel(("Failed to load Shared Folders service %Rrc\n", rc));
|
---|
[3559] | 815 |
|
---|
[22480] | 816 | rc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SSM_VERSION, 4096 /* bad guess */,
|
---|
| 817 | NULL, NULL, NULL,
|
---|
| 818 | NULL, iface_hgcmSave, NULL,
|
---|
| 819 | NULL, iface_hgcmLoad, NULL);
|
---|
| 820 | if (RT_FAILURE(rc))
|
---|
| 821 | return rc;
|
---|
| 822 |
|
---|
[11820] | 823 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 824 |
|
---|
| 825 | return VINF_SUCCESS;
|
---|
| 826 | }
|
---|
| 827 |
|
---|
| 828 |
|
---|
| 829 | /**
|
---|
| 830 | * VMMDevice driver registration record.
|
---|
| 831 | */
|
---|
| 832 | const PDMDRVREG VMMDev::DrvReg =
|
---|
| 833 | {
|
---|
| 834 | /* u32Version */
|
---|
| 835 | PDM_DRVREG_VERSION,
|
---|
| 836 | /* szDriverName */
|
---|
[22480] | 837 | "HGCM",
|
---|
[1] | 838 | /* pszDescription */
|
---|
| 839 | "Main VMMDev driver (Main as in the API).",
|
---|
| 840 | /* fFlags */
|
---|
| 841 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
| 842 | /* fClass. */
|
---|
| 843 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
| 844 | /* cMaxInstances */
|
---|
| 845 | ~0,
|
---|
| 846 | /* cbInstance */
|
---|
| 847 | sizeof(DRVMAINVMMDEV),
|
---|
| 848 | /* pfnConstruct */
|
---|
| 849 | VMMDev::drvConstruct,
|
---|
| 850 | /* pfnDestruct */
|
---|
| 851 | VMMDev::drvDestruct,
|
---|
| 852 | /* pfnIOCtl */
|
---|
| 853 | NULL,
|
---|
| 854 | /* pfnPowerOn */
|
---|
| 855 | NULL,
|
---|
| 856 | /* pfnReset */
|
---|
| 857 | VMMDev::drvReset,
|
---|
| 858 | /* pfnSuspend */
|
---|
| 859 | NULL,
|
---|
| 860 | /* pfnResume */
|
---|
| 861 | NULL,
|
---|
[22277] | 862 | /* pfnAttach */
|
---|
| 863 | NULL,
|
---|
[1] | 864 | /* pfnDetach */
|
---|
[22480] | 865 | NULL,
|
---|
[22277] | 866 | /* pfnPowerOff */
|
---|
[22480] | 867 | NULL,
|
---|
[22277] | 868 | /* pfnSoftReset */
|
---|
| 869 | NULL,
|
---|
| 870 | /* u32EndVersion */
|
---|
| 871 | PDM_DRVREG_VERSION
|
---|
[1] | 872 | };
|
---|
[14772] | 873 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|