Don't send multiple IRP_MJ_PNP/IRP_MN_START_DEVICE in case of a device with lower/upper filters Modified: trunk/reactos/ntoskrnl/include/internal/io.h Modified: trunk/reactos/ntoskrnl/io/device.c Modified: trunk/reactos/ntoskrnl/io/driver.c Modified: trunk/reactos/ntoskrnl/io/iomgr.c Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c _____
Modified: trunk/reactos/ntoskrnl/include/internal/io.h --- trunk/reactos/ntoskrnl/include/internal/io.h 2005-05-16 18:02:10 UTC (rev 15346) +++ trunk/reactos/ntoskrnl/include/internal/io.h 2005-05-16 18:08:55 UTC (rev 15347) @@ -501,6 +501,10 @@
PDEVICE_NODE DeviceNode, PDRIVER_OBJECT DriverObject);
+NTSTATUS +IopStartDevice( + PDEVICE_NODE DeviceNode); + /* driver.c */
VOID FASTCALL _____
Modified: trunk/reactos/ntoskrnl/io/device.c --- trunk/reactos/ntoskrnl/io/device.c 2005-05-16 18:02:10 UTC (rev 15346) +++ trunk/reactos/ntoskrnl/io/device.c 2005-05-16 18:08:55 UTC (rev 15347) @@ -80,8 +80,6 @@
IopInitializeDevice(PDEVICE_NODE DeviceNode, PDRIVER_OBJECT DriverObject) { - IO_STATUS_BLOCK IoStatusBlock; - IO_STACK_LOCATION Stack; PDEVICE_OBJECT Fdo; NTSTATUS Status;
@@ -115,26 +113,6 @@
IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
- DPRINT("Sending IRP_MN_START_DEVICE to driver\n"); - - /* FIXME: Should be DeviceNode->ResourceList */ - Stack.Parameters.StartDevice.AllocatedResources = DeviceNode->BootResources; - /* FIXME: Should be DeviceNode->ResourceListTranslated */ - Stack.Parameters.StartDevice.AllocatedResourcesTranslated = DeviceNode->BootResources; - - Status = IopInitiatePnpIrp( - Fdo, - &IoStatusBlock, - IRP_MN_START_DEVICE, - &Stack); - - if (!NT_SUCCESS(Status)) - { - DPRINT("IopInitiatePnpIrp() failed\n"); - ObDereferenceObject(Fdo); - return Status; - } - if (Fdo->DeviceType == FILE_DEVICE_ACPI) { static BOOLEAN SystemPowerDeviceNodeCreated = FALSE; @@ -147,23 +125,54 @@ } }
+ ObDereferenceObject(Fdo); + } + + return STATUS_SUCCESS; +} + +NTSTATUS +IopStartDevice( + PDEVICE_NODE DeviceNode) +{ + + IO_STATUS_BLOCK IoStatusBlock; + IO_STACK_LOCATION Stack; + PDEVICE_OBJECT Fdo; + NTSTATUS Status; + + DPRINT("Sending IRP_MN_START_DEVICE to driver\n"); + + Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject); + /* FIXME: Should be DeviceNode->ResourceList */ + Stack.Parameters.StartDevice.AllocatedResources = DeviceNode->BootResources; + /* FIXME: Should be DeviceNode->ResourceListTranslated */ + Stack.Parameters.StartDevice.AllocatedResourcesTranslated = DeviceNode->BootResources; + + Status = IopInitiatePnpIrp( + Fdo, + &IoStatusBlock, + IRP_MN_START_DEVICE, + &Stack); + + if (!NT_SUCCESS(Status)) + { + DPRINT("IopInitiatePnpIrp() failed\n"); + } + else + { if (Fdo->DeviceType == FILE_DEVICE_BUS_EXTENDER || Fdo->DeviceType == FILE_DEVICE_ACPI) { DPRINT("Bus extender found\n");
Status = IopInvalidateDeviceRelations(DeviceNode, BusRelations); - if (!NT_SUCCESS(Status)) - { - ObDereferenceObject(Fdo); - return Status; - } } - - ObDereferenceObject(Fdo); }
- return STATUS_SUCCESS; + ObDereferenceObject(Fdo); + + return Status; }
NTSTATUS _____
Modified: trunk/reactos/ntoskrnl/io/driver.c --- trunk/reactos/ntoskrnl/io/driver.c 2005-05-16 18:02:10 UTC (rev 15346) +++ trunk/reactos/ntoskrnl/io/driver.c 2005-05-16 18:08:55 UTC (rev 15347) @@ -1202,6 +1202,10 @@
}
Status = IopInitializeDevice(DeviceNode, DriverObject); + if (NT_SUCCESS(Status)) + { + Status = IopStartDevice(DeviceNode); + }
return Status; } @@ -1938,6 +1942,7 @@ }
IopInitializeDevice(DeviceNode, DriverObject); + Status = IopStartDevice(DeviceNode);
ReleaseCapturedString: RtlReleaseCapturedUnicodeString(&CapturedDriverServiceName, _____
Modified: trunk/reactos/ntoskrnl/io/iomgr.c --- trunk/reactos/ntoskrnl/io/iomgr.c 2005-05-16 18:02:10 UTC (rev 15346) +++ trunk/reactos/ntoskrnl/io/iomgr.c 2005-05-16 18:08:55 UTC (rev 15347) @@ -378,6 +378,14 @@
return; }
+ Status = IopStartDevice(DeviceNode); + if (!NT_SUCCESS(Status)) + { + IopFreeDeviceNode(DeviceNode); + CPRINT("IopInitializeDevice() failed with status (%x)\n", Status); + return; + } + /* * Initialize PnP root releations */ _____
Modified: trunk/reactos/ntoskrnl/io/pnpmgr.c --- trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-05-16 18:02:10 UTC (rev 15346) +++ trunk/reactos/ntoskrnl/io/pnpmgr.c 2005-05-16 18:08:55 UTC (rev 15347) @@ -1523,9 +1523,11 @@
Status = IopInitializeDevice(DeviceNode, DriverObject); if (NT_SUCCESS(Status)) { - IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED); /* Attach upper level filter drivers. */ IopAttachFilterDrivers(DeviceNode, FALSE); + IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED); + + Status = IopStartDevice(DeviceNode); } } }