Helper.cpp revision 296cdbced70651cbf4c98767398d0c898885b54b
/** @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;
}
{
switch (winVer)
{
case WINNT4:
return VBOXOSTYPE_WinNT4;
case WIN2K:
return VBOXOSTYPE_Win2k;
case WINXP:
return VBOXOSTYPE_WinXP;
case WIN2K3:
return VBOXOSTYPE_Win2k3;
case WINVISTA:
return VBOXOSTYPE_WinVista;
case WIN7:
return VBOXOSTYPE_Win7;
default:
break;
}
/* We don't know, therefore NT family. */
return VBOXOSTYPE_WinNT;
}