2004-01-19 15:56:53 +00:00
|
|
|
/*
|
2003-02-15 19:16:34 +00:00
|
|
|
* VideoPort driver
|
|
|
|
*
|
2007-12-20 12:31:39 +00:00
|
|
|
* Copyright (C) 2002-2004, 2007 ReactOS Team
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2009-10-27 10:34:16 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2004-01-19 15:56:53 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
2009-10-27 10:34:16 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2009-10-27 10:34:16 +00:00
|
|
|
* Lesser General Public License for more details.
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-19 15:56:53 +00:00
|
|
|
*
|
2003-02-15 19:16:34 +00:00
|
|
|
*/
|
|
|
|
|
2004-01-19 15:56:53 +00:00
|
|
|
#include "videoprt.h"
|
2003-02-15 19:16:34 +00:00
|
|
|
|
2014-02-04 17:15:06 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <ndk/exfuncs.h>
|
|
|
|
#include <ndk/rtlfuncs.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/* GLOBAL VARIABLES ***********************************************************/
|
|
|
|
|
|
|
|
ULONG CsrssInitialized = FALSE;
|
2005-06-14 13:10:40 +00:00
|
|
|
PKPROCESS Csrss = NULL;
|
2005-11-08 16:24:58 +00:00
|
|
|
ULONG VideoPortDeviceNumber = 0;
|
2017-05-18 21:29:24 +00:00
|
|
|
KMUTEX VideoPortInt10Mutex;
|
2004-03-06 22:25:22 +00:00
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/* PRIVATE FUNCTIONS **********************************************************/
|
2003-02-15 19:16:34 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
DriverEntry(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID Context1,
|
|
|
|
IN PVOID Context2)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
return STATUS_SUCCESS;
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortImageDirectoryEntryToData(
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID BaseAddress,
|
|
|
|
ULONG Directory)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PIMAGE_NT_HEADERS NtHeader;
|
|
|
|
ULONG Va;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
NtHeader = RtlImageNtHeader(BaseAddress);
|
|
|
|
if (NtHeader == NULL)
|
|
|
|
return NULL;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
if (Directory >= NtHeader->OptionalHeader.NumberOfRvaAndSizes)
|
|
|
|
return NULL;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
Va = NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress;
|
|
|
|
if (Va == 0)
|
|
|
|
return NULL;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
return (PVOID)((ULONG_PTR)BaseAddress + Va);
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
IntVideoPortDeferredRoutine(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PKDPC Dpc,
|
|
|
|
IN PVOID DeferredContext,
|
|
|
|
IN PVOID SystemArgument1,
|
|
|
|
IN PVOID SystemArgument2)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID HwDeviceExtension =
|
|
|
|
&((PVIDEO_PORT_DEVICE_EXTENSION)DeferredContext)->MiniPortDeviceExtension;
|
|
|
|
((PMINIPORT_DPC_ROUTINE)SystemArgument1)(HwDeviceExtension, SystemArgument2);
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
IntVideoPortCreateAdapterDeviceObject(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PDRIVER_OBJECT DriverObject,
|
|
|
|
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
|
|
|
IN PDEVICE_OBJECT PhysicalDeviceObject,
|
|
|
|
OUT PDEVICE_OBJECT *DeviceObject OPTIONAL)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
ULONG DeviceNumber;
|
|
|
|
ULONG PciSlotNumber;
|
|
|
|
PCI_SLOT_NUMBER SlotNumber;
|
|
|
|
ULONG Size;
|
|
|
|
NTSTATUS Status;
|
|
|
|
WCHAR DeviceBuffer[20];
|
|
|
|
UNICODE_STRING DeviceName;
|
|
|
|
PDEVICE_OBJECT DeviceObject_;
|
|
|
|
|
|
|
|
if (DeviceObject == NULL)
|
|
|
|
DeviceObject = &DeviceObject_;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the first free device number that can be used for video device
|
|
|
|
* object names and symlinks.
|
|
|
|
*/
|
|
|
|
DeviceNumber = VideoPortDeviceNumber;
|
|
|
|
if (DeviceNumber == 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "Can't find free device number\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the device object.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Create a unicode device name. */
|
|
|
|
swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
|
|
|
|
RtlInitUnicodeString(&DeviceName, DeviceBuffer);
|
|
|
|
|
|
|
|
INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
|
|
|
|
DriverExtension->InitializationData.HwDeviceExtensionSize);
|
|
|
|
|
|
|
|
/* Create the device object. */
|
2013-11-16 18:40:24 +00:00
|
|
|
Size = sizeof(VIDEO_PORT_DEVICE_EXTENSION) +
|
|
|
|
DriverExtension->InitializationData.HwDeviceExtensionSize;
|
|
|
|
Status = IoCreateDevice(DriverObject,
|
|
|
|
Size,
|
|
|
|
&DeviceName,
|
|
|
|
FILE_DEVICE_VIDEO,
|
|
|
|
0,
|
|
|
|
TRUE,
|
|
|
|
DeviceObject);
|
2013-11-13 21:32:16 +00:00
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the buffering strategy here. If you change this, remember
|
|
|
|
* to change VidDispatchDeviceControl too.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(*DeviceObject)->Flags |= DO_BUFFERED_IO;
|
|
|
|
|
|
|
|
/* Initialize device extension. */
|
|
|
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
|
|
|
|
DeviceExtension->Common.Fdo = TRUE;
|
|
|
|
DeviceExtension->DeviceNumber = DeviceNumber;
|
|
|
|
DeviceExtension->DriverObject = DriverObject;
|
|
|
|
DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
|
|
|
|
DeviceExtension->FunctionalDeviceObject = *DeviceObject;
|
|
|
|
DeviceExtension->DriverExtension = DriverExtension;
|
2013-11-22 11:36:22 +00:00
|
|
|
DeviceExtension->SessionId = -1;
|
2013-11-13 21:32:16 +00:00
|
|
|
|
|
|
|
InitializeListHead(&DeviceExtension->ChildDeviceList);
|
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
/* Get the registry path associated with this device. */
|
2013-11-13 21:32:16 +00:00
|
|
|
Status = IntCreateRegistryPath(&DriverExtension->RegistryPath,
|
|
|
|
&DeviceExtension->RegistryPath);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
|
|
|
|
IoDeleteDevice(*DeviceObject);
|
|
|
|
*DeviceObject = NULL;
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PhysicalDeviceObject != NULL)
|
|
|
|
{
|
|
|
|
/* Get bus number from the upper level bus driver. */
|
|
|
|
Size = sizeof(ULONG);
|
2013-11-16 18:40:24 +00:00
|
|
|
Status = IoGetDeviceProperty(PhysicalDeviceObject,
|
|
|
|
DevicePropertyBusNumber,
|
|
|
|
Size,
|
|
|
|
&DeviceExtension->SystemIoBusNumber,
|
|
|
|
&Size);
|
2013-11-13 21:32:16 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
|
|
|
|
"use legacy detection method, but even that doesn't mean that\n"
|
|
|
|
"it will work.\n");
|
|
|
|
DeviceExtension->PhysicalDeviceObject = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceExtension->AdapterInterfaceType =
|
|
|
|
DriverExtension->InitializationData.AdapterInterfaceType;
|
|
|
|
|
|
|
|
if (PhysicalDeviceObject != NULL)
|
|
|
|
{
|
|
|
|
/* Get bus type from the upper level bus driver. */
|
|
|
|
Size = sizeof(ULONG);
|
|
|
|
IoGetDeviceProperty(PhysicalDeviceObject,
|
|
|
|
DevicePropertyLegacyBusType,
|
|
|
|
Size,
|
|
|
|
&DeviceExtension->AdapterInterfaceType,
|
|
|
|
&Size);
|
|
|
|
|
|
|
|
/* Get bus device address from the upper level bus driver. */
|
|
|
|
Size = sizeof(ULONG);
|
|
|
|
IoGetDeviceProperty(PhysicalDeviceObject,
|
|
|
|
DevicePropertyAddress,
|
|
|
|
Size,
|
|
|
|
&PciSlotNumber,
|
|
|
|
&Size);
|
2007-06-27 18:05:04 +00:00
|
|
|
|
|
|
|
/* Convert slotnumber to PCI_SLOT_NUMBER */
|
|
|
|
SlotNumber.u.AsULONG = 0;
|
|
|
|
SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
|
|
|
|
SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
|
|
|
|
DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
2003-10-24 21:39:59 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
InitializeListHead(&DeviceExtension->AddressMappingListHead);
|
|
|
|
InitializeListHead(&DeviceExtension->DmaAdapterList);
|
2010-10-01 17:43:03 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
KeInitializeDpc(&DeviceExtension->DpcObject,
|
|
|
|
IntVideoPortDeferredRoutine,
|
|
|
|
DeviceExtension);
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
|
2005-01-07 01:03:34 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
/* Attach the device. */
|
|
|
|
if (PhysicalDeviceObject != NULL)
|
|
|
|
DeviceExtension->NextDeviceObject = IoAttachDeviceToDeviceStack(
|
|
|
|
*DeviceObject,
|
|
|
|
PhysicalDeviceObject);
|
2005-01-07 01:03:34 +00:00
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
IntCreateNewRegistryPath(DeviceExtension);
|
|
|
|
IntSetupDeviceSettingsKey(DeviceExtension);
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
/* Remove the initailizing flag */
|
|
|
|
(*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
|
|
|
|
return STATUS_SUCCESS;
|
2005-01-07 01:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
IntVideoPortFindAdapter(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PDRIVER_OBJECT DriverObject,
|
|
|
|
IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension,
|
|
|
|
IN PDEVICE_OBJECT DeviceObject)
|
2005-01-07 01:03:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
WCHAR DeviceVideoBuffer[20];
|
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
NTSTATUS Status;
|
|
|
|
VIDEO_PORT_CONFIG_INFO ConfigInfo;
|
|
|
|
SYSTEM_BASIC_INFORMATION SystemBasicInfo;
|
|
|
|
UCHAR Again = FALSE;
|
|
|
|
WCHAR DeviceBuffer[20];
|
|
|
|
UNICODE_STRING DeviceName;
|
|
|
|
WCHAR SymlinkBuffer[20];
|
|
|
|
UNICODE_STRING SymlinkName;
|
|
|
|
BOOL LegacyDetection = FALSE;
|
|
|
|
ULONG DeviceNumber;
|
|
|
|
|
|
|
|
DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
|
|
|
DeviceNumber = DeviceExtension->DeviceNumber;
|
|
|
|
|
|
|
|
/* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
|
|
|
|
RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
|
|
|
|
ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
|
|
|
|
ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
|
|
|
|
if (ConfigInfo.AdapterInterfaceType == PCIBus)
|
|
|
|
ConfigInfo.InterruptMode = LevelSensitive;
|
|
|
|
else
|
|
|
|
ConfigInfo.InterruptMode = Latched;
|
|
|
|
ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
|
|
|
|
ConfigInfo.VideoPortGetProcAddress = IntVideoPortGetProcAddress;
|
|
|
|
ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
|
|
|
|
ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
|
|
|
|
ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
|
|
|
|
|
|
|
|
Status = ZwQuerySystemInformation(SystemBasicInformation,
|
|
|
|
&SystemBasicInfo,
|
2017-08-18 08:44:08 +00:00
|
|
|
sizeof(SystemBasicInfo),
|
|
|
|
NULL);
|
2013-11-13 21:32:16 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ConfigInfo.SystemMemorySize = SystemBasicInfo.NumberOfPhysicalPages *
|
|
|
|
SystemBasicInfo.PageSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call miniport HwVidFindAdapter entry point to detect if
|
|
|
|
* particular device is present. There are two possible code
|
|
|
|
* paths. The first one is for Legacy drivers (NT4) and cases
|
|
|
|
* when we don't have information about what bus we're on. The
|
|
|
|
* second case is the standard one for Plug & Play drivers.
|
|
|
|
*/
|
|
|
|
if (DeviceExtension->PhysicalDeviceObject == NULL)
|
|
|
|
{
|
|
|
|
LegacyDetection = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LegacyDetection)
|
|
|
|
{
|
|
|
|
ULONG BusNumber, MaxBuses;
|
|
|
|
|
|
|
|
MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
|
|
|
|
|
|
|
|
for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
|
|
|
|
{
|
|
|
|
DeviceExtension->SystemIoBusNumber =
|
|
|
|
ConfigInfo.SystemIoBusNumber = BusNumber;
|
|
|
|
|
|
|
|
RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
|
|
|
|
DriverExtension->InitializationData.HwDeviceExtensionSize);
|
|
|
|
|
|
|
|
/* FIXME: Need to figure out what string to pass as param 3. */
|
|
|
|
Status = DriverExtension->InitializationData.HwFindAdapter(
|
|
|
|
&DeviceExtension->MiniPortDeviceExtension,
|
|
|
|
DriverExtension->HwContext,
|
|
|
|
NULL,
|
|
|
|
&ConfigInfo,
|
|
|
|
&Again);
|
|
|
|
|
|
|
|
if (Status == ERROR_DEV_NOT_EXIST)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (Status == NO_ERROR)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
|
2013-11-16 18:40:24 +00:00
|
|
|
goto Failure;
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: Need to figure out what string to pass as param 3. */
|
|
|
|
Status = DriverExtension->InitializationData.HwFindAdapter(
|
|
|
|
&DeviceExtension->MiniPortDeviceExtension,
|
|
|
|
DriverExtension->HwContext,
|
|
|
|
NULL,
|
|
|
|
&ConfigInfo,
|
|
|
|
&Again);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Status != NO_ERROR)
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
|
2013-11-16 18:40:24 +00:00
|
|
|
goto Failure;
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we know the device is present, so let's do all additional tasks
|
|
|
|
* such as creating symlinks or setting up interrupts and timer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Create a unicode device name. */
|
|
|
|
swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
|
|
|
|
RtlInitUnicodeString(&DeviceName, DeviceBuffer);
|
|
|
|
|
|
|
|
/* Create symbolic link "\??\DISPLAYx" */
|
|
|
|
swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
|
|
|
|
RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
|
|
|
|
IoCreateSymbolicLink(&SymlinkName, &DeviceName);
|
|
|
|
|
|
|
|
/* Add entry to DEVICEMAP\VIDEO key in registry. */
|
|
|
|
swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber);
|
|
|
|
RtlWriteRegistryValue(
|
|
|
|
RTL_REGISTRY_DEVICEMAP,
|
|
|
|
L"VIDEO",
|
|
|
|
DeviceVideoBuffer,
|
|
|
|
REG_SZ,
|
|
|
|
DeviceExtension->RegistryPath.Buffer,
|
|
|
|
DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL));
|
|
|
|
|
|
|
|
RtlWriteRegistryValue(
|
|
|
|
RTL_REGISTRY_DEVICEMAP,
|
|
|
|
L"VIDEO",
|
|
|
|
L"MaxObjectNumber",
|
|
|
|
REG_DWORD,
|
|
|
|
&DeviceNumber,
|
|
|
|
sizeof(DeviceNumber));
|
|
|
|
|
|
|
|
/* FIXME: Allocate hardware resources for device. */
|
|
|
|
|
|
|
|
/* Allocate interrupt for device. */
|
|
|
|
if (!IntVideoPortSetupInterrupt(DeviceObject, DriverExtension, &ConfigInfo))
|
|
|
|
{
|
2013-11-16 18:40:24 +00:00
|
|
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
goto Failure;
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
/* Allocate timer for device. */
|
2013-11-13 21:32:16 +00:00
|
|
|
if (!IntVideoPortSetupTimer(DeviceObject, DriverExtension))
|
|
|
|
{
|
|
|
|
if (DeviceExtension->InterruptObject != NULL)
|
|
|
|
IoDisconnectInterrupt(DeviceExtension->InterruptObject);
|
|
|
|
ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
|
2013-11-16 18:40:24 +00:00
|
|
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
goto Failure;
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Query children of the device. */
|
|
|
|
VideoPortEnumerateChildren(&DeviceExtension->MiniPortDeviceExtension, NULL);
|
|
|
|
|
|
|
|
INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
|
|
|
|
return STATUS_SUCCESS;
|
2013-11-16 18:40:24 +00:00
|
|
|
|
|
|
|
Failure:
|
|
|
|
RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
|
|
|
|
if (DeviceExtension->NextDeviceObject)
|
|
|
|
IoDetachDevice(DeviceExtension->NextDeviceObject);
|
|
|
|
IoDeleteDevice(DeviceObject);
|
|
|
|
return Status;
|
2003-11-05 22:31:50 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
IntAttachToCSRSS(
|
2013-11-16 18:40:24 +00:00
|
|
|
PKPROCESS *CallingProcess,
|
2013-11-13 21:32:16 +00:00
|
|
|
PKAPC_STATE ApcState)
|
2005-05-08 02:16:32 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
*CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
|
|
|
if (*CallingProcess != Csrss)
|
|
|
|
{
|
|
|
|
KeStackAttachProcess(Csrss, ApcState);
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
FASTCALL
|
|
|
|
IntDetachFromCSRSS(
|
|
|
|
PKPROCESS *CallingProcess,
|
|
|
|
PKAPC_STATE ApcState)
|
2005-05-08 02:16:32 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
if (*CallingProcess != Csrss)
|
|
|
|
{
|
|
|
|
KeUnstackDetachProcess(ApcState);
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
}
|
2004-03-19 20:58:32 +00:00
|
|
|
|
|
|
|
/* PUBLIC FUNCTIONS ***********************************************************/
|
2003-07-10 21:12:40 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
ULONG
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortInitialize(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID Context1,
|
|
|
|
IN PVOID Context2,
|
|
|
|
IN PVIDEO_HW_INITIALIZATION_DATA HwInitializationData,
|
|
|
|
IN PVOID HwContext)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PDRIVER_OBJECT DriverObject = Context1;
|
|
|
|
PUNICODE_STRING RegistryPath = Context2;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PVIDEO_PORT_DRIVER_EXTENSION DriverExtension;
|
|
|
|
BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE;
|
2017-05-18 21:29:24 +00:00
|
|
|
static BOOLEAN Int10MutexInitialized;
|
2013-11-13 21:32:16 +00:00
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortInitialize\n");
|
|
|
|
|
2017-05-18 21:29:24 +00:00
|
|
|
if (!Int10MutexInitialized)
|
|
|
|
{
|
|
|
|
KeInitializeMutex(&VideoPortInt10Mutex, 0);
|
|
|
|
Int10MutexInitialized = TRUE;
|
|
|
|
}
|
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
/* As a first thing do parameter checks. */
|
|
|
|
if (HwInitializationData->HwInitDataSize > sizeof(VIDEO_HW_INITIALIZATION_DATA))
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
|
|
|
|
return STATUS_REVISION_MISMATCH;
|
|
|
|
}
|
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
if ((HwInitializationData->HwFindAdapter == NULL) ||
|
|
|
|
(HwInitializationData->HwInitialize == NULL) ||
|
|
|
|
(HwInitializationData->HwStartIO == NULL))
|
2013-11-13 21:32:16 +00:00
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "Invalid HwInitializationData\n");
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (HwInitializationData->HwInitDataSize)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* NT4 drivers are special case, because we must use legacy method
|
|
|
|
* of detection instead of the Plug & Play one.
|
|
|
|
*/
|
|
|
|
case SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA:
|
|
|
|
INFO_(VIDEOPRT, "We were loaded by a Windows NT miniport driver.\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA:
|
|
|
|
INFO_(VIDEOPRT, "We were loaded by a Windows 2000 miniport driver.\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case sizeof(VIDEO_HW_INITIALIZATION_DATA):
|
|
|
|
INFO_(VIDEOPRT, "We were loaded by a Windows XP or later miniport driver.\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ERR_(VIDEOPRT, "Invalid HwInitializationData size.\n");
|
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set dispatching routines */
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = IntVideoPortDispatchOpen;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = IntVideoPortDispatchClose;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] =
|
|
|
|
IntVideoPortDispatchDeviceControl;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
|
|
|
|
IntVideoPortDispatchDeviceControl;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_WRITE] =
|
|
|
|
IntVideoPortDispatchWrite; // ReactOS-specific hack
|
|
|
|
DriverObject->DriverUnload = IntVideoPortUnload;
|
|
|
|
|
|
|
|
/* Determine type of the miniport driver */
|
|
|
|
if ((HwInitializationData->HwInitDataSize >=
|
2013-11-16 18:40:24 +00:00
|
|
|
FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) &&
|
|
|
|
(HwInitializationData->HwSetPowerState != NULL) &&
|
|
|
|
(HwInitializationData->HwGetPowerState != NULL) &&
|
|
|
|
(HwInitializationData->HwGetVideoChildDescriptor != NULL))
|
2013-11-13 21:32:16 +00:00
|
|
|
{
|
|
|
|
INFO_(VIDEOPRT, "The miniport is a PnP miniport driver\n");
|
|
|
|
PnpDriver = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if legacy detection should be applied */
|
|
|
|
if (!PnpDriver || HwContext)
|
|
|
|
{
|
|
|
|
INFO_(VIDEOPRT, "Legacy detection for adapter interface %d\n",
|
|
|
|
HwInitializationData->AdapterInterfaceType);
|
|
|
|
|
|
|
|
/* FIXME: Move the code for legacy detection
|
|
|
|
to another function and call it here */
|
|
|
|
LegacyDetection = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE:
|
|
|
|
* The driver extension can be already allocated in case that we were
|
|
|
|
* called by legacy driver and failed detecting device. Some miniport
|
|
|
|
* drivers in that case adjust parameters and call VideoPortInitialize
|
|
|
|
* again.
|
|
|
|
*/
|
|
|
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
|
|
|
if (DriverExtension == NULL)
|
|
|
|
{
|
2013-11-16 18:40:24 +00:00
|
|
|
Status = IoAllocateDriverObjectExtension(DriverObject,
|
|
|
|
DriverObject,
|
|
|
|
sizeof(VIDEO_PORT_DRIVER_EXTENSION),
|
|
|
|
(PVOID *)&DriverExtension);
|
2013-11-13 21:32:16 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "IoAllocateDriverObjectExtension failed 0x%x\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the registry path. This should be done only once even if
|
|
|
|
* VideoPortInitialize is called multiple times.
|
|
|
|
*/
|
|
|
|
if (RegistryPath->Length != 0)
|
|
|
|
{
|
|
|
|
DriverExtension->RegistryPath.Length = 0;
|
|
|
|
DriverExtension->RegistryPath.MaximumLength =
|
|
|
|
RegistryPath->Length + sizeof(UNICODE_NULL);
|
|
|
|
DriverExtension->RegistryPath.Buffer =
|
|
|
|
ExAllocatePoolWithTag(
|
|
|
|
PagedPool,
|
|
|
|
DriverExtension->RegistryPath.MaximumLength,
|
|
|
|
'RTSU');
|
|
|
|
if (DriverExtension->RegistryPath.Buffer == NULL)
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlCopyUnicodeString(&DriverExtension->RegistryPath, RegistryPath);
|
|
|
|
INFO_(VIDEOPRT, "RegistryPath: %wZ\n", &DriverExtension->RegistryPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-24 21:29:24 +00:00
|
|
|
RtlInitUnicodeString(&DriverExtension->RegistryPath, NULL);
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-16 18:40:24 +00:00
|
|
|
/* Copy the correct miniport initialization data to the device extension. */
|
2013-11-13 21:32:16 +00:00
|
|
|
RtlCopyMemory(&DriverExtension->InitializationData,
|
|
|
|
HwInitializationData,
|
|
|
|
HwInitializationData->HwInitDataSize);
|
|
|
|
if (HwInitializationData->HwInitDataSize <
|
|
|
|
sizeof(VIDEO_HW_INITIALIZATION_DATA))
|
|
|
|
{
|
|
|
|
RtlZeroMemory((PVOID)((ULONG_PTR)&DriverExtension->InitializationData +
|
|
|
|
HwInitializationData->HwInitDataSize),
|
|
|
|
sizeof(VIDEO_HW_INITIALIZATION_DATA) -
|
|
|
|
HwInitializationData->HwInitDataSize);
|
|
|
|
}
|
|
|
|
DriverExtension->HwContext = HwContext;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Plug & Play drivers registers the device in AddDevice routine. For
|
|
|
|
* legacy drivers we must do it now.
|
|
|
|
*/
|
|
|
|
if (LegacyDetection)
|
|
|
|
{
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
|
|
|
|
if (HwInitializationData->HwInitDataSize != SIZE_OF_NT4_VIDEO_HW_INITIALIZATION_DATA)
|
|
|
|
{
|
|
|
|
/* power management */
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_POWER] = IntVideoPortDispatchPower;
|
|
|
|
}
|
2013-11-16 18:40:24 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
Status = IntVideoPortCreateAdapterDeviceObject(DriverObject,
|
|
|
|
DriverExtension,
|
|
|
|
NULL,
|
|
|
|
&DeviceObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject returned 0x%x\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = IntVideoPortFindAdapter(DriverObject, DriverExtension, DeviceObject);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
VideoPortDeviceNumber++;
|
|
|
|
else
|
|
|
|
ERR_(VIDEOPRT, "IntVideoPortFindAdapter returned 0x%x\n", Status);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DriverObject->DriverExtension->AddDevice = IntVideoPortAddDevice;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_PNP] = IntVideoPortDispatchPnp;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_POWER] = IntVideoPortDispatchPower;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IntVideoPortDispatchSystemControl;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:12:40 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2004-03-19 20:58:32 +00:00
|
|
|
VOID
|
|
|
|
VideoPortDebugPrint(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN VIDEO_DEBUG_LEVEL DebugPrintLevel,
|
|
|
|
IN PCHAR DebugMessage,
|
|
|
|
...)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
va_list ap;
|
2003-02-25 23:08:54 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
va_start(ap, DebugMessage);
|
|
|
|
vDbgPrintEx(DPFLTR_IHVVIDEO_ID, DebugPrintLevel, DebugMessage, ap);
|
|
|
|
va_end(ap);
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:12:40 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortLogError(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL,
|
|
|
|
IN VP_STATUS ErrorCode,
|
|
|
|
IN ULONG UniqueId)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2007-12-28 14:47:03 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
|
|
|
|
INFO_(VIDEOPRT, "VideoPortLogError ErrorCode %d (0x%x) UniqueId %lu (0x%lx)\n",
|
|
|
|
ErrorCode, ErrorCode, UniqueId, UniqueId);
|
|
|
|
if (Vrp)
|
|
|
|
INFO_(VIDEOPRT, "Vrp->IoControlCode %lu (0x%lx)\n", Vrp->IoControlCode, Vrp->IoControlCode);
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:12:40 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
UCHAR
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortGetCurrentIrql(VOID)
|
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
return KeGetCurrentIrql();
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
typedef struct QueryRegistryCallbackContext
|
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID HwDeviceExtension;
|
|
|
|
PVOID HwContext;
|
|
|
|
PMINIPORT_GET_REGISTRY_ROUTINE HwGetRegistryRoutine;
|
2004-03-19 20:58:32 +00:00
|
|
|
} QUERY_REGISTRY_CALLBACK_CONTEXT, *PQUERY_REGISTRY_CALLBACK_CONTEXT;
|
2003-07-10 21:12:40 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
static
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
QueryRegistryCallback(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PWSTR ValueName,
|
|
|
|
IN ULONG ValueType,
|
|
|
|
IN PVOID ValueData,
|
|
|
|
IN ULONG ValueLength,
|
|
|
|
IN PVOID Context,
|
|
|
|
IN PVOID EntryContext)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PQUERY_REGISTRY_CALLBACK_CONTEXT CallbackContext = (PQUERY_REGISTRY_CALLBACK_CONTEXT) Context;
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
INFO_(VIDEOPRT, "Found registry value for name %S: type %d, length %d\n",
|
2004-03-19 20:58:32 +00:00
|
|
|
ValueName, ValueType, ValueLength);
|
2013-11-13 21:32:16 +00:00
|
|
|
return (*(CallbackContext->HwGetRegistryRoutine))(
|
|
|
|
CallbackContext->HwDeviceExtension,
|
|
|
|
CallbackContext->HwContext,
|
|
|
|
ValueName,
|
|
|
|
ValueData,
|
|
|
|
ValueLength);
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:12:40 +00:00
|
|
|
/*
|
2004-03-19 20:58:32 +00:00
|
|
|
* @unimplemented
|
2003-07-10 21:12:40 +00:00
|
|
|
*/
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortGetRegistryParameters(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PWSTR ParameterName,
|
|
|
|
IN UCHAR IsParameterFileName,
|
|
|
|
IN PMINIPORT_GET_REGISTRY_ROUTINE GetRegistryRoutine,
|
|
|
|
IN PVOID HwContext)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
RTL_QUERY_REGISTRY_TABLE QueryTable[2] = {{0}};
|
|
|
|
QUERY_REGISTRY_CALLBACK_CONTEXT Context;
|
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortGetRegistryParameters ParameterName %S, RegPath: %wZ\n",
|
|
|
|
ParameterName, &DeviceExtension->RegistryPath);
|
|
|
|
|
|
|
|
Context.HwDeviceExtension = HwDeviceExtension;
|
|
|
|
Context.HwContext = HwContext;
|
|
|
|
Context.HwGetRegistryRoutine = GetRegistryRoutine;
|
|
|
|
|
|
|
|
QueryTable[0].QueryRoutine = QueryRegistryCallback;
|
|
|
|
QueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED;
|
|
|
|
QueryTable[0].Name = ParameterName;
|
|
|
|
|
|
|
|
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
|
|
|
|
DeviceExtension->RegistryPath.Buffer,
|
|
|
|
QueryTable,
|
|
|
|
&Context,
|
|
|
|
NULL);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "VideoPortGetRegistryParameters could not find the "
|
|
|
|
"requested parameter\n");
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsParameterFileName)
|
|
|
|
{
|
|
|
|
/* FIXME: need to read the contents of the file */
|
|
|
|
UNIMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NO_ERROR;
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:12:40 +00:00
|
|
|
/*
|
2004-03-19 20:58:32 +00:00
|
|
|
* @implemented
|
2003-07-10 21:12:40 +00:00
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortSetRegistryParameters(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PWSTR ValueName,
|
|
|
|
IN PVOID ValueData,
|
|
|
|
IN ULONG ValueLength)
|
2003-06-21 14:25:30 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
VP_STATUS Status;
|
|
|
|
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortSetRegistryParameters ParameterName %S, RegPath: %wZ\n",
|
|
|
|
ValueName,
|
|
|
|
&DeviceExtension->RegistryPath);
|
|
|
|
ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL);
|
|
|
|
Status = RtlWriteRegistryValue(RTL_REGISTRY_ABSOLUTE,
|
|
|
|
DeviceExtension->RegistryPath.Buffer,
|
|
|
|
ValueName,
|
|
|
|
REG_BINARY,
|
|
|
|
ValueData,
|
|
|
|
ValueLength);
|
|
|
|
if (Status != NO_ERROR)
|
|
|
|
WARN_(VIDEOPRT, "VideoPortSetRegistryParameters error 0x%x\n", Status);
|
|
|
|
|
|
|
|
return Status;
|
2003-06-21 14:25:30 +00:00
|
|
|
}
|
2003-02-15 19:16:34 +00:00
|
|
|
|
2004-01-19 15:56:53 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
2005-05-08 02:16:32 +00:00
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortGetVgaStatus(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
OUT PULONG VgaStatus)
|
2004-01-19 15:56:53 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortGetVgaStatus\n");
|
|
|
|
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
if (KeGetCurrentIrql() == PASSIVE_LEVEL)
|
|
|
|
{
|
|
|
|
if (DeviceExtension->AdapterInterfaceType == PCIBus)
|
|
|
|
{
|
|
|
|
/* VgaStatus: 0 == VGA not enabled, 1 == VGA enabled. */
|
|
|
|
/* Assumed for now */
|
|
|
|
*VgaStatus = 1;
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_INVALID_FUNCTION;
|
2004-01-19 15:56:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortGetRomImage(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PVOID Unused1,
|
|
|
|
IN ULONG Unused2,
|
|
|
|
IN ULONG Length)
|
2004-01-19 15:56:53 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
static PVOID RomImageBuffer = NULL;
|
|
|
|
PKPROCESS CallingProcess;
|
|
|
|
KAPC_STATE ApcState;
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
|
|
|
|
HwDeviceExtension, Length);
|
|
|
|
|
|
|
|
/* If the length is zero then free the existing buffer. */
|
|
|
|
if (Length == 0)
|
|
|
|
{
|
|
|
|
if (RomImageBuffer != NULL)
|
|
|
|
{
|
|
|
|
ExFreePool(RomImageBuffer);
|
|
|
|
RomImageBuffer = NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The DDK says we shouldn't use the legacy C0000 method but get the
|
|
|
|
* rom base address from the corresponding pci or acpi register but
|
|
|
|
* lets ignore that and use C0000 anyway. We have already mapped the
|
|
|
|
* bios area into memory so we'll copy from there.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Copy the bios. */
|
|
|
|
Length = min(Length, 0x10000);
|
|
|
|
if (RomImageBuffer != NULL)
|
|
|
|
{
|
|
|
|
ExFreePool(RomImageBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
RomImageBuffer = ExAllocatePool(PagedPool, Length);
|
|
|
|
if (RomImageBuffer == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
|
|
|
RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
|
|
|
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
|
|
|
|
|
|
|
return RomImageBuffer;
|
|
|
|
}
|
2004-03-19 20:58:32 +00:00
|
|
|
}
|
2003-06-21 14:25:30 +00:00
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortScanRom(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PUCHAR RomBase,
|
|
|
|
IN ULONG RomLength,
|
|
|
|
IN PUCHAR String)
|
2004-03-19 20:58:32 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
ULONG StringLength;
|
|
|
|
BOOLEAN Found;
|
|
|
|
PUCHAR SearchLocation;
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortScanRom RomBase %p RomLength 0x%x String %s\n", RomBase, RomLength, String);
|
|
|
|
|
|
|
|
StringLength = strlen((PCHAR)String);
|
|
|
|
Found = FALSE;
|
|
|
|
SearchLocation = RomBase;
|
|
|
|
for (SearchLocation = RomBase;
|
|
|
|
!Found && SearchLocation < RomBase + RomLength - StringLength;
|
|
|
|
SearchLocation++)
|
|
|
|
{
|
|
|
|
Found = (RtlCompareMemory(SearchLocation, String, StringLength) == StringLength);
|
|
|
|
if (Found)
|
|
|
|
{
|
|
|
|
INFO_(VIDEOPRT, "Match found at %p\n", SearchLocation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Found;
|
2003-02-15 19:16:34 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortSynchronizeExecution(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN VIDEO_SYNCHRONIZE_PRIORITY Priority,
|
|
|
|
IN PMINIPORT_SYNCHRONIZE_ROUTINE SynchronizeRoutine,
|
|
|
|
OUT PVOID Context)
|
2003-02-15 19:16:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
BOOLEAN Ret;
|
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
KIRQL OldIrql;
|
|
|
|
|
|
|
|
switch (Priority)
|
|
|
|
{
|
|
|
|
case VpLowPriority:
|
2004-03-19 20:58:32 +00:00
|
|
|
Ret = (*SynchronizeRoutine)(Context);
|
2013-11-13 21:32:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VpMediumPriority:
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
if (DeviceExtension->InterruptObject == NULL)
|
|
|
|
Ret = (*SynchronizeRoutine)(Context);
|
|
|
|
else
|
|
|
|
Ret = KeSynchronizeExecution(
|
|
|
|
DeviceExtension->InterruptObject,
|
|
|
|
SynchronizeRoutine,
|
|
|
|
Context);
|
|
|
|
break;
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
case VpHighPriority:
|
|
|
|
OldIrql = KeGetCurrentIrql();
|
|
|
|
if (OldIrql < SYNCH_LEVEL)
|
|
|
|
KeRaiseIrql(SYNCH_LEVEL, &OldIrql);
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
Ret = (*SynchronizeRoutine)(Context);
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
if (OldIrql < SYNCH_LEVEL)
|
|
|
|
KeLowerIrql(OldIrql);
|
|
|
|
break;
|
2004-03-19 20:58:32 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
default:
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
2004-03-06 01:22:04 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
return Ret;
|
2003-02-25 23:08:54 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
2005-01-07 01:03:34 +00:00
|
|
|
* @implemented
|
2004-03-08 04:09:02 +00:00
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortEnumerateChildren(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PVOID Reserved)
|
2004-03-06 08:39:06 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
ULONG Status;
|
|
|
|
VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
|
|
|
|
BOOLEAN bHaveLastMonitorID = FALSE;
|
|
|
|
UCHAR LastMonitorID[10];
|
|
|
|
ULONG Unused;
|
|
|
|
UINT i;
|
|
|
|
PDEVICE_OBJECT ChildDeviceObject;
|
|
|
|
PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
|
|
|
|
|
|
|
|
INFO_(VIDEOPRT, "Starting child device probe\n");
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
if (DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor == NULL)
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enumerate the children */
|
|
|
|
for (i = 1; ; i++)
|
|
|
|
{
|
|
|
|
Status = IoCreateDevice(DeviceExtension->DriverObject,
|
|
|
|
sizeof(VIDEO_PORT_CHILD_EXTENSION) +
|
|
|
|
DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize,
|
|
|
|
NULL,
|
|
|
|
FILE_DEVICE_CONTROLLER,
|
|
|
|
FILE_DEVICE_SECURE_OPEN,
|
|
|
|
FALSE,
|
|
|
|
&ChildDeviceObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return Status;
|
|
|
|
|
|
|
|
ChildExtension = ChildDeviceObject->DeviceExtension;
|
|
|
|
|
|
|
|
RtlZeroMemory(ChildExtension,
|
|
|
|
sizeof(VIDEO_PORT_CHILD_EXTENSION) +
|
|
|
|
DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize);
|
|
|
|
|
|
|
|
ChildExtension->Common.Fdo = FALSE;
|
|
|
|
ChildExtension->ChildId = i;
|
|
|
|
ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
|
|
|
|
ChildExtension->DriverObject = DeviceExtension->DriverObject;
|
|
|
|
|
|
|
|
/* Setup the ChildEnumInfo */
|
|
|
|
ChildEnumInfo.Size = sizeof(ChildEnumInfo);
|
|
|
|
ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
|
|
|
|
ChildEnumInfo.ACPIHwId = 0;
|
|
|
|
|
|
|
|
if (DeviceExtension->DriverExtension->InitializationData.HwChildDeviceExtensionSize)
|
|
|
|
ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
|
|
|
|
else
|
|
|
|
ChildEnumInfo.ChildHwDeviceExtension = NULL;
|
|
|
|
|
|
|
|
ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
|
|
|
|
|
|
|
|
INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
|
|
|
|
Status = DeviceExtension->DriverExtension->InitializationData.HwGetVideoChildDescriptor(
|
|
|
|
HwDeviceExtension,
|
|
|
|
&ChildEnumInfo,
|
|
|
|
&ChildExtension->ChildType,
|
|
|
|
ChildExtension->ChildDescriptor,
|
|
|
|
&ChildExtension->ChildId,
|
|
|
|
&Unused);
|
|
|
|
if (Status == VIDEO_ENUM_MORE_DEVICES)
|
|
|
|
{
|
|
|
|
if (ChildExtension->ChildType == Monitor)
|
2007-08-03 12:10:43 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
// Check if the EDID is valid
|
|
|
|
if (ChildExtension->ChildDescriptor[0] == 0x00 &&
|
|
|
|
ChildExtension->ChildDescriptor[1] == 0xFF &&
|
|
|
|
ChildExtension->ChildDescriptor[2] == 0xFF &&
|
|
|
|
ChildExtension->ChildDescriptor[3] == 0xFF &&
|
|
|
|
ChildExtension->ChildDescriptor[4] == 0xFF &&
|
|
|
|
ChildExtension->ChildDescriptor[5] == 0xFF &&
|
|
|
|
ChildExtension->ChildDescriptor[6] == 0xFF &&
|
|
|
|
ChildExtension->ChildDescriptor[7] == 0x00)
|
|
|
|
{
|
|
|
|
if (bHaveLastMonitorID)
|
|
|
|
{
|
|
|
|
// Compare the previous monitor ID with the current one, break the loop if they are identical
|
|
|
|
if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
|
|
|
|
{
|
|
|
|
INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
|
|
|
|
IoDeleteDevice(ChildDeviceObject);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
|
|
|
|
RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
|
|
|
|
bHaveLastMonitorID = TRUE;
|
|
|
|
|
|
|
|
/* Mark it valid */
|
|
|
|
ChildExtension->EdidValid = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Mark it invalid */
|
|
|
|
ChildExtension->EdidValid = FALSE;
|
|
|
|
}
|
2012-03-12 03:29:36 +00:00
|
|
|
}
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
else if (Status == VIDEO_ENUM_INVALID_DEVICE)
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
|
|
|
|
IoDeleteDevice(ChildDeviceObject);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (Status == VIDEO_ENUM_NO_MORE_DEVICES)
|
|
|
|
{
|
|
|
|
INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
|
|
|
|
IoDeleteDevice(ChildDeviceObject);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
|
|
|
|
IoDeleteDevice(ChildDeviceObject);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ChildExtension->ChildType == Monitor)
|
|
|
|
{
|
|
|
|
UINT j;
|
|
|
|
PUCHAR p = ChildExtension->ChildDescriptor;
|
|
|
|
INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
|
|
|
|
for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
|
2012-03-12 03:29:36 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
|
|
|
|
p[j + 0], p[j + 1], p[j + 2], p[j + 3],
|
|
|
|
p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
|
2007-08-03 12:10:43 +00:00
|
|
|
}
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
|
|
|
else if (ChildExtension->ChildType == Other)
|
|
|
|
{
|
|
|
|
INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the init flag */
|
|
|
|
ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
|
|
|
|
|
|
|
|
InsertTailList(&DeviceExtension->ChildDeviceList,
|
|
|
|
&ChildExtension->ListEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Trigger reenumeration by the PnP manager */
|
|
|
|
IoInvalidateDeviceRelations(DeviceExtension->PhysicalDeviceObject, BusRelations);
|
|
|
|
|
|
|
|
return NO_ERROR;
|
2004-03-06 08:39:06 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 04:09:02 +00:00
|
|
|
/*
|
2004-03-19 20:58:32 +00:00
|
|
|
* @unimplemented
|
2004-03-08 04:09:02 +00:00
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortCreateSecondaryDisplay(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN OUT PVOID *SecondaryDeviceExtension,
|
|
|
|
IN ULONG Flag)
|
2004-03-06 22:25:22 +00:00
|
|
|
{
|
2007-12-28 14:47:03 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
return ERROR_DEV_NOT_EXIST;
|
2004-03-06 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortQueueDpc(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN PMINIPORT_DPC_ROUTINE CallbackRoutine,
|
|
|
|
IN PVOID Context)
|
2004-03-06 22:25:22 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
return KeInsertQueueDpc(
|
|
|
|
&VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension)->DpcObject,
|
|
|
|
(PVOID)CallbackRoutine,
|
|
|
|
(PVOID)Context);
|
2004-03-06 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
2005-12-31 16:01:02 +00:00
|
|
|
* @implemented
|
2004-03-19 20:58:32 +00:00
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
VideoPortGetAssociatedDeviceExtension(
|
|
|
|
IN PVOID DeviceObject)
|
2004-03-06 22:25:22 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
2005-12-31 16:01:02 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
TRACE_(VIDEOPRT, "VideoPortGetAssociatedDeviceExtension\n");
|
|
|
|
DeviceExtension = ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
|
|
|
|
if (!DeviceExtension)
|
|
|
|
return NULL;
|
|
|
|
return DeviceExtension->MiniPortDeviceExtension;
|
2004-03-06 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 04:09:02 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortGetVersion(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN OUT PVPOSVERSIONINFO VpOsVersionInfo)
|
2004-03-06 22:25:22 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
RTL_OSVERSIONINFOEXW Version;
|
2004-03-08 08:05:27 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
Version.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
|
|
|
|
if (VpOsVersionInfo->Size >= sizeof(VPOSVERSIONINFO))
|
|
|
|
{
|
2004-03-08 20:27:33 +00:00
|
|
|
#if 1
|
2013-11-13 21:32:16 +00:00
|
|
|
if (NT_SUCCESS(RtlGetVersion((PRTL_OSVERSIONINFOW)&Version)))
|
|
|
|
{
|
|
|
|
VpOsVersionInfo->MajorVersion = Version.dwMajorVersion;
|
|
|
|
VpOsVersionInfo->MinorVersion = Version.dwMinorVersion;
|
|
|
|
VpOsVersionInfo->BuildNumber = Version.dwBuildNumber;
|
|
|
|
VpOsVersionInfo->ServicePackMajor = Version.wServicePackMajor;
|
|
|
|
VpOsVersionInfo->ServicePackMinor = Version.wServicePackMinor;
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2004-03-08 20:27:33 +00:00
|
|
|
#else
|
2013-11-13 21:32:16 +00:00
|
|
|
VpOsVersionInfo->MajorVersion = 5;
|
|
|
|
VpOsVersionInfo->MinorVersion = 0;
|
|
|
|
VpOsVersionInfo->BuildNumber = 2195;
|
|
|
|
VpOsVersionInfo->ServicePackMajor = 4;
|
|
|
|
VpOsVersionInfo->ServicePackMinor = 0;
|
|
|
|
return NO_ERROR;
|
2004-03-08 20:27:33 +00:00
|
|
|
#endif
|
2013-11-13 21:32:16 +00:00
|
|
|
}
|
2004-03-08 08:05:27 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2004-03-06 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
2005-12-31 16:01:02 +00:00
|
|
|
* @implemented
|
2004-03-19 20:58:32 +00:00
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortCheckForDeviceExistence(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN USHORT VendorId,
|
|
|
|
IN USHORT DeviceId,
|
|
|
|
IN UCHAR RevisionId,
|
|
|
|
IN USHORT SubVendorId,
|
|
|
|
IN USHORT SubSystemId,
|
|
|
|
IN ULONG Flags)
|
2004-03-06 22:25:22 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
PCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface;
|
|
|
|
IO_STATUS_BLOCK IoStatusBlock;
|
|
|
|
IO_STACK_LOCATION IoStack;
|
|
|
|
ULONG PciFlags = 0;
|
|
|
|
NTSTATUS Status;
|
|
|
|
BOOL DevicePresent;
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortCheckForDeviceExistence\n");
|
|
|
|
|
|
|
|
if (Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS))
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "VideoPortCheckForDeviceExistence: Unknown flags 0x%lx\n", Flags & ~(CDE_USE_REVISION | CDE_USE_SUBSYSTEM_IDS));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
|
|
|
|
PciDevicePresentInterface.Size = sizeof(PCI_DEVICE_PRESENT_INTERFACE);
|
|
|
|
PciDevicePresentInterface.Version = 1;
|
|
|
|
IoStack.Parameters.QueryInterface.Size = PciDevicePresentInterface.Size;
|
|
|
|
IoStack.Parameters.QueryInterface.Version = PciDevicePresentInterface.Version;
|
|
|
|
IoStack.Parameters.QueryInterface.Interface = (PINTERFACE)&PciDevicePresentInterface;
|
|
|
|
IoStack.Parameters.QueryInterface.InterfaceType =
|
|
|
|
&GUID_PCI_DEVICE_PRESENT_INTERFACE;
|
|
|
|
Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
|
|
|
|
&IoStatusBlock, IRP_MN_QUERY_INTERFACE, &IoStack);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%lx)\n", Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Flags & CDE_USE_REVISION)
|
|
|
|
PciFlags |= PCI_USE_REVISION;
|
|
|
|
if (Flags & CDE_USE_SUBSYSTEM_IDS)
|
|
|
|
PciFlags |= PCI_USE_SUBSYSTEM_IDS;
|
|
|
|
|
|
|
|
DevicePresent = PciDevicePresentInterface.IsDevicePresent(
|
|
|
|
VendorId, DeviceId, RevisionId,
|
|
|
|
SubVendorId, SubSystemId, PciFlags);
|
|
|
|
|
|
|
|
PciDevicePresentInterface.InterfaceDereference(PciDevicePresentInterface.Context);
|
|
|
|
|
|
|
|
return DevicePresent;
|
2004-03-06 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VP_STATUS
|
|
|
|
NTAPI
|
2004-03-19 20:58:32 +00:00
|
|
|
VideoPortRegisterBugcheckCallback(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN ULONG BugcheckCode,
|
|
|
|
IN PVIDEO_BUGCHECK_CALLBACK Callback,
|
|
|
|
IN ULONG BugcheckDataSize)
|
2004-03-07 04:43:55 +00:00
|
|
|
{
|
2007-12-28 14:47:03 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
return NO_ERROR;
|
2004-03-07 04:43:55 +00:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:58:32 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
LONGLONG
|
|
|
|
NTAPI
|
2004-03-09 17:28:49 +00:00
|
|
|
VideoPortQueryPerformanceCounter(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
OUT PLONGLONG PerformanceFrequency OPTIONAL)
|
2004-03-09 17:28:49 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
LARGE_INTEGER Result;
|
2004-03-09 17:28:49 +00:00
|
|
|
|
2013-11-13 21:32:16 +00:00
|
|
|
TRACE_(VIDEOPRT, "VideoPortQueryPerformanceCounter\n");
|
|
|
|
Result = KeQueryPerformanceCounter((PLARGE_INTEGER)PerformanceFrequency);
|
|
|
|
return Result.QuadPart;
|
2004-03-09 17:28:49 +00:00
|
|
|
}
|
2005-01-07 01:03:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
VideoPortAcquireDeviceLock(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension)
|
2005-01-07 01:03:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
NTSTATUS Status;
|
|
|
|
(void)Status;
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortAcquireDeviceLock\n");
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
Status = KeWaitForMutexObject(&DeviceExtension->DeviceLock, Executive,
|
|
|
|
KernelMode, FALSE, NULL);
|
|
|
|
// ASSERT(Status == STATUS_SUCCESS);
|
2005-01-07 01:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2005-01-07 01:03:34 +00:00
|
|
|
VideoPortReleaseDeviceLock(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension)
|
2005-01-07 01:03:34 +00:00
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
LONG Status;
|
|
|
|
(void)Status;
|
|
|
|
|
|
|
|
TRACE_(VIDEOPRT, "VideoPortReleaseDeviceLock\n");
|
|
|
|
DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
|
|
|
|
Status = KeReleaseMutex(&DeviceExtension->DeviceLock, FALSE);
|
|
|
|
//ASSERT(Status == STATUS_SUCCESS);
|
2005-01-07 01:03:34 +00:00
|
|
|
}
|
|
|
|
|
2005-08-03 07:50:16 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2005-08-03 07:50:16 +00:00
|
|
|
VpNotifyEaData(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN PVOID Data)
|
2005-08-03 07:50:16 +00:00
|
|
|
{
|
2007-12-28 14:47:03 +00:00
|
|
|
UNIMPLEMENTED;
|
2005-08-03 07:50:16 +00:00
|
|
|
}
|
2007-06-05 22:51:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2007-06-05 22:51:44 +00:00
|
|
|
VideoPortAllocateContiguousMemory(
|
2013-11-13 21:32:16 +00:00
|
|
|
IN PVOID HwDeviceExtension,
|
|
|
|
IN ULONG NumberOfBytes,
|
|
|
|
IN PHYSICAL_ADDRESS HighestAcceptableAddress
|
|
|
|
)
|
2007-06-05 22:51:44 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
return MmAllocateContiguousMemory(NumberOfBytes, HighestAcceptableAddress);
|
|
|
|
}
|
2010-03-04 21:53:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2013-11-13 21:32:16 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2010-03-04 21:53:12 +00:00
|
|
|
VideoPortIsNoVesa(VOID)
|
|
|
|
{
|
2013-11-13 21:32:16 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
HANDLE KeyHandle;
|
|
|
|
UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control");
|
|
|
|
UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions");
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
|
|
PKEY_VALUE_PARTIAL_INFORMATION KeyInfo;
|
|
|
|
ULONG Length, NewLength;
|
|
|
|
|
|
|
|
/* Initialize object attributes with the path we want */
|
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
&Path,
|
|
|
|
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* Open the key */
|
|
|
|
Status = ZwOpenKey(&KeyHandle,
|
|
|
|
KEY_QUERY_VALUE,
|
|
|
|
&ObjectAttributes);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find out how large our buffer should be */
|
|
|
|
Status = ZwQueryValueKey(KeyHandle,
|
|
|
|
&ValueName,
|
|
|
|
KeyValuePartialInformation,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
&Length);
|
|
|
|
if (Status != STATUS_BUFFER_OVERFLOW && Status != STATUS_BUFFER_TOO_SMALL)
|
|
|
|
{
|
|
|
|
VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
|
|
|
|
ZwClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate it */
|
|
|
|
KeyInfo = ExAllocatePool(PagedPool, Length);
|
|
|
|
if (!KeyInfo)
|
|
|
|
{
|
|
|
|
VideoPortDebugPrint(Error, "Out of memory\n");
|
|
|
|
ZwClose(KeyHandle);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now for real this time */
|
|
|
|
Status = ZwQueryValueKey(KeyHandle,
|
|
|
|
&ValueName,
|
|
|
|
KeyValuePartialInformation,
|
|
|
|
KeyInfo,
|
|
|
|
Length,
|
|
|
|
&NewLength);
|
|
|
|
|
|
|
|
ZwClose(KeyHandle);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status);
|
|
|
|
ExFreePool(KeyInfo);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sanity check */
|
|
|
|
if (KeyInfo->Type != REG_SZ)
|
|
|
|
{
|
|
|
|
VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n");
|
|
|
|
ExFreePool(KeyInfo);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if NOVESA or BASEVIDEO is present in the start options */
|
|
|
|
if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA") ||
|
|
|
|
wcsstr((PWCHAR)KeyInfo->Data, L"BASEVIDEO"))
|
|
|
|
{
|
|
|
|
VideoPortDebugPrint(Info, "VESA mode disabled\n");
|
|
|
|
ExFreePool(KeyInfo);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExFreePool(KeyInfo);
|
|
|
|
|
|
|
|
VideoPortDebugPrint(Info, "VESA mode enabled\n");
|
|
|
|
|
|
|
|
return FALSE;
|
2010-03-04 21:53:12 +00:00
|
|
|
}
|