From: Cameron Gutman Date: Thu, 6 Oct 2011 21:50:07 +0000 (+0000) Subject: [HALACPI] X-Git-Tag: backups/iut-netsh@54410~352 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=d974e84e77b7d427c6487a13d9f4b03fbc3c5408;hp=c91f9ef382101a3d52fc326324ae539c3819cc6c [HALACPI] - Work around a race condition related to devices reported before the I/O subsystem is fully up - Fixes bug #6271 svn path=/trunk/; revision=54035 --- diff --git a/reactos/hal/halx86/acpi/halpnpdd.c b/reactos/hal/halx86/acpi/halpnpdd.c index 1b1c2515b97..8ca5dd3b029 100644 --- a/reactos/hal/halx86/acpi/halpnpdd.c +++ b/reactos/hal/halx86/acpi/halpnpdd.c @@ -50,6 +50,59 @@ 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; + 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 @@ HalpAddDevice(IN PDRIVER_OBJECT DriverObject, { 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,49 +146,14 @@ HalpAddDevice(IN PDRIVER_OBJECT DriverObject, 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"); - } - /* Invalidate device relations since we added a new device */ - IoInvalidateDeviceRelations(TargetDevice, BusRelations); + /* Register for reinitialization to report devices later */ + IoRegisterDriverReinitialization(DriverObject, + HalpReportDetectedDevices, + FdoExtension); /* Return status */ DPRINT("Device added %lx\n", Status);