mirror of
https://github.com/reactos/reactos.git
synced 2024-11-27 13:33:32 +08:00
[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
This commit is contained in:
parent
c91f9ef382
commit
d974e84e77
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user