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)
18 IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine
;
22 USBSTOR_SyncForwardIrpCompletionRoutine(
23 PDEVICE_OBJECT DeviceObject
,
27 if (Irp
->PendingReturned
)
29 KeSetEvent((PKEVENT
)Context
, IO_NO_INCREMENT
, FALSE
);
31 return STATUS_MORE_PROCESSING_REQUIRED
;
36 USBCCGP_SyncForwardIrp(
37 PDEVICE_OBJECT DeviceObject
,
43 /* Initialize event */
44 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
46 /* Copy irp stack location */
47 IoCopyCurrentIrpStackLocationToNext(Irp
);
49 /* Set completion routine */
50 IoSetCompletionRoutine(Irp
,
51 USBSTOR_SyncForwardIrpCompletionRoutine
,
58 Status
= IoCallDriver(DeviceObject
, Irp
);
60 /* Check if pending */
61 if (Status
== STATUS_PENDING
)
63 /* Wait for the request to finish */
64 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
66 /* Copy status code */
67 Status
= Irp
->IoStatus
.Status
;
75 USBCCGP_SyncUrbRequest(
76 IN PDEVICE_OBJECT DeviceObject
,
80 PIO_STACK_LOCATION IoStack
;
85 Irp
= IoAllocateIrp(DeviceObject
->StackSize
, FALSE
);
89 return STATUS_INSUFFICIENT_RESOURCES
;
92 /* Initialize event */
93 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
95 /* Get next stack location */
96 IoStack
= IoGetNextIrpStackLocation(Irp
);
98 /* Initialize stack location */
99 IoStack
->MajorFunction
= IRP_MJ_INTERNAL_DEVICE_CONTROL
;
100 IoStack
->Parameters
.DeviceIoControl
.IoControlCode
= IOCTL_INTERNAL_USB_SUBMIT_URB
;
101 IoStack
->Parameters
.Others
.Argument1
= (PVOID
)UrbRequest
;
102 IoStack
->Parameters
.DeviceIoControl
.InputBufferLength
= UrbRequest
->UrbHeader
.Length
;
103 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
105 /* Setup completion routine */
106 IoSetCompletionRoutine(Irp
,
107 USBSTOR_SyncForwardIrpCompletionRoutine
,
114 Status
= IoCallDriver(DeviceObject
, Irp
);
116 /* Check if request is pending */
117 if (Status
== STATUS_PENDING
)
119 /* Wait for completion */
120 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
123 Status
= Irp
->IoStatus
.Status
;
135 IN POOL_TYPE PoolType
,
139 PVOID Item
= ExAllocatePoolWithTag(PoolType
, ItemSize
, USBCCPG_TAG
);
144 RtlZeroMemory(Item
, ItemSize
);
156 ExFreePoolWithTag(Item
, USBCCPG_TAG
);
160 DumpFunctionDescriptor(
161 IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor
,
162 IN ULONG FunctionDescriptorCount
)
164 ULONG Index
, SubIndex
;
167 DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount
);
168 for (Index
= 0; Index
< FunctionDescriptorCount
; Index
++)
170 DPRINT1("Function %lu\n", Index
);
171 DPRINT1("FunctionNumber %lu\n", FunctionDescriptor
[Index
].FunctionNumber
);
172 DPRINT1("HardwareId %S\n", FunctionDescriptor
[Index
].HardwareId
.Buffer
);
173 DPRINT1("CompatibleId %S\n", FunctionDescriptor
[Index
].CompatibleId
.Buffer
);
174 DPRINT1("FunctionDescription %wZ\n", &FunctionDescriptor
[Index
].FunctionDescription
);
175 DPRINT1("NumInterfaces %lu\n", FunctionDescriptor
[Index
].NumberOfInterfaces
);
177 for(SubIndex
= 0; SubIndex
< FunctionDescriptor
[Index
].NumberOfInterfaces
; SubIndex
++)
179 DPRINT1(" Index %lu Interface %p\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]);
180 DPRINT1(" Index %lu Interface InterfaceNumber %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceNumber
);
181 DPRINT1(" Index %lu Interface Alternate %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bAlternateSetting
);
182 DPRINT1(" Index %lu bLength %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bLength
);
183 DPRINT1(" Index %lu bDescriptorType %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bDescriptorType
);
184 DPRINT1(" Index %lu bInterfaceNumber %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceNumber
);
185 DPRINT1(" Index %lu bAlternateSetting %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bAlternateSetting
);
186 DPRINT1(" Index %lu bNumEndpoints %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bNumEndpoints
);
187 DPRINT1(" Index %lu bInterfaceClass %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceClass
);
188 DPRINT1(" Index %lu bInterfaceSubClass %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceSubClass
);
189 DPRINT1(" Index %lu bInterfaceProtocol %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->bInterfaceProtocol
);
190 DPRINT1(" Index %lu iInterface %x\n", SubIndex
, FunctionDescriptor
[Index
].InterfaceDescriptorList
[SubIndex
]->iInterface
);