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.

149 lines
4.5 KiB

  1. /*
  2. *************************************************************************
  3. * File: IOCTL.C
  4. *
  5. * Module: HID1394.SYS
  6. * HID (Human Input Device) minidriver for IEEE 1394 devices.
  7. *
  8. * Copyright (c) 1998 Microsoft Corporation
  9. *
  10. *
  11. * Author: ervinp
  12. *
  13. *************************************************************************
  14. */
  15. #include <wdm.h>
  16. #include <hidport.h>
  17. #include <1394.h>
  18. #include "hid1394.h"
  19. #include "debug.h"
  20. /*
  21. ************************************************************
  22. * HIDT_InternalIoctl
  23. ************************************************************
  24. *
  25. *
  26. * Note: this function cannot be pageable because reads/writes
  27. * can be made at dispatch-level.
  28. *
  29. * Note: this is an INTERNAL IOCTL handler, so no buffer
  30. * validation is required.
  31. */
  32. NTSTATUS HIDT_InternalIoctl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
  33. {
  34. NTSTATUS ntStatus = STATUS_SUCCESS;
  35. PDEVICE_EXTENSION DeviceExtension;
  36. PIO_STACK_LOCATION irpSp;
  37. BOOLEAN NeedsCompletion = TRUE;
  38. irpSp = IoGetCurrentIrpStackLocation(Irp);
  39. DeviceExtension = GET_MINIDRIVER_DEVICE_EXTENSION(DeviceObject);
  40. switch (irpSp->Parameters.DeviceIoControl.IoControlCode){
  41. case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
  42. /*
  43. * This IOCTL uses buffering method METHOD_NEITHER,
  44. * so the buffer is Irp->UserBuffer.
  45. */
  46. ntStatus = HIDT_GetHidDescriptor(DeviceObject, Irp);
  47. break;
  48. case IOCTL_HID_GET_REPORT_DESCRIPTOR:
  49. /*
  50. * This IOCTL uses buffering method METHOD_NEITHER,
  51. * so the buffer is Irp->UserBuffer.
  52. */
  53. ntStatus = HIDT_GetReportDescriptor(DeviceObject, Irp);
  54. break;
  55. case IOCTL_HID_READ_REPORT:
  56. /*
  57. * This IOCTL uses buffering method METHOD_NEITHER,
  58. * so the buffer is Irp->UserBuffer.
  59. */
  60. ntStatus = HIDT_ReadReport(DeviceObject, Irp, &NeedsCompletion);
  61. break;
  62. case IOCTL_HID_WRITE_REPORT:
  63. /*
  64. * This IOCTL uses buffering method METHOD_NEITHER,
  65. * so the buffer is Irp->UserBuffer.
  66. */
  67. ntStatus = HIDT_WriteReport (DeviceObject, Irp, &NeedsCompletion);
  68. break;
  69. case IOCTL_HID_GET_STRING:
  70. /*
  71. * Get the friendly name for the device.
  72. *
  73. * This IOCTL uses buffering method METHOD_NEITHER,
  74. * so the buffer is Irp->UserBuffer.
  75. */
  76. ntStatus = HIDT_GetStringDescriptor(DeviceObject, Irp);
  77. break;
  78. case IOCTL_HID_GET_INDEXED_STRING:
  79. ntStatus = HIDT_GetStringDescriptor(DeviceObject, Irp);
  80. break;
  81. case IOCTL_HID_GET_FEATURE:
  82. ntStatus = HIDT_GetFeature(DeviceObject, Irp, &NeedsCompletion);
  83. break;
  84. case IOCTL_HID_SET_FEATURE:
  85. ntStatus = HIDT_SetFeature(DeviceObject, Irp, &NeedsCompletion);
  86. break;
  87. case IOCTL_HID_ACTIVATE_DEVICE:
  88. case IOCTL_HID_DEACTIVATE_DEVICE:
  89. /*
  90. * We don't do anything for these IOCTLs but some minidrivers might.
  91. */
  92. ntStatus = STATUS_SUCCESS;
  93. break;
  94. case IOCTL_GET_PHYSICAL_DESCRIPTOR:
  95. /*
  96. * This IOCTL gets information related to the human body part used
  97. * to control a device control.
  98. */
  99. ntStatus = HIDT_GetPhysicalDescriptor(DeviceObject, Irp, &NeedsCompletion);
  100. break;
  101. case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
  102. /*
  103. * This IOCTL uses buffering method METHOD_NEITHER,
  104. * so the buffer is Irp->UserBuffer.
  105. * If the IRP is coming to us from user space,
  106. * we must validate the buffer.
  107. */
  108. ntStatus = HIDT_GetDeviceAttributes(DeviceObject, Irp, &NeedsCompletion);
  109. break;
  110. default:
  111. /*
  112. * Note: do not return STATUS_NOT_SUPPORTED;
  113. * Just keep the default status (this allows filter drivers to work).
  114. */
  115. ntStatus = Irp->IoStatus.Status;
  116. break;
  117. }
  118. /*
  119. * Complete the IRP only if we did not pass it to a lower driver.
  120. */
  121. if (NeedsCompletion) {
  122. ASSERT(ntStatus != STATUS_PENDING);
  123. Irp->IoStatus.Status = ntStatus;
  124. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  125. }
  126. return ntStatus;
  127. }