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)
15 IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine
;
19 USBSTOR_SyncForwardIrpCompletionRoutine(
20 PDEVICE_OBJECT DeviceObject
,
24 if (Irp
->PendingReturned
)
26 KeSetEvent((PKEVENT
)Context
, IO_NO_INCREMENT
, FALSE
);
28 return STATUS_MORE_PROCESSING_REQUIRED
;
33 USBCCGP_SyncForwardIrp(
34 PDEVICE_OBJECT DeviceObject
,
40 /* Initialize event */
41 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
43 /* Copy irp stack location */
44 IoCopyCurrentIrpStackLocationToNext(Irp
);
46 /* Set completion routine */
47 IoSetCompletionRoutine(Irp
,
48 USBSTOR_SyncForwardIrpCompletionRoutine
,
55 Status
= IoCallDriver(DeviceObject
, Irp
);
57 /* Check if pending */
58 if (Status
== STATUS_PENDING
)
60 /* Wait for the request to finish */
61 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
63 /* Copy status code */
64 Status
= Irp
->IoStatus
.Status
;
72 USBCCGP_SyncUrbRequest(
73 IN PDEVICE_OBJECT DeviceObject
,
77 PIO_STACK_LOCATION IoStack
;
82 Irp
= IoAllocateIrp(DeviceObject
->StackSize
, FALSE
);
86 return STATUS_INSUFFICIENT_RESOURCES
;
89 /* Initialize event */
90 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
92 /* Get next stack location */
93 IoStack
= IoGetNextIrpStackLocation(Irp
);
95 /* Initialize stack location */
96 IoStack
->MajorFunction
= IRP_MJ_INTERNAL_DEVICE_CONTROL
;
97 IoStack
->Parameters
.DeviceIoControl
.IoControlCode
= IOCTL_INTERNAL_USB_SUBMIT_URB
;
98 IoStack
->Parameters
.Others
.Argument1
= (PVOID
)UrbRequest
;
99 IoStack
->Parameters
.DeviceIoControl
.InputBufferLength
= UrbRequest
->UrbHeader
.Length
;
100 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
102 /* Setup completion routine */
103 IoSetCompletionRoutine(Irp
,
104 USBSTOR_SyncForwardIrpCompletionRoutine
,
111 Status
= IoCallDriver(DeviceObject
, Irp
);
113 /* Check if request is pending */
114 if (Status
== STATUS_PENDING
)
116 /* Wait for completion */
117 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
120 Status
= Irp
->IoStatus
.Status
;
132 IN POOL_TYPE PoolType
,
136 PVOID Item
= ExAllocatePoolWithTag(PoolType
, ItemSize
, USBCCPG_TAG
);
141 RtlZeroMemory(Item
, ItemSize
);
153 ExFreePoolWithTag(Item
, USBCCPG_TAG
);
157 DumpFunctionDescriptor(
158 IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor
,
159 IN ULONG FunctionDescriptorCount
)
161 ULONG Index
, SubIndex
;
164 DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount
);
165 for (Index
= 0; Index
< FunctionDescriptorCount
; Index
++)
167 DPRINT1("Function %lu\n", Index
);
168 DPRINT1("FunctionNumber %lu\n", FunctionDescriptor
[Index
].FunctionNumber
);
169 DPRINT1("HardwareId %S\n", FunctionDescriptor
[Index
].HardwareId
.Buffer
);
170 DPRINT1("CompatibleId %S\n", FunctionDescriptor
[Index
].CompatibleId
.Buffer
);
171 DPRINT1("FunctionDescription %wZ\n", &FunctionDescriptor
[Index
].FunctionDescription
);
172 DPRINT1("NumInterfaces %lu\n", FunctionDescriptor
[Index
].NumberOfInterfaces
);
174 for(SubIndex
= 0; SubIndex
< FunctionDescriptor
[Index
].NumberOfInterfaces
; SubIndex
++)
176 DPRINT1(" Index %lu Interface %p\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]);
177 DPRINT1(" Index %lu Interface InterfaceNumber %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceNumber
);
178 DPRINT1(" Index %lu Interface Alternate %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bAlternateSetting
);
179 DPRINT1(" Index %lu bLength %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bLength
);
180 DPRINT1(" Index %lu bDescriptorType %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bDescriptorType
);
181 DPRINT1(" Index %lu bInterfaceNumber %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceNumber
);
182 DPRINT1(" Index %lu bAlternateSetting %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bAlternateSetting
);
183 DPRINT1(" Index %lu bNumEndpoints %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bNumEndpoints
);
184 DPRINT1(" Index %lu bInterfaceClass %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceClass
);
185 DPRINT1(" Index %lu bInterfaceSubClass %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceSubClass
);
186 DPRINT1(" Index %lu bInterfaceProtocol %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceProtocol
);
187 DPRINT1(" Index %lu iInterface %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->iInterface
);