Implement IoReportDetectedDevice
authorHervé Poussineau <hpoussin@reactos.org>
Sun, 20 Mar 2005 12:15:33 +0000 (12:15 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Sun, 20 Mar 2005 12:15:33 +0000 (12:15 +0000)
svn path=/trunk/; revision=14215

reactos/ntoskrnl/io/pnpreport.c

index a9ea1d9..0e02c38 100644 (file)
 
 /* INCLUDES ******************************************************************/
 
-//#define NDEBUG
+#define NDEBUG
 #include <ntoskrnl.h>
 #include <internal/debug.h>
 
 /* FUNCTIONS *****************************************************************/
 
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 STDCALL
@@ -32,24 +32,38 @@ IoReportDetectedDevice(
   IN OUT PDEVICE_OBJECT *DeviceObject)
 {
   PDEVICE_NODE DeviceNode;
-  NTSTATUS Status;
+  PDEVICE_OBJECT Pdo;
+  NTSTATUS Status = STATUS_SUCCESS;
   
-  DPRINT("IoReportDetectedDevice called (partly implemented)\n");
-  /* Use IopRootDeviceNode for now */
-  Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
-  if (!NT_SUCCESS(Status))
-  {
-    DPRINT("IopCreateDeviceNode() failed (Status 0x%08x)\n", Status);
-    return Status;
-  }
+  DPRINT("IoReportDetectedDevice (DeviceObject %p, *DeviceObject %p)\n",
+    DeviceObject, DeviceObject ? *DeviceObject : NULL);
   
-  Status = IopInitializePnpServices(DeviceNode, FALSE);
-  if (!NT_SUCCESS(Status))
+  /* if *DeviceObject is not NULL, we must use it as a PDO,
+   * and don't create a new one.
+   */
+  if (DeviceObject && *DeviceObject)
+    Pdo = *DeviceObject;
+  else
   {
-    DPRINT("IopInitializePnpServices() failed (Status 0x%08x)\n", Status);
-    return Status;
+    /* create a new PDO and return it in *DeviceObject */
+    Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
+    if (!NT_SUCCESS(Status))
+    {
+      DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status);
+      return Status;
+    }
+    Pdo = DeviceNode->PhysicalDeviceObject;
+    if (DeviceObject)
+      *DeviceObject = Pdo;
   }
-  return IopInitializeDevice(DeviceNode, DriverObject);
+  
+  /* we don't need to call AddDevice and send IRP_MN_START_DEVICE */
+  
+  /* FIXME: save this device into the root-enumerated list, so this
+   * device would be detected as a PnP device during next startups.
+   */
+  
+  return Status;
 }
 
 /*
@@ -66,7 +80,7 @@ IoReportResourceForDetection(
   IN ULONG DeviceListSize   OPTIONAL,
   OUT PBOOLEAN ConflictDetected)
 {
-  DPRINT("IoReportResourceForDetection UNIMPLEMENTED but returns success.\n");
+  DPRINT1("IoReportResourceForDetection UNIMPLEMENTED but returns success.\n");
   *ConflictDetected = FALSE;
   return STATUS_SUCCESS;
 }