[HAL]
[reactos.git] / reactos / hal / halx86 / legacy / halpnpdd.c
index c3d783d..62534a9 100644 (file)
@@ -50,6 +50,50 @@ PDRIVER_OBJECT HalpDriverObject;
 
 /* PRIVATE FUNCTIONS **********************************************************/
 
+VOID
+NTAPI
+HalpReportDetectedDevices(IN PDRIVER_OBJECT DriverObject,
+                          IN PVOID Context,
+                          IN ULONG Count)
+{
+    PFDO_EXTENSION FdoExtension = Context;
+    PPDO_EXTENSION PdoExtension;
+    PDEVICE_OBJECT PdoDeviceObject;
+    NTSTATUS Status;
+
+    /* Create the PDO */
+    Status = IoCreateDevice(DriverObject,
+                            sizeof(PDO_EXTENSION),
+                            NULL,
+                            FILE_DEVICE_BUS_EXTENDER,
+                            FILE_AUTOGENERATED_DEVICE_NAME,
+                            FALSE,
+                            &PdoDeviceObject);
+    if (!NT_SUCCESS(Status))
+    {
+        /* Fail */
+        DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status);
+        return;
+    }
+
+    /* Setup the PDO device extension */
+    PdoExtension = PdoDeviceObject->DeviceExtension;
+    PdoExtension->ExtensionType = PdoExtensionType;
+    PdoExtension->PhysicalDeviceObject = PdoDeviceObject;
+    PdoExtension->ParentFdoExtension = FdoExtension;
+    PdoExtension->PdoType = AcpiPdo;
+
+    /* Add the PDO to the head of the list */
+    PdoExtension->Next = FdoExtension->ChildPdoList;
+    FdoExtension->ChildPdoList = PdoExtension;
+
+    /* Initialization is finished */
+    PdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+
+    /* Invalidate device relations since we added a new device */
+    IoSynchronousInvalidateDeviceRelations(FdoExtension->PhysicalDeviceObject, BusRelations);
+}
+
 NTSTATUS
 NTAPI
 HalpAddDevice(IN PDRIVER_OBJECT DriverObject,
@@ -57,9 +101,9 @@ HalpAddDevice(IN PDRIVER_OBJECT DriverObject,
 {
     NTSTATUS Status;
     PFDO_EXTENSION FdoExtension;
-    PPDO_EXTENSION PdoExtension;
-    PDEVICE_OBJECT DeviceObject, PdoDeviceObject, AttachedDevice;
+    PDEVICE_OBJECT DeviceObject, AttachedDevice;
 //    PDESCRIPTION_HEADER Wdrt;
+
     DPRINT("HAL: PnP Driver ADD!\n");
 
     /* Create the FDO */
@@ -99,47 +143,10 @@ HalpAddDevice(IN PDRIVER_OBJECT DriverObject,
     /* Save the attachment */
     FdoExtension->AttachedDeviceObject = AttachedDevice;
 
-    /* Create the PDO */
-    Status = IoCreateDevice(DriverObject,
-                            sizeof(PDO_EXTENSION),
-                            NULL,
-                            FILE_DEVICE_BUS_EXTENDER,
-                            FILE_AUTOGENERATED_DEVICE_NAME,
-                            FALSE,
-                            &PdoDeviceObject);
-    if (!NT_SUCCESS(Status))
-    {
-        /* Fail */
-        DPRINT1("HAL: Could not create ACPI device object status=0x%08x\n", Status);
-        return Status;
-    }
-
-    /* Setup the PDO device extension */
-    PdoExtension = PdoDeviceObject->DeviceExtension;
-    PdoExtension->ExtensionType = PdoExtensionType;
-    PdoExtension->PhysicalDeviceObject = PdoDeviceObject;
-    PdoExtension->ParentFdoExtension = FdoExtension;
-    PdoExtension->PdoType = AcpiPdo;
-
-    /* Add the PDO to the head of the list */
-    PdoExtension->Next = FdoExtension->ChildPdoList;
-    FdoExtension->ChildPdoList = PdoExtension;
-
-    /* Initialization is finished */
-    PdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
-
-#if 0
-    /* Find the ACPI watchdog table */
-    Wdrt = HalAcpiGetTable(0, 'TRDW');
-    if (Wdrt)
-    {
-        /* FIXME: TODO */
-        DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
-    }
-#endif
-
-    /* Invalidate device relations since we added a new device */
-    IoInvalidateDeviceRelations(TargetDevice, BusRelations);
+    /* Register for reinitialization to report devices later */
+    IoRegisterBootDriverReinitialization(DriverObject,
+                                         HalpReportDetectedDevices,
+                                         FdoExtension);
 
     /* Return status */
     DPRINT("Device added %lx\n", Status);
@@ -157,8 +164,7 @@ HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject,
                    OUT PULONG Length)
 {
     UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_NO_SUCH_DEVICE;
+    return STATUS_NOT_SUPPORTED;
 }
 
 NTSTATUS
@@ -239,7 +245,7 @@ HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
                 {
                     /* Save our own PDO and reference it */
                     *ObjectEntry++ = PdoExtension->PhysicalDeviceObject;
-                    ObfReferenceObject(PdoExtension->PhysicalDeviceObject);
+                    ObReferenceObject(PdoExtension->PhysicalDeviceObject);
 
                     /* Go to our next PDO */
                     PdoExtension = PdoExtension->Next;
@@ -267,7 +273,7 @@ HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
             /* Fill it out and reference us */
             PdoRelations->Count = 1;
             PdoRelations->Objects[0] = DeviceObject;
-            ObfReferenceObject(DeviceObject);
+            ObReferenceObject(DeviceObject);
 
             /* Return it */
             *DeviceRelations = PdoRelations;
@@ -378,8 +384,8 @@ HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
         ResourceList->Count = 1;
 
         /* Setup the list fields */
-        ResourceList->List[0].BusNumber = -1;
-        ResourceList->List[0].InterfaceType = PNPBus;
+        ResourceList->List[0].BusNumber = 0;
+        ResourceList->List[0].InterfaceType = PCIBus;
         ResourceList->List[0].PartialResourceList.Version = 1;
         ResourceList->List[0].PartialResourceList.Revision = 1;
         ResourceList->List[0].PartialResourceList.Count = 0;