Leaked source code of windows server 2003
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.

425 lines
9.4 KiB

  1. /*++
  2. Copyright (c) 1996-1998 Microsoft Corporation
  3. Module Name:
  4. I82930.H
  5. Abstract:
  6. Header file for I82930 driver
  7. Environment:
  8. kernel mode
  9. Revision History:
  10. 06-01-98 : started rewrite
  11. --*/
  12. //*****************************************************************************
  13. // I N C L U D E S
  14. //*****************************************************************************
  15. #include "dbg.h"
  16. //*****************************************************************************
  17. // D E F I N E S
  18. //*****************************************************************************
  19. #define USB_RECIPIENT_DEVICE 0
  20. #define USB_RECIPIENT_INTERFACE 1
  21. #define USB_RECIPIENT_ENDPOINT 2
  22. #define USB_RECIPIENT_OTHER 3
  23. // Endpoint numbers are 0-15. Endpoint number 0 is the standard control
  24. // endpoint which is not explicitly listed in the Configuration Descriptor.
  25. // There can be an IN endpoint and an OUT endpoint at endpoint numbers
  26. // 1-15 so there can be a maximum of 30 endpoints per device configuration.
  27. //
  28. #define I82930_MAX_PIPES 30
  29. #define POOL_TAG '039I'
  30. #define INCREMENT_OPEN_COUNT(deviceExtension) \
  31. InterlockedIncrement(&(((PDEVICE_EXTENSION)(deviceExtension))->OpenCount))
  32. #define DECREMENT_OPEN_COUNT(deviceExtension) do { \
  33. if (InterlockedDecrement(&(((PDEVICE_EXTENSION)(deviceExtension))->OpenCount)) == 0) { \
  34. KeSetEvent(&((deviceExtension)->RemoveEvent), \
  35. IO_NO_INCREMENT, \
  36. 0); \
  37. } \
  38. } while (0)
  39. //*****************************************************************************
  40. // T Y P E D E F S
  41. //*****************************************************************************
  42. typedef struct _I82930_PIPE {
  43. // Pointer into PDEVICE_EXTENSION->InterfaceInfo.Pipes[]
  44. //
  45. PUSBD_PIPE_INFORMATION PipeInfo;
  46. // Index into PDEVICE_EXTENSION->PipeList[]
  47. //
  48. UCHAR PipeIndex;
  49. // TRUE if pipe is currently open
  50. //
  51. BOOLEAN Opened;
  52. UCHAR Pad[2];
  53. } I82930_PIPE, *PI82930_PIPE;
  54. typedef struct _DEVICE_EXTENSION
  55. {
  56. // PDO passed to I82930_AddDevice
  57. //
  58. PDEVICE_OBJECT PhysicalDeviceObject;
  59. // Our FDO is attached to this device object
  60. //
  61. PDEVICE_OBJECT StackDeviceObject;
  62. // Device Descriptor retrieved from the device
  63. //
  64. PUSB_DEVICE_DESCRIPTOR DeviceDescriptor;
  65. // Configuration Descriptor retrieved from the device
  66. //
  67. PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
  68. // ConfigurationHandle returned from URB_FUNCTION_SELECT_CONFIGURATION
  69. //
  70. USBD_CONFIGURATION_HANDLE ConfigurationHandle;
  71. // Interface info returned from URB_FUNCTION_SELECT_CONFIGURATION
  72. //
  73. PUSBD_INTERFACE_INFORMATION InterfaceInfo;
  74. // Name of our symbolic link
  75. //
  76. UNICODE_STRING SymbolicLinkName;
  77. // Initialized to one in AddDevice.
  78. // Incremented by one for every open.
  79. // Decremented by one for every close.
  80. // Decremented by one in REMOVE_DEVICE.
  81. //
  82. ULONG OpenCount;
  83. // Set when OpenCount is decremented to zero
  84. //
  85. KEVENT RemoveEvent;
  86. // Current system power state
  87. //
  88. SYSTEM_POWER_STATE SystemPowerState;
  89. // Current device power state
  90. //
  91. DEVICE_POWER_STATE DevicePowerState;
  92. // Current power Irp, set by I82930_FdoSetPower(), used by
  93. // I82930_FdoSetPowerCompletion().
  94. //
  95. PIRP CurrentPowerIrp;
  96. // Inialized to FALSE in AddDevice.
  97. // Set to TRUE in START_DEVICE.
  98. // Set to FALSE in STOP_DEVICE and REMOVE_DEVICE.
  99. //
  100. BOOLEAN AcceptingRequests;
  101. UCHAR Pad[3];
  102. // Array of info about each pipe in the current device configuration
  103. //
  104. I82930_PIPE PipeList[I82930_MAX_PIPES];
  105. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  106. //*****************************************************************************
  107. //
  108. // F U N C T I O N P R O T O T Y P E S
  109. //
  110. //*****************************************************************************
  111. //
  112. // I82930.C
  113. //
  114. NTSTATUS
  115. DriverEntry (
  116. IN PDRIVER_OBJECT DriverObject,
  117. IN PUNICODE_STRING RegistryPath
  118. );
  119. VOID
  120. I82930_Unload (
  121. IN PDRIVER_OBJECT DriverObject
  122. );
  123. NTSTATUS
  124. I82930_AddDevice (
  125. IN PDRIVER_OBJECT DriverObject,
  126. IN PDEVICE_OBJECT PhysicalDeviceObject
  127. );
  128. NTSTATUS
  129. I82930_Power (
  130. IN PDEVICE_OBJECT DeviceObject,
  131. IN PIRP Irp
  132. );
  133. NTSTATUS
  134. I82930_FdoSetPower (
  135. IN PDEVICE_OBJECT DeviceObject,
  136. IN PIRP Irp
  137. );
  138. VOID
  139. I82930_FdoSetPowerCompletion(
  140. IN PDEVICE_OBJECT DeviceObject,
  141. IN UCHAR MinorFunction,
  142. IN POWER_STATE PowerState,
  143. IN PVOID Context,
  144. IN PIO_STATUS_BLOCK IoStatus
  145. );
  146. NTSTATUS
  147. I82930_SystemControl (
  148. IN PDEVICE_OBJECT DeviceObject,
  149. IN PIRP Irp
  150. );
  151. NTSTATUS
  152. I82930_Pnp (
  153. IN PDEVICE_OBJECT DeviceObject,
  154. IN PIRP Irp
  155. );
  156. NTSTATUS
  157. I82930_StartDevice (
  158. IN PDEVICE_OBJECT DeviceObject,
  159. IN PIRP Irp
  160. );
  161. NTSTATUS
  162. I82930_StopDevice (
  163. IN PDEVICE_OBJECT DeviceObject,
  164. IN PIRP Irp
  165. );
  166. NTSTATUS
  167. I82930_RemoveDevice (
  168. IN PDEVICE_OBJECT DeviceObject,
  169. IN PIRP Irp
  170. );
  171. NTSTATUS
  172. I82930_QueryStopRemoveDevice (
  173. IN PDEVICE_OBJECT DeviceObject,
  174. IN PIRP Irp
  175. );
  176. NTSTATUS
  177. I82930_CancelStopRemoveDevice (
  178. IN PDEVICE_OBJECT DeviceObject,
  179. IN PIRP Irp
  180. );
  181. NTSTATUS
  182. I82930_QueryCapabilities (
  183. IN PDEVICE_OBJECT DeviceObject,
  184. IN PIRP Irp
  185. );
  186. NTSTATUS
  187. I82930_SyncPassDownIrp (
  188. IN PDEVICE_OBJECT DeviceObject,
  189. IN PIRP Irp,
  190. IN BOOLEAN CopyToNext
  191. );
  192. NTSTATUS
  193. I82930_SyncCompletionRoutine (
  194. IN PDEVICE_OBJECT DeviceObject,
  195. IN PIRP Irp,
  196. IN PVOID Context
  197. );
  198. NTSTATUS
  199. I82930_SyncSendUsbRequest (
  200. IN PDEVICE_OBJECT DeviceObject,
  201. IN PURB Urb
  202. );
  203. NTSTATUS
  204. I82930_GetDescriptor (
  205. IN PDEVICE_OBJECT DeviceObject,
  206. IN UCHAR Recipient,
  207. IN UCHAR DescriptorType,
  208. IN UCHAR Index,
  209. IN USHORT LanguageId,
  210. IN ULONG RetryCount,
  211. IN ULONG DescriptorLength,
  212. OUT PUCHAR *Descriptor
  213. );
  214. NTSTATUS
  215. I82930_SelectConfiguration (
  216. IN PDEVICE_OBJECT DeviceObject
  217. );
  218. NTSTATUS
  219. I82930_UnConfigure (
  220. IN PDEVICE_OBJECT DeviceObject
  221. );
  222. NTSTATUS
  223. I82930_SelectAlternateInterface (
  224. IN PDEVICE_OBJECT DeviceObject,
  225. IN UCHAR AlternateSetting
  226. );
  227. //
  228. // OCRW.C
  229. //
  230. NTSTATUS
  231. I82930_Create (
  232. IN PDEVICE_OBJECT DeviceObject,
  233. IN PIRP Irp
  234. );
  235. NTSTATUS
  236. I82930_Close (
  237. IN PDEVICE_OBJECT DeviceObject,
  238. IN PIRP Irp
  239. );
  240. NTSTATUS
  241. I82930_ReadWrite (
  242. IN PDEVICE_OBJECT DeviceObject,
  243. IN PIRP Irp
  244. );
  245. NTSTATUS
  246. I82930_ReadWrite_Complete (
  247. IN PDEVICE_OBJECT DeviceObject,
  248. IN PIRP Irp,
  249. IN PVOID Context
  250. );
  251. PURB
  252. I82930_BuildAsyncUrb (
  253. IN PDEVICE_OBJECT DeviceObject,
  254. IN PIRP Irp,
  255. IN PI82930_PIPE Pipe
  256. );
  257. PURB
  258. I82930_BuildIsoUrb (
  259. IN PDEVICE_OBJECT DeviceObject,
  260. IN PIRP Irp,
  261. IN PI82930_PIPE Pipe
  262. );
  263. ULONG
  264. I82930_GetCurrentFrame (
  265. IN PDEVICE_OBJECT DeviceObject,
  266. IN PIRP Irp
  267. );
  268. NTSTATUS
  269. I82930_ResetPipe (
  270. IN PDEVICE_OBJECT DeviceObject,
  271. IN PI82930_PIPE Pipe,
  272. IN BOOLEAN IsoClearStall
  273. );
  274. NTSTATUS
  275. I82930_AbortPipe (
  276. IN PDEVICE_OBJECT DeviceObject,
  277. IN PI82930_PIPE Pipe
  278. );
  279. //
  280. // IOCTL.C
  281. //
  282. NTSTATUS
  283. I82930_DeviceControl (
  284. IN PDEVICE_OBJECT DeviceObject,
  285. IN PIRP Irp
  286. );
  287. NTSTATUS
  288. I82930_IoctlGetDeviceDescriptor (
  289. IN PDEVICE_OBJECT DeviceObject,
  290. IN PIRP Irp
  291. );
  292. NTSTATUS
  293. I82930_IoctlGetConfigDescriptor (
  294. IN PDEVICE_OBJECT DeviceObject,
  295. IN PIRP Irp
  296. );
  297. NTSTATUS
  298. I82930_IoctlSetConfigDescriptor (
  299. IN PDEVICE_OBJECT DeviceObject,
  300. IN PIRP Irp
  301. );
  302. BOOLEAN
  303. I82930_ValidateConfigurationDescriptor (
  304. IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDesc,
  305. IN ULONG Length
  306. );
  307. NTSTATUS
  308. I82930_IoctlGetPipeInformation (
  309. IN PDEVICE_OBJECT DeviceObject,
  310. IN PIRP Irp
  311. );
  312. NTSTATUS
  313. I82930_IoctlResetPipe (
  314. IN PDEVICE_OBJECT DeviceObject,
  315. IN PIRP Irp
  316. );
  317. NTSTATUS
  318. I82930_IoctlStallPipe (
  319. IN PDEVICE_OBJECT DeviceObject,
  320. IN PIRP Irp
  321. );
  322. NTSTATUS
  323. I82930_IoctlAbortPipe (
  324. IN PDEVICE_OBJECT DeviceObject,
  325. IN PIRP Irp
  326. );
  327. NTSTATUS
  328. I82930_IoctlResetDevice (
  329. IN PDEVICE_OBJECT DeviceObject,
  330. IN PIRP Irp
  331. );
  332. NTSTATUS
  333. I82930_IoctlSelectAlternateInterface (
  334. IN PDEVICE_OBJECT DeviceObject,
  335. IN PIRP Irp
  336. );