Author: cgutman Date: Wed Mar 21 07:15:55 2012 New Revision: 56200
URL: http://svn.reactos.org/svn/reactos?rev=56200&view=rev Log: [NTOSKRNL] - Create PnpRootRegisterDevice which is used to register a given PDO with the root device so it won't report it twice - Listing devices by connection works with PCI HAL now but it seems that ACPI is detecting multiple ACPI\PNP0C0F\0 instances here in vbox which is causing the same infinite loop
Modified: trunk/reactos/ntoskrnl/include/internal/io.h trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Wed Mar 21 07:15:55 2012 @@ -1027,6 +1027,10 @@ OUT OPTIONAL PUNICODE_STRING FullInstancePath );
+NTSTATUS +PnpRootRegisterDevice( + IN PDEVICE_OBJECT DeviceObject); + // // Driver Routines //
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnprepor... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpreport.c [iso-8859-1] Wed Mar 21 07:15:55 2012 @@ -338,6 +338,10 @@ /* Close the instance key handle */ ZwClose(InstanceKey);
+ /* Register the given DO with PnP root if required */ + if (DeviceObject && *DeviceObject) + PnpRootRegisterDevice(*DeviceObject); + /* Report the device's enumeration to umpnpmgr */ IopQueueTargetDeviceEvent(&GUID_DEVICE_ENUMERATED, &DeviceNode->InstancePath);
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c [iso-8859-1] Wed Mar 21 07:15:55 2012 @@ -126,6 +126,61 @@ return STATUS_NO_SUCH_DEVICE; }
+NTSTATUS +PnpRootRegisterDevice( + IN PDEVICE_OBJECT DeviceObject) +{ + PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension = PnpRootDeviceObject->DeviceExtension; + PPNPROOT_DEVICE Device; + PDEVICE_NODE DeviceNode; + PWSTR InstancePath; + UNICODE_STRING InstancePathCopy; + + Device = ExAllocatePoolWithTag(PagedPool, sizeof(PNPROOT_DEVICE), TAG_PNP_ROOT); + if (!Device) return STATUS_NO_MEMORY; + + DeviceNode = IopGetDeviceNode(DeviceObject); + if (!RtlCreateUnicodeString(&InstancePathCopy, DeviceNode->InstancePath.Buffer)) + { + ExFreePoolWithTag(Device, TAG_PNP_ROOT); + return STATUS_NO_MEMORY; + } + + InstancePath = wcsrchr(InstancePathCopy.Buffer, L'\'); + ASSERT(InstancePath); + + if (!RtlCreateUnicodeString(&Device->InstanceID, InstancePath + 1)) + { + RtlFreeUnicodeString(&InstancePathCopy); + ExFreePoolWithTag(Device, TAG_PNP_ROOT); + return STATUS_NO_MEMORY; + } + + InstancePath[0] = UNICODE_NULL; + + if (!RtlCreateUnicodeString(&Device->DeviceID, InstancePathCopy.Buffer)) + { + RtlFreeUnicodeString(&InstancePathCopy); + RtlFreeUnicodeString(&Device->InstanceID); + ExFreePoolWithTag(Device, TAG_PNP_ROOT); + return STATUS_NO_MEMORY; + } + + InstancePath[0] = L'\'; + + Device->Pdo = DeviceObject; + + KeAcquireGuardedMutex(&DeviceExtension->DeviceListLock); + InsertTailList(&DeviceExtension->DeviceListHead, + &Device->ListEntry); + DeviceExtension->DeviceListCount++; + KeReleaseGuardedMutex(&DeviceExtension->DeviceListLock); + + RtlFreeUnicodeString(&InstancePathCopy); + + return STATUS_SUCCESS; +} + /* Creates a new PnP device for a legacy driver */ NTSTATUS PnpRootCreateDevice(