VBoxMPDriver.cpp revision aaa8c0fe05c212f1a993f92311fa41adb87af513
/* $Id$ */
/** @file
* VBox XPDM Miniport driver interface functions
*/
/*
* Copyright (C) 2011 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.
*/
#include "VBoxMPInternal.h"
#include <VBox/VBoxGuestLib.h>
#include "common/VBoxMPHGSMI.h"
#include "common/VBoxMPCommon.h"
#include "VBoxDisplay.h"
#include <iprt/initterm.h>
/* Resource list */
{
{ 0x000003B0, 0x00000000, 0x0000000C, 1, 1, 1, 0 }, /* VGA regs (0x3B0-0x3BB) */
{ 0x000003C0, 0x00000000, 0x00000020, 1, 1, 1, 0 }, /* VGA regs (0x3C0-0x3DF) */
{ 0x000A0000, 0x00000000, 0x00020000, 0, 0, 1, 0 }, /* Frame buffer (0xA0000-0xBFFFF) */
};
/* Card info for property dialog */
/* Checks if we have a device supported by our driver and initialize
* In particular we obtain VM monitors configuration and configure related structures.
*/
static VP_STATUS
{
PAGED_CODE();
LOGF_ENTER();
/* Init video port api */
if (DispiId != VBE_DISPI_ID2)
{
WARN(("VBE card not found, returning ERROR_DEV_NOT_EXIST"));
return ERROR_DEV_NOT_EXIST;
}
LOG(("found the VBE card"));
/*
* Query the adapter's memory size. It's a bit of a hack, we just read
* an ULONG from the data port without setting an index before.
*/
/* Write hw information to registry, so that it's visible in windows property dialog */
VBoxChipType, sizeof(VBoxChipType));
VBoxDACType, sizeof(VBoxDACType));
&AdapterMemorySize, sizeof(ULONG));
VBoxAdapterString, sizeof(VBoxAdapterString));
VBoxBiosString, sizeof(VBoxBiosString));
/* Call VideoPortGetAccessRanges to ensure interrupt info in ConfigInfo gets set up */
{
if (VBoxQueryWinVersion() == WINNT4)
{
/* NT crashes if either of 'vendorId, 'deviceId' or 'slot' parameters is NULL,
* and needs PCI ids for a successful VideoPortGetAccessRanges call.
*/
}
else
{
}
}
/* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
/* Preinitialize the primary extension. */
pExt->ulFrameBufferOffset = 0;
pExt->ulFrameBufferSize = 0;
/* Guest supports only HGSMI, the old VBVA via VMMDev is not supported. Old
* code will be ifdef'ed and later removed.
* The host will however support both old and new interface to keep compatibility
* with old guest additions.
*/
{
LOGREL(("using HGSMI"));
}
/** @todo pretend success to make the driver work. */
LOGF_LEAVE();
return rc;
}
/* Initial device configuration. */
static BOOLEAN
{
PAGED_CODE();
LOGF_ENTER();
/* Initialize the request pointer. */
/* Check if the chip restricts horizontal resolution or not. */
if (DispiId == VBE_DISPI_ID_ANYX)
else
LOGF_LEAVE();
return TRUE;
}
/* VBoxDrvStartIO parameter check helper macros */
{ \
WARN(("Input buffer too small %d/%d bytes", \
break; \
}
{ \
WARN(("Output buffer too small %d/%d bytes", \
break; \
}
/* Process Video Request Packet. */
static BOOLEAN
{
PAGED_CODE();
LOGF(("IOCTL %#p, fn(%#x)", (void*)RequestPacket->IoControlCode, (RequestPacket->IoControlCode >> 2) & 0xFFF));
switch (RequestPacket->IoControlCode)
{
/* ==================== System VRPs ==================== */
/*Maps FrameBuffer and video RAM to a caller's virtual adress space.*/
{
break;
}
/*Unmaps previously mapped FrameBuffer and video RAM from caller's virtual adress space.*/
{
break;
}
/*Maps FrameBuffer as a linear frame buffer to a caller's virtual adress space. (obsolete)*/
{
break;
}
/*Unmaps framebuffer previously mapped with IOCTL_VIDEO_SHARE_VIDEO_MEMORY*/
{
break;
}
/*Reset device to a state it comes at system boot time.*/
case IOCTL_VIDEO_RESET_DEVICE:
{
break;
}
/*Set adapter video mode.*/
{
break;
}
/*Returns information about current video mode.*/
{
break;
}
/* Returns count of supported video modes and structure size in bytes,
* used to allocate buffer for the following IOCTL_VIDEO_QUERY_AVAIL_MODES call.
*/
{
break;
}
/* Returns information about supported video modes. */
{
if (RequestPacket->OutputBufferLength < VBoxMPXpdmGetVideoModesCount()*sizeof(VIDEO_MODE_INFORMATION))
{
break;
}
break;
}
/* Sets adapter's color registers, have to be implemented if we support palette based modes. */
{
{
break;
}
break;
}
/* Sets pointer attributes. */
{
break;
}
/* Makes pointer visible. */
{
break;
}
/* Hides pointer. */
{
break;
}
/* Sets pointer position, is called after IOCTL_VIDEO_ENABLE_POINTER. */
{
/** @todo set pointer position*/
break;
}
/* Query pointer position. */
{
break;
}
/* Query supported hardware pointer feaures. */
{
break;
}
/* Query pointer attributes. (optional) */
{
/* Not Implemented */
break;
}
{
{
}
break;
}
/* Called to get child device status */
{
{
}
else
{
}
break;
}
/* ==================== VirtualBox specific VRPs ==================== */
/* Called by the display driver when it is ready to switch to VBVA operation mode. */
case IOCTL_VIDEO_VBVA_ENABLE:
{
break;
}
/* Called by the display driver when it recieves visible regions information. */
{
/*Sanity check*/
{
break;
}
break;
}
/* Returns video port api function pointers. */
{
break;
}
/* Returns HGSMI related callbacks. */
{
break;
}
/* Returns hgsmi info for this adapter. */
{
break;
}
/* Enables HGSMI miniport channel. */
{
break;
}
{
/** @todo not implemented */
break;
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* Returns framebuffer offset. */
{
break;
}
#endif
default:
{
WARN(("unsupported IOCTL %p, fn(%#x)",
}
}
if (!bResult)
{
}
LOGF_LEAVE();
return TRUE;
}
/* Called to set out hardware into desired power state, not supported at the moment.
* Required to return NO_ERROR always.
*/
static VP_STATUS
VBoxDrvSetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
{
PAGED_CODE();
LOGF_ENTER();
/*Not implemented*/
LOGF_LEAVE();
return NO_ERROR;
}
/* Called to check if our hardware supports given power state. */
static VP_STATUS
VBoxDrvGetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
{
PAGED_CODE();
LOGF_ENTER();
/*Not implemented*/
LOGF_LEAVE();
return NO_ERROR;
}
/* Called to enumerate child devices of our adapter, attached monitor(s) in our case */
static VP_STATUS
{
PAGED_CODE();
LOGF_ENTER();
if (ChildEnumInfo->ChildIndex>0)
{
{
LOGF_LEAVE();
return VIDEO_ENUM_MORE_DEVICES;
}
}
LOGF_LEAVE();
return ERROR_NO_MORE_DEVICES;
}
/* Called to reset adapter to a given character mode. */
static BOOLEAN
{
LOGF_ENTER();
{
#if 0
/* ResetHW is not the place to do such cleanup. See MSDN. */
{
}
#endif
}
else
{
}
LOGF_LEAVE();
/* Tell the system to use VGA BIOS to set the text video mode. */
return FALSE;
}
#ifdef VBOX_WITH_VIDEOHWACCEL
{
}
static BOOLEAN
{
//LOGF_ENTER();
/* Check if it could be our IRQ*/
{
if ((flags & HGSMIHOSTFLAGS_IRQ) != 0)
{
/* queue a DPC*/
BOOLEAN bResult = pExt->pPrimary->u.primary.VideoPortProcs.pfnQueueDpc(pExt->pPrimary, VBoxMPHGSMIDpc, NULL);
if (!bResult)
{
LOG(("VideoPortQueueDpc failed!"));
}
/* clear the IRQ */
//LOGF_LEAVE();
return TRUE;
}
}
//LOGF_LEAVE();
return FALSE;
}
#endif
/* Video Miniport Driver entry point */
{
PAGED_CODE();
if (RT_FAILURE(irc))
{
return ERROR_INVALID_FUNCTION;
}
LOGF_ENTER();
/*Zero the structure*/
/*Required driver callbacks*/
/*Optional callbacks*/
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
/*Our private storage space*/
/*Claim legacy VGA resource ranges*/
*so we query current version and report the expected size
*to allow our driver to be loaded.
*/
switch (VBoxQueryWinVersion())
{
case WINNT4:
LOG(("WINNT4"));
break;
case WIN2K:
LOG(("WIN2K"));
break;
default:
break;
}
/*Even though msdn claims that this field is ignored and should remain zero-initialized,
windows NT4 SP0 dies without the following line.
*/
/*Allocate system resources*/
{
}
LOGF_LEAVE();
return rc;
}