Index: hal/halx86/acpi/halpnpdd.c =================================================================== --- hal/halx86/acpi/halpnpdd.c (revision 54031) +++ hal/halx86/acpi/halpnpdd.c (working copy) @@ -50,6 +50,59 @@ /* 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; + PDESCRIPTION_HEADER Wdrt; + + /* 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; + + /* 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"); + } + + /* Invalidate device relations since we added a new device */ + IoInvalidateDeviceRelations(FdoExtension->PhysicalDeviceObject, BusRelations); +} + NTSTATUS NTAPI HalpAddDevice(IN PDRIVER_OBJECT DriverObject, @@ -57,9 +110,7 @@ { NTSTATUS Status; PFDO_EXTENSION FdoExtension; - PPDO_EXTENSION PdoExtension; - PDEVICE_OBJECT DeviceObject, PdoDeviceObject, AttachedDevice; - PDESCRIPTION_HEADER Wdrt; + PDEVICE_OBJECT DeviceObject, AttachedDevice; DPRINT("HAL: PnP Driver ADD!\n"); /* Create the FDO */ @@ -95,50 +146,15 @@ IoDeleteDevice(DeviceObject); return STATUS_NO_SUCH_DEVICE; } - + /* 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; - /* 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"); - } + /* Register for reinitialization to report devices later */ + IoRegisterDriverReinitialization(DriverObject, + HalpReportDetectedDevices, + FdoExtension); - /* Invalidate device relations since we added a new device */ - IoInvalidateDeviceRelations(TargetDevice, BusRelations); - /* Return status */ DPRINT("Device added %lx\n", Status); return Status;