VBoxMPDriver.cpp revision 4c98b8b05f3783351cf256cc90cd4478fb28b62b
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * VBox XPDM Miniport driver interface functions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (C) 2011 Oracle Corporation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This file is part of VirtualBox Open Source Edition (OSE), as
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * available from http://www.virtualbox.org. This file is free software;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * you can redistribute it and/or modify it under the terms of the GNU
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * General Public License (GPL) as published by the Free Software
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Foundation, in version 2 as it comes in the "COPYING" file of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Resource list */
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVIDEO_ACCESS_RANGE VBoxLegacyVGAResourceList[] =
f79113ae65937c28690ec71f68f54f862b758baePhill Cunnington { 0x000003B0, 0x00000000, 0x0000000C, 1, 1, 1, 0 }, /* VGA regs (0x3B0-0x3BB) */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster { 0x000003C0, 0x00000000, 0x00000020, 1, 1, 1, 0 }, /* VGA regs (0x3C0-0x3DF) */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster { 0x000A0000, 0x00000000, 0x00020000, 0, 0, 1, 0 }, /* Frame buffer (0xA0000-0xBFFFF) */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Card info for property dialog */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic WCHAR VBoxDACType[] = L"Integrated RAMDAC";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic WCHAR VBoxAdapterString[] = L"VirtualBox Video Adapter";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic WCHAR VBoxBiosString[] = L"Version 0xB0C2 or later";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Checks if we have a device supported by our driver and initialize
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * our driver/card specific information.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * In particular we obtain VM monitors configuration and configure related structures.
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVBoxDrvFindAdapter(IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo, OUT PUCHAR Again)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ULONG cbVRAM = VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Init video port api */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster DispiId = VideoPortReadPortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster WARN(("VBE card not found, returning ERROR_DEV_NOT_EXIST"));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Query the adapter's memory size. It's a bit of a hack, we just read
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * an ULONG from the data port without setting an index before.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster cbVRAM = VideoPortReadPortUlong((PULONG)VBE_DISPI_IOPORT_DATA);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Write hw information to registry, so that it's visible in windows property dialog */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortSetRegistryParameters(pExt, L"HardwareInformation.ChipType",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortSetRegistryParameters(pExt, L"HardwareInformation.DacType",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortSetRegistryParameters(pExt, L"HardwareInformation.MemorySize",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortSetRegistryParameters(pExt, L"HardwareInformation.AdapterString",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortSetRegistryParameters(pExt, L"HardwareInformation.BiosString",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Call VideoPortGetAccessRanges to ensure interrupt info in ConfigInfo gets set up
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and to get LFB aperture data.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortZeroMemory(tmpRanges, sizeof(tmpRanges));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* NT crashes if either of 'vendorId, 'deviceId' or 'slot' parameters is NULL,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and needs PCI ids for a successful VideoPortGetAccessRanges call.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortGetAccessRanges(pExt, 0, NULL, RT_ELEMENTS(tmpRanges), tmpRanges,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster rc = VideoPortGetAccessRanges(pExt, 0, NULL, RT_ELEMENTS(tmpRanges), tmpRanges, NULL, NULL, &slot);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* The first range is the framebuffer. We require that information. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Preinitialize the primary extension. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortZeroMemory(&pExt->areaDisplay, sizeof(HGSMIAREA));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Guest supports only HGSMI, the old VBVA via VMMDev is not supported. Old
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * code will be ifdef'ed and later removed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The host will however support both old and new interface to keep compatibility
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with old guest additions.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VBoxSetupDisplaysHGSMI(&pExt->u.primary.commonInfo, phVRAM, ulApertureSize, cbVRAM, 0);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** @todo pretend success to make the driver work. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Initial device configuration. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Initialize the request pointer. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Check if the chip restricts horizontal resolution or not. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_ANYX);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster DispiId = VideoPortReadPortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* VBoxDrvStartIO parameter check helper macros */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster _type *_name = (_type*) RequestPacket->InputBuffer; \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (RequestPacket->InputBufferLength < sizeof(_type)) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RequestPacket->InputBufferLength, sizeof(_type))); \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster _type *_name = (_type*) RequestPacket->OutputBuffer; \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (RequestPacket->OutputBufferLength < sizeof(_type)) \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RequestPacket->OutputBufferLength, sizeof(_type))); \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Process Video Request Packet. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVBoxDrvStartIO(PVOID HwDeviceExtension, PVIDEO_REQUEST_PACKET RequestPacket)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PSTATUS_BLOCK pStatus = RequestPacket->StatusBlock;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LOGF(("IOCTL %#p, fn(%#x)", (void*)RequestPacket->IoControlCode, (RequestPacket->IoControlCode >> 2) & 0xFFF));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* ==================== System VRPs ==================== */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Maps FrameBuffer and video RAM to a caller's virtual adress space.*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster STARTIO_OUT(VIDEO_MEMORY_INFORMATION, pMemInfo);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPMapVideoMemory(pExt, pMemory, pMemInfo, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Unmaps previously mapped FrameBuffer and video RAM from caller's virtual adress space.*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPUnmapVideoMemory(pExt, pMemory, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Maps FrameBuffer as a linear frame buffer to a caller's virtual adress space. (obsolete)*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster STARTIO_OUT(VIDEO_SHARE_MEMORY_INFORMATION, pShareMemInfo);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPShareVideoMemory(pExt, pShareMemory, pShareMemInfo, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Unmaps framebuffer previously mapped with IOCTL_VIDEO_SHARE_VIDEO_MEMORY*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPUnshareVideoMemory(pExt, pShareMemory, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Reset device to a state it comes at system boot time.*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Set adapter video mode.*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPSetCurrentMode(pExt, pMode, pStatus);
f79113ae65937c28690ec71f68f54f862b758baePhill Cunnington /*Returns information about current video mode.*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster STARTIO_OUT(VIDEO_MODE_INFORMATION, pModeInfo);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPQueryCurrentMode(pExt, pModeInfo, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Returns count of supported video modes and structure size in bytes,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * used to allocate buffer for the following IOCTL_VIDEO_QUERY_AVAIL_MODES call.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPQueryNumAvailModes(pExt, pNumModes, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Returns information about supported video modes. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVIDEO_MODE_INFORMATION pModes = (PVIDEO_MODE_INFORMATION) RequestPacket->OutputBuffer;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (RequestPacket->OutputBufferLength < VBoxMPXpdmGetVideoModesCount()*sizeof(VIDEO_MODE_INFORMATION))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPQueryAvailModes(pExt, pModes, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Sets adapter's color registers, have to be implemented if we support palette based modes. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (RequestPacket->InputBufferLength < (sizeof(VIDEO_CLUT) + pClut->NumEntries * sizeof(ULONG)))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPSetColorRegisters(pExt, pClut, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Sets pointer attributes. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster STARTIO_IN(VIDEO_POINTER_ATTRIBUTES, pPointerAttrs);
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris bResult = VBoxMPSetPointerAttr(pExt, pPointerAttrs, RequestPacket->InputBufferLength, pStatus);
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris /* Makes pointer visible. */
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris bResult = VBoxMPEnablePointer(pExt, TRUE, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Hides pointer. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPEnablePointer(pExt, FALSE, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Sets pointer position, is called after IOCTL_VIDEO_ENABLE_POINTER. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** @todo set pointer position*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPEnablePointer(pExt, TRUE, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Query pointer position. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPQueryPointerPosition(pExt, pPos, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Query supported hardware pointer feaures. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster STARTIO_OUT(VIDEO_POINTER_CAPABILITIES, pCaps);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPQueryPointerCapabilities(pExt, pCaps, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Query pointer attributes. (optional) */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster STARTIO_OUT(VIDEO_POINTER_ATTRIBUTES, pPointerAttrs);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Not Implemented */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Called when a secondary adapter is about to be enabled/disabled. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster pExt->u.secondary.bEnabled = (BOOLEAN)(*pAttach);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Called to get child device status */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (*pChildIndex>0 && *pChildIndex<=(ULONG)VBoxCommonFromDeviceExt(pExt)->cDisplays)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* ==================== VirtualBox specific VRPs ==================== */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Called by the display driver when it is ready to switch to VBVA operation mode. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPVBVAEnable(pExt, (BOOLEAN)*pEnable, pResult, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Called by the display driver when it recieves visible regions information. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uint32_t cRects = RequestPacket->InputBufferLength/sizeof(RTRECT);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Sanity check*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster || RequestPacket->InputBufferLength != cRects * sizeof(RTRECT))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPSetVisibleRegion(cRects, pRects, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Returns video port api function pointers. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPHGSMIQueryPortProcs(pExt, pProcs, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Returns HGSMI related callbacks. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPHGSMIQueryCallbacks(pExt, pCallbacks, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Returns hgsmi info for this adapter. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPQueryHgsmiInfo(pExt, pResult, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Enables HGSMI miniport channel. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPHgsmiHandlerEnable(pExt, pChannel, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /** @todo not implemented */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Returns framebuffer offset. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster bResult = VBoxMPVhwaQueryInfo(pExt, pInfo, pStatus);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (void*)RequestPacket->IoControlCode, (RequestPacket->IoControlCode >> 2) & 0xFFF));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RequestPacket->StatusBlock->Status = ERROR_INVALID_FUNCTION;
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris/* Called to set out hardware into desired power state, not supported at the moment.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Required to return NO_ERROR always.
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVBoxDrvSetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Not implemented*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Called to check if our hardware supports given power state. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVBoxDrvGetPowerState(PVOID HwDeviceExtension, ULONG HwId, PVIDEO_POWER_MANAGEMENT VideoPowerControl)
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris /*Not implemented*/
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris/* Called to enumerate child devices of our adapter, attached monitor(s) in our case */
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVBoxDrvGetVideoChildDescriptor(PVOID HwDeviceExtension, PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVIDEO_CHILD_TYPE VideoChildType, PUCHAR pChildDescriptor, PULONG pUId,
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
9709ff1b979ab7830f3e00b809f1157554566ed3Steve Ferris if ((int)ChildEnumInfo->ChildIndex <= VBoxCommonFromDeviceExt(pExt)->cDisplays)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Called to reset adapter to a given character mode. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterVBoxDrvResetHW(PVOID HwDeviceExtension, ULONG Columns, ULONG Rows)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortWritePortUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_DISABLED);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* ResetHW is not the place to do such cleanup. See MSDN. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VbglGRFree((VMMDevRequestHeader *)pExt->u.primary.pvReqFlush);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VBoxFreeDisplaysHGSMI(VBoxCommonFromDeviceExt(pExt));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LOG(("ignoring non primary device %d", pExt->iDevice));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Tell the system to use VGA BIOS to set the text video mode. */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic VOID VBoxMPHGSMIDpc(IN PVOID HwDeviceExtension, IN PVOID Context)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VBoxHGSMIProcessHostQueue(&VBoxCommonFromDeviceExt(pExt)->hostCtx);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PVBOXMP_DEVEXT pExt = (PVBOXMP_DEVEXT) HwDeviceExtension;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //LOGF_ENTER();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* Check if it could be our IRQ*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (VBoxCommonFromDeviceExt(pExt)->hostCtx.pfHostFlags)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster uint32_t flags = VBoxCommonFromDeviceExt(pExt)->hostCtx.pfHostFlags->u32HostFlags;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* queue a DPC*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster BOOLEAN bResult = pExt->pPrimary->u.primary.VideoPortProcs.pfnQueueDpc(pExt->pPrimary, VBoxMPHGSMIDpc, NULL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* clear the IRQ */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VBoxHGSMIClearIrq(&VBoxCommonFromDeviceExt(pExt)->hostCtx);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //LOGF_LEAVE();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //LOGF_LEAVE();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/* Video Miniport Driver entry point */
8af80418ba1ec431c8027fa9668e5678658d3611Allan FosterULONG DriverEntry(IN PVOID Context1, IN PVOID Context2)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LogRel(("VBoxMP::failed to init IPRT (rc=%#x)", irc));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Zero the structure*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster VideoPortZeroMemory(&vhwData, sizeof(vhwData));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Required driver callbacks*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwSetPowerState = VBoxDrvSetPowerState;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwGetPowerState = VBoxDrvGetPowerState;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwGetVideoChildDescriptor = VBoxDrvGetVideoChildDescriptor;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Optional callbacks*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Our private storage space*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwDeviceExtensionSize = sizeof(VBOXMP_DEVEXT);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Claim legacy VGA resource ranges*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwLegacyResourceList = VBoxLegacyVGAResourceList;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwLegacyResourceCount = RT_ELEMENTS(VBoxLegacyVGAResourceList);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Size of this structure changes between windows/ddk versions,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *so we query current version and report the expected size
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *to allow our driver to be loaded.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwInitDataSize = SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwInitDataSize = SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vhwData.HwInitDataSize = sizeof(VIDEO_HW_INITIALIZATION_DATA);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Even though msdn claims that this field is ignored and should remain zero-initialized,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster windows NT4 SP0 dies without the following line.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*Allocate system resources*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ULONG rc = VideoPortInitialize(Context1, Context2, &vhwData, NULL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster LOG(("VideoPortInitialize failed with %#x", rc));