Helper.cpp revision cf421b81bccd8d2b7a49de6b88ac40da8ab4acc6
/** @file
* VBoxGuest -- VirtualBox Win32 guest support driver
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
//#define LOG_ENABLED
#include "VBoxGuest_Internal.h"
#include "Helper.h"
#include <VBox/VBoxGuestLib.h>
#ifdef ALLOC_PRAGMA
#endif
/* CM_RESOURCE_MEMORY_* flags which were used on XP or earlier. */
#define VBOX_CM_PRE_VISTA_MASK (0x3f)
/**
* Helper to scan the PCI resource list and remember stuff.
*
* @param pResList Resource list
* @param pDevExt Device extension
*/
{
// enumerate the resource list
ULONG rangeCount = 0;
ULONG cMMIORange = 0;
{
switch (partialData->Type)
{
case CmResourceTypePort:
{
// overflow protection
if (rangeCount < PCI_TYPE0_ADDRESSES)
{
dprintf(("I/O range: Base = %08x : %08x Length = %08x \n",
//@todo not so gut
dprintf(("I got all I want, my dear port, oh!\n"));
// save resource information
// next item
rangeCount++; baseAddress++;
}
break;
}
case CmResourceTypeInterrupt:
{
dprintf(("Interrupt: Level = %x Vector = %x Mode = %x \n",
partialData->Flags));
// save information
// check interrupt mode
{
}
else
{
}
break;
}
case CmResourceTypeMemory:
{
// overflow protection
if (rangeCount < PCI_TYPE0_ADDRESSES)
{
dprintf(("Memory range: Base = %08x : %08x Length = %08x \n",
/** @todo reconsider memory type */
if ( cMMIORange == 0 /* only care about the first mmio range (!!!) */
{
// save resource information
// next item
} else
{
}
}
break;
}
case CmResourceTypeDma:
{
dprintf(("DMA resource found. Hmm...\n"));
break;
}
default:
{
break;
}
}
}
// memorize the number of resources found
return rc;
}
{
if (pDevExt->memoryLength != 0)
{
pDevExt->pVMMDevMemory = (VMMDevMemory *)MmMapIoSpace (pDevExt->memoryAddress, pDevExt->memoryLength, MmNonCached);
if (pDevExt->pVMMDevMemory)
{
dprintf(("VBoxGuest::VBoxGuestPnp: VMMDevMemory: version = 0x%x, size = %d\n", pDevExt->pVMMDevMemory->u32Version, pDevExt->pVMMDevMemory->u32Size));
/* Check version of the structure */
{
/* Not our version, refuse operation and unmap the memory */
}
}
else
{
}
}
return rc;
}
{
if (pDevExt->pVMMDevMemory)
{
}
pDevExt->memoryLength = 0;
}
/** @todo Maybe we should drop this routine entirely later because we detecting
* the running OS via VBoxService in ring 3 using guest properties since a while.
*
* @todo Consider of using vboxGuestInitReportGuestInfo in the ..\common\Helper.cpp
* module to have a common base and less redundant code.
*/
{
int rc = VbglGRAlloc ((VMMDevRequestHeader **)&pReq, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);
if (RT_SUCCESS(rc))
{
/* we've already determined the Windows product before */
switch (winVersion)
{
case WINNT4:
break;
case WIN2K:
break;
case WINXP:
break;
case WIN2K3:
break;
case WINVISTA:
break;
case WIN7:
break;
default:
/* we don't know, therefore NT family */
break;
}
/** @todo registry lookup for additional information */
if (RT_FAILURE(rc))
{
dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Error reporting guest info to VMMDev. "
"rc = %Rrc\n", rc));
}
}
if (RT_SUCCESS(rc))
rc = VbglGRAlloc ((VMMDevRequestHeader **)&pReq2, sizeof (VMMDevReportGuestInfo2), VMMDevReq_ReportGuestInfo2);
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
{
dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Error reporting guest info to VMMDev. "
"rc = %Rrc\n", rc));
}
rc = VINF_SUCCESS;
}
/*
* Report guest status to host. Because the host set the "Guest Additions active" flag as soon
* as he received the VMMDevReportGuestInfo above to make sure all is compatible with older Guest
* Additions we now have to disable that flag again here (too early, VBoxService and friends need
* to start up first).
*/
if (RT_SUCCESS(rc))
{
pReq3->guestStatus.status = VBoxGuestStatusCurrent_Active; /** @todo Are we actually *really* active at this point? */
if (RT_FAILURE(rc))
rc = VINF_SUCCESS;
}
}