mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 07:13:01 +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 PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PISAPNP_PDO_EXTENSION PdoExt;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PLIST_ENTRY CurrentEntry;
|
|
||||||
PISAPNP_LOGICAL_DEVICE IsaDevice;
|
|
||||||
PDEVICE_RELATIONS DeviceRelations;
|
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
ULONG i = 0;
|
|
||||||
|
|
||||||
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
||||||
return Irp->IoStatus.Status;
|
return Irp->IoStatus.Status;
|
||||||
|
@ -64,57 +59,7 @@ IsaFdoQueryDeviceRelations(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceRelations = ExAllocatePool(NonPagedPool,
|
return IsaPnpFillDeviceRelations(FdoExt, Irp);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -10,6 +10,73 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#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 IO_COMPLETION_ROUTINE ForwardIrpCompletion;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -51,6 +51,12 @@ typedef struct _ISAPNP_PDO_EXTENSION {
|
||||||
|
|
||||||
/* isapnp.c */
|
/* isapnp.c */
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
IsaPnpFillDeviceRelations(
|
||||||
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
|
IN PIRP Irp);
|
||||||
|
|
||||||
DRIVER_INITIALIZE DriverEntry;
|
DRIVER_INITIALIZE DriverEntry;
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue