From: Hervé Poussineau Date: Tue, 8 Nov 2005 17:20:58 +0000 (+0000) Subject: When a driver is a legacy driver, call its AddDevice function with a NULL Pdo X-Git-Tag: backups/ros-branch-0_2_9@19949~840 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=1974f400e382d323ce402f6ae23f5282fec21b6a When a driver is a legacy driver, call its AddDevice function with a NULL Pdo svn path=/trunk/; revision=19059 --- diff --git a/reactos/drivers/bus/acpi/ospm/acpisys.c b/reactos/drivers/bus/acpi/ospm/acpisys.c index facfd67c894..9aa53cb14a5 100644 --- a/reactos/drivers/bus/acpi/ospm/acpisys.c +++ b/reactos/drivers/bus/acpi/ospm/acpisys.c @@ -143,8 +143,8 @@ ACPIAddDevice( DeviceExtension->Pdo = PhysicalDeviceObject; DeviceExtension->Common.IsFDO = TRUE; - DeviceExtension->Common.Ldo = - IoAttachDeviceToDeviceStack(Fdo, PhysicalDeviceObject); + //DeviceExtension->Common.Ldo = + // IoAttachDeviceToDeviceStack(Fdo, PhysicalDeviceObject); DeviceExtension->State = dsStopped; diff --git a/reactos/drivers/input/i8042prt/i8042prt.c b/reactos/drivers/input/i8042prt/i8042prt.c index 0a62770b56e..ccede6f80e7 100644 --- a/reactos/drivers/input/i8042prt/i8042prt.c +++ b/reactos/drivers/input/i8042prt/i8042prt.c @@ -696,14 +696,15 @@ static NTSTATUS STDCALL I8042AddDevice(PDRIVER_OBJECT DriverObject, PDEVICE_EXTENSION DevExt; PFDO_DEVICE_EXTENSION FdoDevExt; PDEVICE_OBJECT Fdo; - static BOOLEAN AlreadyAdded = FALSE; DPRINT("I8042AddDevice\n"); - /* HACK! */ - if (AlreadyAdded) + if (Pdo != NULL) + { + /* Device detected by pnpmgr. Ignore it, as we already have + * detected the keyboard and mouse at first call */ return STATUS_UNSUCCESSFUL; - AlreadyAdded = TRUE; + } Status = IoCreateDevice(DriverObject, sizeof(DEVICE_EXTENSION), @@ -716,8 +717,6 @@ static NTSTATUS STDCALL I8042AddDevice(PDRIVER_OBJECT DriverObject, if (!NT_SUCCESS(Status)) return Status; - IoAttachDeviceToDeviceStack(Fdo, Pdo); - DevExt = Fdo->DeviceExtension; RtlZeroMemory(DevExt, sizeof(DEVICE_EXTENSION)); diff --git a/reactos/drivers/input/kbdclass/kbdclass.c b/reactos/drivers/input/kbdclass/kbdclass.c index 229e6b143bc..267b8517cb1 100644 --- a/reactos/drivers/input/kbdclass/kbdclass.c +++ b/reactos/drivers/input/kbdclass/kbdclass.c @@ -482,6 +482,9 @@ ClassAddDevice( DPRINT("ClassAddDevice called. Pdo = 0x%p\n", Pdo); + if (Pdo == NULL) + return STATUS_SUCCESS; + DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); /* Create new device object */ diff --git a/reactos/drivers/input/mouclass/mouclass.c b/reactos/drivers/input/mouclass/mouclass.c index b7b972a0c20..49afb16ea2b 100644 --- a/reactos/drivers/input/mouclass/mouclass.c +++ b/reactos/drivers/input/mouclass/mouclass.c @@ -472,6 +472,9 @@ ClassAddDevice( DPRINT("ClassAddDevice called. Pdo = 0x%p\n", Pdo); + if (Pdo == NULL) + return STATUS_SUCCESS; + DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); /* Create new device object */ diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 2e1cdfcfdb6..9e5474261ef 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -72,6 +72,7 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode, { PDEVICE_OBJECT Fdo; NTSTATUS Status; + BOOLEAN IsPnpDriver = FALSE; if (DriverObject->DriverExtension->AddDevice) { @@ -83,39 +84,43 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode, DPRINT("Calling driver AddDevice entrypoint at %08lx\n", DriverObject->DriverExtension->AddDevice); + IsPnpDriver = !IopDeviceNodeHasFlag(DeviceNode, DNF_LEGACY_DRIVER); Status = DriverObject->DriverExtension->AddDevice( - DriverObject, DeviceNode->PhysicalDeviceObject); + DriverObject, IsPnpDriver ? DeviceNode->PhysicalDeviceObject : NULL); if (!NT_SUCCESS(Status)) { return Status; } - Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject); - - if (Fdo == DeviceNode->PhysicalDeviceObject) + if (IsPnpDriver) { - /* FIXME: What do we do? Unload the driver or just disable the device? */ - DbgPrint("An FDO was not attached\n"); - IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED); - return STATUS_UNSUCCESSFUL; - } + Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject); - IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED); - - if (Fdo->DeviceType == FILE_DEVICE_ACPI) - { - static BOOLEAN SystemPowerDeviceNodeCreated = FALSE; + if (Fdo == DeviceNode->PhysicalDeviceObject) + { + /* FIXME: What do we do? Unload the driver or just disable the device? */ + DbgPrint("An FDO was not attached\n"); + IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED); + return STATUS_UNSUCCESSFUL; + } - /* There can be only one system power device */ - if (!SystemPowerDeviceNodeCreated) + if (Fdo->DeviceType == FILE_DEVICE_ACPI) { - PopSystemPowerDeviceNode = DeviceNode; - SystemPowerDeviceNodeCreated = TRUE; + static BOOLEAN SystemPowerDeviceNodeCreated = FALSE; + + /* There can be only one system power device */ + if (!SystemPowerDeviceNodeCreated) + { + PopSystemPowerDeviceNode = DeviceNode; + SystemPowerDeviceNodeCreated = TRUE; + } } + + ObDereferenceObject(Fdo); } - ObDereferenceObject(Fdo); + IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED); } return STATUS_SUCCESS; @@ -564,7 +569,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, if (!NT_SUCCESS(Status)) { - DPRINT1("Cannot insert Device Object into Handle Table\n"); + DPRINT1("Cannot insert Device Object into Handle Table (status 0x%08lx)\n", Status); *DeviceObject = NULL; return Status; }