VMMDevInterface.cpp revision e133679ffb2213d62398b4bd89cce45538706883
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/* $Id$ */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/** @file
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync * VirtualBox Driver Interface to VMM device.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/*
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Copyright (C) 2006-2014 Oracle Corporation
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
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.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "VMMDev.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "ConsoleImpl.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "DisplayImpl.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "GuestImpl.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "MouseImpl.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include "Logging.h"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#include <VBox/vmm/pdmdrv.h>
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#include <VBox/VMMDev.h>
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#include <VBox/shflsvc.h>
ab93606043a9881487aa83be04191d2f4ea24071vboxsync#include <iprt/asm.h>
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#ifdef VBOX_WITH_HGCM
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync# include "HGCM.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync# include "HGCMObjects.h"
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync# if defined(RT_OS_DARWIN) && defined(VBOX_WITH_CROGL)
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync# include <VBox/HostServices/VBoxCrOpenGLSvc.h>
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync# endif
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync#endif
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync//
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync// defines
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync//
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#ifdef RT_OS_OS2
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync# define VBOXSHAREDFOLDERS_DLL "VBoxSFld"
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync#else
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# define VBOXSHAREDFOLDERS_DLL "VBoxSharedFolders"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#endif
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync//
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync// globals
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync//
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * VMMDev driver instance data.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
7ccd30dd4bbced565b32c255a11640cd4093abb6vboxsynctypedef struct DRVMAINVMMDEV
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /** Pointer to the VMMDev object. */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync VMMDev *pVMMDev;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the driver instance structure. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PPDMDRVINS pDrvIns;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the VMMDev port interface of the driver/device above us. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PPDMIVMMDEVPORT pUpPort;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Our VMM device connector interface. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDMIVMMDEVCONNECTOR Connector;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#ifdef VBOX_WITH_HGCM
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Pointer to the HGCM port interface of the driver/device above us. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PPDMIHGCMPORT pHGCMPort;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /** Our HGCM connector interface. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDMIHGCMCONNECTOR HGCMConnector;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#endif
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync} DRVMAINVMMDEV, *PDRVMAINVMMDEV;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync//
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync// constructor / destructor
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync//
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncVMMDev::VMMDev(Console *console)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync : mpDrv(NULL),
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mParent(console)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync int rc = RTSemEventCreate(&mCredentialsEvent);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertRC(rc);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync#ifdef VBOX_WITH_HGCM
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync rc = HGCMHostInit ();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertRC(rc);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync m_fHGCMActive = true;
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync#endif /* VBOX_WITH_HGCM */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mu32CredentialsFlags = 0;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsyncVMMDev::~VMMDev()
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync{
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync#ifdef VBOX_WITH_HGCM
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync if (hgcmIsActive())
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync ASMAtomicWriteBool(&m_fHGCMActive, false);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync HGCMHostShutdown();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#endif /* VBOX_WITH_HGCM */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTSemEventDestroy (mCredentialsEvent);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if (mpDrv)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mpDrv->pVMMDev = NULL;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync mpDrv = NULL;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncPPDMIVMMDEVPORT VMMDev::getVMMDevPort()
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if (!mpDrv)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync return NULL;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync return mpDrv->pUpPort;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync//
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync// public methods
ab93606043a9881487aa83be04191d2f4ea24071vboxsync//
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync/**
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * Wait on event semaphore for guest credential judgement result.
ab93606043a9881487aa83be04191d2f4ea24071vboxsync */
ab93606043a9881487aa83be04191d2f4ea24071vboxsyncint VMMDev::WaitCredentialsJudgement(uint32_t u32Timeout, uint32_t *pu32CredentialsFlags)
ab93606043a9881487aa83be04191d2f4ea24071vboxsync{
ab93606043a9881487aa83be04191d2f4ea24071vboxsync if (u32Timeout == 0)
ab93606043a9881487aa83be04191d2f4ea24071vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync u32Timeout = 5000;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync int rc = RTSemEventWait (mCredentialsEvent, u32Timeout);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if (RT_SUCCESS(rc))
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync *pu32CredentialsFlags = mu32CredentialsFlags;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync }
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync return rc;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync}
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsyncint VMMDev::SetCredentialsJudgementResult(uint32_t u32Flags)
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync{
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync mu32CredentialsFlags = u32Flags;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync int rc = RTSemEventSignal (mCredentialsEvent);
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync AssertRC(rc);
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync return rc;
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync}
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync
2e42e0850e182e37277fe28ba5b5d1c37018e783vboxsync/**
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestStatus}
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
ab93606043a9881487aa83be04191d2f4ea24071vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus,
ab93606043a9881487aa83be04191d2f4ea24071vboxsync uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Console *pConsole = pDrv->pVMMDev->getParent();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Store that information in IGuest */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Guest* guest = pConsole->i_getGuest();
ab93606043a9881487aa83be04191d2f4ea24071vboxsync AssertPtrReturnVoid(guest);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync guest->i_setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pConsole->i_onAdditionsStateChange();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync
ab93606043a9881487aa83be04191d2f4ea24071vboxsync/**
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestUserState}
ab93606043a9881487aa83be04191d2f4ea24071vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestUserState(PPDMIVMMDEVCONNECTOR pInterface,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync const char *pszUser, const char *pszDomain,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t uState,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync const uint8_t *puDetails, uint32_t cbDetails)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync{
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertPtr(pDrv);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync Console *pConsole = pDrv->pVMMDev->getParent();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertPtr(pConsole);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Store that information in IGuest. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Guest* pGuest = pConsole->i_getGuest();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync AssertPtrReturnVoid(pGuest);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync pGuest->i_onUserStateChange(Bstr(pszUser), Bstr(pszDomain), (VBoxGuestUserState)uState,
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync puDetails, cbDetails);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync}
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Reports Guest Additions API and OS version.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * Called whenever the Additions issue a guest version report request or the VM
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * is reset.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @param pInterface Pointer to this interface.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @param guestInfo Pointer to guest information structure.
ab93606043a9881487aa83be04191d2f4ea24071vboxsync * @thread The emulation thread.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync{
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync AssertPtrReturnVoid(guestInfo);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync Console *pConsole = pDrv->pVMMDev->getParent();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync /* Store that information in IGuest */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync Guest* guest = pConsole->i_getGuest();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync AssertPtrReturnVoid(guest);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync if (guestInfo->interfaceVersion != 0)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync char version[16];
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion);
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync guest->i_setAdditionsInfo(Bstr(version), guestInfo->osType);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /*
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Tell the console interface about the event
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync * so that it can notify its consumers.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pConsole->i_onAdditionsStateChange();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if (guestInfo->interfaceVersion < VMMDEV_VERSION)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pConsole->i_onAdditionsOutdated();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync else
ab93606043a9881487aa83be04191d2f4ea24071vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /*
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * The guest additions was disabled because of a reset
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * or driver unload.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
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. */
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync RTTIMESPEC TimeSpecTS;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync RTTimeNow(&TimeSpecTS);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync guest->i_setAdditionsStatus(VBoxGuestFacilityType_All, VBoxGuestFacilityStatus_Inactive, 0 /*fFlags*/, &TimeSpecTS);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pConsole->i_onAdditionsStateChange();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync/**
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestInfo2}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync const char *pszName, uint32_t uRevision, uint32_t fFeatures)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync{
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AssertPtr(pszName);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Assert(uFullVersion);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* Store that information in IGuest. */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Guest *pGuest = pDrv->pVMMDev->getParent()->i_getGuest();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AssertPtrReturnVoid(pGuest);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /* Just pass it on... */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pGuest->i_setAdditionsInfo2(uFullVersion, pszName, uRevision, fFeatures);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /*
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.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
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.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync *
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * @param pInterface Pointer to this interface.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * @param newCapabilities New capabilities.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * @thread The emulation thread.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsyncDECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync{
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AssertPtr(pDrv);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Console *pConsole = pDrv->pVMMDev->getParent();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /* store that information in IGuest */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Guest* pGuest = pConsole->i_getGuest();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AssertPtrReturnVoid(pGuest);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /*
9364fd364e57542419416d69895877915c344826vboxsync * Report our current capabilities (and assume none is active yet).
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync pGuest->i_setSupportedFeatures(newCapabilities);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /*
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Tell the Display, so that it can update the "supports graphics"
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * capability if the graphics card has not asserted it.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Display* pDisplay = pConsole->i_getDisplay();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync AssertPtrReturnVoid(pDisplay);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync pDisplay->i_handleUpdateVMMDevSupportsGraphics(RT_BOOL(newCapabilities & VMMDEV_GUEST_SUPPORTS_GRAPHICS));
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync /*
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * Tell the console interface about the event
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync * so that it can notify its consumers.
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync */
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync pConsole->i_onAdditionsStateChange();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync/**
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 *
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param pInterface Pointer to this interface.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @param newCapabilities New capabilities.
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync * @thread The emulation thread.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Console *pConsole = pDrv->pVMMDev->getParent();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
8fdb63a0d23d1618724f651b8c3d11be48b44d35vboxsync /*
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * Tell the console interface about the event
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync * so that it can notify its consumers.
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Mouse *pMouse = pConsole->i_getMouse();
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync if (pMouse) /** @todo and if not? Can that actually happen? */
e190faad3061288ae099cd3ea8a858bd224c00a7vboxsync pMouse->i_onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK);
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync}
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
0a79c9258d8fae34fa527f125009ab507561b4edvboxsync/**
7e10aea6606a51d35041e5a85f9e4f1bd19c4062vboxsync * Update the pointer shape or visibility.
259e900197d37d0f84ed72e1d4a4eb6c11b4e301vboxsync *
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 *
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.
89dfdbb56cf9dddad3c7685b41bda1e4e4c1d6f9vboxsync */
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsyncDECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha,
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync uint32_t xHot, uint32_t yHot,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t width, uint32_t height,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync void *pShape)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Console *pConsole = pDrv->pVMMDev->getParent();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync /* tell the console about it */
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t cbShape = 0;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if (pShape)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
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 }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync pConsole->i_onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, (uint8_t *)pShape, cbShape);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Console *pConsole = pDrv->pVMMDev->getParent();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Display *display = pConsole->i_getDisplay();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if (display)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync {
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory));
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync return display->VideoAccelEnableVMMDev(fEnable, pVbvaMemory);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync }
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync return VERR_NOT_SUPPORTED;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync{
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Console *pConsole = pDrv->pVMMDev->getParent();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync Display *display = pConsole->i_getDisplay();
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync if (display)
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync {
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n"));
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync display->VideoAccelFlushVMMDev();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync }
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync}
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncDECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync uint32_t bpp, bool *fSupported)
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync{
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync Console *pConsole = pDrv->pVMMDev->getParent();
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync
68308f6fe3c9a03c39acd9615d767ad0b3b5dcedvboxsync if (!fSupported)
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync return VERR_INVALID_PARAMETER;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#ifdef DEBUG_sunlover
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync Log(("vmmdevVideoModeSupported: [%d]: %dx%dx%d\n", display, width, height, bpp));
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync#endif
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync IFramebuffer *framebuffer = NULL;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(display, &framebuffer);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync if (SUCCEEDED(hrc) && framebuffer)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync framebuffer->Release();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync }
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync else
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync#ifdef DEBUG_sunlover
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync Log(("vmmdevVideoModeSupported: hrc %x, framebuffer %p!!!\n", hrc, framebuffer));
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync#endif
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync *fSupported = true;
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync }
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync return VINF_SUCCESS;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync}
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsyncDECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync{
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync Console *pConsole = pDrv->pVMMDev->getParent();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync if (!heightReduction)
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync return VERR_INVALID_PARAMETER;
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync IFramebuffer *framebuffer = NULL;
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync HRESULT hrc = pConsole->i_getDisplay()->QueryFramebuffer(0, &framebuffer);
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync if (SUCCEEDED(hrc) && framebuffer)
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync {
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction);
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync framebuffer->Release();
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync }
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync else
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync *heightReduction = 0;
8e342a5c34610667d2b554cb86f1dc2f38a5313cvboxsync return VINF_SUCCESS;
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync}
333e7ab9cd83b32080826d06ac7b1951c684ccb5vboxsync
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsyncDECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
d605d5391db09e6395a1c091f148f4b86af84bd3vboxsync{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
if (pDrv->pVMMDev)
return pDrv->pVMMDev->SetCredentialsJudgementResult (u32Flags);
return VERR_GENERAL_FAILURE;
}
DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
Console *pConsole = pDrv->pVMMDev->getParent();
/* Forward to Display, which calls corresponding framebuffers. */
pConsole->i_getDisplay()->i_handleSetVisibleRegion(cRect, pRect);
return VINF_SUCCESS;
}
DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
Console *pConsole = pDrv->pVMMDev->getParent();
/* Forward to Display, which calls corresponding framebuffers. */
pConsole->i_getDisplay()->i_handleQueryVisibleRegion(pcRect, pRect);
return VINF_SUCCESS;
}
/**
* Request the statistics interval
*
* @returns VBox status code.
* @param pInterface Pointer to this interface.
* @param pulInterval Pointer to interval in seconds
* @thread The emulation thread.
*/
DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
Console *pConsole = pDrv->pVMMDev->getParent();
ULONG val = 0;
if (!pulInterval)
return VERR_INVALID_POINTER;
/* store that information in IGuest */
Guest* guest = pConsole->i_getGuest();
AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
guest->COMGETTER(StatisticsUpdateInterval)(&val);
*pulInterval = val;
return VINF_SUCCESS;
}
/**
* Query the current balloon size
*
* @returns VBox status code.
* @param pInterface Pointer to this interface.
* @param pcbBalloon Balloon size
* @thread The emulation thread.
*/
DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon)
{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
Console *pConsole = pDrv->pVMMDev->getParent();
ULONG val = 0;
if (!pcbBalloon)
return VERR_INVALID_POINTER;
/* store that information in IGuest */
Guest* guest = pConsole->i_getGuest();
AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
guest->COMGETTER(MemoryBalloonSize)(&val);
*pcbBalloon = val;
return VINF_SUCCESS;
}
/**
* Query the current page fusion setting
*
* @returns VBox status code.
* @param pInterface Pointer to this interface.
* @param pfPageFusionEnabled Pointer to boolean
* @thread The emulation thread.
*/
DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
Console *pConsole = pDrv->pVMMDev->getParent();
BOOL val = 0;
if (!pfPageFusionEnabled)
return VERR_INVALID_POINTER;
/* store that information in IGuest */
Guest* guest = pConsole->i_getGuest();
AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
*pfPageFusionEnabled = !!guest->i_isPageFusionEnabled();
return VINF_SUCCESS;
}
/**
* Report new guest statistics
*
* @returns VBox status code.
* @param pInterface Pointer to this interface.
* @param pGuestStats Guest statistics
* @thread The emulation thread.
*/
DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
{
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
Console *pConsole = pDrv->pVMMDev->getParent();
AssertPtrReturn(pGuestStats, VERR_INVALID_POINTER);
/* store that information in IGuest */
Guest* guest = pConsole->i_getGuest();
AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User);
/** @todo r=bird: Convert from 4KB to 1KB units?
* CollectorGuestHAL::i_getGuestMemLoad says it returns KB units to
* preCollect(). I might be wrong ofc, this is convoluted code... */
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
guest->i_setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
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"));
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
if ( !pServiceLocation
|| ( pServiceLocation->type != VMMDevHGCMLoc_LocalHost
&& pServiceLocation->type != VMMDevHGCMLoc_LocalHost_Existing))
{
return VERR_INVALID_PARAMETER;
}
if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMGuestConnect(pDrv->pHGCMPort, pCmd, pServiceLocation->u.host.achName, pu32ClientID);
}
static DECLCALLBACK(int) iface_hgcmDisconnect(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID)
{
LogSunlover(("Enter\n"));
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMGuestDisconnect(pDrv->pHGCMPort, pCmd, u32ClientID);
}
static DECLCALLBACK(int) iface_hgcmCall(PPDMIHGCMCONNECTOR pInterface, PVBOXHGCMCMD pCmd, uint32_t u32ClientID,
uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms)
{
LogSunlover(("Enter\n"));
PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMGuestCall(pDrv->pHGCMPort, pCmd, u32ClientID, u32Function, cParms, paParms);
}
/**
* 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.
*/
static DECLCALLBACK(int) iface_hgcmSave(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
{
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 VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
return HGCMHostLoadState(pSSM);
}
int VMMDev::hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName)
{
if (!hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMHostLoad(pszServiceLibrary, pszServiceName);
}
int VMMDev::hgcmHostCall(const char *pszServiceName, uint32_t u32Function,
uint32_t cParms, PVBOXHGCMSVCPARM paParms)
{
if (!hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMHostCall(pszServiceName, u32Function, cParms, paParms);
}
void VMMDev::hgcmShutdown(void)
{
ASMAtomicWriteBool(&m_fHGCMActive, false);
HGCMHostShutdown();
}
# ifdef VBOX_WITH_CRHGSMI
int VMMDev::hgcmHostSvcHandleCreate(const char *pszServiceName, HGCMCVSHANDLE * phSvc)
{
if (!hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMHostSvcHandleCreate(pszServiceName, phSvc);
}
int VMMDev::hgcmHostSvcHandleDestroy(HGCMCVSHANDLE hSvc)
{
if (!hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMHostSvcHandleDestroy(hSvc);
}
int VMMDev::hgcmHostFastCallAsync(HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm,
PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)
{
if (!hgcmIsActive())
return VERR_INVALID_STATE;
return HGCMHostFastCallAsync(hSvc, function, pParm, pfnCompletion, pvCompletion);
}
# endif
#endif /* HGCM */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
DECLCALLBACK(void *) VMMDev::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
{
PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
PDRVMAINVMMDEV pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVCONNECTOR, &pDrv->Connector);
#ifdef VBOX_WITH_HGCM
PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMCONNECTOR, &pDrv->HGCMConnector);
#endif
return NULL;
}
/**
* @interface_method_impl{PDMDRVREG,pfnReset}
*/
DECLCALLBACK(void) VMMDev::drvReset(PPDMDRVINS pDrvIns)
{
LogFlow(("VMMDev::drvReset: iInstance=%d\n", pDrvIns->iInstance));
#ifdef VBOX_WITH_HGCM
HGCMHostReset ();
#endif /* VBOX_WITH_HGCM */
}
/**
* @interface_method_impl{PDMDRVREG,pfnDestruct}
*/
DECLCALLBACK(void) VMMDev::drvDestruct(PPDMDRVINS pDrvIns)
{
PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
LogFlow(("VMMDev::drvDestruct: iInstance=%d\n", pDrvIns->iInstance));
#ifdef VBOX_WITH_HGCM
/* HGCM is shut down on the VMMDev destructor. */
#endif /* VBOX_WITH_HGCM */
if (pThis->pVMMDev)
pThis->pVMMDev->mpDrv = NULL;
}
/**
* @interface_method_impl{PDMDRVREG,pfnConstruct}
*/
DECLCALLBACK(int) VMMDev::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
{
PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
PDRVMAINVMMDEV pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINVMMDEV);
LogFlow(("Keyboard::drvConstruct: iInstance=%d\n", pDrvIns->iInstance));
/*
* Validate configuration.
*/
if (!CFGMR3AreValuesValid(pCfgHandle, "Object\0"))
return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
("Configuration error: Not possible to attach anything to this driver!\n"),
VERR_PDM_DRVINS_NO_ATTACH);
/*
* IBase.
*/
pDrvIns->IBase.pfnQueryInterface = VMMDev::drvQueryInterface;
pThis->Connector.pfnUpdateGuestStatus = vmmdevUpdateGuestStatus;
pThis->Connector.pfnUpdateGuestUserState = vmmdevUpdateGuestUserState;
pThis->Connector.pfnUpdateGuestInfo = vmmdevUpdateGuestInfo;
pThis->Connector.pfnUpdateGuestInfo2 = vmmdevUpdateGuestInfo2;
pThis->Connector.pfnUpdateGuestCapabilities = vmmdevUpdateGuestCapabilities;
pThis->Connector.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
pThis->Connector.pfnUpdatePointerShape = vmmdevUpdatePointerShape;
pThis->Connector.pfnVideoAccelEnable = iface_VideoAccelEnable;
pThis->Connector.pfnVideoAccelFlush = iface_VideoAccelFlush;
pThis->Connector.pfnVideoModeSupported = vmmdevVideoModeSupported;
pThis->Connector.pfnGetHeightReduction = vmmdevGetHeightReduction;
pThis->Connector.pfnSetCredentialsJudgementResult = vmmdevSetCredentialsJudgementResult;
pThis->Connector.pfnSetVisibleRegion = vmmdevSetVisibleRegion;
pThis->Connector.pfnQueryVisibleRegion = vmmdevQueryVisibleRegion;
pThis->Connector.pfnReportStatistics = vmmdevReportStatistics;
pThis->Connector.pfnQueryStatisticsInterval = vmmdevQueryStatisticsInterval;
pThis->Connector.pfnQueryBalloonSize = vmmdevQueryBalloonSize;
pThis->Connector.pfnIsPageFusionEnabled = vmmdevIsPageFusionEnabled;
#ifdef VBOX_WITH_HGCM
pThis->HGCMConnector.pfnConnect = iface_hgcmConnect;
pThis->HGCMConnector.pfnDisconnect = iface_hgcmDisconnect;
pThis->HGCMConnector.pfnCall = iface_hgcmCall;
#endif
/*
* Get the IVMMDevPort interface of the above driver/device.
*/
pThis->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIVMMDEVPORT);
AssertMsgReturn(pThis->pUpPort, ("Configuration error: No VMMDev port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
#ifdef VBOX_WITH_HGCM
pThis->pHGCMPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIHGCMPORT);
AssertMsgReturn(pThis->pHGCMPort, ("Configuration error: No HGCM port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
#endif
/*
* Get the Console object pointer and update the mpDrv member.
*/
void *pv;
int rc = CFGMR3QueryPtr(pCfgHandle, "Object", &pv);
if (RT_FAILURE(rc))
{
AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
return rc;
}
pThis->pVMMDev = (VMMDev*)pv; /** @todo Check this cast! */
pThis->pVMMDev->mpDrv = pThis;
#ifdef VBOX_WITH_HGCM
rc = pThis->pVMMDev->hgcmLoadService(VBOXSHAREDFOLDERS_DLL,
"VBoxSharedFolders");
pThis->pVMMDev->fSharedFolderActive = RT_SUCCESS(rc);
if (RT_SUCCESS(rc))
{
PPDMLED pLed;
PPDMILEDPORTS pLedPort;
LogRel(("Shared Folders service loaded\n"));
pLedPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMILEDPORTS);
AssertMsgReturn(pLedPort, ("Configuration error: No LED port interface above!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
rc = pLedPort->pfnQueryStatusLed(pLedPort, 0, &pLed);
if (RT_SUCCESS(rc) && pLed)
{
VBOXHGCMSVCPARM parm;
parm.type = VBOX_HGCM_SVC_PARM_PTR;
parm.u.pointer.addr = pLed;
parm.u.pointer.size = sizeof(*pLed);
rc = HGCMHostCall("VBoxSharedFolders", SHFL_FN_SET_STATUS_LED, 1, &parm);
}
else
AssertMsgFailed(("pfnQueryStatusLed failed with %Rrc (pLed=%x)\n", rc, pLed));
}
else
LogRel(("Failed to load Shared Folders service %Rrc\n", rc));
rc = PDMDrvHlpSSMRegisterEx(pDrvIns, HGCM_SSM_VERSION, 4096 /* bad guess */,
NULL, NULL, NULL,
NULL, iface_hgcmSave, NULL,
NULL, iface_hgcmLoad, NULL);
if (RT_FAILURE(rc))
return rc;
#endif /* VBOX_WITH_HGCM */
return VINF_SUCCESS;
}
/**
* VMMDevice driver registration record.
*/
const PDMDRVREG VMMDev::DrvReg =
{
/* u32Version */
PDM_DRVREG_VERSION,
/* szName */
"HGCM",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Main VMMDev driver (Main as in the API).",
/* fFlags */
PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
/* fClass. */
PDM_DRVREG_CLASS_VMMDEV,
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(DRVMAINVMMDEV),
/* pfnConstruct */
VMMDev::drvConstruct,
/* pfnDestruct */
VMMDev::drvDestruct,
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
VMMDev::drvReset,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
PDM_DRVREG_VERSION
};
/* vi: set tabstop=4 shiftwidth=4 expandtab: */