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.

197 lines
4.3 KiB

  1. /*
  2. *************************************************************************
  3. * File: HID1394.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. NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING registryPath)
  21. /*++
  22. Routine Description:
  23. Installable driver initialization entry point.
  24. This entry point is called directly by the I/O system.
  25. Arguments:
  26. DriverObject - pointer to the driver object
  27. registryPath - pointer to a unicode string representing the path,
  28. to driver-specific key in the registry.
  29. Return Value:
  30. STATUS_SUCCESS if successful,
  31. STATUS_UNSUCCESSFUL otherwise
  32. --*/
  33. {
  34. NTSTATUS ntStatus = STATUS_SUCCESS;
  35. HID_MINIDRIVER_REGISTRATION hidMinidriverRegistration;
  36. //
  37. // Create dispatch points
  38. //
  39. DriverObject->MajorFunction[IRP_MJ_CREATE] =
  40. DriverObject->MajorFunction[IRP_MJ_CLOSE] = HIDT_CreateClose;
  41. DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = HIDT_InternalIoctl;
  42. DriverObject->MajorFunction[IRP_MJ_PNP] = HIDT_PnP;
  43. DriverObject->MajorFunction[IRP_MJ_POWER] = HIDT_Power;
  44. DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HIDT_SystemControl;
  45. DriverObject->DriverExtension->AddDevice = HIDT_AddDevice;
  46. DriverObject->DriverUnload = HIDT_Unload;
  47. //
  48. // Register USB layer with HID.SYS module
  49. //
  50. hidMinidriverRegistration.Revision = HID_REVISION;
  51. hidMinidriverRegistration.DriverObject = DriverObject;
  52. hidMinidriverRegistration.RegistryPath = registryPath;
  53. hidMinidriverRegistration.DeviceExtensionSize = sizeof(DEVICE_EXTENSION);
  54. /*
  55. * HIDUSB is a minidriver for USB devices, which do not need to be polled.
  56. */
  57. hidMinidriverRegistration.DevicesArePolled = FALSE;
  58. ntStatus = HidRegisterMinidriver(&hidMinidriverRegistration);
  59. KeInitializeSpinLock(&resetWorkItemsListSpinLock);
  60. return ntStatus;
  61. }
  62. NTSTATUS HIDT_CreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
  63. /*++
  64. Routine Description:
  65. Process the Create and close IRPs sent to this device.
  66. Arguments:
  67. DeviceObject - pointer to a device object.
  68. Irp - pointer to an I/O Request Packet.
  69. Return Value:
  70. NT status code
  71. --*/
  72. {
  73. PIO_STACK_LOCATION IrpStack;
  74. NTSTATUS ntStatus = STATUS_SUCCESS;
  75. DBGBREAK;
  76. //
  77. // Get a pointer to the current location in the Irp.
  78. //
  79. IrpStack = IoGetCurrentIrpStackLocation(Irp);
  80. switch(IrpStack->MajorFunction)
  81. {
  82. case IRP_MJ_CREATE:
  83. Irp->IoStatus.Information = 0;
  84. break;
  85. case IRP_MJ_CLOSE:
  86. Irp->IoStatus.Information = 0;
  87. break;
  88. default:
  89. ntStatus = STATUS_INVALID_PARAMETER;
  90. break;
  91. }
  92. //
  93. // Save Status for return and complete Irp
  94. //
  95. Irp->IoStatus.Status = ntStatus;
  96. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  97. return ntStatus;
  98. }
  99. NTSTATUS HIDT_AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT FunctionalDeviceObject)
  100. /*++
  101. Routine Description:
  102. Process the IRPs sent to this device.
  103. Arguments:
  104. DeviceObject - pointer to a device object.
  105. PhysicalDeviceObject - pointer to a device object pointer created by the bus
  106. Return Value:
  107. NT status code.
  108. --*/
  109. {
  110. NTSTATUS ntStatus = STATUS_SUCCESS;
  111. PDEVICE_OBJECT DeviceObject = NULL;
  112. PDEVICE_EXTENSION deviceExtension;
  113. DeviceObject = FunctionalDeviceObject;
  114. deviceExtension = GET_MINIDRIVER_DEVICE_EXTENSION( DeviceObject );
  115. deviceExtension->DeviceFlags = 0;
  116. deviceExtension->ResetWorkItem = NULL;
  117. return ntStatus;
  118. }
  119. VOID HIDT_Unload(IN PDRIVER_OBJECT DriverObject)
  120. /*++
  121. Routine Description:
  122. Free all the allocated resources, etc.
  123. Arguments:
  124. DriverObject - pointer to a driver object.
  125. Return Value:
  126. VOID.
  127. --*/
  128. {
  129. ASSERT (!DriverObject->DeviceObject);
  130. }