Helper.cpp revision 45c93a3f9bde721a585c4d33ccf8636d4c5cfee0
/** @file
*
* VBoxGuest -- VirtualBox Win32 guest support driver
*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
//#define LOG_ENABLED
#include "VBoxGuest_Internal.h"
#include "Helper.h"
#include <VBox/VBoxGuestLib.h>
#ifndef TARGET_NT4
#include <aux_klib.h>
#endif
#endif
#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;
}
{
int rc = VbglGRAlloc ((VMMDevRequestHeader **)&req, 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;
default:
/* we don't know, therefore NT family */
break;
}
/** @todo registry lookup for additional information */
{
dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: error reporting guest info to VMMDev."
}
}
}
{
int rc = STATUS_SUCCESS;
#ifndef TARGET_NT4
rc = AuxKlibInitialize();
{
dprintf(("VBoxGuest::VBoxGuestAddDevice: Unabled to initialize AuxKlib!\n"));
return STATUS_DRIVER_UNABLE_TO_LOAD;
}
#endif
/*
* Setup bugcheck callback routine ASAP.
*/
pDevExt->bugcheckContext = (VBOXBUGCHECKCONTEXT*)ExAllocatePool(NonPagedPool, sizeof(VBOXBUGCHECKCONTEXT));
if(!pDevExt->bugcheckContext)
{
dprintf(("VBoxGuest::VBoxGuestAddDevice: Not enough memory for bugcheck context!\n"));
return STATUS_INSUFFICIENT_RESOURCES;
}
sizeof(VBOXBUGCHECKCONTEXT),
(PUCHAR)"VBoxGuest"))
{
LogRelBackdoor(("Could not register bugcheck callback routine!\n"));
}
else
{
dprintf(("VBoxGuest::VBoxGuestAddDevice: Bugcheck callback registered.\n"));
}
return rc;
}
{
LogRelBackdoor(("Windows bugcheck (bluescreen) detected!\n"));
#ifndef TARGET_NT4
if (!RT_SUCCESS(rc))
{
return;
}
LogRelBackdoor(("Bugcheck parameters: 1=%ld 2=%ld 3=%ld 4=%ld\n",
#else
LogRelBackdoor(("No additional information for Windows NT 4.0 bugcheck available.\n"));
#endif
if (pvBuffer)
{
/* @todo - Not used yet. */
}
/* @todo Notify the host somehow over DevVMM. */
}
#endif