VMMDevInterface.cpp revision ad48e47654d22f79b025dc4b21cb162cb123801a
/* $Id$ */
/** @file
* VBox frontends: Basic Frontend (BFE):
* Implementation of VMMDev: driver interface to VMM device
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#define LOG_GROUP LOG_GROUP_MAIN
#ifdef VBOXBFE_WITHOUT_COM
# include "COMDefs.h"
#else
#endif
#include "VBoxBFE.h"
#include "VMMDev.h"
#include "MouseImpl.h"
#include "DisplayImpl.h"
#include "ConsoleImpl.h"
#ifdef VBOX_WITH_HGCM
#include "HGCM.h"
#endif
#ifdef RT_OS_OS2
# define VBOXSHAREDFOLDERS_DLL "VBoxSFld"
#else
# define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
#endif
/**
* VMMDev driver instance data.
*/
typedef struct DRVMAINVMMDEV
{
/** Pointer to the VMMDev object. */
/** Pointer to the driver instance structure. */
/** Our VMM device connector interface. */
#ifdef VBOX_WITH_HGCM
/** Our HGCM connector interface. */
#endif
/** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
#define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
#ifdef VBOX_WITH_HGCM
/** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
#define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
#endif
{
#ifdef VBOX_WITH_HGCM
int rc = VINF_SUCCESS;
if (fActivateHGCM())
rc = HGCMHostInit();
#endif
}
{
#ifdef VBOX_WITH_HGCM
if (fActivateHGCM())
HGCMHostShutdown ();
#endif /* VBOX_WITH_HGCM */
}
{
}
/**
* Update the mouse capabilities.
* This is called when the mouse capabilities change. The new capabilities
* are given and the connector should update its internal state.
*
* @param pInterface Pointer to this interface.
* @param newCapabilities New capabilities.
* @thread The emulation thread.
*/
DECLCALLBACK(void) VMMDev::UpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
{
/*
* Tell the console interface about the event so that it can notify its consumers.
*/
if (gMouse)
if (gConsole)
gConsole->resetCursor();
}
/**
* Update the pointer shape or visibility.
*
* This is called when the mouse pointer shape changes or pointer is hidden/displaying.
* The new shape is passed as a caller allocated buffer that will be freed after returning.
*
* @param pInterface Pointer to this interface.
* @param fVisible Whether the pointer is visible or not.
* @param fAlpha Alpha channel information is present.
* @param xHot Horizontal coordinate of the pointer hot spot.
* @param yHot Vertical coordinate of the pointer hot spot.
* @param width Pointer width in pixels.
* @param height Pointer height in pixels.
* @param pShape The shape buffer. If NULL, then only pointer visibility is being changed.
* @thread The emulation thread.
*/
DECLCALLBACK(void) VMMDev::UpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
void *pShape)
{
if (gConsole)
}
DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
{
if (gDisplay)
return VINF_SUCCESS;
}
{
if (gDisplay)
gDisplay->VideoAccelFlush ();
}
DECLCALLBACK(int) iface_SetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
{
/* not implemented */
return VINF_SUCCESS;
}
DECLCALLBACK(int) iface_QueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
{
/* not implemented */
return VINF_SUCCESS;
}
DECLCALLBACK(int) VMMDev::VideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
{
(void)pDrv;
if (!fSupported)
return VERR_INVALID_PARAMETER;
*fSupported = true;
return VINF_SUCCESS;
}
DECLCALLBACK(int) VMMDev::GetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
{
(void)pDrv;
if (!heightReduction)
return VERR_INVALID_PARAMETER;
/* XXX hard-coded */
*heightReduction = 18;
return VINF_SUCCESS;
}
DECLCALLBACK(int) VMMDev::QueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pu32BalloonSize)
{
(void)pDrv;
*pu32BalloonSize = 0;
return VINF_SUCCESS;
}
#ifdef VBOX_WITH_HGCM
/* HGCM connector interface */
static DECLCALLBACK(int) iface_hgcmConnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, PHGCMSERVICELOCATION pServiceLocation, uint32_t *pu32ClientID)
{
LogSunlover(("Enter\n"));
if ( !pServiceLocation
{
return VERR_INVALID_PARAMETER;
}
}
static DECLCALLBACK(int) iface_hgcmDisconnect (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
{
LogSunlover(("Enter\n"));
}
static DECLCALLBACK(int) iface_hgcmCall (PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID, uint32_t u32Function,
{
LogSunlover(("Enter\n"));
}
/**
* Execute state save operation.
*
* @returns VBox status code.
* @param pDrvIns Driver instance of the driver which registered the data unit.
* @param pSSM SSM operation handle.
*/
{
LogSunlover(("Enter\n"));
return HGCMHostSaveState (pSSM);
}
/**
* Execute state load operation.
*
* @returns VBox status code.
* @param pDrvIns Driver instance of the driver which registered the data unit.
* @param pSSM SSM operation handle.
* @param uVersion Data layout version.
* @param uPass The data pass.
*/
static DECLCALLBACK(int) iface_hgcmLoad(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
{
LogFlowFunc(("Enter\n"));
if (uVersion != HGCM_SSM_VERSION)
return HGCMHostLoadState (pSSM);
}
{
}
{
}
#endif /* HGCM */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
#ifdef VBOX_WITH_HGCM
PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMCONNECTOR, fActivateHGCM() ? &pDrv->HGCMConnector : NULL);
#endif
return NULL;
}
/**
* Destruct a VMMDev driver instance.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
*/
{
/*PDRVMAINVMMDEV pData = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV); - unused variables makes gcc bitch. */
}
/**
* Construct a VMMDev driver instance.
*
* @copydoc FNPDMDRVCONSTRUCT
*/
{
/*
* Validate configuration.
*/
("Configuration error: Not possible to attach anything to this driver!\n"),
/*
* IBase.
*/
//pData->Connector.pfnUpdateGuestStatus = VMMDev::UpdateGuestStatus;
//pData->Connector.pfnUpdateGuestInfo = VMMDev::UpdateGuestInfo;
//pData->Connector.pfnUpdateGuestCapabilities = VMMDev::UpdateGuestCapabilities;
#ifdef VBOX_WITH_HGCM
if (fActivateHGCM())
{
}
#endif
/*
*/
AssertMsgReturn(pData->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
#ifdef VBOX_WITH_HGCM
if (fActivateHGCM())
{
AssertMsgReturn(pData->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
}
#endif
/*
* Get the VMMDev object pointer and update the mpDrv member.
*/
void *pv;
if (RT_FAILURE(rc))
{
return rc;
}
#ifdef VBOX_WITH_HGCM
if (fActivateHGCM())
{
if (RT_SUCCESS(rc))
LogRel(("Shared Folders service loaded.\n"));
else
if (RT_FAILURE(rc))
return rc;
}
#endif /* VBOX_WITH_HGCM */
return VINF_SUCCESS;
}
/**
* VMMDevice driver registration record.
*/
{
/* u32Version */
/* szName */
"HGCM",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Main VMMDev driver (Main as in the API).",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(DRVMAINVMMDEV),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};