mirror of
https://github.com/reactos/reactos.git
synced 2024-11-23 11:33:31 +08: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 *****************************************************************/
|
||||
|
||||
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
|
||||
FdoLocateChildDevice(
|
||||
PPCI_DEVICE *Device,
|
||||
@ -524,9 +484,16 @@ FdoPnpControl(
|
||||
#endif
|
||||
case IRP_MN_START_DEVICE:
|
||||
DPRINT("IRP_MN_START_DEVICE received\n");
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = FdoStartDevice(DeviceObject, Irp);
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (IoForwardIrpSynchronously(DeviceExtension->Ldo, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = FdoStartDevice(DeviceObject, Irp);
|
||||
}
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
@ -340,8 +340,6 @@ i8042StartPacket(
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndWait;
|
||||
|
||||
NTSTATUS
|
||||
DuplicateUnicodeString(
|
||||
IN ULONG Flags,
|
||||
|
@ -14,47 +14,6 @@
|
||||
|
||||
/* 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
|
||||
ForwardIrpAndForget(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -676,6 +676,7 @@ i8042Pnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG MinorFunction;
|
||||
I8042_DEVICE_TYPE DeviceType;
|
||||
@ -684,7 +685,8 @@ i8042Pnp(
|
||||
|
||||
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
MinorFunction = Stack->MinorFunction;
|
||||
DeviceType = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
|
||||
FdoExtension = DeviceObject->DeviceExtension;
|
||||
DeviceType = FdoExtension->Type;
|
||||
|
||||
switch (MinorFunction)
|
||||
{
|
||||
@ -695,12 +697,19 @@ i8042Pnp(
|
||||
/* Call lower driver (if any) */
|
||||
if (DeviceType != PhysicalDeviceObject)
|
||||
{
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = i8042PnpStartDevice(
|
||||
DeviceObject,
|
||||
Stack->Parameters.StartDevice.AllocatedResources,
|
||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = i8042PnpStartDevice(
|
||||
DeviceObject,
|
||||
Stack->Parameters.StartDevice.AllocatedResources,
|
||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
Status = STATUS_SUCCESS;
|
||||
|
@ -163,12 +163,21 @@ ClassDeviceControl(
|
||||
while (Entry != Head)
|
||||
{
|
||||
PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Entry, PORT_DEVICE_EXTENSION, ListEntry);
|
||||
NTSTATUS IntermediateStatus;
|
||||
|
||||
IoGetCurrentIrpStackLocation(Irp)->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
|
||||
IntermediateStatus = ForwardIrpAndWait(DevExt->DeviceObject, Irp);
|
||||
if (!NT_SUCCESS(IntermediateStatus))
|
||||
Status = IntermediateStatus;
|
||||
|
||||
if (IoForwardIrpSynchronously(DevExt->LowerDevice, Irp))
|
||||
{
|
||||
if (!NT_SUCCESS(Irp->IoStatus.Status))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
Entry = Entry->Flink;
|
||||
}
|
||||
break;
|
||||
@ -836,7 +845,15 @@ ClassPnp(
|
||||
switch (IrpSp->MinorFunction)
|
||||
{
|
||||
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))
|
||||
{
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
|
@ -67,11 +67,6 @@ typedef struct _CLASS_DEVICE_EXTENSION
|
||||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||
|
||||
NTSTATUS
|
||||
|
@ -11,47 +11,6 @@
|
||||
|
||||
#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
|
||||
ForwardIrpAndForget(
|
||||
|
@ -11,47 +11,6 @@
|
||||
|
||||
#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
|
||||
ForwardIrpAndForget(
|
||||
|
@ -812,7 +812,15 @@ ClassPnp(
|
||||
switch (IrpSp->MinorFunction)
|
||||
{
|
||||
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))
|
||||
{
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
|
@ -67,11 +67,6 @@ typedef struct _CLASS_DEVICE_EXTENSION
|
||||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||
|
||||
NTSTATUS
|
||||
|
@ -172,11 +172,21 @@ SermousePnp(
|
||||
*/
|
||||
case IRP_MN_START_DEVICE: /* 0x0 */
|
||||
{
|
||||
PSERMOUSE_DEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
TRACE_(SERMOUSE, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = SermouseStartDevice(DeviceObject, Irp);
|
||||
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = SermouseStartDevice(DeviceObject, Irp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
|
||||
|
@ -10,44 +10,6 @@
|
||||
|
||||
#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
|
||||
ForwardIrpAndForget(
|
||||
|
@ -98,11 +98,6 @@ DRIVER_DISPATCH SermouseInternalDeviceControl;
|
||||
|
||||
/************************************ misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS NTAPI
|
||||
ForwardIrpAndForget(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -295,13 +295,16 @@ IKsDevice_PnpStartDevice(
|
||||
DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader);
|
||||
|
||||
/* 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 */
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NextDevice object failed to start with %x\n", Status);
|
||||
Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
@ -459,13 +462,8 @@ IKsDevice_Pnp(
|
||||
}
|
||||
|
||||
/* pass the irp down the driver stack */
|
||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
||||
|
||||
DPRINT("Next Device: Status %x\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||
}
|
||||
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
@ -482,15 +480,9 @@ IKsDevice_Pnp(
|
||||
}
|
||||
|
||||
/* pass the irp down the driver stack */
|
||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
||||
|
||||
DPRINT("Next Device: Status %x\n", Status);
|
||||
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||
/* FIXME delete device resources */
|
||||
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
case IRP_MN_QUERY_INTERFACE:
|
||||
@ -518,23 +510,14 @@ IKsDevice_Pnp(
|
||||
}
|
||||
|
||||
/* pass the irp down the driver stack */
|
||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
||||
|
||||
DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n", Status);
|
||||
Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||
{
|
||||
/* pass the irp down the driver stack */
|
||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
||||
|
||||
DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n", Status);
|
||||
|
||||
//Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||
}
|
||||
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
||||
{
|
||||
@ -550,22 +533,14 @@ IKsDevice_Pnp(
|
||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
||||
{
|
||||
/* pass the irp down the driver stack */
|
||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
||||
|
||||
DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||
}
|
||||
default:
|
||||
DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
|
||||
/* pass the irp down the driver stack */
|
||||
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
CompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
|
||||
/* pass the irp down the driver stack */
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,11 +74,6 @@ KspRegisterDeviceInterfaces(
|
||||
IN PUNICODE_STRING ReferenceString,
|
||||
OUT PLIST_ENTRY SymbolicLinkList);
|
||||
|
||||
NTSTATUS
|
||||
KspForwardIrpSynchronous(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
PVOID
|
||||
AllocateItem(
|
||||
IN POOL_TYPE PoolType,
|
||||
|
@ -46,57 +46,6 @@ FreeItem(
|
||||
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
|
||||
KspCopyCreateRequest(
|
||||
IN PIRP Irp,
|
||||
|
@ -505,6 +505,7 @@ NTAPI
|
||||
FdoPnp(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||
ULONG MinorFunction;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
@ -545,15 +546,21 @@ FdoPnp(IN PDEVICE_OBJECT DeviceObject,
|
||||
case IRP_MN_START_DEVICE: /* 0x0 */
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
|
||||
ASSERT(((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.PnpState == dsStopped);
|
||||
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
FdoExtension = DeviceObject->DeviceExtension;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
ASSERT(FdoExtension->Common.PnpState == dsStopped);
|
||||
|
||||
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = FdoStartDevice(DeviceObject,
|
||||
Stack->Parameters.StartDevice.AllocatedResources,
|
||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = FdoStartDevice(DeviceObject,
|
||||
Stack->Parameters.StartDevice.AllocatedResources,
|
||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -8,52 +8,8 @@
|
||||
#include "parport.h"
|
||||
|
||||
|
||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
||||
|
||||
/* 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
|
||||
NTAPI
|
||||
ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -109,10 +109,6 @@ FdoPower(IN PDEVICE_OBJECT DeviceObject,
|
||||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||
|
||||
PVOID
|
||||
|
@ -15,54 +15,6 @@
|
||||
|
||||
/* 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
|
||||
NTAPI
|
||||
ForwardIrpAndForget(
|
||||
|
@ -263,6 +263,7 @@ ProcessorPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PDEVICE_EXTENSION DeviceExtension;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
ULONG_PTR Information = 0;
|
||||
NTSTATUS Status = STATUS_NOT_SUPPORTED;
|
||||
@ -277,12 +278,18 @@ ProcessorPnp(
|
||||
DPRINT(" IRP_MN_START_DEVICE received\n");
|
||||
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = ProcessorStartDevice(DeviceObject,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResources,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = ProcessorStartDevice(DeviceObject,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResources,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -21,12 +21,6 @@ typedef struct _DEVICE_EXTENSION
|
||||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ForwardIrpAndForget(
|
||||
|
@ -153,6 +153,7 @@ SerenumFdoPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||
ULONG MinorFunction;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
@ -181,9 +182,18 @@ SerenumFdoPnp(
|
||||
{
|
||||
TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = SerenumFdoStartDevice(DeviceObject, Irp);
|
||||
FdoExtension = DeviceObject->DeviceExtension;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = SerenumFdoStartDevice(DeviceObject, Irp);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
|
||||
|
||||
/* I really want PCSZ strings as last arguments because
|
||||
* PnP ids are ANSI-encoded in PnP device string
|
||||
* identification */
|
||||
@ -88,48 +86,6 @@ SerenumInitMultiSzString(
|
||||
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
|
||||
ForwardIrpToLowerDeviceAndForget(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -12,46 +12,6 @@
|
||||
|
||||
#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
|
||||
ForwardIrpAndForget(
|
||||
|
@ -328,6 +328,7 @@ SerialPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PSERIAL_DEVICE_EXTENSION DeviceExtension;
|
||||
ULONG MinorFunction;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = 0;
|
||||
@ -367,15 +368,24 @@ SerialPnp(
|
||||
{
|
||||
TRACE_(SERIAL, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
|
||||
ASSERT(((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->PnpState == dsStopped);
|
||||
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = SerialPnpStartDevice(
|
||||
DeviceObject,
|
||||
Stack->Parameters.StartDevice.AllocatedResources,
|
||||
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
DeviceExtension = DeviceObject->DeviceExtension;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
ASSERT(DeviceExtension->PnpState == dsStopped);
|
||||
|
||||
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;
|
||||
}
|
||||
case IRP_MN_QUERY_DEVICE_RELATIONS: /* (optional) 0x7 */
|
||||
|
@ -242,11 +242,6 @@ SerialDetectUartType(
|
||||
|
||||
/************************************ misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||
|
||||
VOID NTAPI
|
||||
|
@ -16,51 +16,6 @@
|
||||
|
||||
/* 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
|
||||
NTAPI
|
||||
ForwardIrpAndForget(
|
||||
@ -492,6 +447,7 @@ FdcFdoPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
PDEVICE_RELATIONS DeviceRelations = NULL;
|
||||
ULONG_PTR Information = 0;
|
||||
@ -505,14 +461,22 @@ FdcFdoPnp(
|
||||
{
|
||||
case IRP_MN_START_DEVICE:
|
||||
DPRINT(" IRP_MN_START_DEVICE received\n");
|
||||
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
FdoExtension = DeviceObject->DeviceExtension;
|
||||
|
||||
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = FdcFdoStartDevice(DeviceObject,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResources,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = FdcFdoStartDevice(DeviceObject,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResources,
|
||||
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||
|
@ -403,6 +403,7 @@ PciIdeXFdoPnpDispatch(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PFDO_DEVICE_EXTENSION FdoExtension;
|
||||
ULONG MinorFunction;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
ULONG_PTR Information = Irp->IoStatus.Information;
|
||||
@ -416,10 +417,19 @@ PciIdeXFdoPnpDispatch(
|
||||
case IRP_MN_START_DEVICE: /* 0x00 */
|
||||
{
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
|
||||
/* Call lower driver */
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = PciIdeXFdoStartDevice(DeviceObject, Irp);
|
||||
FdoExtension = DeviceObject->DeviceExtension;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = PciIdeXFdoStartDevice(DeviceObject, Irp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
|
||||
|
@ -11,46 +11,6 @@
|
||||
#define NDEBUG
|
||||
#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
|
||||
ForwardIrpAndForget(
|
||||
|
@ -53,18 +53,6 @@ PciIdeXFdoPnpDispatch(
|
||||
|
||||
/* 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
|
||||
ForwardIrpAndForget(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -191,10 +191,18 @@ PortFdoStartDevice(
|
||||
/* Start the lower device if the FDO is in 'stopped' state */
|
||||
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))
|
||||
{
|
||||
DPRINT1("ForwardIrpAndWait() failed (Status 0x%08lx)\n", Status);
|
||||
DPRINT1("Lower device failed the IRP (Status 0x%08lx)\n", Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
@ -15,47 +15,6 @@
|
||||
|
||||
/* 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
|
||||
NTAPI
|
||||
ForwardIrpAndForget(
|
||||
|
@ -178,11 +178,6 @@ MiniportStartIo(
|
||||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
_In_ PDEVICE_OBJECT LowerDevice,
|
||||
_In_ PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ForwardIrpAndForget(
|
||||
|
@ -253,7 +253,14 @@ FDO_StartDevice(
|
||||
ASSERT(FDODeviceExtension->Common.IsFDO);
|
||||
|
||||
/* 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))
|
||||
{
|
||||
@ -435,11 +442,15 @@ FDO_HandlePnp(
|
||||
RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
|
||||
&FDODeviceExtension->Capabilities,
|
||||
sizeof(DEVICE_CAPABILITIES));
|
||||
Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
if (IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp))
|
||||
{
|
||||
/* Surprise removal ok */
|
||||
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -527,7 +538,7 @@ FDO_HandleResetCyclePort(
|
||||
KeReleaseSpinLock(&FDODeviceExtension->Lock, OldLevel);
|
||||
|
||||
/* Forward request synchronized */
|
||||
USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
|
||||
NT_VERIFY(IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp));
|
||||
|
||||
/* Reacquire lock */
|
||||
KeAcquireSpinLock(&FDODeviceExtension->Lock, &OldLevel);
|
||||
|
@ -31,46 +31,6 @@ USBSTOR_SyncForwardIrpCompletionRoutine(
|
||||
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
|
||||
USBCCGP_SyncUrbRequest(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -231,7 +231,15 @@ USBCCGP_PdoHandleQueryId(
|
||||
//
|
||||
// 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))
|
||||
{
|
||||
//
|
||||
|
@ -98,12 +98,6 @@ AllocateInterfaceDescriptorsArray(
|
||||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBCCGP_SyncForwardIrp(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
USBCCGP_SyncUrbRequest(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -160,7 +160,12 @@ USBSTOR_FdoHandleStartDevice(
|
||||
PIO_WORKITEM WorkItem;
|
||||
|
||||
// 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))
|
||||
{
|
||||
DPRINT1("USBSTOR_FdoHandleStartDevice Lower device failed to start %x\n", Status);
|
||||
|
@ -29,29 +29,6 @@ USBSTOR_SyncForwardIrpCompletionRoutine(
|
||||
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
|
||||
NTAPI
|
||||
USBSTOR_GetBusInterface(
|
||||
|
@ -589,16 +589,21 @@ USBSTOR_PdoHandlePnp(
|
||||
case IRP_MN_QUERY_CAPABILITIES:
|
||||
{
|
||||
// just forward irp to lower device
|
||||
Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
|
||||
ASSERT(Status == STATUS_SUCCESS);
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
|
||||
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
|
||||
}
|
||||
if (IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
ASSERT(Status == STATUS_SUCCESS);
|
||||
|
||||
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;
|
||||
}
|
||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||
|
@ -215,11 +215,6 @@ USBSTOR_CreatePDO(
|
||||
//
|
||||
// misc.c routines
|
||||
//
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBSTOR_SyncForwardIrp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
@ -246,13 +241,6 @@ USBSTOR_GetMaxLUN(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PFDO_DEVICE_EXTENSION DeviceExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
USBSTOR_SyncForwardIrpCompletionRoutine(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_ResetDevice(
|
||||
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 */
|
||||
Status = ForwardIrpSynchronous(DeviceObject, Irp);
|
||||
if (IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed to start lower devices */
|
||||
|
@ -102,13 +102,6 @@ StreamClassAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PDEVICE_OBJECT PhysicalDeviceObject);
|
||||
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ForwardIrpSynchronous(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
StreamClassSynchronize(
|
||||
|
Loading…
Reference in New Issue
Block a user