VMMDevInterface.cpp revision 31a693ce9a8a9ebbecdcea9f24ce7f912aef4cd1
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * VirtualBox Driver Interface to VMM device.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Copyright (C) 2006-2010 Oracle Corporation
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This file is part of VirtualBox Open Source Edition (OSE), as
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * available from http://www.virtualbox.org. This file is free software;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * you can redistribute it and/or modify it under the terms of the GNU
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * General Public License (GPL) as published by the Free Software
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Foundation, in version 2 as it comes in the "COPYING" file of the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk# define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * VMMDev driver instance data.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Pointer to the VMMDev object. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Pointer to the driver instance structure. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Pointer to the VMMDev port interface of the driver/device above us. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Our VMM device connector interface. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Pointer to the HGCM port interface of the driver/device above us. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /** Our HGCM connector interface. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk#define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk/** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk#define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// constructor / destructor
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk#endif /* VBOX_WITH_HGCM */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk#endif /* VBOX_WITH_HGCM */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk// public methods
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Wait on event semaphore for guest credential judgement result.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkint VMMDev::WaitCredentialsJudgement(uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk int rc = RTSemEventWait (mCredentialsEvent, u32Timeout);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkint VMMDev::SetCredentialsJudgementResult(uint32_t u32Flags)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Reports Guest Additions status.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Called whenever the Additions issue a guest status report request or the VM is reset.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param pInterface Pointer to this interface.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param guestInfo Pointer to guest information structure
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @thread The emulation thread.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkDECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestStatus *guestStatus)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /* Store that information in IGuest */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk guest->setAdditionsStatus(guestStatus->facility, guestStatus->status, guestStatus->flags);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Reports Guest Additions API and OS version.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Called whenever the Additions issue a guest version report request or the VM is reset.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param pInterface Pointer to this interface.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param guestInfo Pointer to guest information structure.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @thread The emulation thread.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkDECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /* Store that information in IGuest */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk guest->setAdditionsInfo(Bstr(version), guestInfo->osType);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Tell the console interface about the event
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * so that it can notify its consumers.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk if (guestInfo->interfaceVersion < VMMDEV_VERSION)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * The guest additions was disabled because of a reset
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * or driver unload.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk guest->setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk guest->setAdditionsInfo2(Bstr(), Bstr(), Bstr()); /* Clear Guest Additions version. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk guest->setAdditionsStatus(VBoxGuestFacilityType_All,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk 0); /* Flags; not used. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Reports the detailed Guest Additions version.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Called whenever the Additions issue a guest version report request or the VM is reset.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param pInterface Pointer to this interface.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param guestInfo Pointer to Guest Additions information structure.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @thread The emulation thread.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkDECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo2 *guestInfo)
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk /* Store that information in IGuest. */
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
dff2cc5646d4437ab9e0cb1dcb59da65462a5938jeff.schenk RTStrPrintf(version, sizeof(version), "%d.%d.%dr%ld", guestInfo->additionsMajor,
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk RTStrPrintf(revision, sizeof(revision), "%ld", guestInfo->additionsRevision);
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk guest->setAdditionsInfo2(Bstr(version), Bstr(guestInfo->szName), Bstr(revision));
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * No need to tell the console interface about the update;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * vmmdevUpdateGuestInfo takes care of that when called as the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * last event in the chain.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * Update the guest additions capabilities.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * This is called when the guest additions capabilities change. The new capabilities
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * are given and the connector should update its internal state.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk * @param pInterface Pointer to this interface.
DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
if (!pGuest)
DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
* This is called when the mouse pointer shape changes or pointer is hidden/displaying.
DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
void *pShape)
if (pShape)
if (pShape)
pConsole->onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shapeData));
DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
if (display)
return VERR_NOT_SUPPORTED;
if (display)
DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
if (!fSupported)
return VERR_INVALID_PARAMETER;
#ifdef DEBUG_sunlover
#ifdef DEBUG_sunlover
*fSupported = true;
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
if (!heightReduction)
return VERR_INVALID_PARAMETER;
if (framebuffer)
*heightReduction = 0;
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
return VERR_GENERAL_FAILURE;
DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
if (!cRect)
return VERR_INVALID_PARAMETER;
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;
if (!guest)
return VERR_GENERAL_FAILURE;
return VINF_SUCCESS;
if (!pcbBalloon)
return VERR_INVALID_POINTER;
if (!guest)
return VERR_GENERAL_FAILURE;
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
if (!pfPageFusionEnabled)
return VERR_INVALID_POINTER;
if (!guest)
return VERR_GENERAL_FAILURE;
return VINF_SUCCESS;
DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
if (!pGuestStats)
return VERR_INVALID_POINTER;
if (!guest)
return VERR_GENERAL_FAILURE;
guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
return VINF_SUCCESS;
#ifdef VBOX_WITH_HGCM
static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
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, uint32_t u32Function,
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;
int VMMDev::hgcmHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
if (!hgcmIsActive())
return VERR_INVALID_STATE;
#ifdef VBOX_WITH_HGCM
return NULL;
#ifdef VBOX_WITH_HGCM
#ifdef VBOX_WITH_HGCM
HGCMHostReset ();
#ifdef VBOX_WITH_HGCM
AssertMsgReturn(pData->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
#ifdef VBOX_WITH_HGCM
AssertMsgReturn(pData->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,