[CMAKE]
[reactos.git] / drivers / usb / usbehci / irp.c
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/irp.c
5 * PURPOSE: IRP Handling.
6 * PROGRAMMERS:
7 * Michael Martin
8 */
9
10 #include "usbehci.h"
11
12 VOID
13 RequestURBCancel (PDEVICE_OBJECT DeviceObject, PIRP Irp)
14 {
15 PPDO_DEVICE_EXTENSION PdoDeviceExtension;
16
17 PdoDeviceExtension = (PPDO_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
18
19 KIRQL OldIrql = Irp->CancelIrql;
20 IoReleaseCancelSpinLock(DISPATCH_LEVEL);
21
22 KeAcquireSpinLockAtDpcLevel(&PdoDeviceExtension->IrpQueueLock);
23 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
24
25 KeReleaseSpinLock(&PdoDeviceExtension->IrpQueueLock, OldIrql);
26
27 Irp->IoStatus.Status = STATUS_CANCELLED;
28 IoCompleteRequest(Irp, IO_NO_INCREMENT);
29 }
30
31 VOID
32 QueueURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
33 {
34 KIRQL OldIrql;
35
36 KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &OldIrql);
37
38 if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
39 {
40 KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, OldIrql);
41 Irp->IoStatus.Status = STATUS_CANCELLED;
42 IoCompleteRequest(Irp, IO_NO_INCREMENT);
43 }
44 else
45 {
46 InsertTailList(&DeviceExtension->IrpQueue, &Irp->Tail.Overlay.ListEntry);
47 KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, OldIrql);
48 }
49 }
50
51 VOID
52 CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
53 {
54 PLIST_ENTRY NextIrp = NULL;
55 NTSTATUS Status = STATUS_UNSUCCESSFUL;
56 ULONG_PTR Information = 0;
57 PIO_STACK_LOCATION Stack;
58 PUSB_DEVICE UsbDevice = NULL;
59 KIRQL oldIrql;
60 PIRP Irp = NULL;
61 URB *Urb;
62
63 KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
64
65 while (!IsListEmpty(&DeviceExtension->IrpQueue))
66 {
67 NextIrp = RemoveHeadList(&DeviceExtension->IrpQueue);
68 Irp = CONTAINING_RECORD(NextIrp, IRP, Tail.Overlay.ListEntry);
69
70 if (!Irp)
71 break;
72 Stack = IoGetCurrentIrpStackLocation(Irp);
73 ASSERT(Stack);
74
75 Urb = (PURB) Stack->Parameters.Others.Argument1;
76
77 ASSERT(Urb);
78
79 Information = 0;
80 Status = STATUS_SUCCESS;
81
82 DPRINT("TransferBuffer %x\n", Urb->UrbControlDescriptorRequest.TransferBuffer);
83 DPRINT("TransferBufferLength %x\n", Urb->UrbControlDescriptorRequest.TransferBufferLength);
84 DPRINT("UsbdDeviceHandle = %x\n", Urb->UrbHeader.UsbdDeviceHandle);
85
86 UsbDevice = Urb->UrbHeader.UsbdDeviceHandle;
87 /* UsbdDeviceHandle of 0 is root hub */
88 if (UsbDevice == NULL)
89 UsbDevice = DeviceExtension->UsbDevices[0];
90
91 /* Assume URB success */
92 Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
93 /* Set the DeviceHandle to the Internal Device */
94 Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
95
96 switch (Urb->UrbHeader.Function)
97 {
98 case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
99 {
100 DPRINT("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:\n");
101 DPRINT("--->TransferBufferLength %x\n",Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
102 DPRINT("--->TransferBuffer %x\n",Urb->UrbBulkOrInterruptTransfer.TransferBuffer);
103 DPRINT("--->PipeHandle %x\n",Urb->UrbBulkOrInterruptTransfer.PipeHandle);
104 DPRINT("---->(PVOID)&UsbDevice->EndPointDescriptor %x\n", (PVOID)&UsbDevice->ActiveInterface->EndPoints[0]->EndPointDescriptor);
105 DPRINT("--->TransferFlags %x\n", Urb->UrbBulkOrInterruptTransfer.TransferFlags);
106 ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
107 RtlZeroMemory(Urb->UrbBulkOrInterruptTransfer.TransferBuffer, Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
108
109 if (UsbDevice == DeviceExtension->UsbDevices[0])
110 {
111 if (Urb->UrbBulkOrInterruptTransfer.TransferFlags & (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK))
112 {
113 LONG i;
114 for (i = 0; i < 8; i++)
115 {
116 if (i == 0){
117 DPRINT("PortStatus %x\n", DeviceExtension->Ports[i].PortStatus);
118 DPRINT("PortChange %x\n", DeviceExtension->Ports[i].PortChange);}
119 if (DeviceExtension->Ports[i].PortChange)
120 {
121 DPRINT1("Inform hub driver that port %d has changed\n", i+1);
122 ((PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] = 1 << ((i + 1) & 7);
123 }
124 }
125 }
126 else
127 {
128 Urb->UrbHeader.Status = USBD_STATUS_INVALID_PARAMETER;
129 Status = STATUS_UNSUCCESSFUL;
130 DPRINT1("Invalid transfer flags for SCE\n");
131 }
132 }
133 else
134 DPRINT1("Interrupt Transfer not for hub\n");
135 break;
136 }
137 case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
138 {
139 DPRINT("Get Status from Device\n");
140 DPRINT("Index : %d\n", Urb->UrbControlGetStatusRequest.Index);
141
142 if (Urb->UrbControlGetStatusRequest.Index == 0)
143 {
144 ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBuffer != NULL);
145 *(PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer = USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE;
146 }
147 else
148 {
149 DPRINT1("Uknown identifier\n");
150 Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
151 Status = STATUS_UNSUCCESSFUL;
152 }
153 break;
154 }
155 case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
156 {
157 switch(Urb->UrbControlDescriptorRequest.DescriptorType)
158 {
159 case USB_DEVICE_DESCRIPTOR_TYPE:
160 {
161 DPRINT1("USB DEVICE DESC\n");
162 if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= sizeof(USB_DEVICE_DESCRIPTOR))
163 {
164 Urb->UrbControlDescriptorRequest.TransferBufferLength = sizeof(USB_DEVICE_DESCRIPTOR);
165 }
166 ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer != NULL);
167 RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
168 &UsbDevice->DeviceDescriptor,
169 Urb->UrbControlDescriptorRequest.TransferBufferLength);
170 break;
171 }
172 case USB_CONFIGURATION_DESCRIPTOR_TYPE:
173 {
174 PUCHAR BufPtr;
175 LONG i, j;
176
177 DPRINT1("USB CONFIG DESC\n");
178
179 if (Urb->UrbControlDescriptorRequest.TransferBufferLength >= UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength)
180 {
181 Urb->UrbControlDescriptorRequest.TransferBufferLength = UsbDevice->ActiveConfig->ConfigurationDescriptor.wTotalLength;
182 }
183 else
184 {
185 DPRINT1("Buffer to small!!!\n");
186 //ASSERT(FALSE);
187 }
188
189 ASSERT(Urb->UrbControlDescriptorRequest.TransferBuffer);
190 BufPtr = (PUCHAR)Urb->UrbControlDescriptorRequest.TransferBuffer;
191
192 /* Copy the Configuration Descriptor */
193 RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->ConfigurationDescriptor, sizeof(USB_CONFIGURATION_DESCRIPTOR));
194 BufPtr += sizeof(USB_CONFIGURATION_DESCRIPTOR);
195 for (i = 0; i < UsbDevice->ActiveConfig->ConfigurationDescriptor.bNumInterfaces; i++)
196 {
197 /* Copy the Interface Descriptor */
198 RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor, sizeof(USB_INTERFACE_DESCRIPTOR));
199 BufPtr += sizeof(USB_INTERFACE_DESCRIPTOR);
200 for (j = 0; j < UsbDevice->ActiveConfig->Interfaces[i]->InterfaceDescriptor.bNumEndpoints; j++)
201 {
202 /* Copy the EndPoint Descriptor */
203 RtlCopyMemory(BufPtr, &UsbDevice->ActiveConfig->Interfaces[i]->EndPoints[j]->EndPointDescriptor, sizeof(USB_ENDPOINT_DESCRIPTOR));
204 BufPtr += sizeof(USB_ENDPOINT_DESCRIPTOR);
205 }
206 }
207
208 break;
209 }
210 case USB_STRING_DESCRIPTOR_TYPE:
211 {
212 DPRINT1("Usb String Descriptor not implemented\n");
213 break;
214 }
215 default:
216 {
217 DPRINT1("Descriptor Type %x not supported!\n", Urb->UrbControlDescriptorRequest.DescriptorType);
218 }
219 }
220 break;
221 }
222 case URB_FUNCTION_SELECT_CONFIGURATION:
223 {
224 PUSBD_INTERFACE_INFORMATION InterfaceInfo;
225 LONG iCount, pCount;
226
227 DPRINT("Selecting Configuration\n");
228 DPRINT("Length %x\n", Urb->UrbHeader.Length);
229 DPRINT("Urb->UrbSelectConfiguration.ConfigurationHandle %x\n",Urb->UrbSelectConfiguration.ConfigurationHandle);
230
231 if (Urb->UrbSelectConfiguration.ConfigurationDescriptor)
232 {
233 DPRINT("ConfigurationDescriptor = %p\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor);
234 DPRINT(" bLength = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bLength);
235 DPRINT(" bDescriptorType = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bDescriptorType);
236 DPRINT(" wTotalLength = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->wTotalLength);
237 DPRINT(" bNumInterfaces = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces);
238 DPRINT(" bConfigurationValue = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bConfigurationValue);
239 DPRINT(" iConfiguration = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->iConfiguration);
240 DPRINT(" bmAttributes = %04x\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->bmAttributes);
241 DPRINT(" MaxPower = %d\n", Urb->UrbSelectConfiguration.ConfigurationDescriptor->MaxPower);
242
243
244 Urb->UrbSelectConfiguration.ConfigurationHandle = (PVOID)&DeviceExtension->UsbDevices[0]->ActiveConfig->ConfigurationDescriptor;
245 DPRINT("ConfigHandle %x\n", Urb->UrbSelectConfiguration.ConfigurationHandle);
246 InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
247
248 for (iCount = 0; iCount < Urb->UrbSelectConfiguration.ConfigurationDescriptor->bNumInterfaces; iCount++)
249 {
250 DPRINT("InterfaceInformation[%d]\n", iCount);
251 DPRINT(" Length = %d\n", InterfaceInfo->Length);
252 DPRINT(" InterfaceNumber = %d\n", InterfaceInfo->InterfaceNumber);
253 DPRINT(" AlternateSetting = %d\n", InterfaceInfo->AlternateSetting);
254 DPRINT(" Class = %02x\n", (ULONG)InterfaceInfo->Class);
255 DPRINT(" SubClass = %02x\n", (ULONG)InterfaceInfo->SubClass);
256 DPRINT(" Protocol = %02x\n", (ULONG)InterfaceInfo->Protocol);
257 DPRINT(" Reserved = %02x\n", (ULONG)InterfaceInfo->Reserved);
258 DPRINT(" InterfaceHandle = %p\n", InterfaceInfo->InterfaceHandle);
259 DPRINT(" NumberOfPipes = %d\n", InterfaceInfo->NumberOfPipes);
260 InterfaceInfo->InterfaceHandle = (PVOID)&UsbDevice->ActiveInterface->InterfaceDescriptor;
261 InterfaceInfo->Class = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceClass;
262 InterfaceInfo->SubClass = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceSubClass;
263 InterfaceInfo->Protocol = UsbDevice->ActiveInterface->InterfaceDescriptor.bInterfaceProtocol;
264 InterfaceInfo->Reserved = 0;
265
266 for (pCount = 0; pCount < InterfaceInfo->NumberOfPipes; pCount++)
267 {
268 DPRINT("Pipe[%d]\n", pCount);
269 DPRINT(" MaximumPacketSize = %d\n", InterfaceInfo->Pipes[pCount].MaximumPacketSize);
270 DPRINT(" EndpointAddress = %d\n", InterfaceInfo->Pipes[pCount].EndpointAddress);
271 DPRINT(" Interval = %d\n", InterfaceInfo->Pipes[pCount].Interval);
272 DPRINT(" PipeType = %d\n", InterfaceInfo->Pipes[pCount].PipeType);
273 DPRINT(" PipeHandle = %x\n", InterfaceInfo->Pipes[pCount].PipeHandle);
274 DPRINT(" MaximumTransferSize = %d\n", InterfaceInfo->Pipes[pCount].MaximumTransferSize);
275 DPRINT(" PipeFlags = %08x\n", InterfaceInfo->Pipes[pCount].PipeFlags);
276 InterfaceInfo->Pipes[pCount].MaximumPacketSize = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.wMaxPacketSize;
277 InterfaceInfo->Pipes[pCount].EndpointAddress = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bEndpointAddress;
278 InterfaceInfo->Pipes[pCount].Interval = UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor.bInterval;
279 InterfaceInfo->Pipes[pCount].PipeType = UsbdPipeTypeInterrupt;
280 InterfaceInfo->Pipes[pCount].PipeHandle = (PVOID)&UsbDevice->ActiveInterface->EndPoints[pCount]->EndPointDescriptor;
281 if (InterfaceInfo->Pipes[pCount].MaximumTransferSize == 0)
282 InterfaceInfo->Pipes[pCount].MaximumTransferSize = 4096;
283 /* InterfaceInfo->Pipes[j].PipeFlags = 0; */
284 }
285 InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)((PUCHAR)InterfaceInfo + InterfaceInfo->Length);
286 }
287 }
288 else
289 {
290 /* FIXME: Set device to unconfigured state */
291 }
292 break;
293 }
294 case URB_FUNCTION_CLASS_DEVICE:
295 {
296 switch (Urb->UrbControlVendorClassRequest.Request)
297 {
298 case USB_REQUEST_GET_DESCRIPTOR:
299 {
300 DPRINT1("TransferFlags %x\n", Urb->UrbControlVendorClassRequest.TransferFlags);
301 DPRINT1("Urb->UrbControlVendorClassRequest.Value %x\n", Urb->UrbControlVendorClassRequest.Value);
302
303 switch (Urb->UrbControlVendorClassRequest.Value >> 8)
304 {
305 case USB_DEVICE_CLASS_AUDIO:
306 {
307 DPRINT1("USB_DEVICE_CLASS_AUDIO\n");
308 break;
309 }
310 case USB_DEVICE_CLASS_COMMUNICATIONS:
311 {
312 DPRINT1("USB_DEVICE_CLASS_COMMUNICATIONS\n");
313 break;
314 }
315 case USB_DEVICE_CLASS_HUMAN_INTERFACE:
316 {
317 DPRINT1("USB_DEVICE_CLASS_HUMAN_INTERFACE\n");
318 break;
319 }
320 case USB_DEVICE_CLASS_MONITOR:
321 {
322 DPRINT1("USB_DEVICE_CLASS_MONITOR\n");
323 break;
324 }
325 case USB_DEVICE_CLASS_PHYSICAL_INTERFACE:
326 {
327 DPRINT1("USB_DEVICE_CLASS_PHYSICAL_INTERFACE\n");
328 break;
329 }
330 case USB_DEVICE_CLASS_POWER:
331 {
332 DPRINT1("USB_DEVICE_CLASS_POWER\n");
333 break;
334 }
335 case USB_DEVICE_CLASS_PRINTER:
336 {
337 DPRINT1("USB_DEVICE_CLASS_PRINTER\n");
338 break;
339 }
340 case USB_DEVICE_CLASS_STORAGE:
341 {
342 DPRINT1("USB_DEVICE_CLASS_STORAGE\n");
343 break;
344 }
345 case USB_DEVICE_CLASS_RESERVED:
346 DPRINT1("Reserved!!!\n");
347 case USB_DEVICE_CLASS_HUB:
348 {
349
350 PUSB_HUB_DESCRIPTOR UsbHubDescr = Urb->UrbControlVendorClassRequest.TransferBuffer;
351 ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
352 /* FIXME: Handle more than root hub? */
353 if(Urb->UrbControlVendorClassRequest.TransferBufferLength >= sizeof(USB_HUB_DESCRIPTOR))
354 {
355 Urb->UrbControlVendorClassRequest.TransferBufferLength = sizeof(USB_HUB_DESCRIPTOR);
356 }
357 else
358 {
359 /* FIXME: Handle this correctly */
360 UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR);
361 UsbHubDescr->bDescriptorType = 0x29;
362 break;
363 }
364 DPRINT1("USB_DEVICE_CLASS_HUB request\n");
365 UsbHubDescr->bDescriptorLength = sizeof(USB_HUB_DESCRIPTOR);
366 UsbHubDescr->bDescriptorType = 0x29;
367 UsbHubDescr->bNumberOfPorts = 0x08;
368 UsbHubDescr->wHubCharacteristics = 0x0012;
369 UsbHubDescr->bPowerOnToPowerGood = 0x01;
370 UsbHubDescr->bHubControlCurrent = 0x00;
371 UsbHubDescr->bRemoveAndPowerMask[0] = 0x00;
372 UsbHubDescr->bRemoveAndPowerMask[1] = 0x00;
373 UsbHubDescr->bRemoveAndPowerMask[2] = 0xff;
374 break;
375 }
376 default:
377 {
378 DPRINT1("Unknown UrbControlVendorClassRequest Value\n");
379 }
380 }
381 break;
382 }
383 case USB_REQUEST_GET_STATUS:
384 {
385 DPRINT1("DEVICE: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
386
387 if (Urb->UrbControlVendorClassRequest.Index == 1)
388 {
389 ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
390 ((PULONG)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = 0;
391 }
392 break;
393 }
394 default:
395 {
396 DPRINT1("Unhandled URB request for class device\n");
397 Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
398 }
399 }
400 break;
401 }
402 case URB_FUNCTION_CLASS_OTHER:
403 {
404 switch (Urb->UrbControlVendorClassRequest.Request)
405 {
406 case USB_REQUEST_GET_STATUS:
407 {
408 DPRINT1("OTHER: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
409 ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer != 0);
410 ((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus;
411 ((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[1] = DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange;
412 break;
413 }
414 case USB_REQUEST_CLEAR_FEATURE:
415 {
416 DPRINT1("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
417 Urb->UrbControlVendorClassRequest.Value);
418 switch (Urb->UrbControlVendorClassRequest.Value)
419 {
420 case C_PORT_CONNECTION:
421 DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_CONNECT;
422 break;
423 case C_PORT_RESET:
424 DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_RESET;
425 break;
426 default:
427 DPRINT1("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
428 break;
429 }
430 break;
431 }
432 case USB_REQUEST_SET_FEATURE:
433 {
434 DPRINT1("USB_REQUEST_SET_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
435 Urb->UrbControlVendorClassRequest.Value);
436
437 switch(Urb->UrbControlVendorClassRequest.Value)
438 {
439 case PORT_RESET:
440 {
441 DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange |= USB_PORT_STATUS_RESET;
442 break;
443 }
444 case PORT_ENABLE:
445 {
446 DPRINT1("Unhandled Set Feature\n");
447 break;
448 }
449 default:
450 {
451 DPRINT1("Unknown Set Feature!\n");
452 break;
453 }
454 }
455 break;
456 }
457 case USB_REQUEST_SET_ADDRESS:
458 {
459 DPRINT1("USB_REQUEST_SET_ADDRESS\n");
460 break;
461 }
462 case USB_REQUEST_GET_DESCRIPTOR:
463 {
464 DPRINT1("USB_REQUEST_GET_DESCRIPTOR\n");
465 break;
466 }
467 case USB_REQUEST_SET_DESCRIPTOR:
468 {
469 DPRINT1("USB_REQUEST_SET_DESCRIPTOR\n");
470 break;
471 }
472 case USB_REQUEST_GET_CONFIGURATION:
473 {
474 DPRINT1("USB_REQUEST_GET_CONFIGURATION\n");
475 break;
476 }
477 case USB_REQUEST_SET_CONFIGURATION:
478 {
479 DPRINT1("USB_REQUEST_SET_CONFIGURATION\n");
480 break;
481 }
482 case USB_REQUEST_GET_INTERFACE:
483 {
484 DPRINT1("USB_REQUEST_GET_INTERFACE\n");
485 break;
486 }
487 case USB_REQUEST_SET_INTERFACE:
488 {
489 DPRINT1("USB_REQUEST_SET_INTERFACE\n");
490 break;
491 }
492 case USB_REQUEST_SYNC_FRAME:
493 {
494 DPRINT1("USB_REQUEST_SYNC_FRAME\n");
495 break;
496 }
497 default:
498 {
499 DPRINT1("Unknown Function Class Unknown request\n");
500 break;
501 }
502 }
503 break;
504 }
505 default:
506 {
507 DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
508 Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
509 }
510
511 }
512
513 Irp->IoStatus.Status = Status;
514 Irp->IoStatus.Information = Information;
515
516 if (Urb->UrbHeader.Status == USBD_STATUS_SUCCESS)
517 {
518 /* Fake a successful Control Transfer */
519 Urb->UrbHeader.Function = 0x08;
520 Urb->UrbHeader.UsbdFlags = 0;
521 }
522
523 KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
524 IoCompleteRequest(Irp, IO_NO_INCREMENT);
525 KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
526
527 if (DeviceExtension->HaltQueue)
528 break;
529 }
530
531 KeReleaseSpinLock(&DeviceExtension->IrpQueueLock, oldIrql);
532 if (!DeviceExtension->HaltQueue)
533 KeSetEvent(&DeviceExtension->QueueDrainedEvent, 0, FALSE);
534 }
535