Source code of Windows XP (NT5)
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.

189 lines
5.5 KiB

  1. /*++
  2. Module Name:
  3. ioctl.c
  4. Abstract:
  5. Handle ioctl for the isoperf driver
  6. Environment:
  7. kernel mode only
  8. Revision History:
  9. 5-4-96 : created
  10. --*/
  11. #define DRIVER
  12. #pragma warning(disable:4214) // bitfield nonstd
  13. #include "wdm.h"
  14. #pragma warning(default:4214)
  15. #include "stdarg.h"
  16. #include "stdio.h"
  17. #include "devioctl.h"
  18. #pragma warning(disable:4200) //non std struct used
  19. #include "usbdi.h"
  20. #pragma warning(default:4200)
  21. #include "usbdlib.h"
  22. #include "usb.h"
  23. #include "ioctl.h"
  24. #include "isoperf.h"
  25. #include "iso.h"
  26. NTSTATUS
  27. ISOPERF_ProcessIOCTL(
  28. IN PDEVICE_OBJECT DeviceObject,
  29. IN PIRP Irp
  30. )
  31. /*++
  32. Routine Description:
  33. Arguments:
  34. DeviceObject - pointer to the device object for this instance of the 82930
  35. devcice.
  36. Return Value:
  37. NT status code
  38. --*/
  39. {
  40. PIO_STACK_LOCATION irpStack;
  41. PVOID ioBuffer;
  42. ULONG inputBufferLength;
  43. ULONG outputBufferLength;
  44. PDEVICE_EXTENSION deviceExtension;
  45. ULONG ioControlCode;
  46. NTSTATUS ntStatus = STATUS_SUCCESS;
  47. ISOPERF_KdPrint_MAXDEBUG (("In ISOPERF_ProcessIoctl (DObj: %x, Irp: %x)\n",DeviceObject, Irp));
  48. // Get a pointer to the current location in the Irp. This is where
  49. // the function codes and parameters are located.
  50. irpStack = IoGetCurrentIrpStackLocation (Irp);
  51. Irp->IoStatus.Status = STATUS_SUCCESS;
  52. Irp->IoStatus.Information = 0;
  53. // Get a pointer to the device extension
  54. deviceExtension = DeviceObject->DeviceExtension;
  55. ISO_ASSERT (deviceExtension != NULL);
  56. ioBuffer = Irp->AssociatedIrp.SystemBuffer;
  57. inputBufferLength = irpStack->Parameters.DeviceIoControl.InputBufferLength;
  58. outputBufferLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
  59. ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
  60. ISOPERF_KdPrint_MAXDEBUG (("IRP_MJ_DEVICE_CONTROL\n"));
  61. ISOPERF_KdPrint_MAXDEBUG (("DeviceObj: %X | DeviceExt: %X\n",DeviceObject, DeviceObject->DeviceExtension));
  62. ISOPERF_KdPrint_MAXDEBUG (("IOControlCode: %X\n", ioControlCode));
  63. ISOPERF_KdPrint_MAXDEBUG (("ioBuffer: %x\n",ioBuffer));
  64. ISOPERF_KdPrint_MAXDEBUG (("inputBufferLength: %x\n",inputBufferLength));
  65. ISOPERF_KdPrint_MAXDEBUG (("outputBufferLength: %x\n",outputBufferLength));
  66. //
  67. // Handle Ioctls from User mode
  68. //
  69. switch (ioControlCode) {
  70. case IOCTL_ISOPERF_START_ISO_IN_TEST:
  71. ISOPERF_KdPrint_MAXDEBUG(("ISOPERF_START_ISO_IN_TEST\n"));
  72. if (deviceExtension->Stopped == FALSE) {
  73. //Iso test routine will set the .information field in the irp
  74. //Iso test routine will not complete the Irp, so this should do it
  75. ntStatus = ISOPERF_StartIsoInTest (DeviceObject, Irp);
  76. // We stomp on the status so the Irp that is doing the Ioctl succeeds.
  77. // NOTE (kjaff) we may want to put some status here to tell app if ioctl
  78. // didn't start the test properly.
  79. Irp->IoStatus.Status = ntStatus = STATUS_SUCCESS;
  80. Irp->IoStatus.Information = 0;
  81. }//if device is not stopped
  82. break;
  83. case IOCTL_ISOPERF_STOP_ISO_IN_TEST:
  84. ISOPERF_KdPrint_MAXDEBUG(("ISOPERF_STOP_ISO_IN_TEST\n"));
  85. ntStatus = ISOPERF_StopIsoInTest (DeviceObject, Irp);
  86. // We stomp on the status so the Irp that is doing the Ioctl succeeds.
  87. // NOTE (kjaff) we may want to put some status here to tell app if ioctl
  88. // didn't start the test properly.
  89. Irp->IoStatus.Status = ntStatus = STATUS_SUCCESS;
  90. Irp->IoStatus.Information = 0;
  91. break;
  92. case IOCTL_ISOPERF_GET_ISO_IN_STATS:
  93. if ((ioBuffer!=NULL) && (outputBufferLength>0)) {
  94. // GetStats function fills in the Irp Information field (nbr of bytes to copy)
  95. ntStatus = ISOPERF_GetStats (DeviceObject, Irp, ioBuffer, outputBufferLength);
  96. Irp->IoStatus.Status = ntStatus;
  97. }else{
  98. Irp->IoStatus.Status = ntStatus = STATUS_INVALID_PARAMETER;
  99. Irp->IoStatus.Information = 0;
  100. }
  101. break;
  102. case IOCTL_ISOPERF_SET_DRIVER_CONFIG:
  103. ISOPERF_KdPrint_MAXDEBUG(("IOCTL_ISOPERF_SET_DRIVER_CONFIG\n"));
  104. if ((ioBuffer!=NULL) && (inputBufferLength>0)) {
  105. // SetDriverConfig function fills in the Irp Information field (nbr of bytes to copy)
  106. ntStatus = ISOPERF_SetDriverConfig (DeviceObject, Irp, ioBuffer, inputBufferLength);
  107. Irp->IoStatus.Status = ntStatus;
  108. }else{
  109. Irp->IoStatus.Status = ntStatus = STATUS_INVALID_PARAMETER;
  110. Irp->IoStatus.Information = 0;
  111. }
  112. break;
  113. case IOCTL_ISOPERF_WAIT_FOR_ERROR:
  114. Irp->IoStatus.Status = STATUS_SUCCESS;
  115. Irp->IoStatus.Information = 0;
  116. break;
  117. default:
  118. Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
  119. }
  120. ntStatus = Irp->IoStatus.Status;
  121. ISOPERF_KdPrint_MAXDEBUG (("Compltng Irp w/ IoStatus.Status=%X | .Inf = %X | ntSt=%X\n",
  122. Irp->IoStatus.Status, Irp->IoStatus.Information, ntStatus));
  123. IoCompleteRequest (Irp,
  124. IO_NO_INCREMENT
  125. );
  126. return ntStatus;
  127. }