mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 15:36:24 +00:00
[ISAPNP] Extract function to create DOs
This commit is contained in:
parent
d0c7bd98c7
commit
89aff07a67
3 changed files with 74 additions and 56 deletions
|
@ -44,13 +44,8 @@ IsaFdoQueryDeviceRelations(
|
|||
IN PIRP Irp,
|
||||
IN PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
PISAPNP_PDO_EXTENSION PdoExt;
|
||||
NTSTATUS Status;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PISAPNP_LOGICAL_DEVICE IsaDevice;
|
||||
PDEVICE_RELATIONS DeviceRelations;
|
||||
KIRQL OldIrql;
|
||||
ULONG i = 0;
|
||||
|
||||
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
||||
return Irp->IoStatus.Status;
|
||||
|
@ -64,57 +59,7 @@ IsaFdoQueryDeviceRelations(
|
|||
return Status;
|
||||
}
|
||||
|
||||
DeviceRelations = ExAllocatePool(NonPagedPool,
|
||||
sizeof(DEVICE_RELATIONS) + sizeof(DEVICE_OBJECT) * (FdoExt->DeviceCount - 1));
|
||||
if (!DeviceRelations)
|
||||
{
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
CurrentEntry = FdoExt->DeviceListHead.Flink;
|
||||
while (CurrentEntry != &FdoExt->DeviceListHead)
|
||||
{
|
||||
IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, ListEntry);
|
||||
|
||||
if (!IsaDevice->Pdo)
|
||||
{
|
||||
Status = IoCreateDevice(FdoExt->DriverObject,
|
||||
sizeof(ISAPNP_PDO_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_CONTROLLER,
|
||||
FILE_DEVICE_SECURE_OPEN | FILE_AUTOGENERATED_DEVICE_NAME,
|
||||
FALSE,
|
||||
&IsaDevice->Pdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
IsaDevice->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
//Device->Pdo->Flags |= DO_POWER_PAGABLE;
|
||||
|
||||
PdoExt = (PISAPNP_PDO_EXTENSION)IsaDevice->Pdo->DeviceExtension;
|
||||
|
||||
RtlZeroMemory(PdoExt, sizeof(ISAPNP_PDO_EXTENSION));
|
||||
|
||||
PdoExt->Common.IsFdo = FALSE;
|
||||
PdoExt->Common.Self = IsaDevice->Pdo;
|
||||
PdoExt->Common.State = dsStopped;
|
||||
PdoExt->IsaPnpDevice = IsaDevice;
|
||||
}
|
||||
DeviceRelations->Objects[i++] = IsaDevice->Pdo;
|
||||
|
||||
ObReferenceObject(IsaDevice->Pdo);
|
||||
|
||||
CurrentEntry = CurrentEntry->Flink;
|
||||
}
|
||||
|
||||
DeviceRelations->Count = FdoExt->DeviceCount;
|
||||
|
||||
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return IsaPnpFillDeviceRelations(FdoExt, Irp);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -10,6 +10,73 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IsaPnpFillDeviceRelations(
|
||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PISAPNP_PDO_EXTENSION PdoExt;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
PISAPNP_LOGICAL_DEVICE IsaDevice;
|
||||
PDEVICE_RELATIONS DeviceRelations;
|
||||
ULONG i = 0;
|
||||
|
||||
DeviceRelations = ExAllocatePool(NonPagedPool,
|
||||
sizeof(DEVICE_RELATIONS) + sizeof(DEVICE_OBJECT) * FdoExt->DeviceCount);
|
||||
if (!DeviceRelations)
|
||||
{
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
CurrentEntry = FdoExt->DeviceListHead.Flink;
|
||||
while (CurrentEntry != &FdoExt->DeviceListHead)
|
||||
{
|
||||
IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, ListEntry);
|
||||
|
||||
if (!IsaDevice->Pdo)
|
||||
{
|
||||
Status = IoCreateDevice(FdoExt->DriverObject,
|
||||
sizeof(ISAPNP_PDO_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_CONTROLLER,
|
||||
FILE_DEVICE_SECURE_OPEN | FILE_AUTOGENERATED_DEVICE_NAME,
|
||||
FALSE,
|
||||
&IsaDevice->Pdo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
IsaDevice->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
|
||||
//Device->Pdo->Flags |= DO_POWER_PAGABLE;
|
||||
|
||||
PdoExt = (PISAPNP_PDO_EXTENSION)IsaDevice->Pdo->DeviceExtension;
|
||||
|
||||
RtlZeroMemory(PdoExt, sizeof(ISAPNP_PDO_EXTENSION));
|
||||
|
||||
PdoExt->Common.IsFdo = FALSE;
|
||||
PdoExt->Common.Self = IsaDevice->Pdo;
|
||||
PdoExt->Common.State = dsStopped;
|
||||
PdoExt->IsaPnpDevice = IsaDevice;
|
||||
}
|
||||
DeviceRelations->Objects[i++] = IsaDevice->Pdo;
|
||||
|
||||
ObReferenceObject(IsaDevice->Pdo);
|
||||
|
||||
CurrentEntry = CurrentEntry->Flink;
|
||||
}
|
||||
|
||||
DeviceRelations->Count = i;
|
||||
|
||||
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
static IO_COMPLETION_ROUTINE ForwardIrpCompletion;
|
||||
|
||||
static
|
||||
|
|
|
@ -51,6 +51,12 @@ typedef struct _ISAPNP_PDO_EXTENSION {
|
|||
|
||||
/* isapnp.c */
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IsaPnpFillDeviceRelations(
|
||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||
IN PIRP Irp);
|
||||
|
||||
DRIVER_INITIALIZE DriverEntry;
|
||||
|
||||
NTSTATUS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue