[25966] | 1 | /* $Id: VMMDevInterface.cpp 99775 2023-05-12 12:21:58Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
[21227] | 3 | * VirtualBox Driver Interface to VMM device.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[1] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[1] | 26 | */
|
---|
| 27 |
|
---|
[67914] | 28 | #define LOG_GROUP LOG_GROUP_MAIN_VMMDEVINTERFACES
|
---|
| 29 | #include "LoggingNew.h"
|
---|
| 30 |
|
---|
[1] | 31 | #include "VMMDev.h"
|
---|
| 32 | #include "ConsoleImpl.h"
|
---|
| 33 | #include "DisplayImpl.h"
|
---|
| 34 | #include "GuestImpl.h"
|
---|
[26782] | 35 | #include "MouseImpl.h"
|
---|
[1] | 36 |
|
---|
[35346] | 37 | #include <VBox/vmm/pdmdrv.h>
|
---|
[21219] | 38 | #include <VBox/VMMDev.h>
|
---|
[4032] | 39 | #include <VBox/shflsvc.h>
|
---|
[1] | 40 | #include <iprt/asm.h>
|
---|
| 41 |
|
---|
[11820] | 42 | #ifdef VBOX_WITH_HGCM
|
---|
[35374] | 43 | # include "HGCM.h"
|
---|
| 44 | # include "HGCMObjects.h"
|
---|
[1] | 45 | #endif
|
---|
| 46 |
|
---|
| 47 | //
|
---|
| 48 | // defines
|
---|
| 49 | //
|
---|
| 50 |
|
---|
[6762] | 51 | #ifdef RT_OS_OS2
|
---|
| 52 | # define VBOXSHAREDFOLDERS_DLL "VBoxSFld"
|
---|
| 53 | #else
|
---|
| 54 | # define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
|
---|
| 55 | #endif
|
---|
[1] | 56 |
|
---|
| 57 | //
|
---|
| 58 | // globals
|
---|
| 59 | //
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * VMMDev driver instance data.
|
---|
| 64 | */
|
---|
| 65 | typedef struct DRVMAINVMMDEV
|
---|
| 66 | {
|
---|
| 67 | /** Pointer to the VMMDev object. */
|
---|
[75574] | 68 | VMMDev *pVMMDev;
|
---|
[1] | 69 | /** Pointer to the driver instance structure. */
|
---|
| 70 | PPDMDRVINS pDrvIns;
|
---|
| 71 | /** Pointer to the VMMDev port interface of the driver/device above us. */
|
---|
| 72 | PPDMIVMMDEVPORT pUpPort;
|
---|
| 73 | /** Our VMM device connector interface. */
|
---|
| 74 | PDMIVMMDEVCONNECTOR Connector;
|
---|
[4021] | 75 |
|
---|
[11820] | 76 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 77 | /** Pointer to the HGCM port interface of the driver/device above us. */
|
---|
| 78 | PPDMIHGCMPORT pHGCMPort;
|
---|
| 79 | /** Our HGCM connector interface. */
|
---|
| 80 | PDMIHGCMCONNECTOR HGCMConnector;
|
---|
| 81 | #endif
|
---|
[78915] | 82 |
|
---|
| 83 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
| 84 | HGCMSVCEXTHANDLE hHgcmSvcExtGstProps;
|
---|
| 85 | #endif
|
---|
| 86 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
| 87 | HGCMSVCEXTHANDLE hHgcmSvcExtGstCtrl;
|
---|
| 88 | #endif
|
---|
[1] | 89 | } DRVMAINVMMDEV, *PDRVMAINVMMDEV;
|
---|
| 90 |
|
---|
| 91 | //
|
---|
| 92 | // constructor / destructor
|
---|
| 93 | //
|
---|
[27607] | 94 | VMMDev::VMMDev(Console *console)
|
---|
[75955] | 95 | : mpDrv(NULL)
|
---|
| 96 | , mParent(console)
|
---|
[1] | 97 | {
|
---|
[94964] | 98 | int vrc = RTSemEventCreate(&mCredentialsEvent);
|
---|
| 99 | AssertRC(vrc);
|
---|
[11820] | 100 | #ifdef VBOX_WITH_HGCM
|
---|
[94964] | 101 | vrc = HGCMHostInit();
|
---|
| 102 | AssertRC(vrc);
|
---|
[11409] | 103 | m_fHGCMActive = true;
|
---|
[11820] | 104 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 105 | mu32CredentialsFlags = 0;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | VMMDev::~VMMDev()
|
---|
| 109 | {
|
---|
[25973] | 110 | #ifdef VBOX_WITH_HGCM
|
---|
[75574] | 111 | if (ASMAtomicCmpXchgBool(&m_fHGCMActive, false, true))
|
---|
| 112 | HGCMHostShutdown(true /*fUvmIsInvalid*/);
|
---|
| 113 | #endif
|
---|
[69017] | 114 | RTSemEventDestroy(mCredentialsEvent);
|
---|
[1] | 115 | if (mpDrv)
|
---|
| 116 | mpDrv->pVMMDev = NULL;
|
---|
| 117 | mpDrv = NULL;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | PPDMIVMMDEVPORT VMMDev::getVMMDevPort()
|
---|
| 121 | {
|
---|
[41131] | 122 | if (!mpDrv)
|
---|
| 123 | return NULL;
|
---|
[1] | 124 | return mpDrv->pUpPort;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | //
|
---|
| 130 | // public methods
|
---|
| 131 | //
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * Wait on event semaphore for guest credential judgement result.
|
---|
| 135 | */
|
---|
[32851] | 136 | int VMMDev::WaitCredentialsJudgement(uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
|
---|
[1] | 137 | {
|
---|
| 138 | if (u32Timeout == 0)
|
---|
| 139 | {
|
---|
| 140 | u32Timeout = 5000;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[94964] | 143 | int vrc = RTSemEventWait(mCredentialsEvent, u32Timeout);
|
---|
[1] | 144 |
|
---|
[94964] | 145 | if (RT_SUCCESS(vrc))
|
---|
[1] | 146 | {
|
---|
| 147 | *pu32CredentialsFlags = mu32CredentialsFlags;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
[94964] | 150 | return vrc;
|
---|
[1] | 151 | }
|
---|
| 152 |
|
---|
[32851] | 153 | int VMMDev::SetCredentialsJudgementResult(uint32_t u32Flags)
|
---|
[1] | 154 | {
|
---|
| 155 | mu32CredentialsFlags = u32Flags;
|
---|
| 156 |
|
---|
[94964] | 157 | int vrc = RTSemEventSignal(mCredentialsEvent);
|
---|
| 158 | AssertRC(vrc);
|
---|
[1] | 159 |
|
---|
[94964] | 160 | return vrc;
|
---|
[1] | 161 | }
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 | /**
|
---|
[39890] | 165 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestStatus}
|
---|
[30758] | 166 | */
|
---|
[99775] | 167 | static DECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus,
|
---|
| 168 | uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS)
|
---|
[30758] | 169 | {
|
---|
[51096] | 170 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 171 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 172 |
|
---|
[30758] | 173 | /* Store that information in IGuest */
|
---|
[51612] | 174 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 175 | AssertPtrReturnVoid(guest);
|
---|
[30758] | 176 |
|
---|
[52082] | 177 | guest->i_setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
|
---|
[51612] | 178 | pConsole->i_onAdditionsStateChange();
|
---|
[30758] | 179 | }
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | /**
|
---|
[47294] | 183 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestUserState}
|
---|
| 184 | */
|
---|
[99775] | 185 | static DECLCALLBACK(void) vmmdevUpdateGuestUserState(PPDMIVMMDEVCONNECTOR pInterface,
|
---|
| 186 | const char *pszUser, const char *pszDomain,
|
---|
| 187 | uint32_t uState,
|
---|
| 188 | const uint8_t *pabDetails, uint32_t cbDetails)
|
---|
[47294] | 189 | {
|
---|
[51096] | 190 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[47294] | 191 | AssertPtr(pDrv);
|
---|
| 192 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 193 | AssertPtr(pConsole);
|
---|
| 194 |
|
---|
| 195 | /* Store that information in IGuest. */
|
---|
[51612] | 196 | Guest* pGuest = pConsole->i_getGuest();
|
---|
[51096] | 197 | AssertPtrReturnVoid(pGuest);
|
---|
[47294] | 198 |
|
---|
[85309] | 199 | pGuest->i_onUserStateChanged(Utf8Str(pszUser), Utf8Str(pszDomain), (VBoxGuestUserState)uState, pabDetails, cbDetails);
|
---|
[47294] | 200 | }
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | /**
|
---|
[30758] | 204 | * Reports Guest Additions API and OS version.
|
---|
[1] | 205 | *
|
---|
[39882] | 206 | * Called whenever the Additions issue a guest version report request or the VM
|
---|
| 207 | * is reset.
|
---|
| 208 | *
|
---|
[1] | 209 | * @param pInterface Pointer to this interface.
|
---|
[31241] | 210 | * @param guestInfo Pointer to guest information structure.
|
---|
[1] | 211 | * @thread The emulation thread.
|
---|
| 212 | */
|
---|
[99775] | 213 | static DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
|
---|
[1] | 214 | {
|
---|
[51096] | 215 | AssertPtrReturnVoid(guestInfo);
|
---|
[51612] | 216 |
|
---|
[51096] | 217 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 218 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 219 |
|
---|
| 220 | /* Store that information in IGuest */
|
---|
[51612] | 221 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 222 | AssertPtrReturnVoid(guest);
|
---|
[1] | 223 |
|
---|
[31241] | 224 | if (guestInfo->interfaceVersion != 0)
|
---|
[8690] | 225 | {
|
---|
[31241] | 226 | char version[16];
|
---|
| 227 | RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion);
|
---|
[52082] | 228 | guest->i_setAdditionsInfo(Bstr(version), guestInfo->osType);
|
---|
[1] | 229 |
|
---|
[8690] | 230 | /*
|
---|
| 231 | * Tell the console interface about the event
|
---|
| 232 | * so that it can notify its consumers.
|
---|
| 233 | */
|
---|
[51612] | 234 | pConsole->i_onAdditionsStateChange();
|
---|
[8690] | 235 |
|
---|
[31241] | 236 | if (guestInfo->interfaceVersion < VMMDEV_VERSION)
|
---|
[51612] | 237 | pConsole->i_onAdditionsOutdated();
|
---|
[8690] | 238 | }
|
---|
| 239 | else
|
---|
[1] | 240 | {
|
---|
[8690] | 241 | /*
|
---|
[84564] | 242 | * The Guest Additions was disabled because of a reset
|
---|
[8690] | 243 | * or driver unload.
|
---|
| 244 | */
|
---|
[52082] | 245 | guest->i_setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */
|
---|
[39882] | 246 | /** @todo Would be better if GuestImpl.cpp did all this in the above method call
|
---|
| 247 | * while holding down the. */
|
---|
[52082] | 248 | guest->i_setAdditionsInfo2(0, "", 0, 0); /* Clear Guest Additions version. */
|
---|
[39890] | 249 | RTTIMESPEC TimeSpecTS;
|
---|
| 250 | RTTimeNow(&TimeSpecTS);
|
---|
[52082] | 251 | guest->i_setAdditionsStatus(VBoxGuestFacilityType_All, VBoxGuestFacilityStatus_Inactive, 0 /*fFlags*/, &TimeSpecTS);
|
---|
[51612] | 252 | pConsole->i_onAdditionsStateChange();
|
---|
[1] | 253 | }
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | /**
|
---|
[39882] | 257 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestInfo2}
|
---|
[31241] | 258 | */
|
---|
[99775] | 259 | static DECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion,
|
---|
| 260 | const char *pszName, uint32_t uRevision, uint32_t fFeatures)
|
---|
[31241] | 261 | {
|
---|
[51096] | 262 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[39882] | 263 | AssertPtr(pszName);
|
---|
| 264 | Assert(uFullVersion);
|
---|
[31241] | 265 |
|
---|
| 266 | /* Store that information in IGuest. */
|
---|
[51612] | 267 | Guest *pGuest = pDrv->pVMMDev->getParent()->i_getGuest();
|
---|
[51096] | 268 | AssertPtrReturnVoid(pGuest);
|
---|
[31241] | 269 |
|
---|
[39882] | 270 | /* Just pass it on... */
|
---|
[52082] | 271 | pGuest->i_setAdditionsInfo2(uFullVersion, pszName, uRevision, fFeatures);
|
---|
[31241] | 272 |
|
---|
[39882] | 273 | /*
|
---|
| 274 | * No need to tell the console interface about the update;
|
---|
| 275 | * vmmdevUpdateGuestInfo takes care of that when called as the
|
---|
| 276 | * last event in the chain.
|
---|
| 277 | */
|
---|
[31241] | 278 | }
|
---|
| 279 |
|
---|
| 280 | /**
|
---|
[84564] | 281 | * Update the Guest Additions capabilities.
|
---|
| 282 | * This is called when the Guest Additions capabilities change. The new capabilities
|
---|
[3582] | 283 | * are given and the connector should update its internal state.
|
---|
| 284 | *
|
---|
| 285 | * @param pInterface Pointer to this interface.
|
---|
| 286 | * @param newCapabilities New capabilities.
|
---|
| 287 | * @thread The emulation thread.
|
---|
| 288 | */
|
---|
[99775] | 289 | static DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
|
---|
[3582] | 290 | {
|
---|
[51096] | 291 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[35888] | 292 | AssertPtr(pDrv);
|
---|
[32851] | 293 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[3582] | 294 |
|
---|
| 295 | /* store that information in IGuest */
|
---|
[51612] | 296 | Guest* pGuest = pConsole->i_getGuest();
|
---|
[51096] | 297 | AssertPtrReturnVoid(pGuest);
|
---|
[3582] | 298 |
|
---|
[30758] | 299 | /*
|
---|
[33540] | 300 | * Report our current capabilities (and assume none is active yet).
|
---|
[30758] | 301 | */
|
---|
[52082] | 302 | pGuest->i_setSupportedFeatures(newCapabilities);
|
---|
[3582] | 303 |
|
---|
| 304 | /*
|
---|
[53528] | 305 | * Tell the Display, so that it can update the "supports graphics"
|
---|
| 306 | * capability if the graphics card has not asserted it.
|
---|
| 307 | */
|
---|
| 308 | Display* pDisplay = pConsole->i_getDisplay();
|
---|
| 309 | AssertPtrReturnVoid(pDisplay);
|
---|
[54023] | 310 | pDisplay->i_handleUpdateVMMDevSupportsGraphics(RT_BOOL(newCapabilities & VMMDEV_GUEST_SUPPORTS_GRAPHICS));
|
---|
[53528] | 311 |
|
---|
| 312 | /*
|
---|
[3582] | 313 | * Tell the console interface about the event
|
---|
| 314 | * so that it can notify its consumers.
|
---|
| 315 | */
|
---|
[51612] | 316 | pConsole->i_onAdditionsStateChange();
|
---|
[3582] | 317 | }
|
---|
| 318 |
|
---|
| 319 | /**
|
---|
[1] | 320 | * Update the mouse capabilities.
|
---|
| 321 | * This is called when the mouse capabilities change. The new capabilities
|
---|
| 322 | * are given and the connector should update its internal state.
|
---|
| 323 | *
|
---|
| 324 | * @param pInterface Pointer to this interface.
|
---|
[65088] | 325 | * @param fNewCaps New capabilities.
|
---|
[1] | 326 | * @thread The emulation thread.
|
---|
| 327 | */
|
---|
[99775] | 328 | static DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
|
---|
[1] | 329 | {
|
---|
[51096] | 330 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 331 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 332 |
|
---|
[1] | 333 | /*
|
---|
| 334 | * Tell the console interface about the event
|
---|
| 335 | * so that it can notify its consumers.
|
---|
| 336 | */
|
---|
[51612] | 337 | Mouse *pMouse = pConsole->i_getMouse();
|
---|
[26782] | 338 | if (pMouse) /** @todo and if not? Can that actually happen? */
|
---|
[50613] | 339 | pMouse->i_onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
|
---|
[1] | 340 | }
|
---|
| 341 |
|
---|
| 342 | /**
|
---|
| 343 | * Update the pointer shape or visibility.
|
---|
| 344 | *
|
---|
| 345 | * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
|
---|
| 346 | * The new shape is passed as a caller allocated buffer that will be freed after returning.
|
---|
| 347 | *
|
---|
| 348 | * @param pInterface Pointer to this interface.
|
---|
| 349 | * @param fVisible Whether the pointer is visible or not.
|
---|
| 350 | * @param fAlpha Alpha channel information is present.
|
---|
| 351 | * @param xHot Horizontal coordinate of the pointer hot spot.
|
---|
| 352 | * @param yHot Vertical coordinate of the pointer hot spot.
|
---|
| 353 | * @param width Pointer width in pixels.
|
---|
| 354 | * @param height Pointer height in pixels.
|
---|
| 355 | * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
|
---|
| 356 | * @thread The emulation thread.
|
---|
| 357 | */
|
---|
[99775] | 358 | static DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
| 359 | uint32_t xHot, uint32_t yHot,
|
---|
| 360 | uint32_t width, uint32_t height,
|
---|
| 361 | void *pShape)
|
---|
[1] | 362 | {
|
---|
[51096] | 363 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 364 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 365 |
|
---|
| 366 | /* tell the console about it */
|
---|
[52934] | 367 | uint32_t cbShape = 0;
|
---|
[29542] | 368 | if (pShape)
|
---|
| 369 | {
|
---|
[52934] | 370 | cbShape = (width + 7) / 8 * height; /* size of the AND mask */
|
---|
| 371 | cbShape = ((cbShape + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
|
---|
[29542] | 372 | }
|
---|
[52934] | 373 | pConsole->i_onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, (uint8_t *)pShape, cbShape);
|
---|
[1] | 374 | }
|
---|
| 375 |
|
---|
[99775] | 376 | static DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
[1] | 377 | {
|
---|
[51096] | 378 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 379 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 380 |
|
---|
[51612] | 381 | Display *display = pConsole->i_getDisplay();
|
---|
[1] | 382 |
|
---|
| 383 | if (display)
|
---|
| 384 | {
|
---|
[55988] | 385 | Log9(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
|
---|
[52652] | 386 | return display->VideoAccelEnableVMMDev(fEnable, pVbvaMemory);
|
---|
[1] | 387 | }
|
---|
| 388 |
|
---|
| 389 | return VERR_NOT_SUPPORTED;
|
---|
| 390 | }
|
---|
[99775] | 391 |
|
---|
| 392 | static DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
|
---|
[1] | 393 | {
|
---|
[51096] | 394 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 395 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 396 |
|
---|
[51612] | 397 | Display *display = pConsole->i_getDisplay();
|
---|
[1] | 398 |
|
---|
| 399 | if (display)
|
---|
| 400 | {
|
---|
[55988] | 401 | Log9(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
|
---|
[52652] | 402 | display->VideoAccelFlushVMMDev();
|
---|
[1] | 403 | }
|
---|
| 404 | }
|
---|
| 405 |
|
---|
[99775] | 406 | static DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
|
---|
| 407 | uint32_t bpp, bool *fSupported)
|
---|
[1] | 408 | {
|
---|
[51096] | 409 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 410 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 411 |
|
---|
| 412 | if (!fSupported)
|
---|
| 413 | return VERR_INVALID_PARAMETER;
|
---|
[28264] | 414 | #ifdef DEBUG_sunlover
|
---|
| 415 | Log(("vmmdevVideoModeSupported: [%d]: %dx%dx%d\n", display, width, height, bpp));
|
---|
| 416 | #endif
|
---|
| 417 | IFramebuffer *framebuffer = NULL;
|
---|
[51612] | 418 | HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(display, &framebuffer);
|
---|
[28264] | 419 | if (SUCCEEDED(hrc) && framebuffer)
|
---|
| 420 | {
|
---|
[3155] | 421 | framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
|
---|
[28264] | 422 | framebuffer->Release();
|
---|
| 423 | }
|
---|
[3155] | 424 | else
|
---|
[28264] | 425 | {
|
---|
| 426 | #ifdef DEBUG_sunlover
|
---|
| 427 | Log(("vmmdevVideoModeSupported: hrc %x, framebuffer %p!!!\n", hrc, framebuffer));
|
---|
| 428 | #endif
|
---|
[3155] | 429 | *fSupported = true;
|
---|
[28264] | 430 | }
|
---|
[1] | 431 | return VINF_SUCCESS;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
[99775] | 434 | static DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
|
---|
[1] | 435 | {
|
---|
[51096] | 436 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 437 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[1] | 438 |
|
---|
| 439 | if (!heightReduction)
|
---|
| 440 | return VERR_INVALID_PARAMETER;
|
---|
[51436] | 441 | IFramebuffer *framebuffer = NULL;
|
---|
[51612] | 442 | HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(0, &framebuffer);
|
---|
[51436] | 443 | if (SUCCEEDED(hrc) && framebuffer)
|
---|
| 444 | {
|
---|
[3155] | 445 | framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
|
---|
[51436] | 446 | framebuffer->Release();
|
---|
| 447 | }
|
---|
[3155] | 448 | else
|
---|
| 449 | *heightReduction = 0;
|
---|
[1] | 450 | return VINF_SUCCESS;
|
---|
| 451 | }
|
---|
| 452 |
|
---|
[99775] | 453 | static DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
|
---|
[1] | 454 | {
|
---|
[51096] | 455 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[1] | 456 |
|
---|
[32851] | 457 | if (pDrv->pVMMDev)
|
---|
[69017] | 458 | return pDrv->pVMMDev->SetCredentialsJudgementResult(u32Flags);
|
---|
[1] | 459 |
|
---|
[32851] | 460 | return VERR_GENERAL_FAILURE;
|
---|
[1] | 461 | }
|
---|
| 462 |
|
---|
[99775] | 463 | static DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
|
---|
[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. */
|
---|
[52064] | 469 | pConsole->i_getDisplay()->i_handleSetVisibleRegion(cRect, pRect);
|
---|
[3556] | 470 |
|
---|
| 471 | return VINF_SUCCESS;
|
---|
| 472 | }
|
---|
| 473 |
|
---|
[90691] | 474 | /**
|
---|
| 475 | * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateMonitorPositions}
|
---|
| 476 | */
|
---|
| 477 | static DECLCALLBACK(int) vmmdevUpdateMonitorPositions(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cPositions, PCRTPOINT paPositions)
|
---|
[83142] | 478 | {
|
---|
| 479 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
| 480 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
| 481 |
|
---|
[90691] | 482 | pConsole->i_getDisplay()->i_handleUpdateMonitorPositions(cPositions, paPositions);
|
---|
[83142] | 483 |
|
---|
| 484 | return VINF_SUCCESS;
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[99775] | 487 | static DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRects, PRTRECT paRects)
|
---|
[3556] | 488 | {
|
---|
[51096] | 489 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 490 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[3556] | 491 |
|
---|
[28368] | 492 | /* Forward to Display, which calls corresponding framebuffers. */
|
---|
[63240] | 493 | pConsole->i_getDisplay()->i_handleQueryVisibleRegion(pcRects, paRects);
|
---|
[3556] | 494 |
|
---|
| 495 | return VINF_SUCCESS;
|
---|
| 496 | }
|
---|
| 497 |
|
---|
[26295] | 498 | /**
|
---|
| 499 | * Request the statistics interval
|
---|
| 500 | *
|
---|
| 501 | * @returns VBox status code.
|
---|
| 502 | * @param pInterface Pointer to this interface.
|
---|
| 503 | * @param pulInterval Pointer to interval in seconds
|
---|
| 504 | * @thread The emulation thread.
|
---|
| 505 | */
|
---|
[99775] | 506 | static DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
|
---|
[26295] | 507 | {
|
---|
[51096] | 508 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 509 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[26295] | 510 | ULONG val = 0;
|
---|
[4513] | 511 |
|
---|
[26295] | 512 | if (!pulInterval)
|
---|
| 513 | return VERR_INVALID_POINTER;
|
---|
| 514 |
|
---|
| 515 | /* store that information in IGuest */
|
---|
[51612] | 516 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 517 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[26295] | 518 |
|
---|
[27885] | 519 | guest->COMGETTER(StatisticsUpdateInterval)(&val);
|
---|
[26295] | 520 | *pulInterval = val;
|
---|
| 521 | return VINF_SUCCESS;
|
---|
| 522 | }
|
---|
| 523 |
|
---|
[4513] | 524 | /**
|
---|
[28051] | 525 | * Query the current balloon size
|
---|
| 526 | *
|
---|
| 527 | * @returns VBox status code.
|
---|
| 528 | * @param pInterface Pointer to this interface.
|
---|
| 529 | * @param pcbBalloon Balloon size
|
---|
| 530 | * @thread The emulation thread.
|
---|
| 531 | */
|
---|
[99775] | 532 | static DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon)
|
---|
[28051] | 533 | {
|
---|
[51096] | 534 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 535 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[28051] | 536 | ULONG val = 0;
|
---|
| 537 |
|
---|
| 538 | if (!pcbBalloon)
|
---|
| 539 | return VERR_INVALID_POINTER;
|
---|
| 540 |
|
---|
| 541 | /* store that information in IGuest */
|
---|
[51612] | 542 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 543 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[28051] | 544 |
|
---|
| 545 | guest->COMGETTER(MemoryBalloonSize)(&val);
|
---|
| 546 | *pcbBalloon = val;
|
---|
| 547 | return VINF_SUCCESS;
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | /**
|
---|
[29589] | 551 | * Query the current page fusion setting
|
---|
| 552 | *
|
---|
| 553 | * @returns VBox status code.
|
---|
| 554 | * @param pInterface Pointer to this interface.
|
---|
| 555 | * @param pfPageFusionEnabled Pointer to boolean
|
---|
| 556 | * @thread The emulation thread.
|
---|
| 557 | */
|
---|
[99775] | 558 | static DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
|
---|
[29589] | 559 | {
|
---|
[51096] | 560 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 561 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[29589] | 562 |
|
---|
| 563 | if (!pfPageFusionEnabled)
|
---|
| 564 | return VERR_INVALID_POINTER;
|
---|
| 565 |
|
---|
| 566 | /* store that information in IGuest */
|
---|
[51612] | 567 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 568 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[29589] | 569 |
|
---|
[52082] | 570 | *pfPageFusionEnabled = !!guest->i_isPageFusionEnabled();
|
---|
[29589] | 571 | return VINF_SUCCESS;
|
---|
| 572 | }
|
---|
| 573 |
|
---|
| 574 | /**
|
---|
[4513] | 575 | * Report new guest statistics
|
---|
| 576 | *
|
---|
| 577 | * @returns VBox status code.
|
---|
| 578 | * @param pInterface Pointer to this interface.
|
---|
| 579 | * @param pGuestStats Guest statistics
|
---|
| 580 | * @thread The emulation thread.
|
---|
| 581 | */
|
---|
[99775] | 582 | static DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
|
---|
[4513] | 583 | {
|
---|
[51096] | 584 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
|
---|
[32851] | 585 | Console *pConsole = pDrv->pVMMDev->getParent();
|
---|
[4513] | 586 |
|
---|
[51096] | 587 | AssertPtrReturn(pGuestStats, VERR_INVALID_POINTER);
|
---|
[4513] | 588 |
|
---|
| 589 | /* store that information in IGuest */
|
---|
[51612] | 590 | Guest* guest = pConsole->i_getGuest();
|
---|
[51096] | 591 | AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
|
---|
[4513] | 592 |
|
---|
[4570] | 593 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
[52082] | 594 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle);
|
---|
[4513] | 595 |
|
---|
[4570] | 596 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
[52082] | 597 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
|
---|
[4570] | 598 |
|
---|
| 599 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
[52082] | 600 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User);
|
---|
[4570] | 601 |
|
---|
[4513] | 602 |
|
---|
[27971] | 603 | /** @todo r=bird: Convert from 4KB to 1KB units?
|
---|
[51612] | 604 | * CollectorGuestHAL::i_getGuestMemLoad says it returns KB units to
|
---|
[27971] | 605 | * preCollect(). I might be wrong ofc, this is convoluted code... */
|
---|
[4513] | 606 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
[52082] | 607 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal);
|
---|
[4513] | 608 |
|
---|
| 609 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
[52082] | 610 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail);
|
---|
[4513] | 611 |
|
---|
| 612 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
[52082] | 613 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
|
---|
[4513] | 614 |
|
---|
[4575] | 615 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
[52082] | 616 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
|
---|
[8690] | 617 |
|
---|
[4513] | 618 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
[52082] | 619 | guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
|
---|
[4513] | 620 |
|
---|
| 621 | return VINF_SUCCESS;
|
---|
| 622 | }
|
---|
| 623 |
|
---|
[11820] | 624 | #ifdef VBOX_WITH_HGCM
|
---|
[1] | 625 |
|
---|
| 626 | /* HGCM connector interface */
|
---|
| 627 |
|
---|
[51092] | 628 | static DECLCALLBACK(int) iface_hgcmConnect(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd,
|
---|
| 629 | PHGCMSERVICELOCATION pServiceLocation,
|
---|
| 630 | uint32_t *pu32ClientID)
|
---|
[1] | 631 | {
|
---|
[55988] | 632 | Log9(("Enter\n"));
|
---|
[1681] | 633 |
|
---|
[51096] | 634 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
[8690] | 635 |
|
---|
[1711] | 636 | if ( !pServiceLocation
|
---|
| 637 | || ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
|
---|
| 638 | && pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
|
---|
| 639 | {
|
---|
| 640 | return VERR_INVALID_PARAMETER;
|
---|
| 641 | }
|
---|
[1] | 642 |
|
---|
[70599] | 643 | /* Check if service name is a string terminated by zero*/
|
---|
| 644 | size_t cchInfo = 0;
|
---|
| 645 | if (RTStrNLenEx(pServiceLocation->u.host.achName, sizeof(pServiceLocation->u.host.achName), &cchInfo) != VINF_SUCCESS)
|
---|
| 646 | {
|
---|
| 647 | return VERR_INVALID_PARAMETER;
|
---|
| 648 | }
|
---|
| 649 |
|
---|
[32851] | 650 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
[11844] | 651 | return VERR_INVALID_STATE;
|
---|
[32851] | 652 | return HGCMGuestConnect(pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
|
---|
[1] | 653 | }
|
---|
| 654 |
|
---|
[51092] | 655 | static DECLCALLBACK(int) iface_hgcmDisconnect(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
|
---|
[1] | 656 | {
|
---|
[55988] | 657 | Log9(("Enter\n"));
|
---|
[1681] | 658 |
|
---|
[51096] | 659 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
[1] | 660 |
|
---|
[32851] | 661 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
[11844] | 662 | return VERR_INVALID_STATE;
|
---|
| 663 |
|
---|
[32851] | 664 | return HGCMGuestDisconnect(pDrv->pHGCMPort, pCmd, u32ClientID);
|
---|
[1] | 665 | }
|
---|
| 666 |
|
---|
[51092] | 667 | static DECLCALLBACK(int) iface_hgcmCall(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID,
|
---|
[75500] | 668 | uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms, uint64_t tsArrival)
|
---|
[1] | 669 | {
|
---|
[55988] | 670 | Log9(("Enter\n"));
|
---|
[1681] | 671 |
|
---|
[51096] | 672 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
[1] | 673 |
|
---|
[32851] | 674 | if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
|
---|
[11844] | 675 | return VERR_INVALID_STATE;
|
---|
| 676 |
|
---|
[75500] | 677 | return HGCMGuestCall(pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms, tsArrival);
|
---|
[1] | 678 | }
|
---|
| 679 |
|
---|
[75990] | 680 | static DECLCALLBACK(void) iface_hgcmCancelled(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t idClient)
|
---|
| 681 | {
|
---|
| 682 | Log9(("Enter\n"));
|
---|
| 683 |
|
---|
| 684 | PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
|
---|
| 685 | if ( pDrv->pVMMDev
|
---|
| 686 | && pDrv->pVMMDev->hgcmIsActive())
|
---|
| 687 | return HGCMGuestCancelled(pDrv->pHGCMPort, pCmd, idClient);
|
---|
| 688 | }
|
---|
| 689 |
|
---|
[906] | 690 | /**
|
---|
| 691 | * Execute state save operation.
|
---|
| 692 | *
|
---|
| 693 | * @returns VBox status code.
|
---|
| 694 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 695 | * @param pSSM SSM operation handle.
|
---|
| 696 | */
|
---|
[93444] | 697 | /*static*/ DECLCALLBACK(int) VMMDev::hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
|
---|
[906] | 698 | {
|
---|
[93444] | 699 | PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[55988] | 700 | Log9(("Enter\n"));
|
---|
[93444] | 701 |
|
---|
| 702 | AssertReturn(pThis->pVMMDev, VERR_INTERNAL_ERROR_2);
|
---|
| 703 | Console::SafeVMPtrQuiet ptrVM(pThis->pVMMDev->mParent);
|
---|
| 704 | AssertReturn(ptrVM.isOk(), VERR_INTERNAL_ERROR_3);
|
---|
| 705 | return HGCMHostSaveState(pSSM, ptrVM.vtable());
|
---|
[906] | 706 | }
|
---|
| 707 |
|
---|
| 708 |
|
---|
| 709 | /**
|
---|
| 710 | * Execute state load operation.
|
---|
| 711 | *
|
---|
| 712 | * @returns VBox status code.
|
---|
| 713 | * @param pDrvIns Driver instance of the driver which registered the data unit.
|
---|
| 714 | * @param pSSM SSM operation handle.
|
---|
[22480] | 715 | * @param uVersion Data layout version.
|
---|
[22793] | 716 | * @param uPass The data pass.
|
---|
[906] | 717 | */
|
---|
[93444] | 718 | /*static*/ DECLCALLBACK(int) VMMDev::hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
[906] | 719 | {
|
---|
[93444] | 720 | PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1681] | 721 | LogFlowFunc(("Enter\n"));
|
---|
| 722 |
|
---|
[75853] | 723 | if ( uVersion != HGCM_SAVED_STATE_VERSION
|
---|
| 724 | && uVersion != HGCM_SAVED_STATE_VERSION_V2)
|
---|
[1681] | 725 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
[22793] | 726 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
[1681] | 727 |
|
---|
[93444] | 728 | AssertReturn(pThis->pVMMDev, VERR_INTERNAL_ERROR_2);
|
---|
| 729 | Console::SafeVMPtrQuiet ptrVM(pThis->pVMMDev->mParent);
|
---|
| 730 | AssertReturn(ptrVM.isOk(), VERR_INTERNAL_ERROR_3);
|
---|
| 731 | return HGCMHostLoadState(pSSM, ptrVM.vtable(), uVersion);
|
---|
[906] | 732 | }
|
---|
| 733 |
|
---|
[32851] | 734 | int VMMDev::hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName)
|
---|
[1] | 735 | {
|
---|
[32851] | 736 | if (!hgcmIsActive())
|
---|
[11409] | 737 | return VERR_INVALID_STATE;
|
---|
[32851] | 738 |
|
---|
[75853] | 739 | /** @todo Construct all the services in the VMMDev::drvConstruct()!! */
|
---|
| 740 | Assert( (mpDrv && mpDrv->pHGCMPort)
|
---|
| 741 | || !strcmp(pszServiceLibrary, "VBoxHostChannel")
|
---|
| 742 | || !strcmp(pszServiceLibrary, "VBoxSharedClipboard")
|
---|
| 743 | || !strcmp(pszServiceLibrary, "VBoxDragAndDropSvc")
|
---|
| 744 | || !strcmp(pszServiceLibrary, "VBoxGuestPropSvc")
|
---|
| 745 | || !strcmp(pszServiceLibrary, "VBoxSharedCrOpenGL")
|
---|
| 746 | );
|
---|
[75495] | 747 | Console::SafeVMPtrQuiet ptrVM(mParent);
|
---|
[93444] | 748 | return HGCMHostLoad(pszServiceLibrary, pszServiceName, ptrVM.rawUVM(), ptrVM.vtable(), mpDrv ? mpDrv->pHGCMPort : NULL);
|
---|
[1] | 749 | }
|
---|
| 750 |
|
---|
[32851] | 751 | int VMMDev::hgcmHostCall(const char *pszServiceName, uint32_t u32Function,
|
---|
| 752 | uint32_t cParms, PVBOXHGCMSVCPARM paParms)
|
---|
[1] | 753 | {
|
---|
[32851] | 754 | if (!hgcmIsActive())
|
---|
[11409] | 755 | return VERR_INVALID_STATE;
|
---|
[51092] | 756 | return HGCMHostCall(pszServiceName, u32Function, cParms, paParms);
|
---|
[1] | 757 | }
|
---|
[5272] | 758 |
|
---|
[75574] | 759 | /**
|
---|
| 760 | * Used by Console::i_powerDown to shut down the services before the VM is destroyed.
|
---|
| 761 | */
|
---|
| 762 | void VMMDev::hgcmShutdown(bool fUvmIsInvalid /*= false*/)
|
---|
[5272] | 763 | {
|
---|
[78915] | 764 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
[79263] | 765 | if (mpDrv && mpDrv->hHgcmSvcExtGstProps)
|
---|
[78915] | 766 | {
|
---|
| 767 | HGCMHostUnregisterServiceExtension(mpDrv->hHgcmSvcExtGstProps);
|
---|
| 768 | mpDrv->hHgcmSvcExtGstProps = NULL;
|
---|
| 769 | }
|
---|
| 770 | #endif
|
---|
| 771 |
|
---|
| 772 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
[79263] | 773 | if (mpDrv && mpDrv->hHgcmSvcExtGstCtrl)
|
---|
[78915] | 774 | {
|
---|
| 775 | HGCMHostUnregisterServiceExtension(mpDrv->hHgcmSvcExtGstCtrl);
|
---|
| 776 | mpDrv->hHgcmSvcExtGstCtrl = NULL;
|
---|
| 777 | }
|
---|
| 778 | #endif
|
---|
| 779 |
|
---|
[75574] | 780 | if (ASMAtomicCmpXchgBool(&m_fHGCMActive, false, true))
|
---|
| 781 | HGCMHostShutdown(fUvmIsInvalid);
|
---|
[5272] | 782 | }
|
---|
| 783 |
|
---|
[1711] | 784 | #endif /* HGCM */
|
---|
[1] | 785 |
|
---|
| 786 |
|
---|
| 787 | /**
|
---|
[25966] | 788 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
[1] | 789 | */
|
---|
[25966] | 790 | DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
[1] | 791 | {
|
---|
[25966] | 792 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
| 793 | PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
| 794 |
|
---|
[25985] | 795 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
|
---|
[25984] | 796 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVCONNECTOR, &pDrv->Connector);
|
---|
[11820] | 797 | #ifdef VBOX_WITH_HGCM
|
---|
[25984] | 798 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMCONNECTOR, &pDrv->HGCMConnector);
|
---|
[1] | 799 | #endif
|
---|
[25966] | 800 | return NULL;
|
---|
[1] | 801 | }
|
---|
| 802 |
|
---|
[4021] | 803 | /**
|
---|
[75969] | 804 | * @interface_method_impl{PDMDRVREG,pfnSuspend}
|
---|
| 805 | */
|
---|
| 806 | /*static*/ DECLCALLBACK(void) VMMDev::drvSuspend(PPDMDRVINS pDrvIns)
|
---|
| 807 | {
|
---|
| 808 | RT_NOREF(pDrvIns);
|
---|
| 809 | #ifdef VBOX_WITH_HGCM
|
---|
| 810 | HGCMBroadcastEvent(HGCMNOTIFYEVENT_SUSPEND);
|
---|
| 811 | #endif
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 | /**
|
---|
| 815 | * @interface_method_impl{PDMDRVREG,pfnResume}
|
---|
| 816 | */
|
---|
| 817 | /*static*/ DECLCALLBACK(void) VMMDev::drvResume(PPDMDRVINS pDrvIns)
|
---|
| 818 | {
|
---|
| 819 | RT_NOREF(pDrvIns);
|
---|
| 820 | #ifdef VBOX_WITH_HGCM
|
---|
| 821 | HGCMBroadcastEvent(HGCMNOTIFYEVENT_RESUME);
|
---|
| 822 | #endif
|
---|
| 823 | }
|
---|
| 824 |
|
---|
| 825 | /**
|
---|
| 826 | * @interface_method_impl{PDMDRVREG,pfnPowerOff}
|
---|
| 827 | */
|
---|
| 828 | /*static*/ DECLCALLBACK(void) VMMDev::drvPowerOff(PPDMDRVINS pDrvIns)
|
---|
| 829 | {
|
---|
| 830 | RT_NOREF(pDrvIns);
|
---|
| 831 | #ifdef VBOX_WITH_HGCM
|
---|
| 832 | HGCMBroadcastEvent(HGCMNOTIFYEVENT_POWER_ON);
|
---|
| 833 | #endif
|
---|
| 834 | }
|
---|
| 835 |
|
---|
| 836 | /**
|
---|
| 837 | * @interface_method_impl{PDMDRVREG,pfnPowerOn}
|
---|
| 838 | */
|
---|
| 839 | /*static*/ DECLCALLBACK(void) VMMDev::drvPowerOn(PPDMDRVINS pDrvIns)
|
---|
| 840 | {
|
---|
| 841 | RT_NOREF(pDrvIns);
|
---|
| 842 | #ifdef VBOX_WITH_HGCM
|
---|
| 843 | HGCMBroadcastEvent(HGCMNOTIFYEVENT_POWER_ON);
|
---|
| 844 | #endif
|
---|
| 845 | }
|
---|
| 846 |
|
---|
| 847 | /**
|
---|
[45029] | 848 | * @interface_method_impl{PDMDRVREG,pfnReset}
|
---|
[1] | 849 | */
|
---|
[45029] | 850 | DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
|
---|
[1] | 851 | {
|
---|
[63259] | 852 | RT_NOREF(pDrvIns);
|
---|
[45029] | 853 | LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
|
---|
[11820] | 854 | #ifdef VBOX_WITH_HGCM
|
---|
[75991] | 855 | HGCMHostReset(false /*fForShutdown*/);
|
---|
[75969] | 856 | #endif
|
---|
[1] | 857 | }
|
---|
| 858 |
|
---|
| 859 | /**
|
---|
[45029] | 860 | * @interface_method_impl{PDMDRVREG,pfnDestruct}
|
---|
[1] | 861 | */
|
---|
[45029] | 862 | DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
|
---|
[1] | 863 | {
|
---|
[45029] | 864 | PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
|
---|
[45030] | 865 | PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[45029] | 866 | LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
| 867 |
|
---|
[78915] | 868 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
| 869 | if (pThis->hHgcmSvcExtGstProps)
|
---|
| 870 | {
|
---|
| 871 | HGCMHostUnregisterServiceExtension(pThis->hHgcmSvcExtGstProps);
|
---|
| 872 | pThis->hHgcmSvcExtGstProps = NULL;
|
---|
| 873 | }
|
---|
| 874 | #endif
|
---|
| 875 |
|
---|
| 876 | #ifdef VBOX_WITH_GUEST_CONTROL
|
---|
| 877 | if (pThis->hHgcmSvcExtGstCtrl)
|
---|
| 878 | {
|
---|
| 879 | HGCMHostUnregisterServiceExtension(pThis->hHgcmSvcExtGstCtrl);
|
---|
| 880 | pThis->hHgcmSvcExtGstCtrl = NULL;
|
---|
| 881 | }
|
---|
| 882 | #endif
|
---|
| 883 |
|
---|
[75574] | 884 | if (pThis->pVMMDev)
|
---|
| 885 | {
|
---|
[11820] | 886 | #ifdef VBOX_WITH_HGCM
|
---|
[75574] | 887 | /* When VM construction goes wrong, we prefer shutting down HGCM here
|
---|
| 888 | while pUVM is still valid, rather than in ~VMMDev. */
|
---|
| 889 | if (ASMAtomicCmpXchgBool(&pThis->pVMMDev->m_fHGCMActive, false, true))
|
---|
| 890 | HGCMHostShutdown();
|
---|
| 891 | #endif
|
---|
[45030] | 892 | pThis->pVMMDev->mpDrv = NULL;
|
---|
[75574] | 893 | }
|
---|
[1] | 894 | }
|
---|
| 895 |
|
---|
[75955] | 896 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
| 897 |
|
---|
[1] | 898 | /**
|
---|
[75955] | 899 | * Set an array of guest properties
|
---|
| 900 | */
|
---|
| 901 | void VMMDev::i_guestPropSetMultiple(void *names, void *values, void *timestamps, void *flags)
|
---|
| 902 | {
|
---|
| 903 | VBOXHGCMSVCPARM parms[4];
|
---|
| 904 |
|
---|
| 905 | parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 906 | parms[0].u.pointer.addr = names;
|
---|
| 907 | parms[0].u.pointer.size = 0; /* We don't actually care. */
|
---|
| 908 | parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 909 | parms[1].u.pointer.addr = values;
|
---|
| 910 | parms[1].u.pointer.size = 0; /* We don't actually care. */
|
---|
| 911 | parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 912 | parms[2].u.pointer.addr = timestamps;
|
---|
| 913 | parms[2].u.pointer.size = 0; /* We don't actually care. */
|
---|
| 914 | parms[3].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 915 | parms[3].u.pointer.addr = flags;
|
---|
| 916 | parms[3].u.pointer.size = 0; /* We don't actually care. */
|
---|
| 917 |
|
---|
| 918 | hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_PROPS, 4, &parms[0]);
|
---|
| 919 | }
|
---|
| 920 |
|
---|
| 921 | /**
|
---|
| 922 | * Set a single guest property
|
---|
| 923 | */
|
---|
| 924 | void VMMDev::i_guestPropSet(const char *pszName, const char *pszValue, const char *pszFlags)
|
---|
| 925 | {
|
---|
| 926 | VBOXHGCMSVCPARM parms[4];
|
---|
| 927 |
|
---|
| 928 | AssertPtrReturnVoid(pszName);
|
---|
| 929 | AssertPtrReturnVoid(pszValue);
|
---|
| 930 | AssertPtrReturnVoid(pszFlags);
|
---|
| 931 | parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 932 | parms[0].u.pointer.addr = (void *)pszName;
|
---|
| 933 | parms[0].u.pointer.size = (uint32_t)strlen(pszName) + 1;
|
---|
| 934 | parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 935 | parms[1].u.pointer.addr = (void *)pszValue;
|
---|
| 936 | parms[1].u.pointer.size = (uint32_t)strlen(pszValue) + 1;
|
---|
| 937 | parms[2].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 938 | parms[2].u.pointer.addr = (void *)pszFlags;
|
---|
| 939 | parms[2].u.pointer.size = (uint32_t)strlen(pszFlags) + 1;
|
---|
| 940 | hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_PROP, 3, &parms[0]);
|
---|
| 941 | }
|
---|
| 942 |
|
---|
| 943 | /**
|
---|
| 944 | * Set the global flags value by calling the service
|
---|
| 945 | * @returns the status returned by the call to the service
|
---|
| 946 | *
|
---|
| 947 | * @param pTable the service instance handle
|
---|
| 948 | * @param eFlags the flags to set
|
---|
| 949 | */
|
---|
| 950 | int VMMDev::i_guestPropSetGlobalPropertyFlags(uint32_t fFlags)
|
---|
| 951 | {
|
---|
| 952 | VBOXHGCMSVCPARM parm;
|
---|
| 953 | HGCMSvcSetU32(&parm, fFlags);
|
---|
[94964] | 954 | int vrc = hgcmHostCall("VBoxGuestPropSvc", GUEST_PROP_FN_HOST_SET_GLOBAL_FLAGS, 1, &parm);
|
---|
| 955 | if (RT_FAILURE(vrc))
|
---|
[75955] | 956 | {
|
---|
| 957 | char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
|
---|
| 958 | if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags)))
|
---|
| 959 | Log(("Failed to set the global flags.\n"));
|
---|
| 960 | else
|
---|
| 961 | Log(("Failed to set the global flags \"%s\".\n", szFlags));
|
---|
| 962 | }
|
---|
[94964] | 963 | return vrc;
|
---|
[75955] | 964 | }
|
---|
| 965 |
|
---|
| 966 |
|
---|
| 967 | /**
|
---|
| 968 | * Set up the Guest Property service, populate it with properties read from
|
---|
| 969 | * the machine XML and set a couple of initial properties.
|
---|
| 970 | */
|
---|
| 971 | int VMMDev::i_guestPropLoadAndConfigure()
|
---|
| 972 | {
|
---|
| 973 | Assert(mpDrv);
|
---|
| 974 | ComObjPtr<Console> ptrConsole = this->mParent;
|
---|
| 975 | AssertReturn(ptrConsole.isNotNull(), VERR_INVALID_POINTER);
|
---|
| 976 |
|
---|
[75969] | 977 | /*
|
---|
| 978 | * Load the service
|
---|
| 979 | */
|
---|
[94964] | 980 | int vrc = hgcmLoadService("VBoxGuestPropSvc", "VBoxGuestPropSvc");
|
---|
| 981 | if (RT_FAILURE(vrc))
|
---|
[75955] | 982 | {
|
---|
[94964] | 983 | LogRel(("VBoxGuestPropSvc is not available. vrc = %Rrc\n", vrc));
|
---|
[75955] | 984 | return VINF_SUCCESS; /* That is not a fatal failure. */
|
---|
| 985 | }
|
---|
| 986 |
|
---|
| 987 | /*
|
---|
| 988 | * Pull over the properties from the server.
|
---|
| 989 | */
|
---|
| 990 | SafeArray<BSTR> namesOut;
|
---|
| 991 | SafeArray<BSTR> valuesOut;
|
---|
| 992 | SafeArray<LONG64> timestampsOut;
|
---|
| 993 | SafeArray<BSTR> flagsOut;
|
---|
| 994 | HRESULT hrc = ptrConsole->i_pullGuestProperties(ComSafeArrayAsOutParam(namesOut),
|
---|
| 995 | ComSafeArrayAsOutParam(valuesOut),
|
---|
| 996 | ComSafeArrayAsOutParam(timestampsOut),
|
---|
| 997 | ComSafeArrayAsOutParam(flagsOut));
|
---|
| 998 | AssertLogRelMsgReturn(SUCCEEDED(hrc), ("hrc=%Rhrc\n", hrc), VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR);
|
---|
| 999 | size_t const cProps = namesOut.size();
|
---|
| 1000 | size_t const cAlloc = cProps + 1;
|
---|
| 1001 | AssertLogRelReturn(valuesOut.size() == cProps, VERR_INTERNAL_ERROR_2);
|
---|
| 1002 | AssertLogRelReturn(timestampsOut.size() == cProps, VERR_INTERNAL_ERROR_3);
|
---|
| 1003 | AssertLogRelReturn(flagsOut.size() == cProps, VERR_INTERNAL_ERROR_4);
|
---|
| 1004 |
|
---|
| 1005 | char szEmpty[] = "";
|
---|
| 1006 | char **papszNames = (char **)RTMemTmpAllocZ(sizeof(char *) * cAlloc);
|
---|
| 1007 | char **papszValues = (char **)RTMemTmpAllocZ(sizeof(char *) * cAlloc);
|
---|
| 1008 | LONG64 *pai64Timestamps = (LONG64 *)RTMemTmpAllocZ(sizeof(LONG64) * cAlloc);
|
---|
| 1009 | char **papszFlags = (char **)RTMemTmpAllocZ(sizeof(char *) * cAlloc);
|
---|
| 1010 | if (papszNames && papszValues && pai64Timestamps && papszFlags)
|
---|
| 1011 | {
|
---|
[94964] | 1012 | for (unsigned i = 0; RT_SUCCESS(vrc) && i < cProps; ++i)
|
---|
[75955] | 1013 | {
|
---|
[94964] | 1014 | AssertPtrBreakStmt(namesOut[i], vrc = VERR_INVALID_PARAMETER);
|
---|
| 1015 | vrc = RTUtf16ToUtf8(namesOut[i], &papszNames[i]);
|
---|
| 1016 | if (RT_FAILURE(vrc))
|
---|
[75955] | 1017 | break;
|
---|
| 1018 | if (valuesOut[i])
|
---|
[94964] | 1019 | vrc = RTUtf16ToUtf8(valuesOut[i], &papszValues[i]);
|
---|
[75955] | 1020 | else
|
---|
| 1021 | papszValues[i] = szEmpty;
|
---|
[94964] | 1022 | if (RT_FAILURE(vrc))
|
---|
[75955] | 1023 | break;
|
---|
| 1024 | pai64Timestamps[i] = timestampsOut[i];
|
---|
| 1025 | if (flagsOut[i])
|
---|
[94964] | 1026 | vrc = RTUtf16ToUtf8(flagsOut[i], &papszFlags[i]);
|
---|
[75955] | 1027 | else
|
---|
| 1028 | papszFlags[i] = szEmpty;
|
---|
| 1029 | }
|
---|
[94964] | 1030 | if (RT_SUCCESS(vrc))
|
---|
[75955] | 1031 | i_guestPropSetMultiple((void *)papszNames, (void *)papszValues, (void *)pai64Timestamps, (void *)papszFlags);
|
---|
| 1032 | for (unsigned i = 0; i < cProps; ++i)
|
---|
| 1033 | {
|
---|
| 1034 | RTStrFree(papszNames[i]);
|
---|
| 1035 | if (valuesOut[i])
|
---|
| 1036 | RTStrFree(papszValues[i]);
|
---|
| 1037 | if (flagsOut[i])
|
---|
| 1038 | RTStrFree(papszFlags[i]);
|
---|
| 1039 | }
|
---|
| 1040 | }
|
---|
| 1041 | else
|
---|
[94964] | 1042 | vrc = VERR_NO_MEMORY;
|
---|
[75955] | 1043 | RTMemTmpFree(papszNames);
|
---|
| 1044 | RTMemTmpFree(papszValues);
|
---|
| 1045 | RTMemTmpFree(pai64Timestamps);
|
---|
| 1046 | RTMemTmpFree(papszFlags);
|
---|
[94964] | 1047 | AssertRCReturn(vrc, vrc);
|
---|
[75955] | 1048 |
|
---|
| 1049 | /*
|
---|
| 1050 | * Register the host notification callback
|
---|
| 1051 | */
|
---|
[78915] | 1052 | HGCMHostRegisterServiceExtension(&mpDrv->hHgcmSvcExtGstProps, "VBoxGuestPropSvc", Console::i_doGuestPropNotification, ptrConsole.m_p);
|
---|
[75955] | 1053 |
|
---|
| 1054 | # ifdef VBOX_WITH_GUEST_PROPS_RDONLY_GUEST
|
---|
[94964] | 1055 | vrc = i_guestPropSetGlobalPropertyFlags(GUEST_PROP_F_RDONLYGUEST);
|
---|
| 1056 | AssertRCReturn(vrc, vrc);
|
---|
[75955] | 1057 | # endif
|
---|
| 1058 |
|
---|
| 1059 | Log(("Set VBoxGuestPropSvc property store\n"));
|
---|
| 1060 | return VINF_SUCCESS;
|
---|
| 1061 | }
|
---|
| 1062 |
|
---|
| 1063 | #endif /* VBOX_WITH_GUEST_PROPS */
|
---|
| 1064 |
|
---|
| 1065 | /**
|
---|
[45029] | 1066 | * @interface_method_impl{PDMDRVREG,pfnConstruct}
|
---|
[1] | 1067 | */
|
---|
[93444] | 1068 | DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
|
---|
[1] | 1069 | {
|
---|
[45029] | 1070 | PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
|
---|
[93444] | 1071 | RT_NOREF(fFlags, pCfg);
|
---|
[45030] | 1072 | PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
|
---|
[1] | 1073 | LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
|
---|
| 1074 |
|
---|
| 1075 | /*
|
---|
| 1076 | * Validate configuration.
|
---|
| 1077 | */
|
---|
[93444] | 1078 | PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns, "", "");
|
---|
[22480] | 1079 | AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
|
---|
[22277] | 1080 | ("Configuration error: Not possible to attach anything to this driver!\n"),
|
---|
| 1081 | VERR_PDM_DRVINS_NO_ATTACH);
|
---|
[16468] | 1082 |
|
---|
[1] | 1083 | /*
|
---|
| 1084 | * IBase.
|
---|
| 1085 | */
|
---|
| 1086 | pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
|
---|
| 1087 |
|
---|
[45030] | 1088 | pThis->Connector.pfnUpdateGuestStatus = vmmdevUpdateGuestStatus;
|
---|
[47294] | 1089 | pThis->Connector.pfnUpdateGuestUserState = vmmdevUpdateGuestUserState;
|
---|
[45030] | 1090 | pThis->Connector.pfnUpdateGuestInfo = vmmdevUpdateGuestInfo;
|
---|
| 1091 | pThis->Connector.pfnUpdateGuestInfo2 = vmmdevUpdateGuestInfo2;
|
---|
| 1092 | pThis->Connector.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
|
---|
| 1093 | pThis->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
|
---|
| 1094 | pThis->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
|
---|
| 1095 | pThis->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
|
---|
| 1096 | pThis->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
|
---|
| 1097 | pThis->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
|
---|
| 1098 | pThis->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
|
---|
| 1099 | pThis->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
|
---|
| 1100 | pThis->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
|
---|
[83142] | 1101 | pThis->Connector.pfnUpdateMonitorPositions = vmmdevUpdateMonitorPositions;
|
---|
[45030] | 1102 | pThis->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
|
---|
| 1103 | pThis->Connector.pfnReportStatistics = vmmdevReportStatistics;
|
---|
| 1104 | pThis->Connector.pfnQueryStatisticsInterval = vmmdevQueryStatisticsInterval;
|
---|
| 1105 | pThis->Connector.pfnQueryBalloonSize = vmmdevQueryBalloonSize;
|
---|
| 1106 | pThis->Connector.pfnIsPageFusionEnabled = vmmdevIsPageFusionEnabled;
|
---|
[1] | 1107 |
|
---|
[11820] | 1108 | #ifdef VBOX_WITH_HGCM
|
---|
[45030] | 1109 | pThis->HGCMConnector.pfnConnect = iface_hgcmConnect;
|
---|
| 1110 | pThis->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
|
---|
| 1111 | pThis->HGCMConnector.pfnCall = iface_hgcmCall;
|
---|
[75990] | 1112 | pThis->HGCMConnector.pfnCancelled = iface_hgcmCancelled;
|
---|
[1] | 1113 | #endif
|
---|
| 1114 |
|
---|
| 1115 | /*
|
---|
| 1116 | * Get the IVMMDevPort interface of the above driver/device.
|
---|
| 1117 | */
|
---|
[45030] | 1118 | pThis->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIVMMDEVPORT);
|
---|
| 1119 | AssertMsgReturn(pThis->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
[1] | 1120 |
|
---|
[11820] | 1121 | #ifdef VBOX_WITH_HGCM
|
---|
[45030] | 1122 | pThis->pHGCMPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIHGCMPORT);
|
---|
| 1123 | AssertMsgReturn(pThis->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
[1] | 1124 | #endif
|
---|
| 1125 |
|
---|
| 1126 | /*
|
---|
| 1127 | * Get the Console object pointer and update the mpDrv member.
|
---|
| 1128 | */
|
---|
[89952] | 1129 | com::Guid uuid(VMMDEV_OID);
|
---|
[93444] | 1130 | pThis->pVMMDev = (VMMDev *)PDMDrvHlpQueryGenericUserObject(pDrvIns, uuid.raw());
|
---|
[89952] | 1131 | if (!pThis->pVMMDev)
|
---|
[1] | 1132 | {
|
---|
[89952] | 1133 | AssertMsgFailed(("Configuration error: No/bad VMMDev object!\n"));
|
---|
| 1134 | return VERR_NOT_FOUND;
|
---|
[1] | 1135 | }
|
---|
[45030] | 1136 | pThis->pVMMDev->mpDrv = pThis;
|
---|
[1] | 1137 |
|
---|
[94964] | 1138 | int vrc = VINF_SUCCESS;
|
---|
[11820] | 1139 | #ifdef VBOX_WITH_HGCM
|
---|
[75853] | 1140 | /*
|
---|
| 1141 | * Load & configure the shared folders service.
|
---|
| 1142 | */
|
---|
[94964] | 1143 | vrc = pThis->pVMMDev->hgcmLoadService(VBOXSHAREDFOLDERS_DLL, "VBoxSharedFolders");
|
---|
| 1144 | pThis->pVMMDev->fSharedFolderActive = RT_SUCCESS(vrc);
|
---|
| 1145 | if (RT_SUCCESS(vrc))
|
---|
[1681] | 1146 | {
|
---|
[4032] | 1147 | PPDMLED pLed;
|
---|
| 1148 | PPDMILEDPORTS pLedPort;
|
---|
| 1149 |
|
---|
[51642] | 1150 | LogRel(("Shared Folders service loaded\n"));
|
---|
[25984] | 1151 | pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
|
---|
| 1152 | AssertMsgReturn(pLedPort, ("Configuration error: No LED port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
|
---|
[94964] | 1153 | vrc = pLedPort->pfnQueryStatusLed(pLedPort, 0, &pLed);
|
---|
| 1154 | if (RT_SUCCESS(vrc) && pLed)
|
---|
[4032] | 1155 | {
|
---|
| 1156 | VBOXHGCMSVCPARM parm;
|
---|
| 1157 |
|
---|
| 1158 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
| 1159 | parm.u.pointer.addr = pLed;
|
---|
| 1160 | parm.u.pointer.size = sizeof(*pLed);
|
---|
| 1161 |
|
---|
[94964] | 1162 | vrc = HGCMHostCall("VBoxSharedFolders", SHFL_FN_SET_STATUS_LED, 1, &parm);
|
---|
[4032] | 1163 | }
|
---|
| 1164 | else
|
---|
[94964] | 1165 | AssertMsgFailed(("pfnQueryStatusLed failed with %Rrc (pLed=%x)\n", vrc, pLed));
|
---|
[1681] | 1166 | }
|
---|
| 1167 | else
|
---|
[94964] | 1168 | LogRel(("Failed to load Shared Folders service %Rrc\n", vrc));
|
---|
[3559] | 1169 |
|
---|
[75853] | 1170 |
|
---|
| 1171 | /*
|
---|
[75955] | 1172 | * Load and configure the guest control service.
|
---|
[75853] | 1173 | */
|
---|
| 1174 | # ifdef VBOX_WITH_GUEST_CONTROL
|
---|
[94964] | 1175 | vrc = pThis->pVMMDev->hgcmLoadService("VBoxGuestControlSvc", "VBoxGuestControlSvc");
|
---|
| 1176 | if (RT_SUCCESS(vrc))
|
---|
[75853] | 1177 | {
|
---|
[94964] | 1178 | vrc = HGCMHostRegisterServiceExtension(&pThis->hHgcmSvcExtGstCtrl, "VBoxGuestControlSvc",
|
---|
| 1179 | &Guest::i_notifyCtrlDispatcher,
|
---|
| 1180 | pThis->pVMMDev->mParent->i_getGuest());
|
---|
| 1181 | if (RT_SUCCESS(vrc))
|
---|
[75853] | 1182 | LogRel(("Guest Control service loaded\n"));
|
---|
| 1183 | else
|
---|
[94964] | 1184 | LogRel(("Warning: Cannot register VBoxGuestControlSvc extension! vrc=%Rrc\n", vrc));
|
---|
[75853] | 1185 | }
|
---|
| 1186 | else
|
---|
[94964] | 1187 | LogRel(("Warning!: Failed to load the Guest Control Service! %Rrc\n", vrc));
|
---|
[75853] | 1188 | # endif /* VBOX_WITH_GUEST_CONTROL */
|
---|
| 1189 |
|
---|
| 1190 |
|
---|
| 1191 | /*
|
---|
[75955] | 1192 | * Load and configure the guest properties service.
|
---|
| 1193 | */
|
---|
| 1194 | # ifdef VBOX_WITH_GUEST_PROPS
|
---|
[94964] | 1195 | vrc = pThis->pVMMDev->i_guestPropLoadAndConfigure();
|
---|
| 1196 | AssertLogRelRCReturn(vrc, vrc);
|
---|
[75955] | 1197 | # endif
|
---|
| 1198 |
|
---|
| 1199 |
|
---|
| 1200 | /*
|
---|
[75853] | 1201 | * The HGCM saved state.
|
---|
| 1202 | */
|
---|
[94964] | 1203 | vrc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SAVED_STATE_VERSION, 4096 /* bad guess */,
|
---|
| 1204 | NULL, NULL, NULL,
|
---|
| 1205 | NULL, VMMDev::hgcmSave, NULL,
|
---|
| 1206 | NULL, VMMDev::hgcmLoad, NULL);
|
---|
| 1207 | if (RT_FAILURE(vrc))
|
---|
| 1208 | return vrc;
|
---|
[22480] | 1209 |
|
---|
[11820] | 1210 | #endif /* VBOX_WITH_HGCM */
|
---|
[1] | 1211 |
|
---|
| 1212 | return VINF_SUCCESS;
|
---|
| 1213 | }
|
---|
| 1214 |
|
---|
| 1215 |
|
---|
| 1216 | /**
|
---|
| 1217 | * VMMDevice driver registration record.
|
---|
| 1218 | */
|
---|
| 1219 | const PDMDRVREG VMMDev::DrvReg =
|
---|
| 1220 | {
|
---|
| 1221 | /* u32Version */
|
---|
| 1222 | PDM_DRVREG_VERSION,
|
---|
[26166] | 1223 | /* szName */
|
---|
[22480] | 1224 | "HGCM",
|
---|
[25893] | 1225 | /* szRCMod */
|
---|
| 1226 | "",
|
---|
| 1227 | /* szR0Mod */
|
---|
| 1228 | "",
|
---|
[1] | 1229 | /* pszDescription */
|
---|
| 1230 | "Main VMMDev driver (Main as in the API).",
|
---|
| 1231 | /* fFlags */
|
---|
| 1232 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
| 1233 | /* fClass. */
|
---|
| 1234 | PDM_DRVREG_CLASS_VMMDEV,
|
---|
| 1235 | /* cMaxInstances */
|
---|
[40282] | 1236 | ~0U,
|
---|
[1] | 1237 | /* cbInstance */
|
---|
| 1238 | sizeof(DRVMAINVMMDEV),
|
---|
| 1239 | /* pfnConstruct */
|
---|
| 1240 | VMMDev::drvConstruct,
|
---|
| 1241 | /* pfnDestruct */
|
---|
| 1242 | VMMDev::drvDestruct,
|
---|
[25893] | 1243 | /* pfnRelocate */
|
---|
| 1244 | NULL,
|
---|
[1] | 1245 | /* pfnIOCtl */
|
---|
| 1246 | NULL,
|
---|
| 1247 | /* pfnPowerOn */
|
---|
[75969] | 1248 | VMMDev::drvPowerOn,
|
---|
[1] | 1249 | /* pfnReset */
|
---|
| 1250 | VMMDev::drvReset,
|
---|
| 1251 | /* pfnSuspend */
|
---|
[75969] | 1252 | VMMDev::drvSuspend,
|
---|
[1] | 1253 | /* pfnResume */
|
---|
[75969] | 1254 | VMMDev::drvResume,
|
---|
[22277] | 1255 | /* pfnAttach */
|
---|
| 1256 | NULL,
|
---|
[1] | 1257 | /* pfnDetach */
|
---|
[22480] | 1258 | NULL,
|
---|
[22277] | 1259 | /* pfnPowerOff */
|
---|
[75969] | 1260 | VMMDev::drvPowerOff,
|
---|
[22277] | 1261 | /* pfnSoftReset */
|
---|
| 1262 | NULL,
|
---|
| 1263 | /* u32EndVersion */
|
---|
| 1264 | PDM_DRVREG_VERSION
|
---|
[1] | 1265 | };
|
---|
[14772] | 1266 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|