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.

340 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. hidpen.h
  5. Abstract: Contains definitions of all constants and data types for the
  6. serial pen hid driver.
  7. Environment:
  8. Kernel mode
  9. Author:
  10. Michael Tsang (MikeTs) 13-Mar-2000
  11. Revision History:
  12. --*/
  13. #ifndef _HIDPEN_H
  14. #define _HIDPEN_H
  15. //
  16. // Constants
  17. //
  18. #define HPEN_POOL_TAG 'nepH'
  19. // dwfHPen flag values
  20. #define HPENF_DEVICE_STARTED 0x00000001
  21. #define HPENF_DEVICE_REMOVED 0x00000002
  22. #define HPENF_SERIAL_OPENED 0x00000004
  23. #define HPENF_TABLET_STANDBY 0x00000008
  24. // Serial Port FIFO Control Register bits for Receiver Trigger Level
  25. #define SERIAL_IOC_FCR_RCVR_TRIGGER_01_BYTE 0
  26. #define SERIAL_IOC_FCR_RCVR_TRIGGER_04_BYTES SERIAL_IOC_FCR_RCVR_TRIGGER_LSB
  27. #define SERIAL_IOC_FCR_RCVR_TRIGGER_08_BYTES SERIAL_IOC_FCR_RCVR_TRIGGER_MSB
  28. #define SERIAL_IOC_FCR_RCVR_TRIGGER_14_BYTES (SERIAL_IOC_FCR_RCVR_TRIGGER_LSB |\
  29. SERIAL_IOC_FCR_RCVR_TRIGGER_MSB)
  30. //
  31. // Macros
  32. //
  33. #define GET_MINIDRIVER_DEVICE_EXTENSION(DO) \
  34. ((PDEVICE_EXTENSION)(((PHID_DEVICE_EXTENSION)(DO)->DeviceExtension)->MiniDeviceExtension))
  35. #define GET_NEXT_DEVICE_OBJECT(DO) \
  36. (((PHID_DEVICE_EXTENSION)(DO)->DeviceExtension)->NextDeviceObject)
  37. #define GET_PDO(DO) \
  38. (((PHID_DEVICE_EXTENSION)(DO)->DeviceExtension)->PhysicalDeviceObject)
  39. //
  40. // Type Definitions
  41. //
  42. typedef struct _READ_WORKITEM
  43. {
  44. PIO_WORKITEM WorkItem;
  45. PIRP Irp;
  46. PHID_INPUT_REPORT HidReport;
  47. ULONG WorkItemBit;
  48. } READ_WORKITEM, *PREAD_WORKITEM;
  49. typedef struct _DEVICE_EXTENSION
  50. {
  51. #ifdef DEBUG
  52. LIST_ENTRY List; //list of of other tablet devices
  53. #endif
  54. ULONG dwfHPen; //flags
  55. PDEVICE_OBJECT pdo; //pdo of the pen device
  56. PDEVICE_OBJECT SerialDevObj; //points to the serial device object
  57. IO_REMOVE_LOCK RemoveLock; //to protect IRP_MN_REMOVE_DEVICE
  58. DEVICE_POWER_STATE PowerState; //power state of the tablet
  59. SERIAL_BASIC_SETTINGS PrevSerialSettings;
  60. KSPIN_LOCK SpinLock; //to protect the resync buffer
  61. OEM_INPUT_REPORT ResyncData[2];//resync data buffer
  62. ULONG BytesInBuff; //number of bytes in the resync buffer
  63. READ_WORKITEM ReadWorkItem[2];//one for each pending ReadReport
  64. ULONG QueuedWorkItems;//bit mask for queued work items
  65. OEM_DATA OemData; //OEM specific data
  66. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  67. #define QUEUED_WORKITEM_0 0x00000001
  68. #define QUEUED_WORKITEM_1 0x00000002
  69. #define QUEUED_WORKITEM_ALL (QUEUED_WORKITEM_0 | QUEUE_WORKITEM_1)
  70. //
  71. // Global Data Declarations
  72. //
  73. //
  74. // Function prototypes
  75. //
  76. // hidpen.c
  77. NTSTATUS EXTERNAL
  78. DriverEntry(
  79. IN PDRIVER_OBJECT DrvObj,
  80. IN PUNICODE_STRING RegPath
  81. );
  82. NTSTATUS EXTERNAL
  83. HpenCreateClose(
  84. IN PDEVICE_OBJECT DevObj,
  85. IN PIRP Irp
  86. );
  87. NTSTATUS EXTERNAL
  88. HpenAddDevice(
  89. IN PDRIVER_OBJECT DrvObj,
  90. IN PDEVICE_OBJECT DevObj
  91. );
  92. VOID EXTERNAL
  93. HpenUnload(
  94. IN PDRIVER_OBJECT DrvObj
  95. );
  96. // pnp.c
  97. NTSTATUS EXTERNAL
  98. HpenPnp(
  99. IN PDEVICE_OBJECT DevObj,
  100. IN PIRP Irp
  101. );
  102. NTSTATUS EXTERNAL
  103. HpenPower(
  104. IN PDEVICE_OBJECT DevObj,
  105. IN PIRP Irp
  106. );
  107. NTSTATUS INTERNAL
  108. InitDevice(
  109. IN PDEVICE_OBJECT DevObj,
  110. IN PIRP Irp
  111. );
  112. VOID INTERNAL
  113. RemoveDevice(
  114. PDEVICE_OBJECT DevObj,
  115. PIRP Irp
  116. );
  117. NTSTATUS INTERNAL
  118. SendSyncIrp(
  119. IN PDEVICE_OBJECT DevObj,
  120. IN PIRP Irp,
  121. IN BOOLEAN fCopyToNext
  122. );
  123. NTSTATUS INTERNAL
  124. IrpCompletion(
  125. IN PDEVICE_OBJECT DevObj,
  126. IN PIRP Irp,
  127. IN PKEVENT Event
  128. );
  129. // ioctl.c
  130. NTSTATUS EXTERNAL
  131. HpenInternalIoctl(
  132. IN PDEVICE_OBJECT DevObj,
  133. IN PIRP Irp
  134. );
  135. NTSTATUS INTERNAL
  136. GetDeviceDescriptor(
  137. IN PDEVICE_OBJECT DevObj,
  138. IN PIRP Irp
  139. );
  140. NTSTATUS INTERNAL
  141. GetReportDescriptor(
  142. IN PDEVICE_OBJECT DevObj,
  143. IN PIRP Irp
  144. );
  145. NTSTATUS INTERNAL
  146. ReadReport(
  147. IN PDEVICE_OBJECT DevObj,
  148. IN PIRP Irp
  149. );
  150. NTSTATUS INTERNAL
  151. GetString(
  152. PDEVICE_OBJECT DevObj,
  153. PIRP Irp
  154. );
  155. NTSTATUS INTERNAL
  156. GetAttributes(
  157. PDEVICE_OBJECT DevObj,
  158. PIRP Irp
  159. );
  160. NTSTATUS INTERNAL
  161. ReadReportCompletion(
  162. IN PDEVICE_OBJECT DevObj,
  163. IN PIRP Irp,
  164. IN PHID_INPUT_REPORT HidReport
  165. );
  166. // serial.c
  167. NTSTATUS INTERNAL
  168. SerialSyncSendIoctl(
  169. IN ULONG IoctlCode,
  170. IN PDEVICE_OBJECT DevObj,
  171. IN PVOID InBuffer OPTIONAL,
  172. IN ULONG InBufferLen,
  173. OUT PVOID OutBuffer OPTIONAL,
  174. IN ULONG OutBufferLen,
  175. IN BOOLEAN fInternal,
  176. OUT PIO_STATUS_BLOCK Iosb
  177. );
  178. NTSTATUS INTERNAL
  179. SerialAsyncReadWritePort(
  180. IN BOOLEAN fRead,
  181. IN PDEVICE_EXTENSION DevExt,
  182. IN PIRP Irp,
  183. IN PUCHAR Buffer,
  184. IN ULONG BuffLen,
  185. IN PIO_COMPLETION_ROUTINE CompletionRoutine,
  186. IN PVOID Context
  187. );
  188. NTSTATUS INTERNAL
  189. SerialSyncReadWritePort(
  190. IN BOOLEAN fRead,
  191. IN PDEVICE_EXTENSION DevExt,
  192. IN PUCHAR Buffer,
  193. IN ULONG BuffLen,
  194. IN PLARGE_INTEGER Timeout OPTIONAL,
  195. OUT PULONG BytesAccessed OPTIONAL
  196. );
  197. // oempen.c
  198. NTSTATUS EXTERNAL
  199. OemAddDevice(
  200. IN PDEVICE_EXTENSION DevExt
  201. );
  202. NTSTATUS INTERNAL
  203. OemInitSerialPort(
  204. IN PDEVICE_EXTENSION DevExt
  205. );
  206. NTSTATUS INTERNAL
  207. OemInitDevice(
  208. IN PDEVICE_EXTENSION DevExt
  209. );
  210. NTSTATUS INTERNAL
  211. OemQueryDeviceInfo(
  212. IN PDEVICE_EXTENSION DevExt
  213. );
  214. NTSTATUS INTERNAL
  215. OemRemoveDevice(
  216. IN PDEVICE_EXTENSION DevExt
  217. );
  218. NTSTATUS INTERNAL
  219. OemWakeupDevice(
  220. IN PDEVICE_EXTENSION DevExt
  221. );
  222. NTSTATUS INTERNAL
  223. OemStandbyDevice(
  224. IN PDEVICE_EXTENSION DevExt
  225. );
  226. NTSTATUS INTERNAL
  227. OemProcessResyncBuffer(
  228. IN PDEVICE_EXTENSION DevExt,
  229. IN PIRP Irp
  230. );
  231. NTSTATUS INTERNAL
  232. OemProcessInputData(
  233. IN PDEVICE_EXTENSION DevExt,
  234. IN PIRP Irp,
  235. IN PHID_INPUT_REPORT HidReport
  236. );
  237. BOOLEAN INTERNAL
  238. OemIsResyncDataValid(
  239. IN PDEVICE_EXTENSION DevExt
  240. );
  241. VOID INTERNAL
  242. OemReadMoreBytes(
  243. IN PDEVICE_OBJECT DevObj,
  244. IN PREAD_WORKITEM ReadWorkItem
  245. );
  246. NTSTATUS INTERNAL
  247. OemNormalizeInputData(
  248. IN PDEVICE_EXTENSION DevExt,
  249. IN OUT POEM_INPUT_REPORT InData
  250. );
  251. NTSTATUS INTERNAL
  252. OemGetFeatures(
  253. IN PDEVICE_OBJECT DevObj,
  254. IN PIRP Irp
  255. );
  256. NTSTATUS INTERNAL
  257. OemSetFeatures(
  258. IN PDEVICE_OBJECT DevObj,
  259. IN PIRP Irp
  260. );
  261. NTSTATUS INTERNAL
  262. OemSetTabletFeatures(
  263. IN PDEVICE_EXTENSION DevExt,
  264. IN ULONG dwTabletFeatures
  265. );
  266. NTSTATUS INTERNAL
  267. RegQueryDeviceParam(
  268. IN PDEVICE_OBJECT pdo,
  269. IN PWSTR pwstrParamName,
  270. OUT PVOID pbBuff,
  271. IN ULONG dwcbLen
  272. );
  273. NTSTATUS INTERNAL
  274. RegSetDeviceParam(
  275. IN PDEVICE_OBJECT pdo,
  276. IN PWSTR pwstrParamName,
  277. IN ULONG dwType,
  278. IN PVOID pbBuff,
  279. IN ULONG dwcbLen
  280. );
  281. #endif //ifndef _HIDPEN_H