1 /* 2 * PROJECT: ReactOS Serial mouse driver 3 * LICENSE: GPL - See COPYING in the top level directory 4 * FILE: drivers/input/sermouse/fdo.c 5 * PURPOSE: Miscellaneous operations 6 * PROGRAMMERS: Copyright 2005-2006 Herv� Poussineau (hpoussin@reactos.org) 7 */ 8 9 #include "sermouse.h" 10 11 #include <debug.h> 12 13 static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion; 14 15 static NTSTATUS NTAPI 16 ForwardIrpAndWaitCompletion( 17 IN PDEVICE_OBJECT DeviceObject, 18 IN PIRP Irp, 19 IN PVOID Context) 20 { 21 if (Irp->PendingReturned) 22 KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE); 23 return STATUS_MORE_PROCESSING_REQUIRED; 24 } 25 26 NTSTATUS 27 ForwardIrpAndWait( 28 IN PDEVICE_OBJECT DeviceObject, 29 IN PIRP Irp) 30 { 31 PDEVICE_OBJECT LowerDevice = ((PSERMOUSE_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; 32 KEVENT Event; 33 NTSTATUS Status; 34 35 KeInitializeEvent(&Event, NotificationEvent, FALSE); 36 IoCopyCurrentIrpStackLocationToNext(Irp); 37 38 TRACE_(SERMOUSE, "Calling lower device %p\n", LowerDevice); 39 IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE); 40 41 Status = IoCallDriver(LowerDevice, Irp); 42 if (Status == STATUS_PENDING) 43 { 44 Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); 45 if (NT_SUCCESS(Status)) 46 Status = Irp->IoStatus.Status; 47 } 48 49 return Status; 50 } 51 52 NTSTATUS NTAPI 53 ForwardIrpAndForget( 54 IN PDEVICE_OBJECT DeviceObject, 55 IN PIRP Irp) 56 { 57 PDEVICE_OBJECT LowerDevice = ((PSERMOUSE_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice; 58 59 IoSkipCurrentIrpStackLocation(Irp); 60 return IoCallDriver(LowerDevice, Irp); 61 } 62