[NDK]: Update DNF_NEED_TO_ENUM to DNF_LEGACY_RESOURCE_DEVICENODE. The former wasn...
authorAlex Ionescu <aionescu@gmail.com>
Tue, 6 Aug 2013 01:42:43 +0000 (01:42 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Tue, 6 Aug 2013 01:42:43 +0000 (01:42 +0000)
[NTOSKRNL]: Commit an old patch of mine that sets up the right frontend code in IoAssignResources. All it does is add some error checking before calling the old halfplemented backend.

svn path=/trunk/; revision=59653

reactos/include/ndk/iotypes.h
reactos/ntoskrnl/io/iomgr/iorsrce.c
reactos/ntoskrnl/io/pnpmgr/pnpmgr.c

index 32e6349..0cc4e6d 100644 (file)
@@ -174,7 +174,7 @@ extern POBJECT_TYPE NTSYSAPI IoDriverObjectType;
 #define DNF_LEGACY_DRIVER                       0x00004000
 #define DNF_STOPPED                             0x00008000
 #define DNF_WILL_BE_REMOVED                     0x00010000
-#define DNF_NEED_TO_ENUM                        0x00020000
+#define DNF_LEGACY_RESOURCE_DEVICENODE          0x00020000
 #define DNF_NOT_CONFIGURED                      0x00040000
 #define DNF_REINSTALL                           0x00080000
 #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00100000 // ???
index febd24b..a498d6d 100644 (file)
@@ -908,37 +908,86 @@ IoReportResourceUsage(PUNICODE_STRING DriverClassName,
     return STATUS_SUCCESS;
 }
 
-/*
- * @halfplemented
- */
-NTSTATUS NTAPI
-IoAssignResources(PUNICODE_STRING RegistryPath,
-                 PUNICODE_STRING DriverClassName,
-                 PDRIVER_OBJECT DriverObject,
-                 PDEVICE_OBJECT DeviceObject,
-                 PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
-                 PCM_RESOURCE_LIST* AllocatedResources)
+NTSTATUS
+NTAPI
+IopLegacyResourceAllocation(IN ARBITER_REQUEST_SOURCE AllocationType,
+                            IN PDRIVER_OBJECT DriverObject,
+                            IN PDEVICE_OBJECT DeviceObject OPTIONAL,
+                            IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements,
+                            IN OUT PCM_RESOURCE_LIST *AllocatedResources)
 {
     NTSTATUS Status;
-    
-    DPRINT1("IoAssignResources is halfplemented!\n");
 
-    *AllocatedResources = NULL;
-    Status = IopFixupResourceListWithRequirements(RequestedResources,
+    DPRINT1("IopLegacyResourceAllocation is halfplemented!\n");
+
+    Status = IopFixupResourceListWithRequirements(ResourceRequirements,
                                                   AllocatedResources);
     if (!NT_SUCCESS(Status))
     {
         if (Status == STATUS_CONFLICTING_ADDRESSES)
+        {
             DPRINT1("Denying an attempt to claim resources currently in use by another device!\n");
-        
+        }
+
         return Status;
     }
-    
+
     /* TODO: Claim resources in registry */
-    
     return STATUS_SUCCESS;
 }
 
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+IoAssignResources(IN PUNICODE_STRING RegistryPath,
+                  IN PUNICODE_STRING DriverClassName,
+                  IN PDRIVER_OBJECT DriverObject,
+                  IN PDEVICE_OBJECT DeviceObject,
+                  IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
+                  IN OUT PCM_RESOURCE_LIST* AllocatedResources)
+{
+    PDEVICE_NODE DeviceNode;
+
+    /* Do we have a DO? */
+    if (DeviceObject)
+    {
+        /* Get its device node */
+        DeviceNode = IopGetDeviceNode(DeviceObject);
+        if ((DeviceNode) && !(DeviceNode->Flags & DNF_LEGACY_RESOURCE_DEVICENODE))
+        {
+            /* New drivers should not call this API */
+            KeBugCheckEx(PNP_DETECTED_FATAL_ERROR,
+                         0,
+                         0,
+                         (ULONG_PTR)DeviceObject,
+                         (ULONG_PTR)DriverObject);
+        }
+    }
+
+    /* Did the driver supply resources? */
+    if (RequestedResources)
+    {
+        /* Make sure there's actually something useful in them */
+        if (!(RequestedResources->AlternativeLists) || !(RequestedResources->List[0].Count))
+        {
+            /* Empty resources are no resources */
+            RequestedResources = NULL;
+        }
+    }
+
+    /* Initialize output if given */
+    if (AllocatedResources) *AllocatedResources = NULL;
+
+    /* Call internal helper function */
+    return IopLegacyResourceAllocation(ArbiterRequestLegacyAssigned,
+                                       DriverObject,
+                                       DeviceObject,
+                                       RequestedResources,
+                                       AllocatedResources);
+}
+
 /*
  * FUNCTION:
  *     Reads and returns Hardware information from the appropriate hardware registry key.
index 3aca4ce..44fa2ea 100644 (file)
@@ -2268,8 +2268,6 @@ IopEnumerateDevice(
                                   &DeviceNode->InstancePath);
     }
 
-    DeviceNode->Flags &= ~DNF_NEED_TO_ENUM;
-
     DPRINT("Sending IRP_MN_QUERY_DEVICE_RELATIONS to device stack\n");
 
     Stack.Parameters.QueryDeviceRelations.Type = BusRelations;