[USBEHCI_NEW]
[reactos.git] / drivers / usb / usbehci_new / misc.cpp
1 /*
2 * PROJECT: ReactOS Universal Serial Bus Bulk Enhanced Host Controller Interface
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/usb/usbehci/misc.cpp
5 * PURPOSE: USB EHCI device driver.
6 * PROGRAMMERS:
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
9 */
10
11 #include "usbehci.h"
12
13 //
14 // driver verifier
15 //
16 IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine;
17
18 NTSTATUS
19 NTAPI
20 SyncForwardIrpCompletionRoutine(
21 PDEVICE_OBJECT DeviceObject,
22 PIRP Irp,
23 PVOID Context)
24 {
25 if (Irp->PendingReturned)
26 {
27 KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
28 }
29 return STATUS_MORE_PROCESSING_REQUIRED;
30 }
31
32 NTSTATUS
33 NTAPI
34 SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
35 {
36 KEVENT Event;
37 NTSTATUS Status;
38
39 //
40 // initialize event
41 //
42 KeInitializeEvent(&Event, NotificationEvent, FALSE);
43
44 //
45 // copy irp stack location
46 //
47 IoCopyCurrentIrpStackLocationToNext(Irp);
48
49 //
50 // set completion routine
51 //
52 IoSetCompletionRoutine(Irp, SyncForwardIrpCompletionRoutine, &Event, TRUE, TRUE, TRUE);
53
54
55 //
56 // call driver
57 //
58 Status = IoCallDriver(DeviceObject, Irp);
59
60
61 //
62 // check if pending
63 //
64 if (Status == STATUS_PENDING)
65 {
66 //
67 // wait for the request to finish
68 //
69 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
70
71 //
72 // copy status code
73 //
74 Status = Irp->IoStatus.Status;
75 }
76
77 //
78 // done
79 //
80 return Status;
81 }
82