VMMDevInterface.cpp revision e133679ffb2213d62398b4bd89cce45538706883
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * VirtualBox Driver Interface to VMM device.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Copyright (C) 2006-2014 Oracle Corporation
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * available from http://www.virtualbox.org. This file is free software;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * General Public License (GPL) as published by the Free Software
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync# if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * VMMDev driver instance data.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /** Pointer to the VMMDev object. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the driver instance structure. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the VMMDev port interface of the driver/device above us. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Our VMM device connector interface. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the HGCM port interface of the driver/device above us. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Our HGCM connector interface. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync// constructor / destructor
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync#endif /* VBOX_WITH_HGCM */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#endif /* VBOX_WITH_HGCM */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync// public methods
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * Wait on event semaphore for guest credential judgement result.
ab93606043a9881487aa83be04191d2f4ea24071vboxsyncint VMMDev::WaitCredentialsJudgement(uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync int rc = RTSemEventWait (mCredentialsEvent, u32Timeout);
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsyncint VMMDev::SetCredentialsJudgementResult(uint32_t u32Flags)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestStatus}
ab93606043a9881487aa83be04191d2f4ea24071vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Store that information in IGuest */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync guest->i_setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestUserState}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestUserState(PPDMIVMMDEVCONNECTOR pInterface,
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Store that information in IGuest. */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync pGuest->i_onUserStateChange(Bstr(pszUser), Bstr(pszDomain), (VBoxGuestUserState)uState,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Reports Guest Additions API and OS version.
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * Called whenever the Additions issue a guest version report request or the VM
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * is reset.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @param pInterface Pointer to this interface.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @param guestInfo Pointer to guest information structure.
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * @thread The emulation thread.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /* Store that information in IGuest */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync guest->i_setAdditionsInfo(Bstr(version), guestInfo->osType);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Tell the console interface about the event
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync * so that it can notify its consumers.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * The guest additions was disabled because of a reset
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * or driver unload.
ab93606043a9881487aa83be04191d2f4ea24071vboxsync guest->i_setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /** @todo Would be better if GuestImpl.cpp did all this in the above method call
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * while holding down the. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync guest->i_setAdditionsInfo2(0, "", 0, 0); /* Clear Guest Additions version. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync guest->i_setAdditionsStatus(VBoxGuestFacilityType_All, VBoxGuestFacilityStatus_Inactive, 0 /*fFlags*/, &TimeSpecTS);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestInfo2}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync const char *pszName, uint32_t uRevision, uint32_t fFeatures)
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Store that information in IGuest. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Guest *pGuest = pDrv->pVMMDev->getParent()->i_getGuest();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /* Just pass it on... */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pGuest->i_setAdditionsInfo2(uFullVersion, pszName, uRevision, fFeatures);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * No need to tell the console interface about the update;
8fdb63a0d23d1618724f651b8c3d11be48b44d35vboxsync * vmmdevUpdateGuestInfo takes care of that when called as the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * last event in the chain.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Update the guest additions capabilities.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This is called when the guest additions capabilities change. The new capabilities
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * are given and the connector should update its internal state.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * @param pInterface Pointer to this interface.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * @param newCapabilities New capabilities.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @thread The emulation thread.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsyncDECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /* store that information in IGuest */
9364fd364e57542419416d69895877915c344826vboxsync * Report our current capabilities (and assume none is active yet).
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Tell the Display, so that it can update the "supports graphics"
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * capability if the graphics card has not asserted it.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync pDisplay->i_handleUpdateVMMDevSupportsGraphics(RT_BOOL(newCapabilities & VMMDEV_GUEST_SUPPORTS_GRAPHICS));
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Tell the console interface about the event
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * so that it can notify its consumers.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Update the mouse capabilities.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * This is called when the mouse capabilities change. The new capabilities
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * are given and the connector should update its internal state.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param pInterface Pointer to this interface.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param newCapabilities New capabilities.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @thread The emulation thread.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Tell the console interface about the event
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * so that it can notify its consumers.
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync if (pMouse) /** @todo and if not? Can that actually happen? */
e190faad3061288ae099cd3ea8a858bd224c00a7vboxsync pMouse->i_onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync * Update the pointer shape or visibility.
259e900197d37d0f84ed72e1d4a4eb6c11b4e301vboxsync * This is called when the mouse pointer shape changes or pointer is hidden/displaying.
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync * The new shape is passed as a caller allocated buffer that will be freed after returning.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param pInterface Pointer to this interface.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param fVisible Whether the pointer is visible or not.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param fAlpha Alpha channel information is present.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * @param xHot Horizontal coordinate of the pointer hot spot.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param yHot Vertical coordinate of the pointer hot spot.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param width Pointer width in pixels.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param height Pointer height in pixels.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @thread The emulation thread.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsyncDECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* tell the console about it */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync cbShape = (width + 7) / 8 * height; /* size of the AND mask */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync cbShape = ((cbShape + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pConsole->i_onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, (uint8_t *)pShape, cbShape);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync return display->VideoAccelEnableVMMDev(fEnable, pVbvaMemory);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync Log(("vmmdevVideoModeSupported: [%d]: %dx%dx%d\n", display, width, height, bpp));
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(display, &framebuffer);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync Log(("vmmdevVideoModeSupported: hrc %x, framebuffer %p!!!\n", hrc, framebuffer));
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsyncDECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(0, &framebuffer);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsyncDECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
return VERR_GENERAL_FAILURE;
DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
if (!pulInterval)
return VERR_INVALID_POINTER;
return VINF_SUCCESS;
if (!pcbBalloon)
return VERR_INVALID_POINTER;
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
if (!pfPageFusionEnabled)
return VERR_INVALID_POINTER;
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
return VINF_SUCCESS;
#ifdef VBOX_WITH_HGCM
if ( !pServiceLocation
return VERR_INVALID_PARAMETER;
return VERR_INVALID_STATE;
static DECLCALLBACK(int) iface_hgcmDisconnect(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
return VERR_INVALID_STATE;
static DECLCALLBACK(int) iface_hgcmCall(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID,
return VERR_INVALID_STATE;
static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
if (!hgcmIsActive())
return VERR_INVALID_STATE;
if (!hgcmIsActive())
return VERR_INVALID_STATE;
# ifdef VBOX_WITH_CRHGSMI
if (!hgcmIsActive())
return VERR_INVALID_STATE;
if (!hgcmIsActive())
return VERR_INVALID_STATE;
if (!hgcmIsActive())
return VERR_INVALID_STATE;
#ifdef VBOX_WITH_HGCM
return NULL;
#ifdef VBOX_WITH_HGCM
HGCMHostReset ();
#ifdef VBOX_WITH_HGCM
#ifdef VBOX_WITH_HGCM
AssertMsgReturn(pThis->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
#ifdef VBOX_WITH_HGCM
AssertMsgReturn(pThis->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
void *pv;
return rc;
#ifdef VBOX_WITH_HGCM
AssertMsgReturn(pLedPort, ("Configuration error: No LED port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
return rc;
return VINF_SUCCESS;
sizeof(DRVMAINVMMDEV),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,