[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / io / pnpmgr / pnpmgr.c
index 890fd60..f40c505 100644 (file)
@@ -13,7 +13,7 @@
 #define NDEBUG
 #include <debug.h>
 
-//#define ENABLE_ACPI
+#define ENABLE_ACPI
 
 /* GLOBALS *******************************************************************/
 
@@ -1847,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);
 
@@ -1893,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";
@@ -1920,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
@@ -1930,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;
       }
 
@@ -2162,6 +2180,15 @@ IopEnumerateDetectedDevices(
    const UNICODE_STRING IdentifierMouse = RTL_CONSTANT_STRING(L"PointerController");
    UNICODE_STRING HardwareIdMouse = RTL_CONSTANT_STRING(L"*PNP0F13\0");
    static ULONG DeviceIndexMouse = 0;
+   const UNICODE_STRING IdentifierParallel = RTL_CONSTANT_STRING(L"PARALLEL");
+   UNICODE_STRING HardwareIdParallel = RTL_CONSTANT_STRING(L"*PNP0400\0");
+   static ULONG DeviceIndexParallel = 0;
+   const UNICODE_STRING IdentifierFloppy = RTL_CONSTANT_STRING(L"FLOPPY");
+   UNICODE_STRING HardwareIdFloppy = RTL_CONSTANT_STRING(L"*PNP0700\0");
+   static ULONG DeviceIndexFloppy = 0;
+   const UNICODE_STRING IdentifierIsa = RTL_CONSTANT_STRING(L"ISA");
+   UNICODE_STRING HardwareIdIsa = RTL_CONSTANT_STRING(L"*PNP0A00\0");
+   static ULONG DeviceIndexIsa = 0;
    UNICODE_STRING HardwareIdKey;
    PUNICODE_STRING pHardwareId;
    ULONG DeviceIndex = 0;
@@ -2410,6 +2437,11 @@ IopEnumerateDetectedDevices(
             pHardwareId = &HardwareIdPci;
             DeviceIndex = DeviceIndexPci++;
          }
+         else if (RtlCompareUnicodeString(&ValueName, &IdentifierIsa, FALSE) == 0)
+         {
+            pHardwareId = &HardwareIdIsa;
+            DeviceIndex = DeviceIndexIsa++;
+         }
 #ifdef ENABLE_ACPI
          else if (RtlCompareUnicodeString(&ValueName, &IdentifierAcpi, FALSE) == 0)
          {
@@ -2417,11 +2449,33 @@ IopEnumerateDetectedDevices(
             DeviceIndex = DeviceIndexAcpi++;
          }
 #endif
-         else
+         else /* Now let's detect devices with a device number at the end */
          {
-            /* Unknown device */
-            DPRINT("Unknown device '%wZ'\n", &ValueName);
-            goto nextdevice;
+            /* First, we remove the number */
+            ValueName.Length -= sizeof(WCHAR);
+
+            /* Let's see if it is a floppy device */
+            if (RtlCompareUnicodeString(&ValueName, &IdentifierFloppy, FALSE) == 0)
+            {
+                pHardwareId = &HardwareIdFloppy;
+                DeviceIndex = DeviceIndexFloppy++;
+            }
+            /* Nope, is it a parallel port? */
+            else if (RtlCompareUnicodeString(&ValueName, &IdentifierParallel, FALSE) == 0)
+            {
+                pHardwareId = &HardwareIdParallel;
+                DeviceIndex = DeviceIndexParallel++;
+            }
+            /* Nope, out of ideas so let's skip this one */
+            else
+            {
+                ValueName.Length += sizeof(WCHAR);
+                DPRINT("Unknown device '%wZ'\n", &ValueName);
+                goto nextdevice;
+            }
+
+            /* Add the number back */
+            ValueName.Length += sizeof(WCHAR);
          }
       }
       else