[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

svn path=/trunk/; revision=56200
This commit is contained in:
Cameron Gutman 2012-03-21 07:15:55 +00:00
parent 955e4aa159
commit 1cb478ab04
3 changed files with 63 additions and 0 deletions

View file

@ -1027,6 +1027,10 @@ PnpRootCreateDevice(
OUT OPTIONAL PUNICODE_STRING FullInstancePath
);
NTSTATUS
PnpRootRegisterDevice(
IN PDEVICE_OBJECT DeviceObject);
//
// Driver Routines
//

View file

@ -338,6 +338,10 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
/* 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);

View file

@ -126,6 +126,61 @@ LocateChildDevice(
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(