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/usbccgp/misc.c
5 * PURPOSE: USB device driver.
7 * Michael Martin (michael.martin@reactos.org)
8 * Johannes Anderwald (johannes.anderwald@reactos.org)
17 IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine
;
21 USBSTOR_SyncForwardIrpCompletionRoutine(
22 PDEVICE_OBJECT DeviceObject
,
26 if (Irp
->PendingReturned
)
28 KeSetEvent((PKEVENT
)Context
, IO_NO_INCREMENT
, FALSE
);
30 return STATUS_MORE_PROCESSING_REQUIRED
;
35 USBCCGP_SyncForwardIrp(
36 PDEVICE_OBJECT DeviceObject
,
45 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
48 // copy irp stack location
50 IoCopyCurrentIrpStackLocationToNext(Irp
);
53 // set completion routine
55 IoSetCompletionRoutine(Irp
, USBSTOR_SyncForwardIrpCompletionRoutine
, &Event
, TRUE
, TRUE
, TRUE
);
61 Status
= IoCallDriver(DeviceObject
, Irp
);
66 if (Status
== STATUS_PENDING
)
69 // wait for the request to finish
71 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
76 Status
= Irp
->IoStatus
.Status
;
86 USBCCGP_SyncUrbRequest(
87 IN PDEVICE_OBJECT DeviceObject
,
91 PIO_STACK_LOCATION IoStack
;
98 Irp
= IoAllocateIrp(DeviceObject
->StackSize
, FALSE
);
104 return STATUS_INSUFFICIENT_RESOURCES
;
110 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
114 // get next stack location
116 IoStack
= IoGetNextIrpStackLocation(Irp
);
119 // initialize stack location
121 IoStack
->MajorFunction
= IRP_MJ_INTERNAL_DEVICE_CONTROL
;
122 IoStack
->Parameters
.DeviceIoControl
.IoControlCode
= IOCTL_INTERNAL_USB_SUBMIT_URB
;
123 IoStack
->Parameters
.Others
.Argument1
= (PVOID
)UrbRequest
;
124 IoStack
->Parameters
.DeviceIoControl
.InputBufferLength
= UrbRequest
->UrbHeader
.Length
;
125 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
128 // setup completion routine
130 IoSetCompletionRoutine(Irp
, USBSTOR_SyncForwardIrpCompletionRoutine
, &Event
, TRUE
, TRUE
, TRUE
);
135 Status
= IoCallDriver(DeviceObject
, Irp
);
138 // check if request is pending
140 if (Status
== STATUS_PENDING
)
143 // wait for completion
145 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
150 Status
= Irp
->IoStatus
.Status
;
166 IN POOL_TYPE PoolType
,
172 PVOID Item
= ExAllocatePoolWithTag(PoolType
, ItemSize
, USBCCPG_TAG
);
179 RtlZeroMemory(Item
, ItemSize
);
195 ExFreePoolWithTag(Item
, USBCCPG_TAG
);
199 DumpFunctionDescriptor(
200 IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor
,
201 IN ULONG FunctionDescriptorCount
)
203 ULONG Index
, SubIndex
;
206 DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount
);
207 for(Index
= 0; Index
< FunctionDescriptorCount
; Index
++)
209 DPRINT1("Function %lu\n", Index
);
210 DPRINT1("FunctionNumber %lu\n", FunctionDescriptor
[Index
].FunctionNumber
);
211 DPRINT1("HardwareId %wZ\n", &FunctionDescriptor
[Index
].HardwareId
);
212 DPRINT1("CompatibleId %wZ\n", &FunctionDescriptor
[Index
].CompatibleId
);
213 DPRINT1("FunctionDescription %wZ\n", &FunctionDescriptor
[Index
].FunctionDescription
);
214 DPRINT1("NumInterfaces %lu\n", FunctionDescriptor
[Index
].NumberOfInterfaces
);
216 for(SubIndex
= 0; SubIndex
< FunctionDescriptor
[Index
].NumberOfInterfaces
; SubIndex
++)
218 DPRINT1(" Interface %p\n", FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]);
219 DPRINT1(" Interface InterfaceNumber %x\n", FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceNumber
);
220 DPRINT1(" Interface Alternate %x\n", FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bAlternateSetting
);