[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / io / pnpmgr / pnpmgr.c
index 32e2ec5..9cd6347 100644 (file)
@@ -13,7 +13,7 @@
 #define NDEBUG
 #include <debug.h>
 
-//#define ENABLE_ACPI
+#define ENABLE_ACPI
 
 /* GLOBALS *******************************************************************/
 
@@ -515,6 +515,11 @@ IopInitiatePnpIrp(PDEVICE_OBJECT DeviceObject,
    Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
    Irp->IoStatus.Information = 0;
 
+   if (MinorFunction == IRP_MN_FILTER_RESOURCE_REQUIREMENTS)
+   {
+      Irp->IoStatus.Information = (ULONG_PTR)Stack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
+   }
+
    IrpSp = IoGetNextIrpStackLocation(Irp);
    IrpSp->MinorFunction = (UCHAR)MinorFunction;
 
@@ -1415,7 +1420,7 @@ IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
                              sizeof(ULONG));
 
       /* Set 'UINumber' value */
-      if (DeviceCapabilities.UINumber != (ULONG)-1)
+      if (DeviceCapabilities.UINumber != MAXULONG)
       {
          RtlInitUnicodeString(&ValueName, L"UINumber");
          Status = ZwSetValueKey(InstanceKey,
@@ -1842,6 +1847,7 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
    PUNICODE_STRING Service;
    UNICODE_STRING ClassGUID;
    NTSTATUS Status;
+   DEVICE_CAPABILITIES DeviceCaps;
 
    DPRINT("IopActionConfigureChildServices(%p, %p)\n", DeviceNode, Context);
 
@@ -1888,7 +1894,7 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
       RtlInitUnicodeString(&ClassGUID, NULL);
 
       QueryTable[0].Name = L"Service";
-      QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
+      QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
       QueryTable[0].EntryContext = Service;
 
       QueryTable[1].Name = L"ClassGUID";
@@ -1915,9 +1921,22 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
 
       if (Service->Buffer == NULL)
       {
-         IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
+         if (NT_SUCCESS(IopQueryDeviceCapabilities(DeviceNode, &DeviceCaps)) &&
+             DeviceCaps.RawDeviceOK)
+         {
+            DPRINT1("%wZ is using parent bus driver (%wZ)\n", &DeviceNode->InstancePath, &ParentDeviceNode->ServiceName);
+
+            DeviceNode->ServiceName.Length = 0;
+            DeviceNode->ServiceName.MaximumLength = ParentDeviceNode->ServiceName.MaximumLength;
+            DeviceNode->ServiceName.Buffer = ExAllocatePool(PagedPool, DeviceNode->ServiceName.MaximumLength);
+            if (!DeviceNode->ServiceName.Buffer)
+                return STATUS_SUCCESS;
 
-         if (ClassGUID.Length != 0)
+            RtlCopyUnicodeString(&DeviceNode->ServiceName, &ParentDeviceNode->ServiceName);
+
+            IopDeviceNodeSetFlag(DeviceNode, DNF_LEGACY_DRIVER);
+         }
+         else if (ClassGUID.Length != 0)
          {
             /* Device has a ClassGUID value, but no Service value.
              * Suppose it is using the NULL driver, so state the
@@ -1925,6 +1944,10 @@ IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
             DPRINT1("%wZ is using NULL driver\n", &DeviceNode->InstancePath);
             IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED);
          }
+         else
+         {
+            IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
+         }
          return STATUS_SUCCESS;
       }
 
@@ -2847,7 +2870,7 @@ PnpInit(VOID)
        ExInitializeFastMutex(&IopBusTypeGuidListLock);
        
     /* Initialize the Bus Type GUID List */
-    IopBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
+    IopBusTypeGuidList = ExAllocatePool(NonPagedPool, sizeof(IO_BUS_TYPE_GUID_LIST));
     if (!IopBusTypeGuidList) {
        DPRINT1("ExAllocatePool() failed\n");
        KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, STATUS_NO_MEMORY, 0, 0, 0);
@@ -3073,7 +3096,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
     case DevicePropertyAddress:
         /* Query the device caps */
         Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCaps);
-        if (NT_SUCCESS(Status) && (DeviceCaps.Address != (ULONG)-1))
+        if (NT_SUCCESS(Status) && (DeviceCaps.Address != MAXULONG))
         {
             /* Return length */
             *ResultLength = sizeof(ULONG);
@@ -3231,7 +3254,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
         * always contains the enumerator name followed by \\ */
         Ptr = wcschr(DeviceNode->InstancePath.Buffer, L'\\');
         ASSERT(Ptr);
-        Length = (Ptr - DeviceNode->InstancePath.Buffer + 1) * sizeof(WCHAR);
+        Length = (Ptr - DeviceNode->InstancePath.Buffer) * sizeof(WCHAR);
         Data = DeviceNode->InstancePath.Buffer;
         break;