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.

277 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Copyright (c) 1996 Intel Corporation
  4. Module Name:
  5. Sample.h
  6. Abstract:
  7. Header file for the Sample USB Device Driver
  8. Environment:
  9. Kernel & user mode
  10. Revision History:
  11. 8-15-96 : created by Kosar Jaff
  12. --*/
  13. #ifdef DRIVER
  14. #define Sample_NAME_MAX 64
  15. //modes
  16. #define Sample_MODE_USE_POOL 0
  17. #define Sample_MODE_USE_MDL 1
  18. //options
  19. #define Sample_OPT_NONE 0
  20. /*
  21. // This is an unused structure in this driver, but is provided here
  22. // so when you extend the driver to deal with USB pipes, you may wish
  23. // to use this structure as an example or model.
  24. */
  25. typedef struct _Sample_PIPE {
  26. ULONG Mode;
  27. ULONG Option;
  28. ULONG Param1;
  29. ULONG Param2;
  30. PUSBD_PIPE_INFORMATION PipeInfo;
  31. } Sample_PIPE, *PSample_PIPE;
  32. /*
  33. // The interface number on this device that this driver expects to use
  34. // This would be in the bInterfaceNumber field of the Interface Descriptor, hence
  35. // this device driver would need to know this value.
  36. */
  37. #define SAMPLE_INTERFACE_NBR 0x00
  38. // This driver supports only interface
  39. #define MAX_INTERFACE 0x01
  40. //
  41. // A structure representing the instance information associated with
  42. // this particular device.
  43. //
  44. typedef struct _DEVICE_EXTENSION {
  45. // physical device object
  46. PDEVICE_OBJECT PhysicalDeviceObject;
  47. // Device object we call when submitting Urbs/Irps to the USB stack
  48. PDEVICE_OBJECT StackDeviceObject;
  49. // Indicates that we have recieved a STOP message
  50. BOOLEAN Stopped;
  51. // Indicates the device needs to be cleaned up (ie., some configuration
  52. // has occurred and needs to be torn down).
  53. BOOLEAN NeedCleanup;
  54. // configuration handle for the configuration the
  55. // device is currently in
  56. USBD_CONFIGURATION_HANDLE ConfigurationHandle;
  57. // ptr to the USB device descriptor
  58. // for this device
  59. PUSB_DEVICE_DESCRIPTOR DeviceDescriptor;
  60. // we support up to one interface
  61. PUSBD_INTERFACE_INFORMATION Interface;
  62. // Name buffer for our named Functional device object link
  63. WCHAR DeviceLinkNameBuffer[Sample_NAME_MAX];
  64. UCHAR pad[3];
  65. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  66. #if DBG
  67. #define Sample_KdPrint(_x_) DbgPrint("Sample.SYS: "); \
  68. DbgPrint _x_ ;
  69. #define TRAP() DbgBreakPoint()
  70. #else
  71. #define Sample_KdPrint(_x_)
  72. #define TRAP()
  73. #endif
  74. #ifndef max
  75. #define max(a,b) (((a) > (b)) ? (a) : (b))
  76. #endif
  77. NTSTATUS
  78. Sample_Dispatch(
  79. IN PDEVICE_OBJECT DeviceObject,
  80. IN PIRP Irp
  81. );
  82. VOID
  83. Sample_Unload(
  84. IN PDRIVER_OBJECT DriverObject
  85. );
  86. NTSTATUS
  87. Sample_StartDevice(
  88. IN PDEVICE_OBJECT DeviceObject
  89. );
  90. NTSTATUS
  91. Sample_StopDevice(
  92. IN PDEVICE_OBJECT DeviceObject
  93. );
  94. NTSTATUS
  95. Sample_RemoveDevice(
  96. IN PDEVICE_OBJECT DeviceObject
  97. );
  98. NTSTATUS
  99. Sample_CallUSBD(
  100. IN PDEVICE_OBJECT DeviceObject,
  101. IN PURB Urb
  102. );
  103. NTSTATUS
  104. Sample_PnPAddDevice(
  105. IN PDRIVER_OBJECT DriverObject,
  106. IN PDEVICE_OBJECT PhysicalDeviceObject
  107. );
  108. NTSTATUS
  109. Sample_CreateDeviceObject(
  110. IN PDRIVER_OBJECT DriverObject,
  111. IN PDEVICE_OBJECT *DeviceObject,
  112. LONG Instance
  113. );
  114. NTSTATUS
  115. Sample_ConfigureDevice(
  116. IN PDEVICE_OBJECT DeviceObject
  117. );
  118. NTSTATUS
  119. Sample_Create(
  120. IN PDEVICE_OBJECT DeviceObject,
  121. IN PIRP Irp
  122. );
  123. NTSTATUS
  124. Sample_Close(
  125. IN PDEVICE_OBJECT DeviceObject,
  126. IN PIRP Irp
  127. );
  128. NTSTATUS
  129. Sample_Read_Write (
  130. IN PDEVICE_OBJECT DeviceObject,
  131. IN PIRP Irp,
  132. IN BOOLEAN Read
  133. );
  134. NTSTATUS
  135. Sample_ProcessIOCTL(
  136. IN PDEVICE_OBJECT DeviceObject,
  137. IN PIRP Irp
  138. );
  139. NTSTATUS
  140. Sample_SelectInterfaces(
  141. IN PDEVICE_OBJECT DeviceObject,
  142. IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
  143. IN PUSBD_INTERFACE_INFORMATION Interface
  144. );
  145. //PUSB_CONFIGURATION_DESCRIPTOR
  146. //Sample_GetConfigDescriptor(
  147. // IN PDEVICE_OBJECT DeviceObject
  148. // );
  149. VOID
  150. Sample_Cleanup(
  151. PDEVICE_OBJECT DeviceObject
  152. );
  153. ULONG
  154. Sample_GetDeviceDescriptor(
  155. IN PDEVICE_OBJECT DeviceObject,
  156. PVOID pvOutputBuffer
  157. );
  158. ULONG
  159. Sample_GetConfigDescriptor(
  160. IN PDEVICE_OBJECT DeviceObject,
  161. PVOID pvOutputBuffer,
  162. ULONG ulLength
  163. );
  164. #endif //DRIVER section
  165. /*
  166. ///////////////////////////////////////////////////////
  167. //
  168. // IOCTL Definitions
  169. //
  170. // User mode applications wishing to send IOCTLs to a kernel mode driver
  171. // must use this file to set up the correct type of IOCTL code permissions.
  172. //
  173. // Note: this file depends on the file DEVIOCTL.H which contains the macro
  174. // definition for "CTL_CODE" below. Include that file before you include
  175. // this one in your source code.
  176. //
  177. ///////////////////////////////////////////////////////
  178. */
  179. /*
  180. // Set the base of the IOCTL control codes. This is somewhat of an
  181. // arbitrary base number, so you can change this if you want unique
  182. // IOCTL codes. You should consult the Windows NT DDK for valid ranges
  183. // of IOCTL index codes before you choose a base index number.
  184. */
  185. #define Sample_IOCTL_INDEX 0x0800
  186. #define IOCTL_Sample_GET_PIPE_INFO CTL_CODE(FILE_DEVICE_UNKNOWN, \
  187. Sample_IOCTL_INDEX+0,\
  188. METHOD_BUFFERED, \
  189. FILE_ANY_ACCESS)
  190. #define IOCTL_Sample_GET_DEVICE_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \
  191. Sample_IOCTL_INDEX+1,\
  192. METHOD_BUFFERED, \
  193. FILE_ANY_ACCESS)
  194. #define IOCTL_Sample_GET_CONFIGURATION_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \
  195. Sample_IOCTL_INDEX+2,\
  196. METHOD_BUFFERED, \
  197. FILE_ANY_ACCESS)
  198. #define IOCTL_Sample_BULK_OR_INTERRUPT_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, \
  199. Sample_IOCTL_INDEX+3,\
  200. METHOD_BUFFERED, \
  201. FILE_ANY_ACCESS)
  202. #define IOCTL_Sample_BULK_OR_INTERRUPT_READ CTL_CODE(FILE_DEVICE_UNKNOWN, \
  203. Sample_IOCTL_INDEX+4,\
  204. METHOD_BUFFERED, \
  205. FILE_ANY_ACCESS)
  206. /*
  207. // To add more IOCTLs, make sure you add a different offset to the
  208. // Sample_IOCTL_INDEX value in the CTL_CODE macro.
  209. */