Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

827 lines
23 KiB

  1. /*++
  2. Copyright (c) 1996-1998 Microsoft Corporation
  3. Module Name:
  4. IOCTL.C
  5. Abstract:
  6. This source file contains the dispatch routine which handles:
  7. IRP_MJ_DEVICE_CONTROL
  8. Environment:
  9. kernel mode
  10. Revision History:
  11. 06-01-98 : started rewrite
  12. --*/
  13. //*****************************************************************************
  14. // I N C L U D E S
  15. //*****************************************************************************
  16. #include <wdm.h>
  17. #include <usbdi.h>
  18. #include <usbdlib.h>
  19. #include "i82930.h"
  20. #include "ioctl.h"
  21. #ifdef ALLOC_PRAGMA
  22. #pragma alloc_text(PAGE, I82930_DeviceControl)
  23. #pragma alloc_text(PAGE, I82930_IoctlGetDeviceDescriptor)
  24. #pragma alloc_text(PAGE, I82930_IoctlGetConfigDescriptor)
  25. #pragma alloc_text(PAGE, I82930_IoctlSetConfigDescriptor)
  26. #pragma alloc_text(PAGE, I82930_ValidateConfigurationDescriptor)
  27. #pragma alloc_text(PAGE, I82930_IoctlGetPipeInformation)
  28. #pragma alloc_text(PAGE, I82930_IoctlResetPipe)
  29. #endif
  30. //******************************************************************************
  31. //
  32. // I82930_DeviceControl()
  33. //
  34. // Dispatch routine which handles IRP_MJ_DEVICE_CONTROL
  35. //
  36. //******************************************************************************
  37. NTSTATUS
  38. I82930_DeviceControl (
  39. IN PDEVICE_OBJECT DeviceObject,
  40. IN PIRP Irp
  41. )
  42. {
  43. PDEVICE_EXTENSION deviceExtension;
  44. PIO_STACK_LOCATION irpStack;
  45. ULONG ioControlCode;
  46. NTSTATUS ntStatus;
  47. DBGPRINT(2, ("enter: I82930_DeviceControl\n"));
  48. LOGENTRY('IOCT', DeviceObject, Irp, 0);
  49. DBGFBRK(DBGF_BRK_IOCTL);
  50. deviceExtension = DeviceObject->DeviceExtension;
  51. if (deviceExtension->AcceptingRequests)
  52. {
  53. irpStack = IoGetCurrentIrpStackLocation(Irp);
  54. ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
  55. switch (ioControlCode)
  56. {
  57. case IOCTL_I82930_GET_DEVICE_DESCRIPTOR:
  58. ntStatus = I82930_IoctlGetDeviceDescriptor(DeviceObject,
  59. Irp);
  60. break;
  61. case IOCTL_I82930_GET_CONFIG_DESCRIPTOR:
  62. ntStatus = I82930_IoctlGetConfigDescriptor(DeviceObject,
  63. Irp);
  64. break;
  65. case IOCTL_I82930_SET_CONFIG_DESCRIPTOR:
  66. ntStatus = I82930_IoctlSetConfigDescriptor(DeviceObject,
  67. Irp);
  68. break;
  69. case IOCTL_I82930_GET_PIPE_INFORMATION:
  70. ntStatus = I82930_IoctlGetPipeInformation(DeviceObject,
  71. Irp);
  72. break;
  73. case IOCTL_I82930_RESET_PIPE:
  74. ntStatus = I82930_IoctlResetPipe(DeviceObject,
  75. Irp);
  76. break;
  77. case IOCTL_I82930_STALL_PIPE:
  78. ntStatus = I82930_IoctlStallPipe(DeviceObject,
  79. Irp);
  80. break;
  81. case IOCTL_I82930_ABORT_PIPE:
  82. ntStatus = I82930_IoctlAbortPipe(DeviceObject,
  83. Irp);
  84. break;
  85. case IOCTL_I82930_RESET_DEVICE:
  86. ntStatus = I82930_IoctlResetDevice(DeviceObject,
  87. Irp);
  88. break;
  89. case IOCTL_I82930_SELECT_ALTERNATE_INTERFACE:
  90. ntStatus = I82930_IoctlSelectAlternateInterface(DeviceObject,
  91. Irp);
  92. break;
  93. default:
  94. ntStatus = STATUS_INVALID_PARAMETER;
  95. Irp->IoStatus.Status = ntStatus;
  96. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  97. break;
  98. }
  99. }
  100. else
  101. {
  102. ntStatus = STATUS_DELETE_PENDING;
  103. Irp->IoStatus.Status = ntStatus;
  104. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  105. }
  106. DBGPRINT(2, ("exit: I82930_DeviceControl %08X\n", ntStatus));
  107. LOGENTRY('ioct', ntStatus, 0, 0);
  108. return ntStatus;
  109. }
  110. //******************************************************************************
  111. //
  112. // I82930_IoctlGetDeviceDescriptor()
  113. //
  114. // This routine handles IRP_MJ_DEVICE_CONTROL,
  115. // IOCTL_I82930_GET_DEVICE_DESCRIPTOR
  116. //
  117. //******************************************************************************
  118. NTSTATUS
  119. I82930_IoctlGetDeviceDescriptor (
  120. IN PDEVICE_OBJECT DeviceObject,
  121. IN PIRP Irp
  122. )
  123. {
  124. PDEVICE_EXTENSION deviceExtension;
  125. PIO_STACK_LOCATION irpStack;
  126. PVOID dest;
  127. ULONG destLength;
  128. PVOID src;
  129. ULONG srcLength;
  130. ULONG copyLength;
  131. NTSTATUS ntStatus;
  132. DBGPRINT(2, ("enter: I82930_IoctlGetDeviceDescriptor\n"));
  133. deviceExtension = DeviceObject->DeviceExtension;
  134. irpStack = IoGetCurrentIrpStackLocation(Irp);
  135. dest = Irp->AssociatedIrp.SystemBuffer;
  136. destLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
  137. src = deviceExtension->DeviceDescriptor;
  138. srcLength = sizeof(USB_DEVICE_DESCRIPTOR);
  139. copyLength = (destLength < srcLength) ? destLength : srcLength;
  140. RtlCopyMemory(dest, src, copyLength);
  141. ntStatus = STATUS_SUCCESS;
  142. Irp->IoStatus.Status = ntStatus;
  143. Irp->IoStatus.Information = copyLength;
  144. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  145. DBGPRINT(2, ("exit: I82930_IoctlGetDeviceDescriptor %08X\n", ntStatus));
  146. return ntStatus;
  147. }
  148. //******************************************************************************
  149. //
  150. // I82930_IoctlGetConfigDescriptor()
  151. //
  152. // This routine handles IRP_MJ_DEVICE_CONTROL,
  153. // IOCTL_I82930_GET_CONFIG_DESCRIPTOR
  154. //
  155. //******************************************************************************
  156. NTSTATUS
  157. I82930_IoctlGetConfigDescriptor (
  158. IN PDEVICE_OBJECT DeviceObject,
  159. IN PIRP Irp
  160. )
  161. {
  162. PDEVICE_EXTENSION deviceExtension;
  163. PIO_STACK_LOCATION irpStack;
  164. PVOID dest;
  165. ULONG destLength;
  166. PVOID src;
  167. ULONG srcLength;
  168. ULONG copyLength;
  169. NTSTATUS ntStatus;
  170. DBGPRINT(2, ("enter: I82930_IoctlGetConfigDescriptor\n"));
  171. deviceExtension = DeviceObject->DeviceExtension;
  172. irpStack = IoGetCurrentIrpStackLocation(Irp);
  173. dest = Irp->AssociatedIrp.SystemBuffer;
  174. destLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
  175. src = deviceExtension->ConfigurationDescriptor;
  176. srcLength = deviceExtension->ConfigurationDescriptor->wTotalLength;
  177. copyLength = (destLength < srcLength) ? destLength : srcLength;
  178. RtlCopyMemory(dest, src, copyLength);
  179. ntStatus = STATUS_SUCCESS;
  180. Irp->IoStatus.Status = ntStatus;
  181. Irp->IoStatus.Information = copyLength;
  182. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  183. DBGPRINT(2, ("exit: I82930_IoctlGetConfigDescriptor %08X\n", ntStatus));
  184. return ntStatus;
  185. }
  186. //******************************************************************************
  187. //
  188. // I82930_IoctlSetConfigDescriptor()
  189. //
  190. // This routine handles IRP_MJ_DEVICE_CONTROL,
  191. // IOCTL_I82930_SET_CONFIG_DESCRIPTOR
  192. //
  193. //******************************************************************************
  194. NTSTATUS
  195. I82930_IoctlSetConfigDescriptor (
  196. IN PDEVICE_OBJECT DeviceObject,
  197. IN PIRP Irp
  198. )
  199. {
  200. PDEVICE_EXTENSION deviceExtension;
  201. PIO_STACK_LOCATION irpStack;
  202. PUSB_CONFIGURATION_DESCRIPTOR configDesc;
  203. PUSB_CONFIGURATION_DESCRIPTOR configDescCopy;
  204. ULONG length;
  205. NTSTATUS ntStatus;
  206. DBGPRINT(2, ("enter: I82930_IoctlSetConfigDescriptor\n"));
  207. ntStatus = STATUS_SUCCESS;
  208. deviceExtension = DeviceObject->DeviceExtension;
  209. irpStack = IoGetCurrentIrpStackLocation(Irp);
  210. configDesc = (PUSB_CONFIGURATION_DESCRIPTOR)Irp->AssociatedIrp.SystemBuffer;
  211. length = irpStack->Parameters.DeviceIoControl.InputBufferLength;
  212. if (!I82930_ValidateConfigurationDescriptor(configDesc, length))
  213. {
  214. ntStatus = STATUS_INVALID_PARAMETER;
  215. }
  216. if (NT_SUCCESS(ntStatus))
  217. {
  218. configDescCopy = ExAllocatePool(NonPagedPool, length);
  219. if (configDescCopy != NULL)
  220. {
  221. RtlCopyMemory(configDescCopy, configDesc, length);
  222. }
  223. else
  224. {
  225. ntStatus = STATUS_INSUFFICIENT_RESOURCES;
  226. }
  227. }
  228. if (NT_SUCCESS(ntStatus))
  229. {
  230. ntStatus = I82930_UnConfigure(DeviceObject);
  231. }
  232. if (NT_SUCCESS(ntStatus))
  233. {
  234. ASSERT(deviceExtension->ConfigurationDescriptor != NULL);
  235. ExFreePool(deviceExtension->ConfigurationDescriptor);
  236. deviceExtension->ConfigurationDescriptor = configDescCopy;
  237. ntStatus = I82930_SelectConfiguration(DeviceObject);
  238. }
  239. Irp->IoStatus.Status = ntStatus;
  240. Irp->IoStatus.Information = 0;
  241. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  242. DBGPRINT(2, ("exit: I82930_IoctlSetConfigDescriptor %08X\n", ntStatus));
  243. return ntStatus;
  244. }
  245. //******************************************************************************
  246. //
  247. // I82930_ValidateConfigurationDescriptor()
  248. //
  249. // This routine verifies that a Configuration Descriptor is valid.
  250. //
  251. //******************************************************************************
  252. BOOLEAN
  253. I82930_ValidateConfigurationDescriptor (
  254. IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc,
  255. IN ULONG Length
  256. )
  257. {
  258. PUCHAR descEnd;
  259. PUSB_COMMON_DESCRIPTOR commonDesc;
  260. PUSB_INTERFACE_DESCRIPTOR interfaceDesc;
  261. UCHAR numInterfaces;
  262. UCHAR numEndpoints;
  263. PAGED_CODE();
  264. //
  265. // Validate the Configuration Descriptor header
  266. //
  267. if (Length < sizeof(USB_CONFIGURATION_DESCRIPTOR))
  268. {
  269. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad Length\n"));
  270. return FALSE;
  271. }
  272. if (ConfigDesc->bLength != sizeof(USB_CONFIGURATION_DESCRIPTOR))
  273. {
  274. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad bLength\n"));
  275. return FALSE;
  276. }
  277. if (ConfigDesc->bDescriptorType != USB_CONFIGURATION_DESCRIPTOR_TYPE)
  278. {
  279. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad bDescriptorType\n"));
  280. return FALSE;
  281. }
  282. if (ConfigDesc->wTotalLength != Length)
  283. {
  284. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: wTotalLength != Length\n"));
  285. return FALSE;
  286. }
  287. //
  288. // End of descriptor pointer, one byte past the last valid byte.
  289. //
  290. descEnd = (PUCHAR)ConfigDesc + ConfigDesc->wTotalLength;
  291. //
  292. // Start at first descriptor past the Configuration Descriptor header
  293. //
  294. commonDesc = (PUSB_COMMON_DESCRIPTOR)((PUCHAR)ConfigDesc +
  295. sizeof(USB_CONFIGURATION_DESCRIPTOR));
  296. interfaceDesc = NULL;
  297. numInterfaces = 0;
  298. while ((PUCHAR)commonDesc + sizeof(USB_COMMON_DESCRIPTOR) < descEnd &&
  299. (PUCHAR)commonDesc + commonDesc->bLength <= descEnd)
  300. {
  301. // Is this an Interface Descriptor?
  302. //
  303. if ((commonDesc->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE) &&
  304. (commonDesc->bLength == sizeof(USB_INTERFACE_DESCRIPTOR)))
  305. {
  306. if ((interfaceDesc == NULL) ||
  307. (interfaceDesc->bInterfaceNumber !=
  308. ((PUSB_INTERFACE_DESCRIPTOR)commonDesc)->bInterfaceNumber))
  309. {
  310. // One more Interface Descriptor for this Configuration Descriptor
  311. //
  312. numInterfaces++;
  313. }
  314. // If there was a previous Interface Descriptor, verify that there
  315. // were the correct number of Endpoint Descriptors
  316. //
  317. if ((interfaceDesc != NULL) &&
  318. (numEndpoints != interfaceDesc->bNumEndpoints))
  319. {
  320. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad bNumEndpoints\n"));
  321. return FALSE;
  322. }
  323. // Remember the current Interface Descriptor
  324. //
  325. interfaceDesc = (PUSB_INTERFACE_DESCRIPTOR)commonDesc;
  326. // Reset the Endpoint Descriptor count for this Interface Descriptor
  327. //
  328. numEndpoints = 0;
  329. }
  330. // Is this an Endpoint Descriptor?
  331. //
  332. else if ((commonDesc->bDescriptorType == USB_ENDPOINT_DESCRIPTOR_TYPE) &&
  333. (commonDesc->bLength == sizeof(USB_ENDPOINT_DESCRIPTOR)))
  334. {
  335. // One more Endpoint Descriptor for this Interface Descriptor
  336. //
  337. numEndpoints++;
  338. }
  339. else
  340. {
  341. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad bDescriptorType and/or bLength\n"));
  342. return FALSE;
  343. }
  344. // Advance past this descriptor
  345. //
  346. (PUCHAR)commonDesc += commonDesc->bLength;
  347. }
  348. if ((PUCHAR)commonDesc != descEnd)
  349. {
  350. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad final descriptor\n"));
  351. return FALSE;
  352. }
  353. if (numInterfaces != ConfigDesc->bNumInterfaces)
  354. {
  355. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad bNumInterfaces and/or bLength\n"));
  356. }
  357. // If there was a previous Interface Descriptor, verify that there
  358. // were the correct number of Endpoint Descriptors
  359. //
  360. if ((interfaceDesc != NULL) &&
  361. (numEndpoints != interfaceDesc->bNumEndpoints))
  362. {
  363. DBGPRINT(0, ("I82930_ValidateConfigurationDescriptor: Bad bNumEndpoints\n"));
  364. return FALSE;
  365. }
  366. return TRUE;
  367. }
  368. //******************************************************************************
  369. //
  370. // I82930_IoctlGetPipeInformation()
  371. //
  372. // This routine handles IRP_MJ_DEVICE_CONTROL,
  373. // IOCTL_I82930_GET_PIPE_INFORMATION
  374. //
  375. //******************************************************************************
  376. NTSTATUS
  377. I82930_IoctlGetPipeInformation (
  378. IN PDEVICE_OBJECT DeviceObject,
  379. IN PIRP Irp
  380. )
  381. {
  382. PDEVICE_EXTENSION deviceExtension;
  383. PIO_STACK_LOCATION irpStack;
  384. PVOID dest;
  385. ULONG destLength;
  386. PVOID src;
  387. ULONG srcLength;
  388. ULONG copyLength;
  389. NTSTATUS ntStatus;
  390. DBGPRINT(2, ("enter: I82930_IoctlGetPipeInformation\n"));
  391. deviceExtension = DeviceObject->DeviceExtension;
  392. if (deviceExtension->InterfaceInfo != NULL)
  393. {
  394. irpStack = IoGetCurrentIrpStackLocation(Irp);
  395. dest = Irp->AssociatedIrp.SystemBuffer;
  396. destLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
  397. src = deviceExtension->InterfaceInfo;
  398. srcLength = deviceExtension->InterfaceInfo->Length;
  399. copyLength = (destLength < srcLength) ? destLength : srcLength;
  400. RtlCopyMemory(dest, src, copyLength);
  401. ntStatus = STATUS_SUCCESS;
  402. }
  403. else
  404. {
  405. copyLength = 0;
  406. ntStatus = STATUS_INSUFFICIENT_RESOURCES;
  407. }
  408. Irp->IoStatus.Status = ntStatus;
  409. Irp->IoStatus.Information = copyLength;
  410. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  411. DBGPRINT(2, ("exit: I82930_IoctlGetPipeInformation %08X\n", ntStatus));
  412. return ntStatus;
  413. }
  414. //******************************************************************************
  415. //
  416. // I82930_IoctlResetPipe()
  417. //
  418. // This routine handles IRP_MJ_DEVICE_CONTROL,
  419. // IOCTL_I82930_RESET_PIPE
  420. //
  421. //******************************************************************************
  422. NTSTATUS
  423. I82930_IoctlResetPipe (
  424. IN PDEVICE_OBJECT DeviceObject,
  425. IN PIRP Irp
  426. )
  427. {
  428. PDEVICE_EXTENSION deviceExtension;
  429. PIO_STACK_LOCATION irpStack;
  430. PFILE_OBJECT fileObject;
  431. PI82930_PIPE pipe;
  432. NTSTATUS ntStatus;
  433. DBGPRINT(2, ("enter: I82930_IoctlResetPipe\n"));
  434. deviceExtension = DeviceObject->DeviceExtension;
  435. irpStack = IoGetCurrentIrpStackLocation(Irp);
  436. fileObject = irpStack->FileObject;
  437. pipe = fileObject->FsContext;
  438. if (pipe != NULL)
  439. {
  440. DBGPRINT(2, ("Reset pipe %2d %08X\n",
  441. pipe->PipeIndex, pipe));
  442. ntStatus = I82930_ResetPipe(DeviceObject,
  443. pipe,
  444. TRUE);
  445. }
  446. else
  447. {
  448. ntStatus = STATUS_INVALID_PARAMETER;
  449. }
  450. Irp->IoStatus.Status = ntStatus;
  451. Irp->IoStatus.Information = 0;
  452. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  453. DBGPRINT(2, ("exit: I82930_IoctlResetPipe %08X\n", ntStatus));
  454. return ntStatus;
  455. }
  456. //******************************************************************************
  457. //
  458. // I82930_IoctlStallPipe()
  459. //
  460. // This routine handles IRP_MJ_DEVICE_CONTROL,
  461. // IOCTL_I82930_STALL_PIPE
  462. //
  463. //******************************************************************************
  464. NTSTATUS
  465. I82930_IoctlStallPipe (
  466. IN PDEVICE_OBJECT DeviceObject,
  467. IN PIRP Irp
  468. )
  469. {
  470. PDEVICE_EXTENSION deviceExtension;
  471. PIO_STACK_LOCATION irpStack;
  472. PFILE_OBJECT fileObject;
  473. PI82930_PIPE pipe;
  474. PURB urb;
  475. NTSTATUS ntStatus;
  476. DBGPRINT(2, ("enter: I82930_IoctlStallPipe\n"));
  477. deviceExtension = DeviceObject->DeviceExtension;
  478. irpStack = IoGetCurrentIrpStackLocation(Irp);
  479. fileObject = irpStack->FileObject;
  480. pipe = fileObject->FsContext;
  481. if (pipe != NULL)
  482. {
  483. DBGPRINT(2, ("Stall pipe %2d %08X\n",
  484. pipe->PipeIndex, pipe));
  485. // Allocate URB for CONTROL_FEATURE request
  486. //
  487. urb = ExAllocatePool(NonPagedPool,
  488. sizeof(struct _URB_CONTROL_FEATURE_REQUEST));
  489. if (urb != NULL)
  490. {
  491. // Initialize CONTROL_FEATURE request URB
  492. //
  493. urb->UrbHeader.Length = sizeof (struct _URB_CONTROL_FEATURE_REQUEST);
  494. urb->UrbHeader.Function = URB_FUNCTION_SET_FEATURE_TO_ENDPOINT;
  495. urb->UrbControlFeatureRequest.UrbLink = NULL;
  496. urb->UrbControlFeatureRequest.FeatureSelector = USB_FEATURE_ENDPOINT_STALL;
  497. urb->UrbControlFeatureRequest.Index = pipe->PipeInfo->EndpointAddress;
  498. // Submit CONTROL_FEATURE request URB
  499. //
  500. ntStatus = I82930_SyncSendUsbRequest(DeviceObject, urb);
  501. // Done with URB for CONTROL_FEATURE request, free it
  502. //
  503. ExFreePool(urb);
  504. }
  505. else
  506. {
  507. ntStatus = STATUS_INSUFFICIENT_RESOURCES;
  508. }
  509. }
  510. else
  511. {
  512. ntStatus = STATUS_INVALID_PARAMETER;
  513. }
  514. Irp->IoStatus.Status = ntStatus;
  515. Irp->IoStatus.Information = 0;
  516. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  517. DBGPRINT(2, ("exit: I82930_IoctlStallPipe %08X\n", ntStatus));
  518. return ntStatus;
  519. }
  520. //******************************************************************************
  521. //
  522. // I82930_IoctlAbortPipe()
  523. //
  524. // This routine handles IRP_MJ_DEVICE_CONTROL,
  525. // IOCTL_I82930_ABORT_PIPE
  526. //
  527. //******************************************************************************
  528. NTSTATUS
  529. I82930_IoctlAbortPipe (
  530. IN PDEVICE_OBJECT DeviceObject,
  531. IN PIRP Irp
  532. )
  533. {
  534. PDEVICE_EXTENSION deviceExtension;
  535. PIO_STACK_LOCATION irpStack;
  536. PFILE_OBJECT fileObject;
  537. PI82930_PIPE pipe;
  538. NTSTATUS ntStatus;
  539. DBGPRINT(2, ("enter: I82930_IoctlAbortPipe\n"));
  540. deviceExtension = DeviceObject->DeviceExtension;
  541. irpStack = IoGetCurrentIrpStackLocation(Irp);
  542. fileObject = irpStack->FileObject;
  543. pipe = fileObject->FsContext;
  544. if (pipe != NULL)
  545. {
  546. DBGPRINT(2, ("Abort pipe %2d %08X\n",
  547. pipe->PipeIndex, pipe));
  548. ntStatus = I82930_AbortPipe(DeviceObject,
  549. pipe);
  550. }
  551. else
  552. {
  553. ntStatus = STATUS_INVALID_PARAMETER;
  554. }
  555. Irp->IoStatus.Status = ntStatus;
  556. Irp->IoStatus.Information = 0;
  557. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  558. DBGPRINT(2, ("exit: I82930_IoctlAbortPipe %08X\n", ntStatus));
  559. return ntStatus;
  560. }
  561. //******************************************************************************
  562. //
  563. // I82930_IoctlResetDevice()
  564. //
  565. // This routine handles IRP_MJ_DEVICE_CONTROL,
  566. // IOCTL_I82930_RESET_DEVICE
  567. //
  568. //******************************************************************************
  569. NTSTATUS
  570. I82930_IoctlResetDevice (
  571. IN PDEVICE_OBJECT DeviceObject,
  572. IN PIRP Irp
  573. )
  574. {
  575. PDEVICE_EXTENSION deviceExtension;
  576. PIO_STACK_LOCATION nextStack;
  577. NTSTATUS ntStatus;
  578. DBGPRINT(2, ("enter: I82930_IoctlResetDevice\n"));
  579. deviceExtension = DeviceObject->DeviceExtension;
  580. // Set the Irp parameters
  581. //
  582. nextStack = IoGetNextIrpStackLocation(Irp);
  583. nextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
  584. nextStack->Parameters.DeviceIoControl.IoControlCode =
  585. IOCTL_INTERNAL_USB_RESET_PORT;
  586. ntStatus = I82930_SyncPassDownIrp(DeviceObject,
  587. Irp,
  588. FALSE);
  589. // Must complete request since completion routine returned
  590. // STATUS_MORE_PROCESSING_REQUIRED
  591. //
  592. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  593. DBGPRINT(2, ("exit: I82930_IoctlResetDevice %08X\n", ntStatus));
  594. return ntStatus;
  595. }
  596. //******************************************************************************
  597. //
  598. // I82930_IoctlSelectAlternateInterface()
  599. //
  600. // This routine handles IRP_MJ_DEVICE_CONTROL,
  601. // IOCTL_I82930_SELECT_ALTERNATE_INTERFACE
  602. //
  603. //******************************************************************************
  604. NTSTATUS
  605. I82930_IoctlSelectAlternateInterface (
  606. IN PDEVICE_OBJECT DeviceObject,
  607. IN PIRP Irp
  608. )
  609. {
  610. PDEVICE_EXTENSION deviceExtension;
  611. PIO_STACK_LOCATION irpStack;
  612. UCHAR alternateSetting;
  613. NTSTATUS ntStatus;
  614. DBGPRINT(2, ("enter: I82930_IoctlSelectAlternateInterface\n"));
  615. deviceExtension = DeviceObject->DeviceExtension;
  616. irpStack = IoGetCurrentIrpStackLocation(Irp);
  617. if (irpStack->Parameters.DeviceIoControl.InputBufferLength == sizeof(UCHAR))
  618. {
  619. alternateSetting = *(PUCHAR)Irp->AssociatedIrp.SystemBuffer;
  620. DBGPRINT(2, ("Select AlternateInterface %d\n",
  621. alternateSetting));
  622. ntStatus = I82930_SelectAlternateInterface(DeviceObject,
  623. alternateSetting);
  624. }
  625. else
  626. {
  627. ntStatus = STATUS_INVALID_PARAMETER;
  628. }
  629. Irp->IoStatus.Status = ntStatus;
  630. Irp->IoStatus.Information = 0;
  631. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  632. DBGPRINT(2, ("exit: I82930_IoctlSelectAlternateInterface %08X\n", ntStatus));
  633. return ntStatus;
  634. }