[25966] | 1 | /* $Id: VMMDevInterface.cpp 70599 2018-01-16 15:36:41Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
[21227] | 3 | * VirtualBox Driver Interface to VMM device.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[69500] | 7 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
[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.
|
---|
[1] | 16 | */
|
---|
| 17 |
|
---|
[67914] | 18 | #define LOG_GROUP LOG_GROUP_MAIN_VMMDEVINTERFACES
|
---|
| 19 | #include "LoggingNew.h"
|
---|
| 20 |
|
---|
[1] | 21 | #include "VMMDev.h"
|
---|
| 22 | #include "ConsoleImpl.h"
|
---|
| 23 | #include "DisplayImpl.h"
|
---|
| 24 | #include "GuestImpl.h"
|
---|
[26782] | 25 | #include "MouseImpl.h"
|
---|
[1] | 26 |
|
---|
[35346] | 27 | #include <VBox/vmm/pdmdrv.h>
|
---|
[21219] | 28 | #include <VBox/VMMDev.h>
|
---|
[4032] | 29 | #include <VBox/shflsvc.h>
|
---|
[1] | 30 | #include <iprt/asm.h>
|
---|
| 31 |
|
---|
[11820] | 32 | #ifdef VBOX_WITH_HGCM
|
---|
[35374] | 33 | # include "HGCM.h"
|
---|
| 34 | # include "HGCMObjects.h"
|
---|
[18637] | 35 | # if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
|
---|
| 36 | # include <VBox/HostServices/VBoxCrOpenGLSvc.h>
|
---|
| 37 | # endif
|
---|
[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. */
|
---|
[32851] | 61 | VMMDev *pVMMDev;
|
---|
[1] | 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 | //
|
---|
| 78 | // constructor / destructor
|
---|
| 79 | //
|
---|
[27607] | 80 | VMMDev::VMMDev(Console *console)
|
---|
| 81 | : mpDrv(NULL),
|
---|
| 82 | mParent(console)
|
---|
[1] | 83 | {
|
---|
| 84 | int rc = RTSemEventCreate(&mCredentialsEvent);
|
---|
| 85 | AssertRC(rc);
|
---|
[11820] | 86 | #ifdef VBOX_WITH_HGCM
|
---|
[69017] | 87 | rc = HGCMHostInit();
|
---|
[1] | 88 | AssertRC(rc);
|
---|
[11409] | 89 | m_fHGCMActive = true;
|
---|
[11820] | 90 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 91 | mu32CredentialsFlags = 0;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | VMMDev::~VMMDev()
|
---|
| 95 | {
|
---|
[25973] | 96 | #ifdef VBOX_WITH_HGCM
|
---|
| 97 | if (hgcmIsActive())
|
---|
| 98 | {
|
---|
| 99 | ASMAtomicWriteBool(&m_fHGCMActive, false);
|
---|
| 100 | HGCMHostShutdown();
|
---|
| 101 | }
|
---|
| 102 | #endif /* VBOX_WITH_HGCM */
|
---|
[69017] | 103 | RTSemEventDestroy(mCredentialsEvent);
|
---|
[1] | 104 | if (mpDrv)
|
---|
| 105 | mpDrv->pVMMDev = NULL;
|
---|
| 106 | mpDrv = NULL;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
|
---|
| 110 | {
|
---|
[41131] | 111 | if (!mpDrv)
|
---|
| 112 | return NULL;
|
---|
[1] | 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 | */
|
---|
[32851] | 125 | int VMMDev::WaitCredentialsJudgement(uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
|
---|
[1] | 126 | {
|
---|
| 127 | if (u32Timeout == 0)
|
---|
| 128 | {
|
---|
| 129 | u32Timeout = 5000;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[69017] | 132 | int rc = RTSemEventWait(mCredentialsEvent, u32Timeout);
|
---|
[1] | 133 |
|
---|
[21878] | 134 | if (RT_SUCCESS(rc))
|
---|
[1] | 135 | {
|
---|
| 136 | *pu32CredentialsFlags = mu32CredentialsFlags;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | return rc;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[32851] | 142 | int VMMDev::SetCredentialsJudgementResult(uint32_t u32Flags)
|
---|
[1] | 143 | {
|
---|
| 144 | mu32CredentialsFlags = u32Flags;
|
---|
| 145 |
|
---|
[69017] | 146 | int rc = RTSemEventSignal(mCredentialsEvent);
|
---|
[1] | 147 | AssertRC(rc);
|
---|
| 148 |
|
---|
| 149 | return rc;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
[39890] | 154 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestStatus}
|
---|
[30758] | 155 | */
|
---|
[39890] | 156 | DECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus,
|
---|
| 157 | uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS)
|
---|
[30758] | 158 | {
|
---|
[51096] | 159 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 160 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 161 |
|
---|
[30758] | 162 | /* Store that information in IGuest */
|
---|
[51612] | 163 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 164 | AssertPtrReturnVoid(guest);
|
---|
[30758] | 165 |
|
---|
[52082] | 166 | guest->i_setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
|
---|
[51612] | 167 | pConsole->i_onAdditionsStateChange();
|
---|
[30758] | 168 | }
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | /**
|
---|
[47294] | 172 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestUserState}
|
---|
| 173 | */
|
---|
| 174 | DECLCALLBACK(void) vmmdevUpdateGuestUserState(PPDMIVMMDEVCONNECTOR pInterface,
|
---|
| 175 | const char *pszUser, const char *pszDomain,
|
---|
| 176 | uint32_t uState,
|
---|
[65088] | 177 | const uint8_t *pabDetails, uint32_t cbDetails)
|
---|
[47294] | 178 | {
|
---|
[51096] | 179 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[47294] | 180 | AssertPtr(pDrv);
|
---|
| 181 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 182 | AssertPtr(pConsole);
|
---|
| 183 |
|
---|
| 184 | /* Store that information in IGuest. */
|
---|
[51612] | 185 | Guest* pGuest = pConsole->i_getGuest();
|
---|
[51096] | 186 | AssertPtrReturnVoid(pGuest);
|
---|
[47294] | 187 |
|
---|
[52082] | 188 | pGuest->i_onUserStateChange(Bstr(pszUser), Bstr(pszDomain), (VBoxGuestUserState)uState,
|
---|
[65088] | 189 | pabDetails, cbDetails);
|
---|
[47294] | 190 | }
|
---|
| 191 |
|
---|
| 192 |
|
---|
| 193 | /**
|
---|
[30758] | 194 | * Reports Guest Additions API and OS version.
|
---|
[1] | 195 | *
|
---|
[39882] | 196 | * Called whenever the Additions issue a guest version report request or the VM
|
---|
| 197 | * is reset.
|
---|
| 198 | *
|
---|
[1] | 199 | * @param pInterface Pointer to this interface.
|
---|
[31241] | 200 | * @param guestInfo Pointer to guest information structure.
|
---|
[1] | 201 | * @thread The emulation thread.
|
---|
| 202 | */
|
---|
[30758] | 203 | DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
|
---|
[1] | 204 | {
|
---|
[51096] | 205 | AssertPtrReturnVoid(guestInfo);
|
---|
[51612] | 206 |
|
---|
[51096] | 207 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 208 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 209 |
|
---|
| 210 | /* Store that information in IGuest */
|
---|
[51612] | 211 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 212 | AssertPtrReturnVoid(guest);
|
---|
[1] | 213 |
|
---|
[31241] | 214 | if (guestInfo->interfaceVersion != 0)
|
---|
[8690] | 215 | {
|
---|
[31241] | 216 | char version[16];
|
---|
| 217 | RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion);
|
---|
[52082] | 218 | guest->i_setAdditionsInfo(Bstr(version), guestInfo->osType);
|
---|
[1] | 219 |
|
---|
[8690] | 220 | /*
|
---|
| 221 | * Tell the console interface about the event
|
---|
| 222 | * so that it can notify its consumers.
|
---|
| 223 | */
|
---|
[51612] | 224 | pConsole->i_onAdditionsStateChange();
|
---|
[8690] | 225 |
|
---|
[31241] | 226 | if (guestInfo->interfaceVersion < VMMDEV_VERSION)
|
---|
[51612] | 227 | pConsole->i_onAdditionsOutdated();
|
---|
[8690] | 228 | }
|
---|
| 229 | else
|
---|
[1] | 230 | {
|
---|
[8690] | 231 | /*
|
---|
| 232 | * The guest additions was disabled because of a reset
|
---|
| 233 | * or driver unload.
|
---|
| 234 | */
|
---|
[52082] | 235 | guest->i_setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */
|
---|
[39882] | 236 | /** @todo Would be better if GuestImpl.cpp did all this in the above method call
|
---|
| 237 | * while holding down the. */
|
---|
[52082] | 238 | guest->i_setAdditionsInfo2(0, "", 0, 0); /* Clear Guest Additions version. */
|
---|
[39890] | 239 | RTTIMESPEC TimeSpecTS;
|
---|
| 240 | RTTimeNow(&TimeSpecTS);
|
---|
[52082] | 241 | guest->i_setAdditionsStatus(VBoxGuestFacilityType_All, VBoxGuestFacilityStatus_Inactive, 0 /*fFlags*/, &TimeSpecTS);
|
---|
[51612] | 242 | pConsole->i_onAdditionsStateChange();
|
---|
[1] | 243 | }
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | /**
|
---|
[39882] | 247 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestInfo2}
|
---|
[31241] | 248 | */
|
---|
[39882] | 249 | DECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion,
|
---|
| 250 | const char *pszName, uint32_t uRevision, uint32_t fFeatures)
|
---|
[31241] | 251 | {
|
---|
[51096] | 252 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[39882] | 253 | AssertPtr(pszName);
|
---|
| 254 | Assert(uFullVersion);
|
---|
[31241] | 255 |
|
---|
| 256 | /* Store that information in IGuest. */
|
---|
[51612] | 257 | Guest *pGuest = pDrv->pVMMDev->getParent()->i_getGuest();
|
---|
[51096] | 258 | AssertPtrReturnVoid(pGuest);
|
---|
[31241] | 259 |
|
---|
[39882] | 260 | /* Just pass it on... */
|
---|
[52082] | 261 | pGuest->i_setAdditionsInfo2(uFullVersion, pszName, uRevision, fFeatures);
|
---|
[31241] | 262 |
|
---|
[39882] | 263 | /*
|
---|
| 264 | * No need to tell the console interface about the update;
|
---|
| 265 | * vmmdevUpdateGuestInfo takes care of that when called as the
|
---|
| 266 | * last event in the chain.
|
---|
| 267 | */
|
---|
[31241] | 268 | }
|
---|
| 269 |
|
---|
| 270 | /**
|
---|
[3582] | 271 | * Update the guest additions capabilities.
|
---|
| 272 | * This is called when the guest additions capabilities change. The new capabilities
|
---|
| 273 | * are given and the connector should update its internal state.
|
---|
| 274 | *
|
---|
| 275 | * @param pInterface Pointer to this interface.
|
---|
| 276 | * @param newCapabilities New capabilities.
|
---|
| 277 | * @thread The emulation thread.
|
---|
| 278 | */
|
---|
| 279 | DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
| 280 | {
|
---|
[51096] | 281 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[35888] | 282 | AssertPtr(pDrv);
|
---|
[32851] | 283 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[3582] | 284 |
|
---|
| 285 | /* store that information in IGuest */
|
---|
[51612] | 286 | Guest* pGuest = pConsole->i_getGuest();
|
---|
[51096] | 287 | AssertPtrReturnVoid(pGuest);
|
---|
[3582] | 288 |
|
---|
[30758] | 289 | /*
|
---|
[33540] | 290 | * Report our current capabilities (and assume none is active yet).
|
---|
[30758] | 291 | */
|
---|
[52082] | 292 | pGuest->i_setSupportedFeatures(newCapabilities);
|
---|
[3582] | 293 |
|
---|
| 294 | /*
|
---|
[53528] | 295 | * Tell the Display, so that it can update the "supports graphics"
|
---|
| 296 | * capability if the graphics card has not asserted it.
|
---|
| 297 | */
|
---|
| 298 | Display* pDisplay = pConsole->i_getDisplay();
|
---|
| 299 | AssertPtrReturnVoid(pDisplay);
|
---|
[54023] | 300 | pDisplay->i_handleUpdateVMMDevSupportsGraphics(RT_BOOL(newCapabilities & VMMDEV_GUEST_SUPPORTS_GRAPHICS));
|
---|
[53528] | 301 |
|
---|
| 302 | /*
|
---|
[3582] | 303 | * Tell the console interface about the event
|
---|
| 304 | * so that it can notify its consumers.
|
---|
| 305 | */
|
---|
[51612] | 306 | pConsole->i_onAdditionsStateChange();
|
---|
[3582] | 307 | }
|
---|
| 308 |
|
---|
| 309 | /**
|
---|
[1] | 310 | * Update the mouse capabilities.
|
---|
| 311 | * This is called when the mouse capabilities change. The new capabilities
|
---|
| 312 | * are given and the connector should update its internal state.
|
---|
| 313 | *
|
---|
| 314 | * @param pInterface Pointer to this interface.
|
---|
[65088] | 315 | * @param fNewCaps New capabilities.
|
---|
[1] | 316 | * @thread The emulation thread.
|
---|
| 317 | */
|
---|
[33758] | 318 | DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
|
---|
[1] | 319 | {
|
---|
[51096] | 320 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 321 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 322 |
|
---|
[1] | 323 | /*
|
---|
| 324 | * Tell the console interface about the event
|
---|
| 325 | * so that it can notify its consumers.
|
---|
| 326 | */
|
---|
[51612] | 327 | Mouse *pMouse = pConsole->i_getMouse();
|
---|
[26782] | 328 | if (pMouse) /** @todo and if not? Can that actually happen? */
|
---|
[50613] | 329 | pMouse->i_onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
|
---|
[1] | 330 | }
|
---|
| 331 |
|
---|
| 332 | /**
|
---|
| 333 | * Update the pointer shape or visibility.
|
---|
| 334 | *
|
---|
| 335 | * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
|
---|
| 336 | * The new shape is passed as a caller allocated buffer that will be freed after returning.
|
---|
| 337 | *
|
---|
| 338 | * @param pInterface Pointer to this interface.
|
---|
| 339 | * @param fVisible Whether the pointer is visible or not.
|
---|
| 340 | * @param fAlpha Alpha channel information is present.
|
---|
| 341 | * @param xHot Horizontal coordinate of the pointer hot spot.
|
---|
| 342 | * @param yHot Vertical coordinate of the pointer hot spot.
|
---|
| 343 | * @param width Pointer width in pixels.
|
---|
| 344 | * @param height Pointer height in pixels.
|
---|
| 345 | * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
|
---|
| 346 | * @thread The emulation thread.
|
---|
| 347 | */
|
---|
| 348 | DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
| 349 | uint32_t xHot, uint32_t yHot,
|
---|
| 350 | uint32_t width, uint32_t height,
|
---|
| 351 | void *pShape)
|
---|
| 352 | {
|
---|
[51096] | 353 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 354 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 355 |
|
---|
| 356 | /* tell the console about it */
|
---|
[52934] | 357 | uint32_t cbShape = 0;
|
---|
[29542] | 358 | if (pShape)
|
---|
| 359 | {
|
---|
[52934] | 360 | cbShape = (width + 7) / 8 * height; /* size of the AND mask */
|
---|
| 361 | cbShape = ((cbShape + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
|
---|
[29542] | 362 | }
|
---|
[52934] | 363 | pConsole->i_onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, (uint8_t *)pShape, cbShape);
|
---|
[1] | 364 | }
|
---|
| 365 |
|
---|
| 366 | DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
| 367 | {
|
---|
[51096] | 368 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 369 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 370 |
|
---|
[51612] | 371 | Display *display = pConsole->i_getDisplay();
|
---|
[1] | 372 |
|
---|
| 373 | if (display)
|
---|
| 374 | {
|
---|
[55988] | 375 | Log9(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
|
---|
[52652] | 376 | return display->VideoAccelEnableVMMDev(fEnable, pVbvaMemory);
|
---|
[1] | 377 | }
|
---|
| 378 |
|
---|
| 379 | return VERR_NOT_SUPPORTED;
|
---|
| 380 | }
|
---|
| 381 | DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
|
---|
| 382 | {
|
---|
[51096] | 383 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 384 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 385 |
|
---|
[51612] | 386 | Display *display = pConsole->i_getDisplay();
|
---|
[1] | 387 |
|
---|
| 388 | if (display)
|
---|
| 389 | {
|
---|
[55988] | 390 | Log9(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
|
---|
[52652] | 391 | display->VideoAccelFlushVMMDev();
|
---|
[1] | 392 | }
|
---|
| 393 | }
|
---|
| 394 |
|
---|
[28264] | 395 | DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
|
---|
[1] | 396 | uint32_t bpp, bool *fSupported)
|
---|
| 397 | {
|
---|
[51096] | 398 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 399 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 400 |
|
---|
| 401 | if (!fSupported)
|
---|
| 402 | return VERR_INVALID_PARAMETER;
|
---|
[28264] | 403 | #ifdef DEBUG_sunlover
|
---|
| 404 | Log(("vmmdevVideoModeSupported: [%d]: %dx%dx%d\n", display, width, height, bpp));
|
---|
| 405 | #endif
|
---|
| 406 | IFramebuffer *framebuffer = NULL;
|
---|
[51612] | 407 | HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(display, &framebuffer);
|
---|
[28264] | 408 | if (SUCCEEDED(hrc) && framebuffer)
|
---|
| 409 | {
|
---|
[3155] | 410 | framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
|
---|
[28264] | 411 | framebuffer->Release();
|
---|
| 412 | }
|
---|
[3155] | 413 | else
|
---|
[28264] | 414 | {
|
---|
| 415 | #ifdef DEBUG_sunlover
|
---|
| 416 | Log(("vmmdevVideoModeSupported: hrc %x, framebuffer %p!!!\n", hrc, framebuffer));
|
---|
| 417 | #endif
|
---|
[3155] | 418 | *fSupported = true;
|
---|
[28264] | 419 | }
|
---|
[1] | 420 | return VINF_SUCCESS;
|
---|
| 421 | }
|
---|
| 422 |
|
---|
| 423 | DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
|
---|
| 424 | {
|
---|
[51096] | 425 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 426 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 427 |
|
---|
| 428 | if (!heightReduction)
|
---|
| 429 | return VERR_INVALID_PARAMETER;
|
---|
[51436] | 430 | IFramebuffer *framebuffer = NULL;
|
---|
[51612] | 431 | HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(0, &framebuffer);
|
---|
[51436] | 432 | if (SUCCEEDED(hrc) && framebuffer)
|
---|
| 433 | {
|
---|
[3155] | 434 | framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
|
---|
[51436] | 435 | framebuffer->Release();
|
---|
| 436 | }
|
---|
[3155] | 437 | else
|
---|
| 438 | *heightReduction = 0;
|
---|
[1] | 439 | return VINF_SUCCESS;
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
|
---|
| 443 | {
|
---|
[51096] | 444 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[1] | 445 |
|
---|
[32851] | 446 | if (pDrv->pVMMDev)
|
---|
[69017] | 447 | return pDrv->pVMMDev->SetCredentialsJudgementResult(u32Flags);
|
---|
[1] | 448 |
|
---|
[32851] | 449 | return VERR_GENERAL_FAILURE;
|
---|
[1] | 450 | }
|
---|
| 451 |
|
---|
[3556] | 452 | DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
|
---|
| 453 | {
|
---|
[51096] | 454 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 455 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[3556] | 456 |
|
---|
[28368] | 457 | /* Forward to Display, which calls corresponding framebuffers. */
|
---|
[52064] | 458 | pConsole->i_getDisplay()->i_handleSetVisibleRegion(cRect, pRect);
|
---|
[3556] | 459 |
|
---|
| 460 | return VINF_SUCCESS;
|
---|
| 461 | }
|
---|
| 462 |
|
---|
[63240] | 463 | DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRects, PRTRECT paRects)
|
---|
[3556] | 464 | {
|
---|
[51096] | 465 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 466 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[3556] | 467 |
|
---|
[28368] | 468 | /* Forward to Display, which calls corresponding framebuffers. */
|
---|
[63240] | 469 | pConsole->i_getDisplay()->i_handleQueryVisibleRegion(pcRects, paRects);
|
---|
[3556] | 470 |
|
---|
| 471 | return VINF_SUCCESS;
|
---|
| 472 | }
|
---|
| 473 |
|
---|
[26295] | 474 | /**
|
---|
| 475 | * Request the statistics interval
|
---|
| 476 | *
|
---|
| 477 | * @returns VBox status code.
|
---|
| 478 | * @param pInterface Pointer to this interface.
|
---|
| 479 | * @param pulInterval Pointer to interval in seconds
|
---|
| 480 | * @thread The emulation thread.
|
---|
| 481 | */
|
---|
| 482 | DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
|
---|
| 483 | {
|
---|
[51096] | 484 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 485 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[26295] | 486 | ULONG val = 0;
|
---|
[4513] | 487 |
|
---|
[26295] | 488 | if (!pulInterval)
|
---|
| 489 | return VERR_INVALID_POINTER;
|
---|
| 490 |
|
---|
| 491 | /* store that information in IGuest */
|
---|
[51612] | 492 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 493 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[26295] | 494 |
|
---|
[27885] | 495 | guest->COMGETTER(StatisticsUpdateInterval)(&val);
|
---|
[26295] | 496 | *pulInterval = val;
|
---|
| 497 | return VINF_SUCCESS;
|
---|
| 498 | }
|
---|
| 499 |
|
---|
[4513] | 500 | /**
|
---|
[28051] | 501 | * Query the current balloon size
|
---|
| 502 | *
|
---|
| 503 | * @returns VBox status code.
|
---|
| 504 | * @param pInterface Pointer to this interface.
|
---|
| 505 | * @param pcbBalloon Balloon size
|
---|
| 506 | * @thread The emulation thread.
|
---|
| 507 | */
|
---|
| 508 | DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon)
|
---|
| 509 | {
|
---|
[51096] | 510 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 511 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[28051] | 512 | ULONG val = 0;
|
---|
| 513 |
|
---|
| 514 | if (!pcbBalloon)
|
---|
| 515 | return VERR_INVALID_POINTER;
|
---|
| 516 |
|
---|
| 517 | /* store that information in IGuest */
|
---|
[51612] | 518 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 519 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[28051] | 520 |
|
---|
| 521 | guest->COMGETTER(MemoryBalloonSize)(&val);
|
---|
| 522 | *pcbBalloon = val;
|
---|
| 523 | return VINF_SUCCESS;
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 | /**
|
---|
[29589] | 527 | * Query the current page fusion setting
|
---|
| 528 | *
|
---|
| 529 | * @returns VBox status code.
|
---|
| 530 | * @param pInterface Pointer to this interface.
|
---|
| 531 | * @param pfPageFusionEnabled Pointer to boolean
|
---|
| 532 | * @thread The emulation thread.
|
---|
| 533 | */
|
---|
| 534 | DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
|
---|
| 535 | {
|
---|
[51096] | 536 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 537 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[29589] | 538 |
|
---|
| 539 | if (!pfPageFusionEnabled)
|
---|
| 540 | return VERR_INVALID_POINTER;
|
---|
| 541 |
|
---|
| 542 | /* store that information in IGuest */
|
---|
[51612] | 543 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 544 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[29589] | 545 |
|
---|
[52082] | 546 | *pfPageFusionEnabled = !!guest->i_isPageFusionEnabled();
|
---|
[29589] | 547 | return VINF_SUCCESS;
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | /**
|
---|
[4513] | 551 | * Report new guest statistics
|
---|
| 552 | *
|
---|
| 553 | * @returns VBox status code.
|
---|
| 554 | * @param pInterface Pointer to this interface.
|
---|
| 555 | * @param pGuestStats Guest statistics
|
---|
| 556 | * @thread The emulation thread.
|
---|
| 557 | */
|
---|
| 558 | DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
|
---|
| 559 | {
|
---|
[51096] | 560 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 561 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[4513] | 562 |
|
---|
[51096] | 563 | AssertPtrReturn(pGuestStats, VERR_INVALID_POINTER);
|
---|
[4513] | 564 |
|
---|
| 565 | /* store that information in IGuest */
|
---|
[51612] | 566 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 567 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[4513] | 568 |
|
---|
[4570] | 569 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
[52082] | 570 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle);
|
---|
[4513] | 571 |
|
---|
[4570] | 572 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
[52082] | 573 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
|
---|
[4570] | 574 |
|
---|
| 575 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
[52082] | 576 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User);
|
---|
[4570] | 577 |
|
---|
[4513] | 578 |
|
---|
[27971] | 579 | /** @todo r=bird: Convert from 4KB to 1KB units?
|
---|
[51612] | 580 | * CollectorGuestHAL::i_getGuestMemLoad says it returns KB units to
|
---|
[27971] | 581 | * preCollect(). I might be wrong ofc, this is convoluted code... */
|
---|
[4513] | 582 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
[52082] | 583 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal);
|
---|
[4513] | 584 |
|
---|
| 585 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
[52082] | 586 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail);
|
---|
[4513] | 587 |
|
---|
| 588 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
[52082] | 589 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
|
---|
[4513] | 590 |
|
---|
[4575] | 591 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
[52082] | 592 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
|
---|
[8690] | 593 |
|
---|
[4513] | 594 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
[52082] | 595 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
|
---|
[4513] | 596 |
|
---|
| 597 | return VINF_SUCCESS;
|
---|
| 598 | }
|
---|
| 599 |
|
---|
[11820] | 600 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 601 |
|
---|
| 602 | /* HGCM connector interface */
|
---|
| 603 |
|
---|
[51092] | 604 | static DECLCALLBACK(int) iface_hgcmConnect(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd,
|
---|
| 605 | PHGCMSERVICELOCATION pServiceLocation,
|
---|
| 606 | uint32_t *pu32ClientID)
|
---|
[1] | 607 | {
|
---|
[55988] | 608 | Log9(("Enter\n"));
|
---|
[1681] | 609 |
|
---|
[51096] | 610 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
[8690] | 611 |
|
---|
[1711] | 612 | if ( !pServiceLocation
|
---|
| 613 | || ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
|
---|
| 614 | && pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
|
---|
| 615 | {
|
---|
| 616 | return VERR_INVALID_PARAMETER;
|
---|
| 617 | }
|
---|
[1] | 618 |
|
---|
[70599] | 619 | /* Check if service name is a string terminated by zero*/
|
---|
| 620 | size_t cchInfo = 0;
|
---|
| 621 | if (RTStrNLenEx(pServiceLocation->u.host.achName, sizeof(pServiceLocation->u.host.achName), &cchInfo) != VINF_SUCCESS)
|
---|
| 622 | {
|
---|
| 623 | return VERR_INVALID_PARAMETER;
|
---|
| 624 | }
|
---|
| 625 |
|
---|
[32851] | 626 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
[11844] | 627 | return VERR_INVALID_STATE;
|
---|
[32851] | 628 | return HGCMGuestConnect(pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
|
---|
[1] | 629 | }
|
---|
| 630 |
|
---|
[51092] | 631 | static DECLCALLBACK(int) iface_hgcmDisconnect(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
|
---|
[1] | 632 | {
|
---|
[55988] | 633 | Log9(("Enter\n"));
|
---|
[1681] | 634 |
|
---|
[51096] | 635 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
[1] | 636 |
|
---|
[32851] | 637 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
[11844] | 638 | return VERR_INVALID_STATE;
|
---|
| 639 |
|
---|
[32851] | 640 | return HGCMGuestDisconnect(pDrv->pHGCMPort, pCmd, u32ClientID);
|
---|
[1] | 641 | }
|
---|
| 642 |
|
---|
[51092] | 643 | static DECLCALLBACK(int) iface_hgcmCall(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID,
|
---|
| 644 | uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
[1] | 645 | {
|
---|
[55988] | 646 | Log9(("Enter\n"));
|
---|
[1681] | 647 |
|
---|
[51096] | 648 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
[1] | 649 |
|
---|
[32851] | 650 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
[11844] | 651 | return VERR_INVALID_STATE;
|
---|
| 652 |
|
---|
[32851] | 653 | return HGCMGuestCall(pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms);
|
---|
[1] | 654 | }
|
---|
| 655 |
|
---|
[906] | 656 | /**
|
---|
| 657 | * Execute state save operation.
|
---|
| 658 | *
|
---|
| 659 | * @returns VBox status code.
|
---|
| 660 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 661 | * @param pSSM SSM operation handle.
|
---|
| 662 | */
|
---|
| 663 | static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
|
---|
| 664 | {
|
---|
[63244] | 665 | RT_NOREF(pDrvIns);
|
---|
[55988] | 666 | Log9(("Enter\n"));
|
---|
[32851] | 667 | return HGCMHostSaveState(pSSM);
|
---|
[906] | 668 | }
|
---|
| 669 |
|
---|
| 670 |
|
---|
| 671 | /**
|
---|
| 672 | * Execute state load operation.
|
---|
| 673 | *
|
---|
| 674 | * @returns VBox status code.
|
---|
| 675 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 676 | * @param pSSM SSM operation handle.
|
---|
[22480] | 677 | * @param uVersion Data layout version.
|
---|
[22793] | 678 | * @param uPass The data pass.
|
---|
[906] | 679 | */
|
---|
[22793] | 680 | static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
[906] | 681 | {
|
---|
[63244] | 682 | RT_NOREF(pDrvIns);
|
---|
[1681] | 683 | LogFlowFunc(("Enter\n"));
|
---|
| 684 |
|
---|
[22480] | 685 | if (uVersion != HGCM_SSM_VERSION)
|
---|
[1681] | 686 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
[22793] | 687 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
[1681] | 688 |
|
---|
[32851] | 689 | return HGCMHostLoadState(pSSM);
|
---|
[906] | 690 | }
|
---|
| 691 |
|
---|
[32851] | 692 | int VMMDev::hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName)
|
---|
[1] | 693 | {
|
---|
[32851] | 694 | if (!hgcmIsActive())
|
---|
[11409] | 695 | return VERR_INVALID_STATE;
|
---|
[32851] | 696 |
|
---|
| 697 | return HGCMHostLoad(pszServiceLibrary, pszServiceName);
|
---|
[1] | 698 | }
|
---|
| 699 |
|
---|
[32851] | 700 | int VMMDev::hgcmHostCall(const char *pszServiceName, uint32_t u32Function,
|
---|
| 701 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
[1] | 702 | {
|
---|
[32851] | 703 | if (!hgcmIsActive())
|
---|
[11409] | 704 | return VERR_INVALID_STATE;
|
---|
[51092] | 705 | return HGCMHostCall(pszServiceName, u32Function, cParms, paParms);
|
---|
[1] | 706 | }
|
---|
[5272] | 707 |
|
---|
[32851] | 708 | void VMMDev::hgcmShutdown(void)
|
---|
[5272] | 709 | {
|
---|
[11409] | 710 | ASMAtomicWriteBool(&m_fHGCMActive, false);
|
---|
[32851] | 711 | HGCMHostShutdown();
|
---|
[5272] | 712 | }
|
---|
| 713 |
|
---|
[33146] | 714 | # ifdef VBOX_WITH_CRHGSMI
|
---|
[51092] | 715 | int VMMDev::hgcmHostSvcHandleCreate(const char *pszServiceName, HGCMCVSHANDLE * phSvc)
|
---|
[33146] | 716 | {
|
---|
| 717 | if (!hgcmIsActive())
|
---|
| 718 | return VERR_INVALID_STATE;
|
---|
| 719 | return HGCMHostSvcHandleCreate(pszServiceName, phSvc);
|
---|
| 720 | }
|
---|
| 721 |
|
---|
[51092] | 722 | int VMMDev::hgcmHostSvcHandleDestroy(HGCMCVSHANDLE hSvc)
|
---|
[33146] | 723 | {
|
---|
| 724 | if (!hgcmIsActive())
|
---|
| 725 | return VERR_INVALID_STATE;
|
---|
| 726 | return HGCMHostSvcHandleDestroy(hSvc);
|
---|
| 727 | }
|
---|
| 728 |
|
---|
[51092] | 729 | int VMMDev::hgcmHostFastCallAsync(HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm,
|
---|
| 730 | PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
|
---|
[33146] | 731 | {
|
---|
| 732 | if (!hgcmIsActive())
|
---|
| 733 | return VERR_INVALID_STATE;
|
---|
| 734 | return HGCMHostFastCallAsync(hSvc, function, pParm, pfnCompletion, pvCompletion);
|
---|
| 735 | }
|
---|
| 736 | # endif
|
---|
| 737 |
|
---|
[1711] | 738 | #endif /* HGCM */
|
---|
[1] | 739 |
|
---|
| 740 |
|
---|
| 741 | /**
|
---|
[25966] | 742 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
[1] | 743 | */
|
---|
[25966] | 744 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
[1] | 745 | {
|
---|
[25966] | 746 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
| 747 | PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
| 748 |
|
---|
[25985] | 749 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
|
---|
[25984] | 750 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVCONNECTOR, &pDrv->Connector);
|
---|
[11820] | 751 | #ifdef VBOX_WITH_HGCM
|
---|
[25984] | 752 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMCONNECTOR, &pDrv->HGCMConnector);
|
---|
[1] | 753 | #endif
|
---|
[25966] | 754 | return NULL;
|
---|
[1] | 755 | }
|
---|
| 756 |
|
---|
[4021] | 757 | /**
|
---|
[45029] | 758 | * @interface_method_impl{PDMDRVREG,pfnReset}
|
---|
[1] | 759 | */
|
---|
[45029] | 760 | DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
|
---|
[1] | 761 | {
|
---|
[63259] | 762 | RT_NOREF(pDrvIns);
|
---|
[45029] | 763 | LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
|
---|
[11820] | 764 | #ifdef VBOX_WITH_HGCM
|
---|
[63259] | 765 | HGCMHostReset();
|
---|
[11820] | 766 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 767 | }
|
---|
| 768 |
|
---|
| 769 | /**
|
---|
[45029] | 770 | * @interface_method_impl{PDMDRVREG,pfnDestruct}
|
---|
[1] | 771 | */
|
---|
[45029] | 772 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
[1] | 773 | {
|
---|
[45029] | 774 | PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
|
---|
[45030] | 775 | PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[45029] | 776 | LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
| 777 |
|
---|
[11820] | 778 | #ifdef VBOX_WITH_HGCM
|
---|
[45029] | 779 | /* HGCM is shut down on the VMMDev destructor. */
|
---|
[11820] | 780 | #endif /* VBOX_WITH_HGCM */
|
---|
[45030] | 781 | if (pThis->pVMMDev)
|
---|
| 782 | pThis->pVMMDev->mpDrv = NULL;
|
---|
[1] | 783 | }
|
---|
| 784 |
|
---|
| 785 | /**
|
---|
[45029] | 786 | * @interface_method_impl{PDMDRVREG,pfnConstruct}
|
---|
[1] | 787 | */
|
---|
[22277] | 788 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
|
---|
[1] | 789 | {
|
---|
[63244] | 790 | RT_NOREF(fFlags);
|
---|
[45029] | 791 | PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
|
---|
[45030] | 792 | PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 793 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
| 794 |
|
---|
| 795 | /*
|
---|
| 796 | * Validate configuration.
|
---|
| 797 | */
|
---|
[16468] | 798 | if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
|
---|
[1] | 799 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
[22480] | 800 | AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
|
---|
[22277] | 801 | ("Configuration error: Not possible to attach anything to this driver!\n"),
|
---|
| 802 | VERR_PDM_DRVINS_NO_ATTACH);
|
---|
[16468] | 803 |
|
---|
[1] | 804 | /*
|
---|
| 805 | * IBase.
|
---|
| 806 | */
|
---|
| 807 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
| 808 |
|
---|
[45030] | 809 | pThis->Connector.pfnUpdateGuestStatus = vmmdevUpdateGuestStatus;
|
---|
[47294] | 810 | pThis->Connector.pfnUpdateGuestUserState = vmmdevUpdateGuestUserState;
|
---|
[45030] | 811 | pThis->Connector.pfnUpdateGuestInfo = vmmdevUpdateGuestInfo;
|
---|
| 812 | pThis->Connector.pfnUpdateGuestInfo2 = vmmdevUpdateGuestInfo2;
|
---|
| 813 | pThis->Connector.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
|
---|
| 814 | pThis->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
|
---|
| 815 | pThis->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
|
---|
| 816 | pThis->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
| 817 | pThis->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
| 818 | pThis->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
|
---|
| 819 | pThis->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
|
---|
| 820 | pThis->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
|
---|
| 821 | pThis->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
|
---|
| 822 | pThis->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
|
---|
| 823 | pThis->Connector.pfnReportStatistics = vmmdevReportStatistics;
|
---|
| 824 | pThis->Connector.pfnQueryStatisticsInterval = vmmdevQueryStatisticsInterval;
|
---|
| 825 | pThis->Connector.pfnQueryBalloonSize = vmmdevQueryBalloonSize;
|
---|
| 826 | pThis->Connector.pfnIsPageFusionEnabled = vmmdevIsPageFusionEnabled;
|
---|
[1] | 827 |
|
---|
[11820] | 828 | #ifdef VBOX_WITH_HGCM
|
---|
[45030] | 829 | pThis->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
| 830 | pThis->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
| 831 | pThis->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
[1] | 832 | #endif
|
---|
| 833 |
|
---|
| 834 | /*
|
---|
| 835 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
| 836 | */
|
---|
[45030] | 837 | pThis->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIVMMDEVPORT);
|
---|
| 838 | AssertMsgReturn(pThis->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
[1] | 839 |
|
---|
[11820] | 840 | #ifdef VBOX_WITH_HGCM
|
---|
[45030] | 841 | pThis->pHGCMPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIHGCMPORT);
|
---|
| 842 | AssertMsgReturn(pThis->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
[1] | 843 | #endif
|
---|
| 844 |
|
---|
| 845 | /*
|
---|
| 846 | * Get the Console object pointer and update the mpDrv member.
|
---|
| 847 | */
|
---|
| 848 | void *pv;
|
---|
[22277] | 849 | int rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
|
---|
[13835] | 850 | if (RT_FAILURE(rc))
|
---|
[1] | 851 | {
|
---|
[13837] | 852 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
|
---|
[1] | 853 | return rc;
|
---|
| 854 | }
|
---|
| 855 |
|
---|
[45030] | 856 | pThis->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
|
---|
| 857 | pThis->pVMMDev->mpDrv = pThis;
|
---|
[1] | 858 |
|
---|
[11820] | 859 | #ifdef VBOX_WITH_HGCM
|
---|
[45030] | 860 | rc = pThis->pVMMDev->hgcmLoadService(VBOXSHAREDFOLDERS_DLL,
|
---|
[32851] | 861 | "VBoxSharedFolders");
|
---|
[45030] | 862 | pThis->pVMMDev->fSharedFolderActive = RT_SUCCESS(rc);
|
---|
[13835] | 863 | if (RT_SUCCESS(rc))
|
---|
[1681] | 864 | {
|
---|
[4032] | 865 | PPDMLED pLed;
|
---|
| 866 | PPDMILEDPORTS pLedPort;
|
---|
| 867 |
|
---|
[51642] | 868 | LogRel(("Shared Folders service loaded\n"));
|
---|
[25984] | 869 | pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
|
---|
| 870 | AssertMsgReturn(pLedPort, ("Configuration error: No LED port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
[4032] | 871 | rc = pLedPort->pfnQueryStatusLed(pLedPort, 0, &pLed);
|
---|
[13835] | 872 | if (RT_SUCCESS(rc) && pLed)
|
---|
[4032] | 873 | {
|
---|
| 874 | VBOXHGCMSVCPARM parm;
|
---|
| 875 |
|
---|
| 876 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 877 | parm.u.pointer.addr = pLed;
|
---|
| 878 | parm.u.pointer.size = sizeof(*pLed);
|
---|
| 879 |
|
---|
| 880 | rc = HGCMHostCall("VBoxSharedFolders", SHFL_FN_SET_STATUS_LED, 1, &parm);
|
---|
| 881 | }
|
---|
| 882 | else
|
---|
[13837] | 883 | AssertMsgFailed(("pfnQueryStatusLed failed with %Rrc (pLed=%x)\n", rc, pLed));
|
---|
[1681] | 884 | }
|
---|
| 885 | else
|
---|
[13837] | 886 | LogRel(("Failed to load Shared Folders service %Rrc\n", rc));
|
---|
[3559] | 887 |
|
---|
[22480] | 888 | rc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SSM_VERSION, 4096 /* bad guess */,
|
---|
| 889 | NULL, NULL, NULL,
|
---|
| 890 | NULL, iface_hgcmSave, NULL,
|
---|
| 891 | NULL, iface_hgcmLoad, NULL);
|
---|
| 892 | if (RT_FAILURE(rc))
|
---|
| 893 | return rc;
|
---|
| 894 |
|
---|
[11820] | 895 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 896 |
|
---|
| 897 | return VINF_SUCCESS;
|
---|
| 898 | }
|
---|
| 899 |
|
---|
| 900 |
|
---|
| 901 | /**
|
---|
| 902 | * VMMDevice driver registration record.
|
---|
| 903 | */
|
---|
| 904 | const PDMDRVREG VMMDev::DrvReg =
|
---|
| 905 | {
|
---|
| 906 | /* u32Version */
|
---|
| 907 | PDM_DRVREG_VERSION,
|
---|
[26166] | 908 | /* szName */
|
---|
[22480] | 909 | "HGCM",
|
---|
[25893] | 910 | /* szRCMod */
|
---|
| 911 | "",
|
---|
| 912 | /* szR0Mod */
|
---|
| 913 | "",
|
---|
[1] | 914 | /* pszDescription */
|
---|
| 915 | "Main VMMDev driver (Main as in the API).",
|
---|
| 916 | /* fFlags */
|
---|
| 917 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
| 918 | /* fClass. */
|
---|
| 919 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
| 920 | /* cMaxInstances */
|
---|
[40282] | 921 | ~0U,
|
---|
[1] | 922 | /* cbInstance */
|
---|
| 923 | sizeof(DRVMAINVMMDEV),
|
---|
| 924 | /* pfnConstruct */
|
---|
| 925 | VMMDev::drvConstruct,
|
---|
| 926 | /* pfnDestruct */
|
---|
| 927 | VMMDev::drvDestruct,
|
---|
[25893] | 928 | /* pfnRelocate */
|
---|
| 929 | NULL,
|
---|
[1] | 930 | /* pfnIOCtl */
|
---|
| 931 | NULL,
|
---|
| 932 | /* pfnPowerOn */
|
---|
| 933 | NULL,
|
---|
| 934 | /* pfnReset */
|
---|
| 935 | VMMDev::drvReset,
|
---|
| 936 | /* pfnSuspend */
|
---|
| 937 | NULL,
|
---|
| 938 | /* pfnResume */
|
---|
| 939 | NULL,
|
---|
[22277] | 940 | /* pfnAttach */
|
---|
| 941 | NULL,
|
---|
[1] | 942 | /* pfnDetach */
|
---|
[22480] | 943 | NULL,
|
---|
[22277] | 944 | /* pfnPowerOff */
|
---|
[22480] | 945 | NULL,
|
---|
[22277] | 946 | /* pfnSoftReset */
|
---|
| 947 | NULL,
|
---|
| 948 | /* u32EndVersion */
|
---|
| 949 | PDM_DRVREG_VERSION
|
---|
[1] | 950 | };
|
---|
[14772] | 951 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|