VMMDev.cpp revision 821c1ce042196f3f06a8c6fda218aa9dd5be42d2
/* $Id$ */
/** @file
*/
/*
* Copyright (C) 2006-2013 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/* Enable dev_vmm Log3 statements to get IRQ-related logging. */
#define LOG_GROUP LOG_GROUP_DEV_VMM
#include <iprt/asm-amd64-x86.h>
#include <iprt/buildconfig.h>
#ifndef IN_RC
#endif
#ifdef IN_RING3
#endif
#include "VMMDevState.h"
#ifdef VBOX_WITH_HGCM
# include "VMMDevHGCM.h"
#endif
#ifndef VBOX_WITHOUT_TESTING_FEATURES
# include "VMMDevTesting.h"
#endif
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define VBOX_GUEST_INTERFACE_VERSION_1_03(s) \
#define VBOX_GUEST_INTERFACE_VERSION_OK(additionsVersion) \
#define VBOX_GUEST_INTERFACE_VERSION_OLD(additionsVersion) \
#define VBOX_GUEST_INTERFACE_VERSION_NEW(additionsVersion) \
/** The saved state version. */
#define VMMDEV_SAVED_STATE_VERSION 15
/** The saved state version which is missing the guest facility statuses. */
/** The saved state version which is missing the guestInfo2 bits. */
/** The saved state version used by VirtualBox 3.0.
* This doesn't have the config part. */
#define VMMDEV_SAVED_STATE_VERSION_VBOX_30 11
#ifndef VBOX_DEVICE_STRUCT_TESTCASE
/** @page pg_vmmdev VMMDev
*
* 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 occurred 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.
*
*/
/* -=-=-=-=- Misc Helpers -=-=-=-=- */
/**
* Sets the IRQ (raise it or lower it) for 1.03 additions.
*
* @param pThis The VMMDev state.
* @thread Any.
* @remarks Must be called owning the critical section.
*/
{
if (!pThis->fu32AdditionsOk)
{
Log(("vmmdevSetIRQ: IRQ is not generated, guest has not yet reported to us.\n"));
return;
}
/* Filter unsupported events */
Log(("vmmdevSetIRQ: u32EventFlags=%#010x, u32HostEventFlags=%#010x, u32GuestEventMask=%#010x.\n",
/* Move event flags to VMMDev RAM */
uint32_t u32IRQLevel = 0;
if (u32EventFlags)
{
/* Clear host flags which will be delivered to guest. */
u32IRQLevel = 1;
}
/* Set IRQ level for pin 0 (see NoWait comment in vmmdevMaybeSetIRQ). */
/** @todo make IRQ pin configurable, at least a symbolic constant */
}
/**
* Sets the IRQ if there are events to be delivered.
*
* @param pThis The VMMDev state.
* @thread Any.
* @remarks Must be called owning the critical section.
*/
{
Log3(("vmmdevMaybeSetIRQ: u32HostEventFlags=%#010x, u32GuestFilterMask=%#010x.\n",
{
/*
* Note! No need to wait for the IRQs to be set (if we're not luck
* with the locks, etc). It is a notification about something,
* which has already happened.
*/
Log3(("vmmdevMaybeSetIRQ: IRQ set.\n"));
}
}
/**
* Notifies the guest about new events (@a fAddEvents).
*
* @param pThis The VMMDev state.
* @param fAddEvents New events to add.
* @thread Any.
* @remarks Must be called owning the critical section.
*/
{
{
Log3(("vmmdevNotifyGuestWorker: Old additions detected.\n"));
}
else
{
Log3(("vmmdevNotifyGuestWorker: New additions detected.\n"));
if (!pThis->fu32AdditionsOk)
{
Log(("vmmdevNotifyGuestWorker: IRQ is not generated, guest has not yet reported to us.\n"));
return;
}
Log3(("vmmdevNotifyGuestWorker: fHadEvents=%d, u32HostEventFlags=%#010x, u32GuestFilterMask=%#010x.\n",
if (!fHadEvents)
}
}
/* -=-=-=-=- Interfaces shared with VMMDevHGCM.cpp -=-=-=-=- */
/**
* Notifies the guest about new events (@a fAddEvents).
*
* This is used by VMMDev.cpp as well as VMMDevHGCM.cpp.
*
* @param pThis The VMMDev state.
* @param fAddEvents New events to add.
* @thread Any.
*/
{
/*
*/
if ( enmVMState != VMSTATE_RUNNING
&& enmVMState != VMSTATE_RUNNING_LS)
return;
}
/**
* Code shared by VMMDevReq_CtlGuestFilterMask and HGCM for controlling the
* events the guest are interested in.
*
* @param pThis The VMMDev state.
* @param fOrMask Events to add (VMMDEV_EVENT_XXX). Pass 0 for no
* change.
* @param fNotMask Events to remove (VMMDEV_EVENT_XXX). Pass 0 for no
* change.
*
* @remarks When HGCM will automatically enable VMMDEV_EVENT_HGCM when the guest
* starts submitting HGCM requests. Otherwise, the events are
* controlled by the guest.
*/
{
Log(("VMMDevCtlSetGuestFilterMask: fOrMask=%#010x, u32NotMask=%#010x, fHadEvents=%d.\n", fOrMask, fNotMask, fHadEvents));
if (fHadEvents)
{
if (!pThis->fNewGuestFilterMask)
pThis->fNewGuestFilterMask = true;
}
else
{
}
}
/* -=-=-=-=- Request processing functions. -=-=-=-=- */
/**
* Handles VMMDevReq_ReportGuestInfo.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pRequestHeader The header of the request to handle.
*/
{
AssertMsgReturn(pRequestHeader->size == sizeof(VMMDevReportGuestInfo), ("%u\n", pRequestHeader->size), VERR_INVALID_PARAMETER);
{
/* Make a copy of supplied information. */
/* Check additions interface version. */
LogRel(("Guest Additions information report: Interface = 0x%08X osType = 0x%08X\n",
}
if (!pThis->fu32AdditionsOk)
return VERR_VERSION_MISMATCH;
/* Clear our IRQ in case it was high for whatever reason. */
return VINF_SUCCESS;
}
/**
* Validates a publisher tag.
*
* @returns true / false.
* @param pszTag Tag to validate.
*/
static bool vmmdevReqIsValidPublisherTag(const char *pszTag)
{
/* Note! This character set is also found in Config.kmk. */
static char const s_szValidChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz()[]{}+-.,";
while (*pszTag != '\0')
{
return false;
pszTag++;
}
return true;
}
/**
* Validates a build tag.
*
* @returns true / false.
* @param pszTag Tag to validate.
*/
static bool vmmdevReqIsValidBuildTag(const char *pszTag)
{
int cchPrefix;
cchPrefix = 2;
cchPrefix = 4;
cchPrefix = 5;
else
return false;
return true;
return rc == VINF_SUCCESS;
}
/**
* Handles VMMDevReq_ReportGuestInfo2.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReportGuestInfo2), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
LogRel(("Guest Additions information report: Version %d.%d.%d r%d '%.*s'\n",
/* The interface was introduced in 3.2 and will definitely not be
backported beyond 3.0 (bird). */
/* The version must fit in a full version compression. */
uint32_t uFullVersion = VBOX_FULL_VERSION_MAKE(pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild);
/*
* Validate the name.
* Be less strict towards older additions (< v4.1.50).
*/
/* The version number which shouldn't be there. */
size_t cchStart = RTStrPrintf(szTmp, sizeof(szTmp), "%u.%u.%u", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild);
AssertMsgReturn(!strncmp(pszName, szTmp, cchStart), ("%s != %s\n", pszName, szTmp), VERR_INVALID_PARAMETER);
if (*pszName != '\0')
{
const char *pszRelaxedName = "";
bool fOk = false;
if (*pszName == '_')
{
pszName++;
if (!pszTag2)
{
}
else
{
*pszTag2++ = '\0';
if (fOk)
{
if (!fOk)
}
}
}
if (!fOk)
{
/* non-strict mode, just zap the extra stuff. */
LogRel(("ReportGuestInfo2: Ignoring unparsable version name bits: '%s' -> '%s'.\n", pszName, pszRelaxedName));
}
}
/*
* Save the info and tell Main or whoever is listening.
*/
pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, uFullVersion, pszName, pInfo2->additionsRevision, pInfo2->additionsFeatures);
/* Clear our IRQ in case it was high for whatever reason. */
return VINF_SUCCESS;
}
/**
* Allocates a new facility status entry, initializing it to inactive.
*
* @returns Pointer to a facility status entry on success, NULL on failure
* (table full).
* @param pThis The VMMDev instance data.
* @param uFacility The facility type code - VBoxGuestFacilityType.
* @param fFixed This is set when allocating the standard entries
* from the constructor.
* @param pTimeSpecNow Optionally giving the entry timestamp to use (ctor).
*/
static PVMMDEVFACILITYSTATUSENTRY
vmmdevAllocFacilityStatusEntry(PVMMDEV pThis, uint32_t uFacility, bool fFixed, PCRTTIMESPEC pTimeSpecNow)
{
/* If full, expunge one inactive entry. */
{
while (i-- > 0)
{
{
if (cToMove)
break;
}
}
return NULL;
}
/* Find location in array (it's sorted). */
while (i-- > 0)
break;
i++;
/* Move. */
if (cToMove > 0)
/* Initialize. */
if (pTimeSpecNow)
else
return &pThis->aFacilityStatuses[i];
}
/**
* Gets a facility status entry, allocating a new one if not already present.
*
* @returns Pointer to a facility status entry on success, NULL on failure
* (table full).
* @param pThis The VMMDev instance data.
* @param uFacility The facility type code - VBoxGuestFacilityType.
*/
{
/** @todo change to binary search. */
while (i-- > 0)
{
return &pThis->aFacilityStatuses[i];
break;
}
}
/**
* Handles VMMDevReq_ReportGuestStatus.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
/*
* Validate input.
*/
AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReportGuestStatus), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
/*
* Do the update.
*/
{
while (i-- > 0)
{
}
}
else
{
if (!pEntry)
{
static int g_cLogEntries = 0;
if (g_cLogEntries++ < 10)
LogRel(("VMM: Facility table is full - facility=%u status=%u.\n", pStatus->facility, pStatus->status));
return VERR_OUT_OF_RESOURCES;
}
}
pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now);
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_ReportGuestUserState.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
/*
* Validate input.
*/
AssertMsgReturn(pReqHdr->size >= sizeof(VMMDevReportGuestUserState), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
{
{
return VERR_INVALID_PARAMETER;
}
/* pyDynamic marks the beginning of the struct's dynamically
* allocated data area. */
return VERR_INVALID_PARAMETER;
/* Note: pszDomain can be NULL. */
/* Note: puDetails can be NULL. */
/* State */
/* State details */
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_ReportGuestCapabilities.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* Enable this automatically for guests using the old
request to report their capabilities. */
/** @todo change this when we next bump the interface version */
{
/* make a copy of supplied information */
LogRel(("Guest Additions capability report: (0x%x) seamless: %s, hostWindowMapping: %s, graphics: %s\n",
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_SetGuestCapabilities.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
LogRel(("Guest Additions capability report: (%#x -> %#x) seamless: %s, hostWindowMapping: %s, graphics: %s\n",
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetMouseStatus.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
LogRel2(("VMMDevReq_GetMouseStatus: features = %#x, xAbs = %d, yAbs = %d\n",
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_SetMouseStatus.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
bool fNotify = false;
!= ( pThis->mouseCapabilities
fNotify = true;
/*
* Notify connector if something changed.
*/
if (fNotify)
{
LogRelFlowFunc(("notifying connector\n"));
}
return VINF_SUCCESS;
}
{
/* Should be enough for most mouse pointers. */
return VERR_INVALID_PARAMETER;
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_SetPointerShape.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
{
AssertMsg(pReq->header.size == 0x10028 && pReq->header.version == 10000, /* don't complain about legacy!!! */
("VMMDev mouse shape structure has invalid size %d (%#x) version=%d!\n",
return VERR_INVALID_PARAMETER;
}
Log(("VMMDevReq_SetPointerShape: visible: %d, alpha: %d, shape = %d, width: %d, height: %d\n",
{
/* The guest did not provide the shape actually. */
fShape = false;
}
/* forward call to driver */
if (fShape)
{
if (RT_FAILURE(rc))
return rc;
pReq->pointerData);
}
else
{
0,
0, 0,
0, 0,
NULL);
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetHostTime.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
return VERR_NOT_SUPPORTED;
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetHypervisorInfo.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
}
/**
* Handles VMMDevReq_SetHypervisorInfo.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
int rc;
if (pReq->hypervisorStart == 0)
else
{
/* only if the client has queried the size before! */
{
/* new reservation */
LogRel(("Guest reported fixed hypervisor window at 0%010x (size = %#x, rc = %Rrc)\n",
}
else if (RT_FAILURE(rc))
rc = VERR_TRY_AGAIN;
}
return rc;
}
/**
* Handles VMMDevReq_RegisterPatchMemory.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
}
/**
* Handles VMMDevReq_DeregisterPatchMemory.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
return VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pThis->pDevIns), pReq->pPatchMem, pReq->cbPatchMem);
}
/**
* Handles VMMDevReq_SetPowerStatus.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
switch (pReq->powerState)
{
case VMMDevPowerState_Pause:
{
LogRel(("Guest requests the VM to be suspended (paused)\n"));
}
{
LogRel(("Guest requests the VM to be turned off\n"));
}
{
if (true /*pThis->fAllowGuestToSaveState*/)
{
LogRel(("Guest requests the VM to be saved and powered off\n"));
}
LogRel(("Guest requests the VM to be saved and powered off, declined\n"));
return VERR_ACCESS_DENIED;
}
default:
return VERR_INVALID_PARAMETER;
}
}
/**
* Handles VMMDevReq_GetDisplayChangeRequest
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
* @remarks Deprecated.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/**
* @todo It looks like a multi-monitor guest which only uses
* @a VMMDevReq_GetDisplayChangeRequest (not the *2 version)
* will get into a @a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST event
* loop if it tries to acknowlege host requests for additional
* monitors. Should the loop which checks for those requests
* be removed?
*/
{
/* Current request has been read at least once. */
pDispRequest->fPending = false;
/* Check if there are more pending requests. */
{
{
break;
}
}
/* Remember which resolution the client has queried, subsequent reads
* will return the same values. */
}
{
}
else
{
/* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
* read the last valid video mode hint. This happens when the guest X server
* determines the initial mode. */
}
Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d\n", pReq->xres, pReq->yres, pReq->bpp));
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetDisplayChangeRequest2.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
{
/* Select a pending request to report. */
unsigned i;
{
{
/* Remember which request should be reported. */
Log3(("VMMDev: will report pending request for %u\n", i));
break;
}
}
/* Check if there are more pending requests. */
i++;
{
{
Log3(("VMMDev: another pending at %u\n", i));
break;
}
}
if (pDispRequest)
{
/* Current request has been read at least once. */
pDispRequest->fPending = false;
/* Remember which resolution the client has queried, subsequent reads
* will return the same values. */
}
else
{
Log3(("VMMDev: no pending request!!!\n"));
}
}
if (!pDispRequest)
{
}
{
}
else
{
/* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
* read the last valid video mode hint. This happens when the guest X server
* determines the initial video mode. */
}
Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d at %d\n",
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetDisplayChangeRequestEx.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
{
/* Select a pending request to report. */
unsigned i;
{
{
/* Remember which request should be reported. */
Log3(("VMMDev: will report pending request for %d\n",
i));
break;
}
}
/* Check if there are more pending requests. */
i++;
{
{
Log3(("VMMDev: another pending at %d\n",
i));
break;
}
}
if (pDispRequest)
{
/* Current request has been read at least once. */
pDispRequest->fPending = false;
/* Remember which resolution the client has queried, subsequent reads
* will return the same values. */
}
else
{
Log3(("VMMDev: no pending request!!!\n"));
}
}
if (!pDispRequest)
{
Log3(("VMMDev: default to %d\n",
}
{
}
else
{
/* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
* read the last valid video mode hint. This happens when the guest X server
* determines the initial video mode. */
}
Log(("VMMDevEx: returning display change request xres = %d, yres = %d, bpp = %d id %d xPos = %d, yPos = %d & Enabled=%d\n",
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_VideoModeSupported.
*
* Query whether the given video mode is supported.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* forward the call */
0, /* primary screen. */
&pReq->fSupported);
}
/**
* Handles VMMDevReq_VideoModeSupported2.
*
* Query whether the given video mode is supported for a specific display
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* forward the call */
&pReq->fSupported);
}
/**
* Handles VMMDevReq_GetHeightReduction.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* forward the call */
}
/**
* Handles VMMDevReq_AcknowledgeEvents.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
{
}
else
{
if (pThis->fNewGuestFilterMask)
{
pThis->fNewGuestFilterMask = false;
}
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_CtlGuestFilterMask.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
LogRelFlowFunc(("VMMDevCtlGuestFilterMask: or mask: %#x, not mask: %#x\n", pReq->u32OrMask, pReq->u32NotMask));
/* HGCM event notification is enabled by the VMMDev device
* automatically when any HGCM command is issued. The guest
* cannot disable these notifications. */
return VINF_SUCCESS;
}
#ifdef VBOX_WITH_HGCM
/**
* Handles VMMDevReq_HGCMConnect.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
* @param GCPhysReqHdr The guest physical address of the request header.
*/
static int vmmdevReqHandler_HGCMConnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
{
AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this is >= ... */
{
Log(("VMMDevReq_HGCMConnect: HGCM Connector is NULL!\n"));
return VERR_NOT_SUPPORTED;
}
Log(("VMMDevReq_HGCMConnect\n"));
}
/**
* Handles VMMDevReq_HGCMDisconnect.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
* @param GCPhysReqHdr The guest physical address of the request header.
*/
static int vmmdevReqHandler_HGCMDisconnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
{
AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
{
Log(("VMMDevReq_VMMDevHGCMDisconnect: HGCM Connector is NULL!\n"));
return VERR_NOT_SUPPORTED;
}
Log(("VMMDevReq_VMMDevHGCMDisconnect\n"));
}
/**
* Handles VMMDevReq_HGCMCall.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
* @param GCPhysReqHdr The guest physical address of the request header.
*/
static int vmmdevReqHandler_HGCMCall(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
{
AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER);
{
Log(("VMMDevReq_HGCMCall: HGCM Connector is NULL!\n"));
return VERR_NOT_SUPPORTED;
}
#ifdef VBOX_WITH_64_BITS_GUESTS
#else
bool f64Bits = false;
#endif /* VBOX_WITH_64_BITS_GUESTS */
}
/**
* Handles VMMDevReq_HGCMCancel.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
* @param GCPhysReqHdr The guest physical address of the request header.
*/
static int vmmdevReqHandler_HGCMCancel(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
{
AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
{
Log(("VMMDevReq_VMMDevHGCMCancel: HGCM Connector is NULL!\n"));
return VERR_NOT_SUPPORTED;
}
Log(("VMMDevReq_VMMDevHGCMCancel\n"));
}
/**
* Handles VMMDevReq_HGCMCancel2.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
{
Log(("VMMDevReq_HGCMConnect2: HGCM Connector is NULL!\n"));
return VERR_NOT_SUPPORTED;
}
Log(("VMMDevReq_VMMDevHGCMCancel\n"));
}
#endif /* VBOX_WITH_HGCM */
/**
* Handles VMMDevReq_VideoAccelEnable.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
{
Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!!\n"));
return VERR_NOT_SUPPORTED;
}
{
/* The guest driver seems compiled with another headers. */
Log(("VMMDevReq_VideoAccelEnable guest ring buffer size %d, should be %d!!!\n", pReq->cbRingBuffer, VBVA_RING_BUFFER_SIZE));
return VERR_INVALID_PARAMETER;
}
/* The request is correct. */
&& RT_SUCCESS(rc))
{
/* 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. */
pThis->u32VideoAccelEnabled = 0;
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_VideoAccelFlush.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
{
Log(("VMMDevReq_VideoAccelFlush: Connector is NULL!!!\n"));
return VERR_NOT_SUPPORTED;
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_VideoSetVisibleRegion.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size + sizeof(RTRECT) >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
{
Log(("VMMDevReq_VideoSetVisibleRegion: Connector is NULL!!!\n"));
return VERR_NOT_SUPPORTED;
}
|| pReq->header.size != sizeof(VMMDevVideoSetVisibleRegion) + pReq->cRect * sizeof(RTRECT) - sizeof(RTRECT))
{
Log(("VMMDevReq_VideoSetVisibleRegion: cRects=%#x doesn't match size=%#x or is out of bounds\n",
return VERR_INVALID_PARAMETER;
}
/* forward the call */
}
/**
* Handles VMMDevReq_GetSeamlessChangeRequest.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* just pass on the information */
if (pThis->fSeamlessEnabled)
else
{
/* Remember which mode the client has queried. */
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetVRDPChangeRequest.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* just pass on the information */
Log(("VMMDev: returning VRDP status %d level %d\n", pThis->fVRDPEnabled, pThis->uVRDPExperienceLevel));
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetMemBalloonChangeRequest.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* just pass on the information */
{
/* Remember which mode the client has queried. */
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_ChangeMemBalloon.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
AssertMsgReturn(pReq->cPages == VMMDEV_MEMORY_BALLOON_CHUNK_PAGES, ("%u\n", pReq->cPages), VERR_INVALID_PARAMETER);
AssertMsgReturn(pReq->header.size == (uint32_t)RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[pReq->cPages]),
Log(("VMMDevReq_ChangeMemBalloon\n"));
int rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pThis->pDevIns), !!pReq->fInflate, pReq->cPages, pReq->aPhysPage);
else
return rc;
}
/**
* Handles VMMDevReq_GetStatisticsChangeRequest.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
Log(("VMMDevReq_GetStatisticsChangeRequest\n"));
/* just pass on the information */
{
/* Remember which mode the client has queried. */
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_ReportGuestStats.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
Log(("VMMDevReq_ReportGuestStats\n"));
#ifdef LOG_ENABLED
Log(("Current statistics:\n"));
/* Note that reported values are in pages; upper layers expect them in megabytes */
Log(("CPU%u: Total physical memory %-4d MB\n", pGuestStats->u32CpuId, (pGuestStats->u32PhysMemTotal + (_1M/_4K)-1) / (_1M/_4K)));
Log(("CPU%u: Free physical memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemAvail / (_1M/_4K)));
Log(("CPU%u: Memory balloon size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemBalloon / (_1M/_4K)));
Log(("CPU%u: Committed memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemCommitTotal / (_1M/_4K)));
Log(("CPU%u: Total kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelTotal / (_1M/_4K)));
Log(("CPU%u: Paged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelPaged / (_1M/_4K)));
Log(("CPU%u: Nonpaged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelNonPaged / (_1M/_4K)));
Log(("CPU%u: System cache size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemSystemCache / (_1M/_4K)));
Log(("CPU%u: Page file size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PageFileSize / (_1M/_4K)));
Log(("Statistics end *******************\n"));
#endif /* LOG_ENABLED */
/* forward the call */
}
/**
* Handles VMMDevReq_QueryCredentials.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* 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
}
if (!pThis->fKeepCredentials)
{
/* 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? */
{
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_ReportCredentialsJudgement.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* what does the guest think about the credentials? (note: the order is important here!) */
else
{
/** @todo why don't we return VERR_INVALID_PARAMETER to the guest? */
}
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetHostVersion.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
* @since 3.1.0
* @note The ring-0 VBoxGuestLib uses this to check whether
* VMMDevHGCMParmType_PageList is supported.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_GetCpuHotPlugRequest.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/* Clear the event */
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_SetCpuHotPlugStatus.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
pThis->fCpuHotPlugEventsEnabled = false;
pThis->fCpuHotPlugEventsEnabled = true;
else
return VERR_INVALID_PARAMETER;
return VINF_SUCCESS;
}
#ifdef DEBUG
/**
* Handles VMMDevReq_LogString.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
AssertMsgReturn(pReq->szString[pReq->header.size - RT_OFFSETOF(VMMDevReqLogString, szString) - 1] == '\0',
("not null terminated\n"), VERR_INVALID_PARAMETER);
LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("DEBUG LOG: %s", pReq->szString));
return VINF_SUCCESS;
}
#endif /* DEBUG */
/**
* Handles VMMDevReq_GetSessionId.
*
* Get a unique "session" ID for this VM, where the ID will be different after each
* start, reset or restore of the VM. This can be used for restore detection
* inside the guest.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
return VINF_SUCCESS;
}
#ifdef VBOX_WITH_PAGE_SHARING
/**
* Handles VMMDevReq_RegisterSharedModule.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
/*
* Basic input validation (more done by GMM).
*/
AssertMsgReturn(pReq->header.size == RT_UOFFSETOF(VMMDevSharedModuleRegistrationRequest, aRegions[pReq->cRegions]),
/*
* Forward the request to the VMM.
*/
return PGMR3SharedModuleRegister(PDMDevHlpGetVM(pThis->pDevIns), pReq->enmGuestOS, pReq->szName, pReq->szVersion,
}
/**
* Handles VMMDevReq_UnregisterSharedModule.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
/*
* Basic input validation.
*/
/*
* Forward the request to the VMM.
*/
}
/**
* Handles VMMDevReq_CheckSharedModules.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
}
/**
* Handles VMMDevReq_GetPageSharingStatus.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
if (RT_FAILURE(rc))
return VINF_SUCCESS;
}
/**
* Handles VMMDevReq_DebugIsPageShared.
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr The header of the request to handle.
*/
{
# ifdef DEBUG
return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pThis->pDevIns), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);
# else
return VERR_NOT_IMPLEMENTED;
# endif
}
#endif /* VBOX_WITH_PAGE_SHARING */
/**
* Handles VMMDevReq_WriteCoreDumpe
*
* @returns VBox status code that the guest should see.
* @param pThis The VMMDev instance data.
* @param pReqHdr Pointer to the request header.
*/
{
AssertMsgReturn(pReq->header.size == sizeof(VMMDevReqWriteCoreDump), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
/*
* Only available if explicitly enabled by the user.
*/
if (!pThis->fGuestCoreDumpEnabled)
return VERR_ACCESS_DENIED;
/*
* User makes sure the directory exists before composing the path.
*/
return VERR_PATH_NOT_FOUND;
char szCorePath[RTPATH_MAX];
/*
* Rotate existing cores based on number of additional cores to keep around.
*/
if (pThis->cGuestCoreDumps > 0)
{
char szFilePathOld[RTPATH_MAX];
if (i == 0)
else
char szFilePathNew[RTPATH_MAX];
if (vrc == VERR_FILE_NOT_FOUND)
}
/*
* Write the core file.
*/
}
/**
* Dispatch the request to the appropriate handler function.
*
* @returns Port I/O handler exit code.
* @param pThis The VMM device instance data.
* @param pReqHdr The request header (cached in host memory).
* @param GCPhysReqHdr The guest physical address of the request (for
* HGCM).
* @param pfDelayedUnlock Where to indicate whether the critical section exit
* needs to be delayed till after the request has been
* written back. This is a HGCM kludge, see critsect
* work in hgcmCompletedWorker for more details.
*/
static int vmmdevReqDispatcher(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr, bool *pfDelayedUnlock)
{
int rcRet = VINF_SUCCESS;
*pfDelayedUnlock = false;
switch (pReqHdr->requestType)
{
break;
break;
break;
break;
break;
break;
case VMMDevReq_WriteCoreDump:
break;
case VMMDevReq_GetMouseStatus:
break;
case VMMDevReq_SetMouseStatus:
break;
break;
case VMMDevReq_GetHostTime:
break;
break;
break;
break;
break;
case VMMDevReq_SetPowerStatus:
{
break;
}
break;
break;
break;
break;
break;
break;
break;
break;
#ifdef VBOX_WITH_HGCM
case VMMDevReq_HGCMConnect:
*pfDelayedUnlock = true;
break;
case VMMDevReq_HGCMDisconnect:
*pfDelayedUnlock = true;
break;
# ifdef VBOX_WITH_64_BITS_GUESTS
case VMMDevReq_HGCMCall32:
case VMMDevReq_HGCMCall64:
# else
case VMMDevReq_HGCMCall:
# endif /* VBOX_WITH_64_BITS_GUESTS */
*pfDelayedUnlock = true;
break;
case VMMDevReq_HGCMCancel:
*pfDelayedUnlock = true;
break;
case VMMDevReq_HGCMCancel2:
break;
#endif /* VBOX_WITH_HGCM */
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
case VMMDevReq_GetHostVersion:
break;
break;
break;
#ifdef VBOX_WITH_PAGE_SHARING
break;
break;
break;
break;
break;
#endif /* VBOX_WITH_PAGE_SHARING */
#ifdef DEBUG
case VMMDevReq_LogString:
break;
#endif
case VMMDevReq_GetSessionId:
break;
/*
* Guest wants to give up a timeslice.
* Note! This was only ever used by experimental GAs!
*/
/** @todo maybe we could just remove this? */
case VMMDevReq_Idle:
{
/* just return to EMT telling it that we want to halt */
break;
}
default:
{
break;
}
}
return rcRet;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, Port I/O Handler for the generic
* request interface.}
*/
static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
/*
* The caller has passed the guest context physical address of the request
* structure. We'll copy all of it into a heap buffer eventually, but we
* will have to start off with the header.
*/
/* 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;
}
int rcRet = VINF_SUCCESS;
bool fDelayedUnlock = false;
/* Check that is doesn't exceed the max packet size. */
{
/*
* We require the GAs to report it's information before we let it have
* access to all the functions. The VMMDevReq_ReportGuestInfo request
* is the one which unlocks the access. Newer additions will first
* issue VMMDevReq_ReportGuestInfo2, older ones doesn't know this one.
* Two exceptions: VMMDevReq_GetHostVersion and VMMDevReq_WriteCoreDump.
*/
if ( pThis->fu32AdditionsOk
)
{
/*
* The request looks fine. Allocate a heap block for it, read the
* entire package from guest memory and feed it to the dispatcher.
*/
if (pRequestHeader)
{
if (cbLeft)
cbLeft);
if (!fDelayedUnlock)
}
else
{
Log(("VMMDev: RTMemAlloc failed!\n"));
}
}
else
{
static int s_cRelWarn;
if (s_cRelWarn < 10)
{
s_cRelWarn++;
LogRel(("VMMDev: the guest has not yet reported to us -- refusing operation of request #%d\n",
}
}
}
else
{
static int s_cRelWarn;
if (s_cRelWarn < 50)
{
s_cRelWarn++;
}
}
/*
* Write the result back to guest memory
*/
if (pRequestHeader)
{
if (fDelayedUnlock)
}
else
{
/* early error case; write back header only */
}
return rcRet;
}
/* -=-=-=-=-=- PCI Device -=-=-=-=-=- */
/**
*/
static DECLCALLBACK(int)
vmmdevIORAMRegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
{
LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
int rc;
if (iRegion == 1)
{
if (GCPhysAddress != NIL_RTGCPHYS)
{
/*
* Map the MMIO2 memory.
*/
}
else
{
/*
* It is about to be unmapped, just clean up.
*/
rc = VINF_SUCCESS;
}
}
else if (iRegion == 2)
{
if (GCPhysAddress != NIL_RTGCPHYS)
{
/*
* Map the MMIO2 memory.
*/
if (RT_SUCCESS(rc))
rc = PDMDevHlpRegisterVMMDevHeap(pPciDev->pDevIns, GCPhysAddress, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
}
else
{
/*
* It is about to be unmapped, just clean up.
*/
rc = VINF_SUCCESS;
}
}
else
{
}
return rc;
}
/**
* @interface_method_impl{FNPCIIOREGIONMAP, I/O Port Region}
*/
static DECLCALLBACK(int)
vmmdevIOPortRegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
{
AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
/*
* Register our port IO handlers.
*/
int rc = PDMDevHlpIOPortRegister(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
return rc;
}
/* -=-=-=-=-=- Backdoor Logging and Time Sync. -=-=-=-=-=- */
/**
* @callback_method_impl{FNIOMIOPORTOUT, Backdoor Logging.}
*/
static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
{
/* The raw version. */
switch (u32)
{
case '\r': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <return>\n")); break;
case '\n': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <newline>\n")); break;
case '\t': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <tab>\n")); break;
default: LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: %c (%02x)\n", u32, u32)); break;
}
/* The readable, buffered version. */
{
LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("Guest Log: %s\n", pThis->szMsg));
}
else
{
{
LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("Guest Log: %s\n", pThis->szMsg));
}
}
}
return VINF_SUCCESS;
}
#ifdef VMMDEV_WITH_ALT_TIMESYNC
/**
* @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.}
*/
static DECLCALLBACK(int) vmmdevAltTimeSyncWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
if (cb == 4)
{
/* Selects high (0) or low (1) DWORD. The high has to be read first. */
switch (u32)
{
case 0:
pThis->fTimesyncBackdoorLo = false;
break;
case 1:
pThis->fTimesyncBackdoorLo = true;
break;
default:
break;
}
}
else
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.}
*/
static DECLCALLBACK(int) vmmdevAltTimeSyncRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
int rc;
if (cb == 4)
{
if (pThis->fTimesyncBackdoorLo)
else
{
/* Reading the high dword gets and saves the current time. */
}
rc = VINF_SUCCESS;
}
else
{
}
return rc;
}
#endif /* VMMDEV_WITH_ALT_TIMESYNC */
/* -=-=-=-=-=- IBase -=-=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
#ifdef VBOX_WITH_HGCM
#endif
/* Currently only for shared folders. */
return NULL;
}
/* -=-=-=-=-=- ILeds -=-=-=-=-=- */
/**
* Gets the pointer to the status LED of a unit.
*
* @returns VBox status code.
* @param pInterface Pointer to the interface structure containing the called function pointer.
* @param iLUN The unit which status LED we desire.
* @param ppLed Where to store the LED pointer.
*/
static DECLCALLBACK(int) vmmdevQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
{
if (iLUN == 0) /* LUN 0 is shared folders */
{
return VINF_SUCCESS;
}
return VERR_PDM_LUN_NOT_FOUND;
}
/* -=-=-=-=-=- PDMIVMMDEVPORT (VMMDEV::IPort) -=-=-=-=-=- */
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnQueryAbsoluteMouse}
*/
static DECLCALLBACK(int) vmmdevIPort_QueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t *pxAbs, int32_t *pyAbs)
{
/** @todo at the first sign of trouble in this area, just enter the critsect.
* As indicated by the comment below, the atomic reads serves no real purpose
* here since we can assume cache coherency protocoles and int32_t alignment
* rules making sure we won't see a halfwritten value. */
if (pxAbs)
if (pyAbs)
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnSetAbsoluteMouse}
*/
static DECLCALLBACK(int) vmmdevIPort_SetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t xAbs, int32_t yAbs)
{
{
Log2(("vmmdevIPort_SetAbsoluteMouse : settings absolute position to x = %d, y = %d\n", xAbs, yAbs));
}
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnQueryMouseCapabilities}
*/
static DECLCALLBACK(int) vmmdevIPort_QueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pfCapabilities)
{
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnUpdateMouseCapabilities}
*/
static DECLCALLBACK(int)
vmmdevIPort_UpdateMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved)
{
LogRelFlowFunc(("fCapsAdded=0x%x, fCapsRemoved=0x%x, fNotify=%RTbool\n", fCapsAdded, fCapsRemoved, fNotify));
if (fNotify)
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnRequestDisplayChange}
*/
static DECLCALLBACK(int)
vmmdevIPort_RequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t cx, uint32_t cy, uint32_t cBits, uint32_t idxDisplay,
{
return VERR_INVALID_PARAMETER;
/* Verify that the new resolution is different and that guest does not yet know about it. */
{
/* Special case of reset video mode. */
fSameResolution = false;
}
Log3(("vmmdevIPort_RequestDisplayChange: same=%d. new: cx=%d, cy=%d, cBits=%d, idxDisplay=%d.\
old: cx=%d, cy=%d, cBits=%d, idxDisplay=%d. \n \
,OriginX = %d , OriginY=%d, Enabled=%d, ChangeOrigin=%d\n",
if (!fSameResolution)
{
LogRel(("VMMDev::SetVideoModeHint: got a video mode hint (%dx%dx%d)@(%dx%d),(%d;%d) at %d\n",
/* 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;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnRequestSeamlessChange}
*/
static DECLCALLBACK(int) vmmdevIPort_RequestSeamlessChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
{
/* Verify that the new resolution is different and that guest does not yet know about it. */
if (!fSameMode)
{
/* 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;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnSetMemoryBalloon}
*/
static DECLCALLBACK(int) vmmdevIPort_SetMemoryBalloon(PPDMIVMMDEVPORT pInterface, uint32_t cMbBalloon)
{
/* Verify that the new resolution is different and that guest does not yet know about it. */
{
/* 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;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnVRDPChange}
*/
static DECLCALLBACK(int) vmmdevIPort_VRDPChange(PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t uVRDPExperienceLevel)
{
if (!fSame)
{
}
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnSetStatisticsInterval}
*/
static DECLCALLBACK(int) vmmdevIPort_SetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t cSecsStatInterval)
{
/* Verify that the new resolution is different and that guest does not yet know about it. */
Log(("vmmdevIPort_SetStatisticsInterval: old=%d. new=%d\n", pThis->u32LastStatIntervalSize, cSecsStatInterval));
if (!fSame)
{
/* 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;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnSetCredentials}
*/
static DECLCALLBACK(int) vmmdevIPort_SetCredentials(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
{
AssertReturn(fFlags & (VMMDEV_SETCREDENTIALS_GUESTLOGON | VMMDEV_SETCREDENTIALS_JUDGE), VERR_INVALID_PARAMETER);
/*
* Logon mode
*/
{
/* memorize the data */
}
/*
* Credentials verification mode?
*/
else
{
/* memorize the data */
}
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnVBVAChange}
*
* Notification from the Display. Especially useful when acceleration is
* disabled after a video mode change.
*/
{
/* Only used by saved state, which I guess is why we don't bother with locking here. */
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnCpuHotUnplug}
*/
static DECLCALLBACK(int) vmmdevIPort_CpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
{
int rc = VINF_SUCCESS;
{
}
else
return rc;
}
/**
* @interface_method_impl{PDMIVMMDEVPORT, pfnCpuHotPlug}
*/
static DECLCALLBACK(int) vmmdevIPort_CpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
{
int rc = VINF_SUCCESS;
{
}
else
return rc;
}
/* -=-=-=-=-=- Saved State -=-=-=-=-=- */
/**
* @callback_method_impl{NSSMDEVLIVEEXEC}
*/
{
return VINF_SSM_DONT_CALL_AGAIN;
}
/**
* @callback_method_impl{FNSSMDEVSAVEEXEC}
*/
{
/* The following is not strictly necessary as PGM restores MMIO2, keeping it for historical reasons. */
#ifdef VBOX_WITH_HGCM
#endif /* VBOX_WITH_HGCM */
{
}
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNSSMDEVLOADEXEC}
*/
static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
{
/** @todo The code load code is assuming we're always loaded into a freshly
* constructed VM. */
int rc;
|| uVersion < 6)
/* config */
{
bool f;
if (pThis->fGetHostTimeDisabled != f)
LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f));
if (pThis->fBackdoorLogDisabled != f)
LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f));
if (pThis->fKeepCredentials != f)
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),
pThis->fKeepCredentials, f);
if (pThis->fHeapEnabled != f)
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),
pThis->fHeapEnabled, f);
}
if (uPass != SSM_PASS_FINAL)
return VINF_SUCCESS;
/* state */
// SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
// here be dragons (probably)
if (uVersion > 10)
/* Attributes which were temporarily introduced in r30072 */
if (uVersion == 7)
{
}
#ifdef VBOX_WITH_HGCM
#endif /* VBOX_WITH_HGCM */
if (uVersion >= 10)
{
}
{
for (uint32_t i = 0; i < cFacilityStatuses; i++)
{
("VMMDev: Ran out of entries restoring the guest facility statuses. Saved state has %u.\n", cFacilityStatuses),
}
}
/*
* 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", pThis->mouseCapabilities));
{
if (uVersion >= 10)
/*fAlpha=*/false,
/*xHot=*/0, /*yHot=*/0,
/*cx=*/0, /*cy=*/0,
/*pvShape=*/NULL);
}
if (pThis->fu32AdditionsOk)
{
LogRel(("Guest Additions information report: additionsVersion = 0x%08X, osType = 0x%08X\n",
{
pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName,
{
}
}
}
return VINF_SUCCESS;
}
/**
* Load state done callback. Notify guest of restore event.
*
* @returns VBox status code.
* @param pDevIns The device instance.
* @param pSSM The handle to the saved state.
*/
{
#ifdef VBOX_WITH_HGCM
#endif /* VBOX_WITH_HGCM */
/* Reestablish the acceleration status. */
if ( pThis->u32VideoAccelEnabled
{
pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, !!pThis->u32VideoAccelEnabled, &pThis->pVMMDevRAMR3->vbvaMemory);
}
return VINF_SUCCESS;
}
/* -=-=-=-=- PDMDEVREG -=-=-=-=- */
/**
* (Re-)initializes the MMIO2 data.
*
* @param pThis Pointer to the VMMDev instance data.
*/
{
}
/**
* @interface_method_impl{PDMDEVREG,pfnReset}
*/
{
/*
* Reset the mouse integration feature bits
*/
{
/* notify the connector */
}
pThis->fHostCursorRequested = false;
pThis->hypervisorSize = 0;
/* re-initialize the VMMDev memory */
if (pThis->pVMMDevRAMR3)
/* credentials have to go away (by default) */
if (!pThis->fKeepCredentials)
{
}
/* Reset means that additions will report again. */
if (fVersionChanged)
Log(("vmmdevReset: fu32AdditionsOk=%d additionsVersion=%x osType=%#x\n",
pThis->fu32AdditionsOk = false;
/* Clear facilities. No need to tell Main as it will get a
pfnUpdateGuestInfo callback. */
while (iFacility-- > 0)
{
}
/* clear pending display change request. */
{
memset (&pRequest->lastReadDisplayChangeRequest, 0, sizeof (pRequest->lastReadDisplayChangeRequest));
}
/* disable seamless mode */
pThis->fLastSeamlessEnabled = false;
/* disabled memory ballooning */
pThis->cMbMemoryBalloonLast = 0;
/* disabled statistics updating */
pThis->u32LastStatIntervalSize = 0;
#ifdef VBOX_WITH_HGCM
/* Clear the "HGCM event enabled" flag so the event can be automatically reenabled. */
pThis->u32HGCMEnabled = 0;
#endif
/*
* Clear the event variables.
*
* XXX By design we should NOT clear pThis->u32HostEventFlags because it is designed
* that way so host events do not depend on guest resets. However, the pending
* event flags actually _were_ cleared since ages so we mask out events from
* clearing which we really need to survive the reset. See xtracker 5767.
*/
pThis->u32GuestFilterMask = 0;
pThis->u32NewGuestFilterMask = 0;
pThis->fNewGuestFilterMask = 0;
/* This is the default, as Windows and OS/2 guests take this for granted. (Actually, neither does...) */
/** @todo change this when we next bump the interface version */
if (fCapsChanged)
pThis->guestCaps = VMMDEV_GUEST_SUPPORTS_GRAPHICS; /** @todo r=bird: why? I cannot see this being done at construction?*/
/*
* Call the update functions as required.
*/
/* Generate a unique session id for this VM; it will be changed for each start, reset or restore.
* This can be used for restore detection inside the guest.
*/
}
/**
* @interface_method_impl{PDMDEVREG,pfnRelocate}
*/
{
}
/**
* @interface_method_impl{PDMDEVREG,pfnDestruct}
*/
{
/*
* Wipe and free the credentials.
*/
if (pThis->pCredentials)
{
}
#ifdef VBOX_WITH_HGCM
#endif
#ifndef VBOX_WITHOUT_TESTING_FEATURES
/*
* Clean up the testing device.
*/
#endif
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMDEVREG,pfnConstruct}
*/
{
int rc;
/*
* Initialize data (most of it anyway).
*/
/* Save PDM device instance data for future reference. */
/* 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 */
vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxGuestDriver, true /*fFixed*/, &TimeStampNow);
vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxService, true /*fFixed*/, &TimeStampNow);
vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxTrayClient, true /*fFixed*/, &TimeStampNow);
vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_Seamless, true /*fFixed*/, &TimeStampNow);
vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_Graphics, true /*fFixed*/, &TimeStampNow);
/*
* Interfaces
*/
/* IBase */
/* VMMDev port */
/* Shared folder LED */
#ifdef VBOX_WITH_HGCM
/* HGCM port */
#endif
if (!pThis->pCredentials)
return VERR_NO_MEMORY;
/*
* Validate and read the configuration.
*/
"GetHostTimeDisabled|"
"BackdoorLogDisabled|"
"KeepCredentials|"
"HeapEnabled|"
"RamSize|"
"RZEnabled|"
"GuestCoreDumpEnabled|"
"GuestCoreDumpDir|"
"GuestCoreDumpCount|"
"TestingEnabled|"
"TestingMMIO|"
"TestintXmlOutputFile"
,
"");
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"RamSize\" as a 64-bit unsigned integer"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"GetHostTimeDisabled\" as a boolean"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"BackdoorLogDisabled\" as a boolean"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"HeapEnabled\" as a boolean"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"RZEnabled\" as a boolean"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean"));
char *pszGuestCoreDumpDir = NULL;
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"GuestCoreDumpCount\" as a 32-bit unsigned integer"));
#ifndef VBOX_WITHOUT_TESTING_FEATURES
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed querying \"TestingMMIO\" as a boolean"));
if (RT_FAILURE(rc))
return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestintXmlOutputFile\" as a string"));
/** @todo image-to-load-filename? */
#endif
/*
* We do our own locking entirely. So, install NOP critsect for the device
* and create our own critsect for use where it really matters (++).
*/
/*
* Register the backdoor logging port
*/
#ifdef VMMDEV_WITH_ALT_TIMESYNC
/*
* Alternative timesync source.
*
* This was orignally added for creating a simple time sync service in an
* OpenBSD guest without requiring VBoxGuest and VBoxService to be ported
* first. We keep it in case it comes in handy.
*/
#endif
/*
* Allocate and initialize the MMIO2 memory.
*/
rc = PDMDevHlpMMIO2Register(pDevIns, 1 /*iRegion*/, VMMDEV_RAM_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevRAMR3, "VMMDev");
if (RT_FAILURE(rc))
if (pThis->fHeapEnabled)
{
rc = PDMDevHlpMMIO2Register(pDevIns, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap");
if (RT_FAILURE(rc))
}
/*
* Register the PCI device.
*/
if (RT_FAILURE(rc))
return rc;
Log(("!!WARNING!!: pThis->PciDev.devfn=%d (ignore if testcase or no started by Main)\n", pThis->PciDev.devfn));
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);
if (RT_FAILURE(rc))
return rc;
if (pThis->fHeapEnabled)
{
rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);
if (RT_FAILURE(rc))
return rc;
}
#ifndef VBOX_WITHOUT_TESTING_FEATURES
/*
* Initialize testing.
*/
if (RT_FAILURE(rc))
return rc;
#endif
/*
* Get the corresponding connector interface
*/
if (RT_SUCCESS(rc))
{
AssertMsgReturn(pThis->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);
#ifdef VBOX_WITH_HGCM
{
/* this is not actually an error, just means that there is no support for HGCM */
}
#endif
/* Query the initial balloon size. */
}
else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
{
Log(("%s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
rc = VINF_SUCCESS;
}
else
/*
* Attach status driver for shared folders (optional).
*/
if (RT_SUCCESS(rc))
else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
{
return rc;
}
/*
* Register saved state and init the HGCM CmdList critsect.
*/
#ifdef VBOX_WITH_HGCM
pThis->u32HGCMEnabled = 0;
#endif /* VBOX_WITH_HGCM */
/*
* In this version of VirtualBox the GUI checks whether "needs host cursor"
* changes.
*/
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Memory balloon size", "/Devices/VMMDev/BalloonChunks");
/*
* Generate a unique session id for this VM; it will be changed for each
* start, reset or restore. This can be used for restore detection inside
* the guest.
*/
return rc;
}
/**
* The device registration structure.
*/
{
/* u32Version */
/* szName */
"VMMDev",
/* szRCMod */
"VBoxDDGC.gc",
/* szR0Mod */
"VBoxDDR0.r0",
/* pszDescription */
"VirtualBox VMM Device\n",
/* fFlags */
PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
/* fClass */
/* cMaxInstances */
1,
/* cbInstance */
sizeof(VMMDevState),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
/* pfnMemSetup */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnQueryInterface. */
NULL,
/* pfnInitComplete */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32VersionEnd */
};
#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */