mirror of
https://github.com/reactos/reactos.git
synced 2024-05-19 20:02:03 +00:00
[DRIVERS] Use IoForwardIrpSynchronously in drivers
Instead of having an own routine in each driver IoForwardIrpSynchronously can be used.
This commit is contained in:
parent
8e8f61989a
commit
7ed1883c8e
|
@ -14,46 +14,6 @@
|
||||||
|
|
||||||
/*** PRIVATE *****************************************************************/
|
/*** PRIVATE *****************************************************************/
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Ldo;
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
FdoLocateChildDevice(
|
FdoLocateChildDevice(
|
||||||
PPCI_DEVICE *Device,
|
PPCI_DEVICE *Device,
|
||||||
|
@ -524,9 +484,16 @@ FdoPnpControl(
|
||||||
#endif
|
#endif
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
DPRINT("IRP_MN_START_DEVICE received\n");
|
DPRINT("IRP_MN_START_DEVICE received\n");
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = FdoStartDevice(DeviceObject, Irp);
|
if (IoForwardIrpSynchronously(DeviceExtension->Ldo, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = FdoStartDevice(DeviceObject, Irp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
|
@ -340,8 +340,6 @@ i8042StartPacket(
|
||||||
|
|
||||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
|
|
||||||
DRIVER_DISPATCH ForwardIrpAndWait;
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
DuplicateUnicodeString(
|
DuplicateUnicodeString(
|
||||||
IN ULONG Flags,
|
IN ULONG Flags,
|
||||||
|
|
|
@ -14,47 +14,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
|
||||||
__analysis_assume(Context != NULL);
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent(Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -676,6 +676,7 @@ i8042Pnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
ULONG MinorFunction;
|
ULONG MinorFunction;
|
||||||
I8042_DEVICE_TYPE DeviceType;
|
I8042_DEVICE_TYPE DeviceType;
|
||||||
|
@ -684,7 +685,8 @@ i8042Pnp(
|
||||||
|
|
||||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
MinorFunction = Stack->MinorFunction;
|
MinorFunction = Stack->MinorFunction;
|
||||||
DeviceType = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
|
FdoExtension = DeviceObject->DeviceExtension;
|
||||||
|
DeviceType = FdoExtension->Type;
|
||||||
|
|
||||||
switch (MinorFunction)
|
switch (MinorFunction)
|
||||||
{
|
{
|
||||||
|
@ -695,12 +697,19 @@ i8042Pnp(
|
||||||
/* Call lower driver (if any) */
|
/* Call lower driver (if any) */
|
||||||
if (DeviceType != PhysicalDeviceObject)
|
if (DeviceType != PhysicalDeviceObject)
|
||||||
{
|
{
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = i8042PnpStartDevice(
|
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||||
DeviceObject,
|
{
|
||||||
Stack->Parameters.StartDevice.AllocatedResources,
|
Status = Irp->IoStatus.Status;
|
||||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = i8042PnpStartDevice(
|
||||||
|
DeviceObject,
|
||||||
|
Stack->Parameters.StartDevice.AllocatedResources,
|
||||||
|
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
|
|
|
@ -163,12 +163,21 @@ ClassDeviceControl(
|
||||||
while (Entry != Head)
|
while (Entry != Head)
|
||||||
{
|
{
|
||||||
PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Entry, PORT_DEVICE_EXTENSION, ListEntry);
|
PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Entry, PORT_DEVICE_EXTENSION, ListEntry);
|
||||||
NTSTATUS IntermediateStatus;
|
|
||||||
|
|
||||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
|
IoGetCurrentIrpStackLocation(Irp)->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
|
||||||
IntermediateStatus = ForwardIrpAndWait(DevExt->DeviceObject, Irp);
|
|
||||||
if (!NT_SUCCESS(IntermediateStatus))
|
if (IoForwardIrpSynchronously(DevExt->LowerDevice, Irp))
|
||||||
Status = IntermediateStatus;
|
{
|
||||||
|
if (!NT_SUCCESS(Irp->IoStatus.Status))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
Entry = Entry->Flink;
|
Entry = Entry->Flink;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -836,7 +845,15 @@ ClassPnp(
|
||||||
switch (IrpSp->MinorFunction)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
|
|
@ -67,11 +67,6 @@ typedef struct _CLASS_DEVICE_EXTENSION
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -11,47 +11,6 @@
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO);
|
|
||||||
LowerDevice = ((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
TRACE_(CLASS_NAME, "Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -11,47 +11,6 @@
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO);
|
|
||||||
LowerDevice = ((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
TRACE_(CLASS_NAME, "Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -812,7 +812,15 @@ ClassPnp(
|
||||||
switch (IrpSp->MinorFunction)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
|
|
@ -67,11 +67,6 @@ typedef struct _CLASS_DEVICE_EXTENSION
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -172,11 +172,21 @@ SermousePnp(
|
||||||
*/
|
*/
|
||||||
case IRP_MN_START_DEVICE: /* 0x0 */
|
case IRP_MN_START_DEVICE: /* 0x0 */
|
||||||
{
|
{
|
||||||
|
PSERMOUSE_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
TRACE_(SERMOUSE, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
TRACE_(SERMOUSE, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||||
if (NT_SUCCESS(Status))
|
{
|
||||||
Status = SermouseStartDevice(DeviceObject, Irp);
|
Status = Irp->IoStatus.Status;
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = SermouseStartDevice(DeviceObject, Irp);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
|
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
|
||||||
|
|
|
@ -10,44 +10,6 @@
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice = ((PSERMOUSE_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
TRACE_(SERMOUSE, "Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -98,11 +98,6 @@ DRIVER_DISPATCH SermouseInternalDeviceControl;
|
||||||
|
|
||||||
/************************************ misc.c */
|
/************************************ misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -295,13 +295,16 @@ IKsDevice_PnpStartDevice(
|
||||||
DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader);
|
DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader);
|
||||||
|
|
||||||
/* first forward irp to lower device object */
|
/* first forward irp to lower device object */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
if (!IoForwardIrpSynchronously(DeviceHeader->KsDevice.NextDeviceObject, Irp))
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
/* check for success */
|
/* check for success */
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("NextDevice object failed to start with %x\n", Status);
|
DPRINT1("NextDevice object failed to start with %x\n", Status);
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -459,13 +462,8 @@ IKsDevice_Pnp(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pass the irp down the driver stack */
|
/* pass the irp down the driver stack */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||||
DPRINT("Next Device: Status %x\n", Status);
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case IRP_MN_REMOVE_DEVICE:
|
case IRP_MN_REMOVE_DEVICE:
|
||||||
|
@ -482,15 +480,9 @@ IKsDevice_Pnp(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pass the irp down the driver stack */
|
/* pass the irp down the driver stack */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||||
DPRINT("Next Device: Status %x\n", Status);
|
|
||||||
|
|
||||||
/* FIXME delete device resources */
|
/* FIXME delete device resources */
|
||||||
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_INTERFACE:
|
case IRP_MN_QUERY_INTERFACE:
|
||||||
|
@ -518,23 +510,14 @@ IKsDevice_Pnp(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pass the irp down the driver stack */
|
/* pass the irp down the driver stack */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||||
DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n", Status);
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||||
{
|
{
|
||||||
/* pass the irp down the driver stack */
|
/* pass the irp down the driver stack */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||||
DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n", Status);
|
|
||||||
|
|
||||||
//Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
||||||
{
|
{
|
||||||
|
@ -550,22 +533,14 @@ IKsDevice_Pnp(
|
||||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
||||||
{
|
{
|
||||||
/* pass the irp down the driver stack */
|
/* pass the irp down the driver stack */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||||
DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
|
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
|
DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
|
||||||
/* pass the irp down the driver stack */
|
/* pass the irp down the driver stack */
|
||||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,6 @@ KspRegisterDeviceInterfaces(
|
||||||
IN PUNICODE_STRING ReferenceString,
|
IN PUNICODE_STRING ReferenceString,
|
||||||
OUT PLIST_ENTRY SymbolicLinkList);
|
OUT PLIST_ENTRY SymbolicLinkList);
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
KspForwardIrpSynchronous(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
AllocateItem(
|
AllocateItem(
|
||||||
IN POOL_TYPE PoolType,
|
IN POOL_TYPE PoolType,
|
||||||
|
|
|
@ -46,57 +46,6 @@ FreeItem(
|
||||||
ExFreePool(Item);
|
ExFreePool(Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
KspForwardIrpSynchronousCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned != FALSE)
|
|
||||||
{
|
|
||||||
KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
}
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
KspForwardIrpSynchronous(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PDEVICE_EXTENSION DeviceExtension;
|
|
||||||
PKSIDEVICE_HEADER DeviceHeader;
|
|
||||||
|
|
||||||
ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
|
|
||||||
|
|
||||||
/* get device extension */
|
|
||||||
DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
|
||||||
/* get device header */
|
|
||||||
DeviceHeader = DeviceExtension->DeviceHeader;
|
|
||||||
|
|
||||||
/* initialize the notification event */
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp, KspForwardIrpSynchronousCompletion, (PVOID)&Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
/* now call the driver */
|
|
||||||
Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
|
||||||
/* did the request complete yet */
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
/* not yet, lets wait a bit */
|
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
KspCopyCreateRequest(
|
KspCopyCreateRequest(
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
|
|
|
@ -505,6 +505,7 @@ NTAPI
|
||||||
FdoPnp(IN PDEVICE_OBJECT DeviceObject,
|
FdoPnp(IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||||
ULONG MinorFunction;
|
ULONG MinorFunction;
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
ULONG_PTR Information = 0;
|
ULONG_PTR Information = 0;
|
||||||
|
@ -545,15 +546,21 @@ FdoPnp(IN PDEVICE_OBJECT DeviceObject,
|
||||||
case IRP_MN_START_DEVICE: /* 0x0 */
|
case IRP_MN_START_DEVICE: /* 0x0 */
|
||||||
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||||
|
|
||||||
ASSERT(((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.PnpState == dsStopped);
|
|
||||||
|
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
FdoExtension = DeviceObject->DeviceExtension;
|
||||||
if (NT_SUCCESS(Status))
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
|
ASSERT(FdoExtension->Common.PnpState == dsStopped);
|
||||||
|
|
||||||
|
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||||
{
|
{
|
||||||
Status = FdoStartDevice(DeviceObject,
|
Status = Irp->IoStatus.Status;
|
||||||
Stack->Parameters.StartDevice.AllocatedResources,
|
if (NT_SUCCESS(Status))
|
||||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
{
|
||||||
|
Status = FdoStartDevice(DeviceObject,
|
||||||
|
Stack->Parameters.StartDevice.AllocatedResources,
|
||||||
|
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -8,52 +8,8 @@
|
||||||
#include "parport.h"
|
#include "parport.h"
|
||||||
|
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
static
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
DPRINT("Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject,
|
ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -109,10 +109,6 @@ FdoPower(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
|
|
||||||
PVOID
|
PVOID
|
||||||
|
|
|
@ -15,54 +15,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
LowerDevice = ((PDEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
DPRINT("Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -263,6 +263,7 @@ ProcessorPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
ULONG_PTR Information = 0;
|
ULONG_PTR Information = 0;
|
||||||
NTSTATUS Status = STATUS_NOT_SUPPORTED;
|
NTSTATUS Status = STATUS_NOT_SUPPORTED;
|
||||||
|
@ -277,12 +278,18 @@ ProcessorPnp(
|
||||||
DPRINT(" IRP_MN_START_DEVICE received\n");
|
DPRINT(" IRP_MN_START_DEVICE received\n");
|
||||||
|
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
if (NT_SUCCESS(Status))
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||||
{
|
{
|
||||||
Status = ProcessorStartDevice(DeviceObject,
|
Status = Irp->IoStatus.Status;
|
||||||
IrpSp->Parameters.StartDevice.AllocatedResources,
|
if (NT_SUCCESS(Status))
|
||||||
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
{
|
||||||
|
Status = ProcessorStartDevice(DeviceObject,
|
||||||
|
IrpSp->Parameters.StartDevice.AllocatedResources,
|
||||||
|
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,6 @@ typedef struct _DEVICE_EXTENSION
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -153,6 +153,7 @@ SerenumFdoPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||||
ULONG MinorFunction;
|
ULONG MinorFunction;
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
ULONG_PTR Information = 0;
|
ULONG_PTR Information = 0;
|
||||||
|
@ -181,9 +182,18 @@ SerenumFdoPnp(
|
||||||
{
|
{
|
||||||
TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
FdoExtension = DeviceObject->DeviceExtension;
|
||||||
if (NT_SUCCESS(Status))
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
Status = SerenumFdoStartDevice(DeviceObject, Irp);
|
|
||||||
|
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = SerenumFdoStartDevice(DeviceObject, Irp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
|
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
/* I really want PCSZ strings as last arguments because
|
/* I really want PCSZ strings as last arguments because
|
||||||
* PnP ids are ANSI-encoded in PnP device string
|
* PnP ids are ANSI-encoded in PnP device string
|
||||||
* identification */
|
* identification */
|
||||||
|
@ -88,48 +86,6 @@ SerenumInitMultiSzString(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
|
||||||
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
TRACE_(SERENUM, "Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpToLowerDeviceAndForget(
|
ForwardIrpToLowerDeviceAndForget(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -12,46 +12,6 @@
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static NTSTATUS NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice = ((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
TRACE_(SERIAL, "Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -328,6 +328,7 @@ SerialPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PSERIAL_DEVICE_EXTENSION DeviceExtension;
|
||||||
ULONG MinorFunction;
|
ULONG MinorFunction;
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
ULONG_PTR Information = 0;
|
ULONG_PTR Information = 0;
|
||||||
|
@ -367,15 +368,24 @@ SerialPnp(
|
||||||
{
|
{
|
||||||
TRACE_(SERIAL, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
TRACE_(SERIAL, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||||
|
|
||||||
ASSERT(((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->PnpState == dsStopped);
|
|
||||||
|
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
if (NT_SUCCESS(Status))
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
Status = SerialPnpStartDevice(
|
|
||||||
DeviceObject,
|
ASSERT(DeviceExtension->PnpState == dsStopped);
|
||||||
Stack->Parameters.StartDevice.AllocatedResources,
|
|
||||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = SerialPnpStartDevice(
|
||||||
|
DeviceObject,
|
||||||
|
Stack->Parameters.StartDevice.AllocatedResources,
|
||||||
|
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* (optional) 0x7 */
|
case IRP_MN_QUERY_DEVICE_RELATIONS: /* (optional) 0x7 */
|
||||||
|
|
|
@ -242,11 +242,6 @@ SerialDetectUartType(
|
||||||
|
|
||||||
/************************************ misc.c */
|
/************************************ misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||||
|
|
||||||
VOID NTAPI
|
VOID NTAPI
|
||||||
|
|
|
@ -16,51 +16,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
|
||||||
|
|
||||||
static
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
DPRINT("Calling lower device %p\n", LowerDevice);
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
@ -492,6 +447,7 @@ FdcFdoPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||||
PIO_STACK_LOCATION IrpSp;
|
PIO_STACK_LOCATION IrpSp;
|
||||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||||
ULONG_PTR Information = 0;
|
ULONG_PTR Information = 0;
|
||||||
|
@ -505,14 +461,22 @@ FdcFdoPnp(
|
||||||
{
|
{
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
DPRINT(" IRP_MN_START_DEVICE received\n");
|
DPRINT(" IRP_MN_START_DEVICE received\n");
|
||||||
|
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
if (NT_SUCCESS(Status))
|
FdoExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
|
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||||
{
|
{
|
||||||
Status = FdcFdoStartDevice(DeviceObject,
|
Status = Irp->IoStatus.Status;
|
||||||
IrpSp->Parameters.StartDevice.AllocatedResources,
|
if (NT_SUCCESS(Status))
|
||||||
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
{
|
||||||
|
Status = FdcFdoStartDevice(DeviceObject,
|
||||||
|
IrpSp->Parameters.StartDevice.AllocatedResources,
|
||||||
|
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||||
|
|
|
@ -403,6 +403,7 @@ PciIdeXFdoPnpDispatch(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||||
ULONG MinorFunction;
|
ULONG MinorFunction;
|
||||||
PIO_STACK_LOCATION Stack;
|
PIO_STACK_LOCATION Stack;
|
||||||
ULONG_PTR Information = Irp->IoStatus.Information;
|
ULONG_PTR Information = Irp->IoStatus.Information;
|
||||||
|
@ -416,10 +417,19 @@ PciIdeXFdoPnpDispatch(
|
||||||
case IRP_MN_START_DEVICE: /* 0x00 */
|
case IRP_MN_START_DEVICE: /* 0x00 */
|
||||||
{
|
{
|
||||||
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||||
|
|
||||||
/* Call lower driver */
|
/* Call lower driver */
|
||||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
FdoExtension = DeviceObject->DeviceExtension;
|
||||||
if (NT_SUCCESS(Status))
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
Status = PciIdeXFdoStartDevice(DeviceObject, Irp);
|
|
||||||
|
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
Status = PciIdeXFdoStartDevice(DeviceObject, Irp);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
|
case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
|
||||||
|
|
|
@ -11,46 +11,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
|
||||||
PciIdeXGenericCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT LowerDevice;
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
|
||||||
LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
|
|
||||||
IoSetCompletionRoutine(Irp, PciIdeXGenericCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -53,18 +53,6 @@ PciIdeXFdoPnpDispatch(
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
IO_COMPLETION_ROUTINE PciIdeXGenericCompletion;
|
|
||||||
NTSTATUS NTAPI
|
|
||||||
PciIdeXGenericCompletion(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -191,10 +191,18 @@ PortFdoStartDevice(
|
||||||
/* Start the lower device if the FDO is in 'stopped' state */
|
/* Start the lower device if the FDO is in 'stopped' state */
|
||||||
if (DeviceExtension->PnpState == dsStopped)
|
if (DeviceExtension->PnpState == dsStopped)
|
||||||
{
|
{
|
||||||
Status = ForwardIrpAndWait(DeviceExtension->LowerDevice, Irp);
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("ForwardIrpAndWait() failed (Status 0x%08lx)\n", Status);
|
DPRINT1("Lower device failed the IRP (Status 0x%08lx)\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,47 +15,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
static
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpAndWaitCompletion(
|
|
||||||
_In_ PDEVICE_OBJECT DeviceObject,
|
|
||||||
_In_ PIRP Irp,
|
|
||||||
_In_ PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned)
|
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
_In_ PDEVICE_OBJECT LowerDevice,
|
|
||||||
_In_ PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
ASSERT(LowerDevice);
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(LowerDevice, Irp);
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -178,11 +178,6 @@ MiniportStartIo(
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
ForwardIrpAndWait(
|
|
||||||
_In_ PDEVICE_OBJECT LowerDevice,
|
|
||||||
_In_ PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpAndForget(
|
ForwardIrpAndForget(
|
||||||
|
|
|
@ -253,7 +253,14 @@ FDO_StartDevice(
|
||||||
ASSERT(FDODeviceExtension->Common.IsFDO);
|
ASSERT(FDODeviceExtension->Common.IsFDO);
|
||||||
|
|
||||||
/* First start lower device */
|
/* First start lower device */
|
||||||
Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
|
if (IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -435,11 +442,15 @@ FDO_HandlePnp(
|
||||||
RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
|
RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
|
||||||
&FDODeviceExtension->Capabilities,
|
&FDODeviceExtension->Capabilities,
|
||||||
sizeof(DEVICE_CAPABILITIES));
|
sizeof(DEVICE_CAPABILITIES));
|
||||||
Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
|
if (IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp))
|
||||||
{
|
{
|
||||||
/* Surprise removal ok */
|
Status = Irp->IoStatus.Status;
|
||||||
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -527,7 +538,7 @@ FDO_HandleResetCyclePort(
|
||||||
KeReleaseSpinLock(&FDODeviceExtension->Lock, OldLevel);
|
KeReleaseSpinLock(&FDODeviceExtension->Lock, OldLevel);
|
||||||
|
|
||||||
/* Forward request synchronized */
|
/* Forward request synchronized */
|
||||||
USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
|
NT_VERIFY(IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp));
|
||||||
|
|
||||||
/* Reacquire lock */
|
/* Reacquire lock */
|
||||||
KeAcquireSpinLock(&FDODeviceExtension->Lock, &OldLevel);
|
KeAcquireSpinLock(&FDODeviceExtension->Lock, &OldLevel);
|
||||||
|
|
|
@ -31,46 +31,6 @@ USBSTOR_SyncForwardIrpCompletionRoutine(
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
USBCCGP_SyncForwardIrp(
|
|
||||||
PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Initialize event */
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
|
|
||||||
/* Copy irp stack location */
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
/* Set completion routine */
|
|
||||||
IoSetCompletionRoutine(Irp,
|
|
||||||
USBSTOR_SyncForwardIrpCompletionRoutine,
|
|
||||||
&Event,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
/* Call driver */
|
|
||||||
Status = IoCallDriver(DeviceObject, Irp);
|
|
||||||
|
|
||||||
/* Check if pending */
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
/* Wait for the request to finish */
|
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
|
||||||
|
|
||||||
/* Copy status code */
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Done */
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
USBCCGP_SyncUrbRequest(
|
USBCCGP_SyncUrbRequest(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -231,7 +231,15 @@ USBCCGP_PdoHandleQueryId(
|
||||||
//
|
//
|
||||||
// handle query device id
|
// handle query device id
|
||||||
//
|
//
|
||||||
Status = USBCCGP_SyncForwardIrp(PDODeviceExtension->NextDeviceObject, Irp);
|
if (IoForwardIrpSynchronously(PDODeviceExtension->NextDeviceObject, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
|
@ -98,12 +98,6 @@ AllocateInterfaceDescriptorsArray(
|
||||||
|
|
||||||
/* misc.c */
|
/* misc.c */
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
USBCCGP_SyncForwardIrp(
|
|
||||||
PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
USBCCGP_SyncUrbRequest(
|
USBCCGP_SyncUrbRequest(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -160,7 +160,12 @@ USBSTOR_FdoHandleStartDevice(
|
||||||
PIO_WORKITEM WorkItem;
|
PIO_WORKITEM WorkItem;
|
||||||
|
|
||||||
// forward irp to lower device
|
// forward irp to lower device
|
||||||
Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
|
if (!IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
|
||||||
|
{
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("USBSTOR_FdoHandleStartDevice Lower device failed to start %x\n", Status);
|
DPRINT1("USBSTOR_FdoHandleStartDevice Lower device failed to start %x\n", Status);
|
||||||
|
|
|
@ -29,29 +29,6 @@ USBSTOR_SyncForwardIrpCompletionRoutine(
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
USBSTOR_SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
IoSetCompletionRoutine(Irp, USBSTOR_SyncForwardIrpCompletionRoutine, &Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
Status = IoCallDriver(DeviceObject, Irp);
|
|
||||||
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
// wait for the request to finish
|
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
USBSTOR_GetBusInterface(
|
USBSTOR_GetBusInterface(
|
||||||
|
|
|
@ -589,16 +589,21 @@ USBSTOR_PdoHandlePnp(
|
||||||
case IRP_MN_QUERY_CAPABILITIES:
|
case IRP_MN_QUERY_CAPABILITIES:
|
||||||
{
|
{
|
||||||
// just forward irp to lower device
|
// just forward irp to lower device
|
||||||
Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
ASSERT(Status == STATUS_SUCCESS);
|
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
|
||||||
{
|
{
|
||||||
// check if no unique id
|
Status = Irp->IoStatus.Status;
|
||||||
Caps = (PDEVICE_CAPABILITIES)IoStack->Parameters.DeviceCapabilities.Capabilities;
|
ASSERT(Status == STATUS_SUCCESS);
|
||||||
Caps->UniqueID = FALSE; // no unique id is supported
|
|
||||||
Caps->Removable = TRUE; //FIXME
|
if (NT_SUCCESS(Status))
|
||||||
}
|
{
|
||||||
|
// check if no unique id
|
||||||
|
Caps = (PDEVICE_CAPABILITIES)IoStack->Parameters.DeviceCapabilities.Capabilities;
|
||||||
|
Caps->UniqueID = FALSE; // no unique id is supported
|
||||||
|
Caps->Removable = TRUE; //FIXME
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||||
|
|
|
@ -215,11 +215,6 @@ USBSTOR_CreatePDO(
|
||||||
//
|
//
|
||||||
// misc.c routines
|
// misc.c routines
|
||||||
//
|
//
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
USBSTOR_SyncForwardIrp(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN OUT PIRP Irp);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -246,13 +241,6 @@ USBSTOR_GetMaxLUN(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PFDO_DEVICE_EXTENSION DeviceExtension);
|
IN PFDO_DEVICE_EXTENSION DeviceExtension);
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
USBSTOR_SyncForwardIrpCompletionRoutine(
|
|
||||||
PDEVICE_OBJECT DeviceObject,
|
|
||||||
PIRP Irp,
|
|
||||||
PVOID Context);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
USBSTOR_ResetDevice(
|
USBSTOR_ResetDevice(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS Kernel Streaming
|
|
||||||
* FILE: drivers/wdm/audio/legacy/stream/helper.c
|
|
||||||
* PURPOSE: irp helper routines
|
|
||||||
* PROGRAMMER: Johannes Anderwald
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "stream.h"
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
CompletionRoutine(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp,
|
|
||||||
IN PVOID Context)
|
|
||||||
{
|
|
||||||
if (Irp->PendingReturned != FALSE)
|
|
||||||
{
|
|
||||||
KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
}
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpSynchronous(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp)
|
|
||||||
{
|
|
||||||
KEVENT Event;
|
|
||||||
PSTREAM_DEVICE_EXTENSION DeviceExt;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DeviceExt = (PSTREAM_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
|
||||||
|
|
||||||
/* initialize the notification event */
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
|
||||||
|
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp, CompletionRoutine, (PVOID)&Event, TRUE, TRUE, TRUE);
|
|
||||||
|
|
||||||
/* now call the driver */
|
|
||||||
Status = IoCallDriver(DeviceExt->LowerDeviceObject, Irp);
|
|
||||||
/* did the request complete yet */
|
|
||||||
if (Status == STATUS_PENDING)
|
|
||||||
{
|
|
||||||
/* not yet, lets wait a bit */
|
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
|
||||||
Status = Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
return Status;
|
|
||||||
}
|
|
|
@ -353,7 +353,15 @@ StreamClassStartDevice(
|
||||||
|
|
||||||
|
|
||||||
/* First forward the request to lower attached device object */
|
/* First forward the request to lower attached device object */
|
||||||
Status = ForwardIrpSynchronous(DeviceObject, Irp);
|
if (IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
|
||||||
|
{
|
||||||
|
Status = Irp->IoStatus.Status;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Failed to start lower devices */
|
/* Failed to start lower devices */
|
||||||
|
|
|
@ -102,13 +102,6 @@ StreamClassAddDevice(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PDEVICE_OBJECT PhysicalDeviceObject);
|
IN PDEVICE_OBJECT PhysicalDeviceObject);
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
ForwardIrpSynchronous(
|
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
|
||||||
IN PIRP Irp);
|
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
StreamClassSynchronize(
|
StreamClassSynchronize(
|
||||||
|
|
Loading…
Reference in a new issue