mirror of
https://github.com/reactos/reactos.git
synced 2024-12-19 00:53:33 +08:00
Implement IoForwardIrpSynchronously
Use it in root bus svn path=/trunk/; revision=30979
This commit is contained in:
parent
3e89cd6ca5
commit
3f543f3230
@ -1411,16 +1411,56 @@ IofCompleteRequest(IN PIRP Irp,
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
IopSynchronousCompletion(
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return FALSE;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Check if next stack location is available */
|
||||
if (Irp->CurrentLocation < Irp->StackCount)
|
||||
{
|
||||
/* No more stack location */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize event */
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
|
||||
/* Copy stack location for next driver */
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
/* Set a completion routine, which will signal the event */
|
||||
IoSetCompletionRoutine(Irp, IopSynchronousCompletion, &Event, TRUE, TRUE, TRUE);
|
||||
|
||||
/* Call next driver */
|
||||
Status = IoCallDriver(DeviceObject, Irp);
|
||||
|
||||
/* Check if irp is pending */
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
/* Yes, wait for its completion */
|
||||
KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -226,48 +226,6 @@ cleanup:
|
||||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
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;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
ForwardIrpAndWait(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
|
||||
ASSERT(((PPNPROOT_COMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
|
||||
LowerDevice = ((PPNPROOT_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Ldo;
|
||||
|
||||
ASSERT(LowerDevice);
|
||||
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||
|
||||
DPRINT("Calling lower device %p [%wZ]\n", LowerDevice, &LowerDevice->DriverObject->DriverName);
|
||||
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 NTAPI
|
||||
QueryStringCallback(
|
||||
IN PWSTR ValueName,
|
||||
@ -702,10 +660,14 @@ PnpRootFdoPnpControl(
|
||||
|
||||
case IRP_MN_START_DEVICE:
|
||||
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
DeviceExtension->State = dsStarted;
|
||||
Status = STATUS_SUCCESS;
|
||||
if (!IoForwardIrpSynchronously(DeviceExtension->Ldo, Irp))
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
else
|
||||
{
|
||||
Status = Irp->IoStatus.Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
DeviceExtension->State = dsStarted;
|
||||
}
|
||||
break;
|
||||
|
||||
case IRP_MN_STOP_DEVICE:
|
||||
|
Loading…
Reference in New Issue
Block a user