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.

303 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Copyright (c) 1996 Intel Corporation
  4. Module Name:
  5. ISOPERF.h
  6. Abstract:
  7. Header file for the ISOPERF 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. extern ULONG gIsoPerfMaxDebug;
  15. extern PDEVICE_OBJECT gMyOutputDevice;
  16. #define ISOPERF_NAME_MAX 64
  17. #define USB_CLASS_CODE_TEST_CLASS_DEVICE 0xdc
  18. #define USB_SUBCLASS_CODE_TEST_CLASS_ISO 0x50
  19. #define USB_PROTOCOL_CODE_TEST_CLASS_INPATTERN_ALT 0x00 //In ISO w/ Pattern coming back (sof #) -original setting
  20. #define USB_PROTOCOL_CODE_TEST_CLASS_INPATTERN 0x10 //In ISO w/ Pattern coming back (sof #)
  21. #define USB_PROTOCOL_CODE_TEST_CLASS_OUTINTERR 0x80 //Out with interrupt coming back
  22. #define USB_PROTOCOL_CODE_TEST_CLASS_OUTNOCHEK 0x90 //Out with no checks for hiccups
  23. //modes
  24. #define ISOPERF_MODE_USE_POOL 0
  25. #define ISOPERF_MODE_USE_MDL 1
  26. //options
  27. #define ISOPERF_OPT_NONE 0
  28. /*
  29. // This is an unused structure in this driver, but is provided here
  30. // so when you extend the driver to deal with USB pipes, you may wish
  31. // to use this structure as an example or model.
  32. */
  33. typedef struct _ISOPERF_PIPE {
  34. ULONG Mode;
  35. ULONG Option;
  36. ULONG Param1;
  37. ULONG Param2;
  38. PUSBD_PIPE_INFORMATION PipeInfo;
  39. } ISOPERF_PIPE, *PISOPERF_PIPE;
  40. // Work Item structure used to start worker threads in this driver
  41. typedef struct _ISOPERF_WORKITEM {
  42. PDEVICE_OBJECT DeviceObject;
  43. PVOID pvBuffer;
  44. ULONG ulBufferLen;
  45. ULONG ulNumberOfFrames;
  46. USHORT InMaxPacket;
  47. USHORT Padding;
  48. BOOLEAN bFirstUrb;
  49. } ISOPERF_WORKITEM, *PISOPERF_WORKITEM;
  50. /*
  51. // The interface number on this device that this driver expects to use
  52. // This would be in the bInterfaceNumber field of the Interface Descriptor, hence
  53. // this device driver would need to know this value.
  54. */
  55. #define SAMPLE_INTERFACE_NBR 0x00
  56. #define MAX_INTERFACE 0x04
  57. //
  58. // A structure representing the instance information associated with
  59. // this particular device.
  60. //
  61. typedef struct _DEVICE_EXTENSION {
  62. // physical device object
  63. PDEVICE_OBJECT PhysicalDeviceObject;
  64. // Device object we call when submitting Urbs/Irps to the USB stack
  65. PDEVICE_OBJECT StackDeviceObject;
  66. //Test Device Type (enum defined above)
  67. dtDeviceType dtTestDeviceType;
  68. //Device object that mates with this one for the Iso In->Out tests
  69. PDEVICE_OBJECT MateDeviceObject;
  70. // Indicates that we have recieved a STOP message
  71. ULONG Stopped;
  72. // Indicates that the device has been removed or disabled and we need to stop submitting transfers on it
  73. ULONG StopTransfers;
  74. // Indicates if outstanding transfers exist on this device
  75. ULONG DeviceIsBusy;
  76. // Indicates the device needs to be cleaned up (ie., some configuration
  77. // has occurred and needs to be torn down).
  78. ULONG NeedCleanup;
  79. // Indicates that a user request is requesting the Iso test to stop
  80. ULONG bStopIsoTest;
  81. // A counter that is decremented by the driver once the bStopIsoTest flag is set, until this
  82. // reaches zero, at which time the iso tests are stopped
  83. // NOTE: (kosar) this is done to work around a reentrancy problem
  84. ULONG ulCountDownToStop;
  85. ULONG ulNumberOfOutstandingIrps;
  86. // configuration handle for the configuration the
  87. // device is currently in
  88. USBD_CONFIGURATION_HANDLE ConfigurationHandle;
  89. // ptr to the USB device descriptor
  90. // for this device
  91. PUSB_DEVICE_DESCRIPTOR DeviceDescriptor;
  92. // Number of Interfaces on this device
  93. ULONG NumberOfInterfaces;
  94. // Pointers to interface info structs
  95. PUSBD_INTERFACE_INFORMATION Interface[MAX_INTERFACE];
  96. // Pointer to the configuration and status information structure (allocated at device attach)
  97. pConfig_Stat_Info pConfig_Stat_Information;
  98. // Timer stuff for timeout / watchdog code
  99. KTIMER TimeoutTimer;
  100. KDPC TimeoutDpc;
  101. // Name buffer for our named Functional device object link
  102. WCHAR DeviceLinkNameBuffer[ISOPERF_NAME_MAX];
  103. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  104. #if DBG
  105. #define ISOPERF_KdPrint(_x_) DbgPrint("IPERF: "); \
  106. DbgPrint _x_ ;
  107. #define TRAP() DbgBreakPoint()
  108. #define ISOPERF_KdPrint_MAXDEBUG(_x_) \
  109. if (gIsoPerfMaxDebug==TRUE){ \
  110. ISOPERF_KdPrint(_x_) \
  111. } \
  112. #else
  113. #define ISOPERF_KdPrint(_x_)
  114. #define ISOPERF_KdPrint_MAXDEBUG(_x_)
  115. #define TRAP()
  116. #endif
  117. #ifndef max
  118. #define max(a,b) (((a) > (b)) ? (a) : (b))
  119. #endif
  120. NTSTATUS
  121. ISOPERF_Dispatch(
  122. IN PDEVICE_OBJECT DeviceObject,
  123. IN PIRP Irp
  124. );
  125. VOID
  126. ISOPERF_Unload(
  127. IN PDRIVER_OBJECT DriverObject
  128. );
  129. NTSTATUS
  130. ISOPERF_StartDevice(
  131. IN PDEVICE_OBJECT DeviceObject
  132. );
  133. NTSTATUS
  134. ISOPERF_StopDevice(
  135. IN PDEVICE_OBJECT DeviceObject
  136. );
  137. NTSTATUS
  138. ISOPERF_RemoveDevice(
  139. IN PDEVICE_OBJECT DeviceObject
  140. );
  141. NTSTATUS
  142. ISOPERF_CallUSBD(
  143. IN PDEVICE_OBJECT DeviceObject,
  144. IN PURB Urb
  145. );
  146. NTSTATUS
  147. ISOPERF_PnPAddDevice(
  148. IN PDRIVER_OBJECT DriverObject,
  149. IN PDEVICE_OBJECT PhysicalDeviceObject
  150. );
  151. NTSTATUS
  152. ISOPERF_CreateDeviceObject(
  153. IN PDRIVER_OBJECT DriverObject,
  154. IN PDEVICE_OBJECT *DeviceObject,
  155. LONG Instance
  156. );
  157. NTSTATUS
  158. ISOPERF_ConfigureDevice(
  159. IN PDEVICE_OBJECT DeviceObject
  160. );
  161. NTSTATUS
  162. ISOPERF_Write(
  163. IN PDEVICE_OBJECT DeviceObject,
  164. IN PIRP Irp
  165. );
  166. NTSTATUS
  167. ISOPERF_Create(
  168. IN PDEVICE_OBJECT DeviceObject,
  169. IN PIRP Irp
  170. );
  171. NTSTATUS
  172. ISOPERF_Close(
  173. IN PDEVICE_OBJECT DeviceObject,
  174. IN PIRP Irp
  175. );
  176. NTSTATUS
  177. ISOPERF_Read(
  178. IN PDEVICE_OBJECT DeviceObject,
  179. IN PIRP Irp
  180. );
  181. NTSTATUS
  182. ISOPERF_SelectInterfaces(
  183. IN PDEVICE_OBJECT DeviceObject,
  184. IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
  185. IN PUSBD_INTERFACE_INFORMATION Interface
  186. );
  187. VOID
  188. ISOPERF_Cleanup(
  189. PDEVICE_OBJECT DeviceObject
  190. );
  191. NTSTATUS
  192. ISOPERF_ProcessIOCTL(
  193. IN PDEVICE_OBJECT DeviceObject,
  194. IN PIRP Irp
  195. );
  196. NTSTATUS
  197. ISOPERF_CallUSBDEx (
  198. IN PDEVICE_OBJECT DeviceObject,
  199. IN PURB Urb,
  200. IN BOOLEAN fBlock,
  201. PIO_COMPLETION_ROUTINE CompletionRoutine,
  202. PVOID pvContext,
  203. BOOLEAN fWantTimeOut
  204. );
  205. VOID
  206. ISOPERF_SyncTimeoutDPC(
  207. IN PKDPC Dpc,
  208. IN PVOID DeferredContext,
  209. IN PVOID SystemArgument1,
  210. IN PVOID SystemArgument2
  211. );
  212. ULONG
  213. ISOPERF_Internal_GetNumberOfPipes (
  214. PUSB_CONFIGURATION_DESCRIPTOR pCD
  215. );
  216. PVOID
  217. ISOPERF_ExAllocatePool(
  218. IN POOL_TYPE PoolType,
  219. IN ULONG NumberOfBytes,
  220. IN PULONG pTallyOfBytesAllocated
  221. );
  222. VOID
  223. ISOPERF_ExFreePool(
  224. IN PVOID P,
  225. IN PULONG pTallyBytesFreed
  226. );
  227. #endif //DRIVER section