mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 06:15:52 +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
45 changed files with 238 additions and 866 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue