VBoxDev.cpp revision 24d466e56e3082b3497e64b59d6ecdd42359258d
/** @file
*
* Virtual communication device
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/* #define LOG_ENABLED */
#define TIMESYNC_BACKDOOR
#include <stdio.h>
#include <string.h>
#include <VBox/VBoxGuest.h>
#define LOG_GROUP LOG_GROUP_DEV_VMM
#include "VMMDevState.h"
#ifdef VBOX_HGCM
#include "VMMDevHGCM.h"
#endif
#define VBOX_GUEST_ADDITIONS_VERSION_1_03(s) \
#define VBOX_GUEST_ADDITIONS_VERSION_OK(additionsVersion) \
#define VBOX_GUEST_ADDITIONS_VERSION_OLD(additionsVersion) \
#define VBOX_GUEST_ADDITIONS_VERSION_NEW(additionsVersion) \
/* Whenever host wants to inform guest about something
* an IRQ notification will be raised.
*
* VMMDev PDM interface will contain the guest notification method.
*
* There is a 32 bit event mask which will be read
* by guest on an interrupt. A non zero bit in the mask
* means that the specific event occured and requires
* processing on guest side.
*
* After reading the event mask guest must issue a
* generic request AcknowlegdeEvents.
*
* IRQ line is set to 1 (request) if there are unprocessed
* events, that is the event mask is not zero.
*
* After receiving an interrupt and checking event mask,
* the guest must process events using the event specific
* mechanism.
*
* That is if mouse capabilities were changed,
* guest will use VMMDev_GetMouseStatus generic request.
*
* Event mask is only a set of flags indicating that guest
* must proceed with a procedure.
*
* Unsupported events are therefore ignored.
* The guest additions must inform host which events they
* want to receive, to avoid unnecessary IRQ processing.
* By default no events are signalled to guest.
*
* This seems to be fast method. It requires
* only one context switch for an event processing.
*
*/
{
if (!pVMMDevState->fu32AdditionsOk)
{
Log(("vmmdevSetIRQ: IRQ is not generated, guest has not yet reported to us.\n"));
return;
}
uint32_t u32IRQLevel = 0;
/* Filter unsupported events */
Log(("vmmdevSetIRQ: u32EventFlags = 0x%08X, "
"pVMMDevState->u32HostEventFlags = 0x%08X, "
"pVMMDevState->pVMMDevRAMHC->u32GuestEventMask = 0x%08X\n",
/* Move event flags to VMMDev RAM */
if (u32EventFlags)
{
/* Clear host flags which will be delivered to guest. */
Log(("vmmdevSetIRQ: pVMMDevState->u32HostEventFlags = 0x%08X\n",
u32IRQLevel = 1;
}
/* Set IRQ level for pin 0 */
/** @todo make IRQ pin configurable, at least a symbolic constant */
}
{
#ifdef DEBUG_sunlover
Log(("vmmdevMaybeSetIRQ_EMT: u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
#endif /* DEBUG_sunlover */
{
#ifdef DEBUG_sunlover
Log(("vmmdevMaybeSetIRQ_EMT: IRQ set.\n"));
#endif /* DEBUG_sunlover */
}
}
{
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
{
#ifdef DEBUG_sunlover
Log(("VMMDevNotifyGuest_EMT: Old additions detected.\n"));
#endif /* DEBUG_sunlover */
}
else
{
#ifdef DEBUG_sunlover
Log(("VMMDevNotifyGuest_EMT: New additions detected.\n"));
#endif /* DEBUG_sunlover */
if (!pVMMDevState->fu32AdditionsOk)
{
Log(("vmmdevNotifyGuest_EMT: IRQ is not generated, guest has not yet reported to us.\n"));
return;
}
const bool fHadEvents =
#ifdef DEBUG_sunlover
Log(("VMMDevNotifyGuest_EMT: fHadEvents = %d, u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
#endif /* DEBUG_sunlover */
if (!fHadEvents)
}
}
{
const bool fHadEvents =
if (fHadEvents)
{
if (!pVMMDevState->fNewGuestFilterMask)
pVMMDevState->fNewGuestFilterMask = true;
}
else
{
}
}
{
int rc;
#ifdef DEBUG_sunlover
#endif /* DEBUG_sunlover */
VMR3ReqFree (pReq);
}
/**
* Port I/O Handler for OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param uPort Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
#define LOG_GROUP LOG_GROUP_DEV_VMM_BACKDOOR
static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
{
/* The raw version. */
switch (u32)
{
}
/* The readable, buffered version. */
{
}
else
{
{
}
}
}
return VINF_SUCCESS;
}
#define LOG_GROUP LOG_GROUP_DEV_VMM
#ifdef TIMESYNC_BACKDOOR
/**
* Port I/O Handler for OUT operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param uPort Port number used for the IN operation.
* @param u32 The value to output.
* @param cb The value size in bytes.
*/
static DECLCALLBACK(int) vmmdevTimesyncBackdoorWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb == 4)
{
switch (u32)
{
case 0:
pData->fTimesyncBackdoorLo = false;
break;
case 1:
pData->fTimesyncBackdoorLo = true;
}
return VINF_SUCCESS;
}
return VINF_SUCCESS;
}
/**
* Port I/O Handler for backdoor timesync IN operations.
*
* @returns VBox status code.
*
* @param pDevIns The device instance.
* @param pvUser User argument - ignored.
* @param uPort Port number used for the IN operation.
* @param pu32 Where to store the result.
* @param cb Number of bytes read.
*/
static DECLCALLBACK(int) vmmdevTimesyncBackdoorRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
int rc;
if (cb == 4)
{
if (pData->fTimesyncBackdoorLo)
{
}
else
{
}
rc = VINF_SUCCESS;
}
else
return rc;
}
#endif /* TIMESYNC_BACKDOOR */
/**
* Port I/O Handler for the generic request interface
* @see FNIOMIOPORTOUT for details.
*/
static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
int rc;
/*
* The caller has passed the guest context physical address
* of the request structure. Get the corresponding host virtual
* address.
*/
{
AssertMsgFailed(("VMMDev could not convert guest physical address to host virtual! rc = %Vrc\n", rc));
return VINF_SUCCESS;
}
/* the structure size must be greater or equal to the header size */
{
return VINF_SUCCESS;
}
/* check the version of the header structure */
{
Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader->version, VMMDEV_REQUEST_HEADER_VERSION));
return VINF_SUCCESS;
}
&& !pData->fu32AdditionsOk)
{
Log(("VMMDev: guest has not yet reported to us. Refusing operation.\n"));
return VINF_SUCCESS;
}
/* which request was sent? */
switch (requestHeader->requestType)
{
/*
* Guest wants to give up a timeslice
*/
case VMMDevReq_Idle:
{
/* just return to EMT telling it that we want to halt */
return VINF_EM_HALT;
break;
}
/*
* Guest is reporting its information
*/
{
{
AssertMsgFailed(("VMMDev guest information structure has invalid size!\n"));
}
else
{
{
/* make a copy of supplied information */
/* Check additions version */
LogRel(("Guest Additions information report:\t"
" additionsVersion = 0x%08X\t"
" osType = 0x%08X\n",
}
if (pData->fu32AdditionsOk)
{
}
else
{
}
}
break;
}
/*
* Retrieve mouse information
*/
case VMMDevReq_GetMouseStatus:
{
{
AssertMsgFailed(("VMMDev mouse status structure has invalid size!\n"));
}
else
{
mouseStatus->mouseFeatures = 0;
{
}
{
}
{
}
}
break;
}
/*
* Set mouse information
*/
case VMMDevReq_SetMouseStatus:
{
{
AssertMsgFailed(("VMMDev mouse status structure has invalid size %d (%#x) version=%d!\n",
}
else
{
bool bCapsChanged = false;
/* check if the guest wants absolute coordinates */
{
/* set the capability flag and the changed flag if it's actually a change */
{
bCapsChanged = true;
LogRel(("Guest requests mouse pointer integration\n"));
}
} else
{
{
bCapsChanged = true;
LogRel(("Guest disables mouse pointer integration\n"));
}
}
else
/*
* Notify connector if something has changed
*/
if (bCapsChanged)
{
Log(("VMMDevReq_SetMouseStatus: capabilities changed (%x), informing connector\n", pData->mouseCapabilities));
}
}
break;
}
/*
* Set a new mouse pointer shape
*/
{
{
AssertMsg(requestHeader->size == 0x10028 && requestHeader->version == 10000, /* don't bitch about legacy!!! */
("VMMDev mouse shape structure has invalid size %d (%#x) version=%d!\n",
}
else
{
Log(("VMMDevReq_SetPointerShape: visible: %d, alpha: %d, shape = %d, width: %d, height: %d\n",
/* forward call to driver */
if (fShape)
{
}
else
{
0,
0, 0,
0, 0,
NULL);
}
}
break;
}
/*
* Query the system time from the host
*/
case VMMDevReq_GetHostTime:
{
{
AssertMsgFailed(("VMMDev host time structure has invalid size!\n"));
}
else
{
}
break;
}
/*
* Query information about the hypervisor
*/
{
{
AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n"));
}
else
{
size_t hypervisorSize = 0;
}
break;
}
/*
* Set hypervisor information
*/
{
{
AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n"));
}
else
{
if (hypervisorInfo->hypervisorStart == 0)
{
} else
{
/* only if the client has queried the size before! */
{
/* new reservation */
LogRel(("Guest reported fixed hypervisor window at 0x%p (size = 0x%x, rc = %Vrc)\n",
requestHeader->rc));
}
}
}
break;
}
/*
* Set the system power status
*/
case VMMDevReq_SetPowerStatus:
{
{
AssertMsgFailed(("VMMDev power state request structure has invalid size!\n"));
}
else
{
switch(powerStateRequest->powerState)
{
case VMMDevPowerState_Pause:
{
LogRel(("Guest requests the VM to be suspended (paused)\n"));
break;
}
{
LogRel(("Guest requests the VM to be turned off\n"));
break;
}
{
/** @todo no API for that yet */
break;
}
default:
break;
}
}
break;
}
/*
* Get display change request
*/
{
{
/* Assert only if the size also not equal to a previous version size to prevent
* assertion with old additions.
*/
("VMMDev display change request structure has invalid size!\n"));
}
else
{
/* just pass on the information */
Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d\n",
pData->displayChangeRequest.xres, pData->displayChangeRequest.yres, pData->displayChangeRequest.bpp));
{
/* Remember which resolution the client have queried. */
}
}
break;
}
/*
* Query whether the given video mode is supported
*/
{
{
AssertMsgFailed(("VMMDev video mode supported request structure has invalid size!\n"));
}
else
{
VMMDevVideoModeSupportedRequest *videoModeSupportedRequest = (VMMDevVideoModeSupportedRequest*)requestHeader;
/* forward the call */
}
break;
}
/*
* Query the height reduction in pixels
*/
{
{
AssertMsgFailed(("VMMDev height reduction request structure has invalid size!\n"));
}
else
{
VMMDevGetHeightReductionRequest *heightReductionRequest = (VMMDevGetHeightReductionRequest*)requestHeader;
/* forward the call */
}
break;
}
/*
* Acknowledge VMMDev events
*/
{
{
AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n"));
}
else
{
{
}
else
{
if (pData->fNewGuestFilterMask)
{
pData->fNewGuestFilterMask = false;
}
}
}
break;
}
/*
* Change guest filter mask
*/
{
{
AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n"));
}
else
{
}
break;
}
#ifdef VBOX_HGCM
/*
* Process HGCM request
*/
case VMMDevReq_HGCMConnect:
{
{
AssertMsgFailed(("VMMDevReq_HGCMConnect structure has invalid size!\n"));
}
{
Log(("VMMDevReq_HGCMConnect HGCM Connector is NULL!\n"));
}
else
{
Log(("VMMDevReq_HGCMConnect\n"));
}
break;
}
case VMMDevReq_HGCMDisconnect:
{
{
AssertMsgFailed(("VMMDevReq_HGCMDisconnect structure has invalid size!\n"));
}
{
Log(("VMMDevReq_HGCMDisconnect HGCM Connector is NULL!\n"));
}
else
{
Log(("VMMDevReq_VMMDevHGCMDisconnect\n"));
}
break;
}
case VMMDevReq_HGCMCall:
{
{
AssertMsgFailed(("VMMDevReq_HGCMCall structure has invalid size!\n"));
}
{
Log(("VMMDevReq_HGCMCall HGCM Connector is NULL!\n"));
}
else
{
}
break;
}
#endif
{
{
Log(("VMMDevReq_VideoAccelEnable request size too small!!!\n"));
}
{
Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!!\n"));
}
else
{
{
/* The guest driver seems compiled with another headers. */
Log(("VMMDevReq_VideoAccelEnable guest ring buffer size %d, should be %d!!!\n", ptr->cbRingBuffer, VBVA_RING_BUFFER_SIZE));
}
else
{
/* The request is correct. */
{
/* Remember that guest successfully enabled acceleration.
* We need to reestablish it on restoring the VM from saved state.
*/
}
else
{
/* The acceleration was not enabled. Remember that. */
pData->u32VideoAccelEnabled = 0;
}
}
}
break;
}
{
{
AssertMsgFailed(("VMMDevReq_VideoAccelFlush request size too small.\n"));
}
{
Log(("VMMDevReq_VideoAccelFlush Connector is NULL!\n"));
}
else
{
}
break;
}
{
{
AssertMsgFailed(("VMMDevReq_QueryCredentials request size too small.\n"));
}
else
{
/* let's start by nulling out the data */
/* should we return whether we got credentials for a logon? */
{
{
}
else
{
}
}
/* does the guest want to read logon credentials? */
{
else
}
/* does the caller want us to destroy the logon credentials? */
{
}
/* does the guest want to read credentials for verification? */
{
}
/* does the caller want us to destroy the judgement credentials? */
{
}
}
break;
}
{
{
AssertMsgFailed(("VMMDevReq_ReportCredentialsJudgement request size too small.\n"));
}
else
{
/* what does the guest think about the credentials? (note: the order is important here!) */
{
}
{
}
{
}
else
}
break;
}
default:
{
break;
}
}
return VINF_SUCCESS;
}
/**
* Callback function for mapping an PCI I/O region.
*
* @return VBox status code.
* @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
* @param iRegion The region number.
* @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
* I/O port, else it's a physical address.
* This address is *NOT* relative to pci_mem_base like earlier!
* @param enmType One of the PCI_ADDRESS_SPACE_* values.
*/
static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
{
int rc;
LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%VGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
/*
* VMMDev RAM mapping.
*/
{
/*
* Register and lock the RAM.
*
* Windows usually re-initializes the PCI devices, so we have to check whether the memory was
* already registered before trying to do that all over again.
*/
if (pData->GCPhysVMMDevRAM)
{
/*
* Relocate the already registered VMMDevRAM.
*/
if (VBOX_SUCCESS(rc))
{
return VINF_SUCCESS;
}
AssertReleaseMsgFailed(("Failed to relocate VMMDev RAM from %VGp to %VGp! rc=%Vra\n", pData->GCPhysVMMDevRAM, GCPhysAddress, rc));
}
else
{
/*
* Register and lock the VMMDevRAM.
*/
/** @todo MM_RAM_FLAGS_MMIO2 seems to be appropriate for a RW memory.
* Need to check. May be a RO memory is enough for the device.
*/
rc = MMR3PhysRegister(pVM, pData->pVMMDevRAMHC, GCPhysAddress, VMMDEV_RAM_SIZE, MM_RAM_FLAGS_MMIO2, "VBoxDev");
if (VBOX_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
return rc;
}
return VERR_INTERNAL_ERROR;
}
/**
* Callback function for mapping a PCI I/O region.
*
* @return VBox status code.
* @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
* @param iRegion The region number.
* @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
* I/O port, else it's a physical address.
* This address is *NOT* relative to pci_mem_base like earlier!
* @param enmType One of the PCI_ADDRESS_SPACE_* values.
*/
static DECLCALLBACK(int) vmmdevIOPortRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
{
int rc = VINF_SUCCESS;
AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
/*
* Save the base port address to simplify Port offset calculations.
*/
/*
* Register our port IO handlers.
*/
(void*)pData, vmmdevRequestHandler,
return rc;
}
/**
* Queries an interface to the driver.
*
* @returns Pointer to interface.
* @returns NULL if the interface was not supported by the driver.
* @param pInterface Pointer to this interface structure.
* @param enmInterface The requested interface identification.
* @thread Any thread.
*/
static DECLCALLBACK(void *) vmmdevPortQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
{
switch (enmInterface)
{
case PDMINTERFACE_BASE:
case PDMINTERFACE_VMMDEV_PORT:
#ifdef VBOX_HGCM
case PDMINTERFACE_HGCM_PORT:
#endif
default:
return NULL;
}
}
/* -=-=-=-=-=- IVMMDevPort -=-=-=-=-=- */
/** Converts a VMMDev port interface pointer to a VMMDev state pointer. */
#define IVMMDEVPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState*)((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, Port)) )
/**
* Return the current absolute mouse position in pixels
*
* @returns VBox status code
* @param pAbsX Pointer of result value, can be NULL
* @param pAbsY Pointer of result value, can be NULL
*/
static DECLCALLBACK(int) vmmdevQueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, uint32_t *pAbsX, uint32_t *pAbsY)
{
if (pAbsX)
if (pAbsY)
return VINF_SUCCESS;
}
/**
* Set the new absolute mouse position in pixels
*
* @returns VBox status code
* @param absX New absolute X position
* @param absY New absolute Y position
*/
static DECLCALLBACK(int) vmmdevSetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, uint32_t absX, uint32_t absY)
{
return VINF_SUCCESS;
}
/**
* Return the current mouse capability flags
*
* @returns VBox status code
* @param pCapabilities Pointer of result value
*/
static DECLCALLBACK(int) vmmdevQueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pCapabilities)
{
if (!pCapabilities)
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
}
/**
* Set the current mouse capability flag (host side)
*
* @returns VBox status code
* @param capabilities Capability mask
*/
static DECLCALLBACK(int) vmmdevSetMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t capabilities)
{
else
else
if (bCapsChanged)
return VINF_SUCCESS;
}
static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres, uint32_t bpp)
{
/* Verify that the new resolution is different and that guest does not yet know about it. */
{
/* Special case of reset video mode. */
fSameResolution = false;
}
#ifdef DEBUG_sunlover
Log(("vmmdevRequestDisplayChange: same=%d. new: xres=%d, yres=%d, bpp=%d. old: xres=%d, yres=%d, bpp=%d.\n",
fSameResolution, xres, yres, bpp, pData->lastReadDisplayChangeRequest.xres, pData->lastReadDisplayChangeRequest.yres, pData->lastReadDisplayChangeRequest.bpp));
#endif /* DEBUG_sunlover */
if (!fSameResolution)
{
/* we could validate the information here but hey, the guest can do that as well! */
/* IRQ so the guest knows what's going on */
}
return VINF_SUCCESS;
}
const char *pszPassword, const char *pszDomain,
{
/* logon mode? */
{
/* memorize the data */
}
/* credentials verification mode? */
else if (u32Flags & VMMDEV_SETCREDENTIALS_JUDGE)
{
/* memorize the data */
}
else
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
}
/**
* Notification from the Display. Especially useful when
* acceleration is disabled after a video mode change.
*
* @param fEnable Current acceleration status.
*/
{
if (pData)
{
}
return;
}
/* -=-=-=-=-=- IHGCMPort -=-=-=-=-=- */
/** Converts a VMMDev port interface pointer to a VMMDev state pointer. */
#define IHGCMPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState*)((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, HGCMPort)) )
#define VMMDEV_SSM_VERSION 2
/**
* Saves a state of the VMM device.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param pSSMHandle The handle to save the state to.
*/
{
// here be dragons (probably)
// SSMR3PutBool(pSSMHandle, pData->pVMMDevRAMHC->V.V1_04.fHaveEvents);
return VINF_SUCCESS;
}
/**
* Loads the saved VMM device state.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param pSSMHandle The handle to the saved state.
* @param u32Version The data unit version number.
*/
static DECLCALLBACK(int) vmmdevLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t u32Version)
{
if (u32Version != VMMDEV_SSM_VERSION)
// SSMR3GetBool(pSSMHandle, &pData->pVMMDevRAMHC->fHaveEvents);
// here be dragons (probably)
/*
* On a resume, we send the capabilities changed message so
* that listeners can sync their state again
*/
Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pData->mouseCapabilities));
/* Reestablish the acceleration status. */
if (pData->u32VideoAccelEnabled)
{
pData->pDrv->pfnVideoAccelEnable (pData->pDrv, !!pData->u32VideoAccelEnabled, &pData->pVMMDevRAMHC->vbvaMemory);
}
return VINF_SUCCESS;
}
/**
* Load state done callback. Notify guest of restore event.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param pSSMHandle The handle to the saved state.
*/
{
return VINF_SUCCESS;
}
/**
* Construct a device instance for a VM.
*
* @returns VBox status.
* @param pDevIns The device instance data.
* If the registration structure is needed, pDevIns->pDevReg points to it.
* @param iInstance Instance number. Use this to figure out which registers and such to use.
* The device number is also found in pDevIns->iInstance, but since it's
* likely to be freqently used PDM passes it as parameter.
* @param pCfgHandle Configuration node handle for the device. Use this to obtain the configuration
* of the device instance. It's also found in pDevIns->pCfgHandle, but like
* iInstance it's expected to be used a bit in this function.
*/
{
int rc;
/*
* Validate configuration.
*/
/*
* Initialize data (most of it anyway).
*/
/* PCI vendor, just a free bogus value */
/* device ID */
/* class sub code (other type of system peripheral) */
/* class base code (base system peripheral) */
/* header type */
/* interrupt on pin 0 */
/*
* Register the backdoor logging port
*/
rc = PDMDevHlpIOPortRegister(pDevIns, RTLOG_DEBUG_PORT, 1, NULL, vmmdevBackdoorLog, NULL, NULL, NULL, "VMMDev backdoor logging");
#ifdef TIMESYNC_BACKDOOR
/*
* Alternative timesync source (temporary!)
*/
rc = PDMDevHlpIOPortRegister(pDevIns, 0x505, 1, NULL, vmmdevTimesyncBackdoorWrite, vmmdevTimesyncBackdoorRead, NULL, NULL, "VMMDev timesync backdoor");
#endif
/*
* Register the PCI device.
*/
if (VBOX_FAILURE(rc))
return rc;
Log(("!!WARNING!!: pData->dev.devfn=%d (ignore if testcase or no started by Main)\n", pData->dev.devfn));
if (VBOX_FAILURE(rc))
return rc;
rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);
if (VBOX_FAILURE(rc))
return rc;
/*
* Interfaces
*/
/* Base */
/* VMMDev port */
#ifdef VBOX_HGCM
/* HGCM port */
#endif
/* * Get the corresponding connector interface
*/
if (VBOX_SUCCESS(rc))
{
pData->pDrv = (PPDMIVMMDEVCONNECTOR)pData->pDrvBase->pfnQueryInterface(pData->pDrvBase, PDMINTERFACE_VMMDEV_CONNECTOR);
{
}
#ifdef VBOX_HGCM
else
{
pData->pHGCMDrv = (PPDMIHGCMCONNECTOR)pData->pDrvBase->pfnQueryInterface(pData->pDrvBase, PDMINTERFACE_HGCM_CONNECTOR);
{
/* this is not actually an error, just means that there is no support for HGCM */
}
}
#endif
}
else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
{
Log(("%s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
rc = VINF_SUCCESS;
}
else
/* Save PDM device instance data for future reference. */
/*
* Allocate the VMMDev RAM region.
*/
/** @todo freeing of the RAM. */
if (VBOX_FAILURE(rc))
{
}
/* initialize the VMMDev memory */
return rc;
}
/**
* Reset notification.
*
* @returns VBox status.
* @param pDrvIns The driver instance data.
*/
{
/*
* Reset the mouse integration feature bit
*/
{
/* notify the connector */
}
pData->hypervisorSize = 0;
pData->u32HostEventFlags = 0;
if (pData->pVMMDevRAMHC)
{
}
/* credentials have to go away */
/* Reset means that additions will report again. */
pData->fu32AdditionsOk = false;
/* Clear the event variables.
*
* Note: The pData->u32HostEventFlags is not cleared.
* It is designed that way so host events do not
* depend on guest resets.
*/
pData->u32GuestFilterMask = 0;
pData->u32NewGuestFilterMask = 0;
pData->fNewGuestFilterMask = 0;
}
/**
* The device registration structure.
*/
{
/* u32Version */
/* szDeviceName */
"VMMDev",
/* szGCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"VirtualBox VMM Device\n",
/* fFlags */
/* fClass */
/* cMaxInstances */
1,
/* cbInstance */
sizeof(VMMDevState),
/* pfnConstruct */
/* pfnDestruct */
NULL,
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnQueryInterface. */
};