Author: fireball Date: Thu Dec 20 15:31:39 2007 New Revision: 31350
URL: http://svn.reactos.org/svn/reactos?rev=31350&view=rev Log: - Make VBEMP look like a legacy driver. - Reorganize VideoPortInitialize (firstly do all checks, then do Driver Object Extension related operations). - Fix the hack Magnus Olsen added for the "No PNP videocard" problem, by adding a real check Windows 2003 SP1 videoport driver is performing (information got by building "stub" miniports and trying to load them with a checked build of W2K3SP1's videoprt.sys). - Add stubbed handler for IRP_MJ_SYSTEM_CONTROL (for PnP miniports) and IRP_MJ_INTERNAL_DEVICE_CONTROL.
Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.c trunk/reactos/drivers/video/videoprt/dispatch.c trunk/reactos/drivers/video/videoprt/videoprt.c trunk/reactos/drivers/video/videoprt/videoprt.h
Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/miniport/vbe/... ============================================================================== --- trunk/reactos/drivers/video/miniport/vbe/vbemp.c (original) +++ trunk/reactos/drivers/video/miniport/vbe/vbemp.c Thu Dec 20 15:31:39 2007 @@ -42,9 +42,9 @@ InitData.HwInitialize = VBEInitialize; InitData.HwStartIO = VBEStartIO; InitData.HwResetHw = VBEResetHw; - InitData.HwGetPowerState = VBEGetPowerState; - InitData.HwSetPowerState = VBESetPowerState; - InitData.HwGetVideoChildDescriptor = VBEGetVideoChildDescriptor; + //InitData.HwGetPowerState = VBEGetPowerState; + //InitData.HwSetPowerState = VBESetPowerState; + //InitData.HwGetVideoChildDescriptor = VBEGetVideoChildDescriptor; InitData.HwDeviceExtensionSize = sizeof(VBE_DEVICE_EXTENSION);
return VideoPortInitialize(Context1, Context2, &InitData, NULL);
Modified: trunk/reactos/drivers/video/videoprt/dispatch.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/disp... ============================================================================== --- trunk/reactos/drivers/video/videoprt/dispatch.c (original) +++ trunk/reactos/drivers/video/videoprt/dispatch.c Thu Dec 20 15:31:39 2007 @@ -509,6 +509,14 @@ return STATUS_NOT_IMPLEMENTED; }
+NTSTATUS NTAPI +IntVideoPortDispatchSystemControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + return STATUS_NOT_IMPLEMENTED; +} + VOID NTAPI IntVideoPortUnload(PDRIVER_OBJECT DriverObject) {
Modified: trunk/reactos/drivers/video/videoprt/videoprt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/vide... ============================================================================== --- trunk/reactos/drivers/video/videoprt/videoprt.c (original) +++ trunk/reactos/drivers/video/videoprt/videoprt.c Thu Dec 20 15:31:39 2007 @@ -1,7 +1,7 @@ /* * VideoPort driver * - * Copyright (C) ReactOS Team + * Copyright (C) 2002-2004, 2007 ReactOS Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -553,7 +553,7 @@ PUNICODE_STRING RegistryPath = Context2; NTSTATUS Status; PVIDEO_PORT_DRIVER_EXTENSION DriverExtension; - BOOL LegacyDetection = FALSE; + BOOLEAN PnpDriver = FALSE, LegacyDetection = FALSE;
DPRINT("VideoPortInitialize\n");
@@ -571,6 +571,63 @@ HwInitializationData->HwStartIO == NULL) { 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: + DPRINT("We were loaded by a Windows NT miniport driver.\n"); + break; + + case SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA: + DPRINT("We were loaded by a Windows 2000 miniport driver.\n"); + break; + + case sizeof(VIDEO_HW_INITIALIZATION_DATA): + DPRINT("We were loaded by a Windows XP or later miniport driver.\n"); + break; + + default: + DPRINT("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 >= + FIELD_OFFSET(VIDEO_HW_INITIALIZATION_DATA, HwQueryInterface)) + && HwInitializationData->HwSetPowerState + && HwInitializationData->HwGetPowerState + && HwInitializationData->HwGetVideoChildDescriptor) + { + DPRINT("The miniport is a PnP miniport driver\n"); + PnpDriver = TRUE; + } + + /* Check if legacy detection should be applied */ + if (!PnpDriver || HwContext) + { + DPRINT("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; }
/* @@ -643,45 +700,6 @@ } DriverExtension->HwContext = HwContext;
- 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: - DPRINT("We were loaded by a Windows NT miniport driver.\n"); - LegacyDetection = TRUE; - break; - - case SIZE_OF_W2K_VIDEO_HW_INITIALIZATION_DATA: - DPRINT("We were loaded by a Windows 2000 miniport driver.\n"); - break; - - case sizeof(VIDEO_HW_INITIALIZATION_DATA): - DPRINT("We were loaded by a Windows XP or later miniport driver.\n"); - break; - - default: - DPRINT("Invalid HwInitializationData size.\n"); - return STATUS_UNSUCCESSFUL; - } - - /* We can't check HwInitializationData->AdapterInterfaceType to know if - * we have to use legacy detection, as MSDN states that this member is - * ignored by videoprt and should remain zero-initialized. - * Force legacy detection, so NT4 drivers will still work on ReactOS. - * WARNING: this will cause all Plug-and-Play IRPs to fail. - */ - LegacyDetection = TRUE; - - DriverObject->MajorFunction[IRP_MJ_CREATE] = IntVideoPortDispatchOpen; - DriverObject->MajorFunction[IRP_MJ_CLOSE] = IntVideoPortDispatchClose; - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IntVideoPortDispatchDeviceControl; - DriverObject->MajorFunction[IRP_MJ_WRITE] = IntVideoPortDispatchWrite; - DriverObject->DriverUnload = IntVideoPortUnload; - /* * Plug & Play drivers registers the device in AddDevice routine. For * legacy drivers we must do it now. @@ -710,6 +728,7 @@ 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; }
Modified: trunk/reactos/drivers/video/videoprt/videoprt.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/vide... ============================================================================== --- trunk/reactos/drivers/video/videoprt/videoprt.h (original) +++ trunk/reactos/drivers/video/videoprt/videoprt.h Thu Dec 20 15:31:39 2007 @@ -165,6 +165,11 @@ IN PIRP Irp);
NTSTATUS NTAPI +IntVideoPortDispatchSystemControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS NTAPI IntVideoPortDispatchWrite( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);