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.

695 lines
26 KiB

  1. /*++ BUILD Version: 0002 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntddser.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. accessing the Serial device.
  8. Author:
  9. Steve Wood (stevewo) 27-May-1990
  10. Revision History:
  11. Louis J. Giliberto, Jr. (louisg) 28-Oct-97
  12. --*/
  13. //
  14. // Interface GUIDs
  15. //
  16. // need these GUIDs outside conditional includes so that user can
  17. // #include <ntddser.h> in precompiled header
  18. // #include <initguid.h> in a single source file
  19. // #include <ntddser.h> in that source file a second time to instantiate the GUIDs
  20. //
  21. #ifdef DEFINE_GUID
  22. //
  23. // Make sure FAR is defined...
  24. //
  25. #ifndef FAR
  26. #ifdef _WIN32
  27. #define FAR
  28. #else
  29. #define FAR _far
  30. #endif
  31. #endif
  32. // begin_wioctlguids
  33. DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
  34. DEFINE_GUID(GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, 0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
  35. // end_wioctlguids
  36. // begin_wioctlobsoleteguids
  37. #define GUID_CLASS_COMPORT GUID_DEVINTERFACE_COMPORT
  38. #define GUID_SERENUM_BUS_ENUMERATOR GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR
  39. // end_wioctlobsoleteguids
  40. #endif // DEFINE_GUID
  41. #ifndef _NTDDSER_
  42. #define _NTDDSER_
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. //
  47. // NtDeviceIoControlFile IoControlCode values for this device.
  48. //
  49. #define IOCTL_SERIAL_SET_BAUD_RATE CTL_CODE(FILE_DEVICE_SERIAL_PORT, 1,METHOD_BUFFERED,FILE_ANY_ACCESS)
  50. #define IOCTL_SERIAL_SET_QUEUE_SIZE CTL_CODE(FILE_DEVICE_SERIAL_PORT, 2,METHOD_BUFFERED,FILE_ANY_ACCESS)
  51. #define IOCTL_SERIAL_SET_LINE_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT, 3,METHOD_BUFFERED,FILE_ANY_ACCESS)
  52. #define IOCTL_SERIAL_SET_BREAK_ON CTL_CODE(FILE_DEVICE_SERIAL_PORT, 4,METHOD_BUFFERED,FILE_ANY_ACCESS)
  53. #define IOCTL_SERIAL_SET_BREAK_OFF CTL_CODE(FILE_DEVICE_SERIAL_PORT, 5,METHOD_BUFFERED,FILE_ANY_ACCESS)
  54. #define IOCTL_SERIAL_IMMEDIATE_CHAR CTL_CODE(FILE_DEVICE_SERIAL_PORT, 6,METHOD_BUFFERED,FILE_ANY_ACCESS)
  55. #define IOCTL_SERIAL_SET_TIMEOUTS CTL_CODE(FILE_DEVICE_SERIAL_PORT, 7,METHOD_BUFFERED,FILE_ANY_ACCESS)
  56. #define IOCTL_SERIAL_GET_TIMEOUTS CTL_CODE(FILE_DEVICE_SERIAL_PORT, 8,METHOD_BUFFERED,FILE_ANY_ACCESS)
  57. #define IOCTL_SERIAL_SET_DTR CTL_CODE(FILE_DEVICE_SERIAL_PORT, 9,METHOD_BUFFERED,FILE_ANY_ACCESS)
  58. #define IOCTL_SERIAL_CLR_DTR CTL_CODE(FILE_DEVICE_SERIAL_PORT,10,METHOD_BUFFERED,FILE_ANY_ACCESS)
  59. #define IOCTL_SERIAL_RESET_DEVICE CTL_CODE(FILE_DEVICE_SERIAL_PORT,11,METHOD_BUFFERED,FILE_ANY_ACCESS)
  60. #define IOCTL_SERIAL_SET_RTS CTL_CODE(FILE_DEVICE_SERIAL_PORT,12,METHOD_BUFFERED,FILE_ANY_ACCESS)
  61. #define IOCTL_SERIAL_CLR_RTS CTL_CODE(FILE_DEVICE_SERIAL_PORT,13,METHOD_BUFFERED,FILE_ANY_ACCESS)
  62. #define IOCTL_SERIAL_SET_XOFF CTL_CODE(FILE_DEVICE_SERIAL_PORT,14,METHOD_BUFFERED,FILE_ANY_ACCESS)
  63. #define IOCTL_SERIAL_SET_XON CTL_CODE(FILE_DEVICE_SERIAL_PORT,15,METHOD_BUFFERED,FILE_ANY_ACCESS)
  64. #define IOCTL_SERIAL_GET_WAIT_MASK CTL_CODE(FILE_DEVICE_SERIAL_PORT,16,METHOD_BUFFERED,FILE_ANY_ACCESS)
  65. #define IOCTL_SERIAL_SET_WAIT_MASK CTL_CODE(FILE_DEVICE_SERIAL_PORT,17,METHOD_BUFFERED,FILE_ANY_ACCESS)
  66. #define IOCTL_SERIAL_WAIT_ON_MASK CTL_CODE(FILE_DEVICE_SERIAL_PORT,18,METHOD_BUFFERED,FILE_ANY_ACCESS)
  67. #define IOCTL_SERIAL_PURGE CTL_CODE(FILE_DEVICE_SERIAL_PORT,19,METHOD_BUFFERED,FILE_ANY_ACCESS)
  68. #define IOCTL_SERIAL_GET_BAUD_RATE CTL_CODE(FILE_DEVICE_SERIAL_PORT,20,METHOD_BUFFERED,FILE_ANY_ACCESS)
  69. #define IOCTL_SERIAL_GET_LINE_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT,21,METHOD_BUFFERED,FILE_ANY_ACCESS)
  70. #define IOCTL_SERIAL_GET_CHARS CTL_CODE(FILE_DEVICE_SERIAL_PORT,22,METHOD_BUFFERED,FILE_ANY_ACCESS)
  71. #define IOCTL_SERIAL_SET_CHARS CTL_CODE(FILE_DEVICE_SERIAL_PORT,23,METHOD_BUFFERED,FILE_ANY_ACCESS)
  72. #define IOCTL_SERIAL_GET_HANDFLOW CTL_CODE(FILE_DEVICE_SERIAL_PORT,24,METHOD_BUFFERED,FILE_ANY_ACCESS)
  73. #define IOCTL_SERIAL_SET_HANDFLOW CTL_CODE(FILE_DEVICE_SERIAL_PORT,25,METHOD_BUFFERED,FILE_ANY_ACCESS)
  74. #define IOCTL_SERIAL_GET_MODEMSTATUS CTL_CODE(FILE_DEVICE_SERIAL_PORT,26,METHOD_BUFFERED,FILE_ANY_ACCESS)
  75. #define IOCTL_SERIAL_GET_COMMSTATUS CTL_CODE(FILE_DEVICE_SERIAL_PORT,27,METHOD_BUFFERED,FILE_ANY_ACCESS)
  76. #define IOCTL_SERIAL_XOFF_COUNTER CTL_CODE(FILE_DEVICE_SERIAL_PORT,28,METHOD_BUFFERED,FILE_ANY_ACCESS)
  77. #define IOCTL_SERIAL_GET_PROPERTIES CTL_CODE(FILE_DEVICE_SERIAL_PORT,29,METHOD_BUFFERED,FILE_ANY_ACCESS)
  78. #define IOCTL_SERIAL_GET_DTRRTS CTL_CODE(FILE_DEVICE_SERIAL_PORT,30,METHOD_BUFFERED,FILE_ANY_ACCESS)
  79. //
  80. // Serenum reserves function codes between 128 and 255. Do not use.
  81. //
  82. // begin_winioctl
  83. #define IOCTL_SERIAL_LSRMST_INSERT CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  84. #define IOCTL_SERENUM_EXPOSE_HARDWARE CTL_CODE(FILE_DEVICE_SERENUM,128,METHOD_BUFFERED,FILE_ANY_ACCESS)
  85. #define IOCTL_SERENUM_REMOVE_HARDWARE CTL_CODE(FILE_DEVICE_SERENUM,129,METHOD_BUFFERED,FILE_ANY_ACCESS)
  86. #define IOCTL_SERENUM_PORT_DESC CTL_CODE(FILE_DEVICE_SERENUM,130,METHOD_BUFFERED,FILE_ANY_ACCESS)
  87. #define IOCTL_SERENUM_GET_PORT_NAME CTL_CODE(FILE_DEVICE_SERENUM,131,METHOD_BUFFERED,FILE_ANY_ACCESS)
  88. // end_winioctl
  89. #define IOCTL_SERIAL_CONFIG_SIZE CTL_CODE(FILE_DEVICE_SERIAL_PORT,32,METHOD_BUFFERED,FILE_ANY_ACCESS)
  90. #define IOCTL_SERIAL_GET_COMMCONFIG CTL_CODE(FILE_DEVICE_SERIAL_PORT,33,METHOD_BUFFERED,FILE_ANY_ACCESS)
  91. #define IOCTL_SERIAL_SET_COMMCONFIG CTL_CODE(FILE_DEVICE_SERIAL_PORT,34,METHOD_BUFFERED,FILE_ANY_ACCESS)
  92. #define IOCTL_SERIAL_GET_STATS CTL_CODE(FILE_DEVICE_SERIAL_PORT,35,METHOD_BUFFERED,FILE_ANY_ACCESS)
  93. #define IOCTL_SERIAL_CLEAR_STATS CTL_CODE(FILE_DEVICE_SERIAL_PORT,36,METHOD_BUFFERED,FILE_ANY_ACCESS)
  94. #define IOCTL_SERIAL_GET_MODEM_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT,37,METHOD_BUFFERED,FILE_ANY_ACCESS)
  95. #define IOCTL_SERIAL_SET_MODEM_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT,38,METHOD_BUFFERED,FILE_ANY_ACCESS)
  96. #define IOCTL_SERIAL_SET_FIFO_CONTROL CTL_CODE(FILE_DEVICE_SERIAL_PORT,39,METHOD_BUFFERED,FILE_ANY_ACCESS)
  97. //
  98. // internal serial IOCTL's
  99. //
  100. #define IOCTL_SERIAL_INTERNAL_DO_WAIT_WAKE CTL_CODE(FILE_DEVICE_SERIAL_PORT, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  101. #define IOCTL_SERIAL_INTERNAL_CANCEL_WAIT_WAKE CTL_CODE(FILE_DEVICE_SERIAL_PORT, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  102. #define IOCTL_SERIAL_INTERNAL_BASIC_SETTINGS CTL_CODE(FILE_DEVICE_SERIAL_PORT, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  103. #define IOCTL_SERIAL_INTERNAL_RESTORE_SETTINGS CTL_CODE(FILE_DEVICE_SERIAL_PORT, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
  104. typedef struct _SERIALPERF_STATS {
  105. ULONG ReceivedCount;
  106. ULONG TransmittedCount;
  107. ULONG FrameErrorCount;
  108. ULONG SerialOverrunErrorCount;
  109. ULONG BufferOverrunErrorCount;
  110. ULONG ParityErrorCount;
  111. } SERIALPERF_STATS, *PSERIALPERF_STATS;
  112. typedef struct _SERIALCONFIG {
  113. ULONG Size;
  114. USHORT Version;
  115. ULONG SubType;
  116. ULONG ProvOffset;
  117. ULONG ProviderSize;
  118. WCHAR ProviderData[1];
  119. } SERIALCONFIG,*PSERIALCONFIG;
  120. //
  121. // NtDeviceIoControlFile InputBuffer/OutputBuffer record structures for
  122. // this device.
  123. //
  124. //
  125. // This structure used to set line parameters.
  126. //
  127. typedef struct _SERIAL_LINE_CONTROL {
  128. UCHAR StopBits;
  129. UCHAR Parity;
  130. UCHAR WordLength;
  131. } SERIAL_LINE_CONTROL,*PSERIAL_LINE_CONTROL;
  132. typedef struct _SERIAL_TIMEOUTS {
  133. ULONG ReadIntervalTimeout;
  134. ULONG ReadTotalTimeoutMultiplier;
  135. ULONG ReadTotalTimeoutConstant;
  136. ULONG WriteTotalTimeoutMultiplier;
  137. ULONG WriteTotalTimeoutConstant;
  138. } SERIAL_TIMEOUTS,*PSERIAL_TIMEOUTS;
  139. //
  140. // This structure used to resize the input/output buffers.
  141. // An error code will be returned if the size exceeds the
  142. // drivers capacity. The driver reserves the right to
  143. // allocate a larger buffer.
  144. //
  145. typedef struct _SERIAL_QUEUE_SIZE {
  146. ULONG InSize;
  147. ULONG OutSize;
  148. } SERIAL_QUEUE_SIZE,*PSERIAL_QUEUE_SIZE;
  149. //
  150. // This structure used by set baud rate
  151. //
  152. typedef struct _SERIAL_BAUD_RATE {
  153. ULONG BaudRate;
  154. } SERIAL_BAUD_RATE,*PSERIAL_BAUD_RATE;
  155. //
  156. // Defines the bitmask that the driver can used to notify
  157. // app of various changes in the state of the UART.
  158. //
  159. #define SERIAL_EV_RXCHAR 0x0001 // Any Character received
  160. #define SERIAL_EV_RXFLAG 0x0002 // Received certain character
  161. #define SERIAL_EV_TXEMPTY 0x0004 // Transmitt Queue Empty
  162. #define SERIAL_EV_CTS 0x0008 // CTS changed state
  163. #define SERIAL_EV_DSR 0x0010 // DSR changed state
  164. #define SERIAL_EV_RLSD 0x0020 // RLSD changed state
  165. #define SERIAL_EV_BREAK 0x0040 // BREAK received
  166. #define SERIAL_EV_ERR 0x0080 // Line status error occurred
  167. #define SERIAL_EV_RING 0x0100 // Ring signal detected
  168. #define SERIAL_EV_PERR 0x0200 // Printer error occured
  169. #define SERIAL_EV_RX80FULL 0x0400 // Receive buffer is 80 percent full
  170. #define SERIAL_EV_EVENT1 0x0800 // Provider specific event 1
  171. #define SERIAL_EV_EVENT2 0x1000 // Provider specific event 2
  172. //
  173. // A longword is used to send down a mask that
  174. // instructs the driver what to purge.
  175. //
  176. // SERIAL_PURGE_TXABORT - Implies the current and all pending writes.
  177. // SERIAL_PURGE_RXABORT - Implies the current and all pending reads.
  178. // SERIAL_PURGE_TXCLEAR - Implies the transmit buffer if exists
  179. // SERIAL_PURGE_RXCLEAR - Implies the receive buffer if exists.
  180. //
  181. #define SERIAL_PURGE_TXABORT 0x00000001
  182. #define SERIAL_PURGE_RXABORT 0x00000002
  183. #define SERIAL_PURGE_TXCLEAR 0x00000004
  184. #define SERIAL_PURGE_RXCLEAR 0x00000008
  185. //
  186. // Communication defines
  187. //
  188. #define STOP_BIT_1 0
  189. #define STOP_BITS_1_5 1
  190. #define STOP_BITS_2 2
  191. #define NO_PARITY 0
  192. #define ODD_PARITY 1
  193. #define EVEN_PARITY 2
  194. #define MARK_PARITY 3
  195. #define SPACE_PARITY 4
  196. //
  197. // This structure is used to set and retrieve the special characters
  198. // used by the nt serial driver.
  199. //
  200. // Note that the driver will return an error if xonchar == xoffchar.
  201. //
  202. typedef struct _SERIAL_CHARS {
  203. UCHAR EofChar;
  204. UCHAR ErrorChar;
  205. UCHAR BreakChar;
  206. UCHAR EventChar;
  207. UCHAR XonChar;
  208. UCHAR XoffChar;
  209. } SERIAL_CHARS,*PSERIAL_CHARS;
  210. //
  211. // This structure is used to contain the flow control
  212. // and handshaking setup.
  213. //
  214. // A reasonably precise explaination of how they all
  215. // work can be found in the OS/2 tech references.
  216. //
  217. // For Xon/Xofflimit:
  218. //
  219. // When there are more characters then
  220. //
  221. // (typeaheadbuffersize - xofflimit)
  222. //
  223. // in the typeahead buffer then the driver will perform all flow
  224. // control that the app has enabled so that the sender will (hopefully)
  225. // stop sending characters.
  226. //
  227. // When there are less than xonlimit number of characters in the
  228. // typeahead buffer the driver will perform all flow control that
  229. // the app has enabled so that the sender will hopefully start sending
  230. // characters again.
  231. //
  232. // It should be noted that if Xoff character is sent then the
  233. // driver will also stop transmitting any more characters. This is to
  234. // provide support for those systems that take any character that
  235. // follows an Xoff as an implied Xon.
  236. //
  237. typedef struct _SERIAL_HANDFLOW {
  238. ULONG ControlHandShake;
  239. ULONG FlowReplace;
  240. LONG XonLimit;
  241. LONG XoffLimit;
  242. } SERIAL_HANDFLOW,*PSERIAL_HANDFLOW;
  243. #define SERIAL_DTR_MASK ((ULONG)0x03)
  244. #define SERIAL_DTR_CONTROL ((ULONG)0x01)
  245. #define SERIAL_DTR_HANDSHAKE ((ULONG)0x02)
  246. #define SERIAL_CTS_HANDSHAKE ((ULONG)0x08)
  247. #define SERIAL_DSR_HANDSHAKE ((ULONG)0x10)
  248. #define SERIAL_DCD_HANDSHAKE ((ULONG)0x20)
  249. #define SERIAL_OUT_HANDSHAKEMASK ((ULONG)0x38)
  250. #define SERIAL_DSR_SENSITIVITY ((ULONG)0x40)
  251. #define SERIAL_ERROR_ABORT ((ULONG)0x80000000)
  252. #define SERIAL_CONTROL_INVALID ((ULONG)0x7fffff84)
  253. #define SERIAL_AUTO_TRANSMIT ((ULONG)0x01)
  254. #define SERIAL_AUTO_RECEIVE ((ULONG)0x02)
  255. #define SERIAL_ERROR_CHAR ((ULONG)0x04)
  256. #define SERIAL_NULL_STRIPPING ((ULONG)0x08)
  257. #define SERIAL_BREAK_CHAR ((ULONG)0x10)
  258. #define SERIAL_RTS_MASK ((ULONG)0xc0)
  259. #define SERIAL_RTS_CONTROL ((ULONG)0x40)
  260. #define SERIAL_RTS_HANDSHAKE ((ULONG)0x80)
  261. #define SERIAL_TRANSMIT_TOGGLE ((ULONG)0xc0)
  262. #define SERIAL_XOFF_CONTINUE ((ULONG)0x80000000)
  263. #define SERIAL_FLOW_INVALID ((ULONG)0x7fffff20)
  264. //
  265. // These are the following reasons that the device could be holding.
  266. //
  267. #define SERIAL_TX_WAITING_FOR_CTS ((ULONG)0x00000001)
  268. #define SERIAL_TX_WAITING_FOR_DSR ((ULONG)0x00000002)
  269. #define SERIAL_TX_WAITING_FOR_DCD ((ULONG)0x00000004)
  270. #define SERIAL_TX_WAITING_FOR_XON ((ULONG)0x00000008)
  271. #define SERIAL_TX_WAITING_XOFF_SENT ((ULONG)0x00000010)
  272. #define SERIAL_TX_WAITING_ON_BREAK ((ULONG)0x00000020)
  273. #define SERIAL_RX_WAITING_FOR_DSR ((ULONG)0x00000040)
  274. //
  275. // These are the error values that can be returned by the
  276. // driver.
  277. //
  278. #define SERIAL_ERROR_BREAK ((ULONG)0x00000001)
  279. #define SERIAL_ERROR_FRAMING ((ULONG)0x00000002)
  280. #define SERIAL_ERROR_OVERRUN ((ULONG)0x00000004)
  281. #define SERIAL_ERROR_QUEUEOVERRUN ((ULONG)0x00000008)
  282. #define SERIAL_ERROR_PARITY ((ULONG)0x00000010)
  283. //
  284. // This structure is used by IOCTL_SERIAL_INTERNAL_BASIC_SETTINGS
  285. // and IOCTL_SERIAL_INTERNAL_RESTORE_SETTINGS
  286. //
  287. typedef struct _SERIAL_BASIC_SETTINGS {
  288. SERIAL_TIMEOUTS Timeouts;
  289. SERIAL_HANDFLOW HandFlow;
  290. ULONG RxFifo;
  291. ULONG TxFifo;
  292. } SERIAL_BASIC_SETTINGS, *PSERIAL_BASIC_SETTINGS;
  293. //
  294. // This structure is used to get the current error and
  295. // general status of the driver.
  296. //
  297. typedef struct _SERIAL_STATUS {
  298. ULONG Errors;
  299. ULONG HoldReasons;
  300. ULONG AmountInInQueue;
  301. ULONG AmountInOutQueue;
  302. BOOLEAN EofReceived;
  303. BOOLEAN WaitForImmediate;
  304. } SERIAL_STATUS,*PSERIAL_STATUS;
  305. //
  306. // This structure is used for XOFF counter ioctl. The xoff ioctl
  307. // is used to support those subsystems that feel the need to emulate
  308. // the serial chip in software.
  309. //
  310. // It has the following semantics:
  311. //
  312. // This io request is placed into the normal device write
  313. // queue. That is, it will be queued behind any writes
  314. // already given to the driver.
  315. //
  316. // When this request becomes the current request, the character
  317. // specified in the field XoffChar will be sent, subject to
  318. // all other flow control already defined.
  319. //
  320. // Immediately upon sending the character the driver will
  321. // perform the following actions.
  322. //
  323. // A timer will be initiated that will expire after the
  324. // number of milliseconds in the Timeout field of the
  325. // SERIAL_XOFF_COUNTER structure.
  326. //
  327. // The driver will initialize a counter to the value specified
  328. // in the Counter field of the SERIAL_XOFF_RECORD. The driver
  329. // will decrement this counter whenever a character is received.
  330. //
  331. // This request will then be held by the driver. It will
  332. // actually complete under the following circumstances:
  333. //
  334. // 1) If there is another "write" request behind it in the queue.
  335. // The "xoff" request will be completed with the informational status
  336. // STATUS_SERIAL_MORE_WRITES. The Information field of the
  337. // IOSTATUS block will be set to 0.
  338. //
  339. // Note: By write request we mean another SERIAL_XOFF_COUNTER
  340. // request, or a simple write request. If the only subsequent
  341. // request is a flush request, the driver WILL NOT automatically
  342. // complete the SERIAL_XOFF_COUNTER request. NOTE: Transmit
  343. // immediate requests DO NOT count as a normal write, and therefore
  344. // would not cause a counter request to complete.
  345. //
  346. // 2) The timer expires. The driver will complete the request
  347. // with the informational status STATUS_SERIAL_COUNTER_TIMEOUT.
  348. // The Information field of the IOSTATUS of the request will be set to 0.
  349. //
  350. // 3) The driver maintained counter goes to zero. (By implication,
  351. // at least "Counter" number of characters have been received.)
  352. // The request will be completed with a successful status
  353. // of STATUS_SUCCESS. The Information field of the
  354. // IOSTATUS of the request will be set to 0.
  355. //
  356. // 4) This is really a degenerate case of "1" above. The request
  357. // is started and no request follow it on the queue. However
  358. // at some point, before "2" or "3" above occur, another "write"
  359. // request is started. This will cause the completion actions
  360. // stated in "1" to occur.
  361. //
  362. // NOTE: This request being issued WILL NOT cause the normal flow
  363. // control code of the driver to be invoked.
  364. //
  365. // NOTE: This request has no interaction with the IOCTL_SERIAL_WAIT_ON_MASK
  366. // request. An application CAN NOT wait via the above ^^^^^^ ioctl
  367. // on the counter going to zero. The application must synchronize
  368. // with the particular IOCTL_SERIAL_XOFF_COUNTER request.
  369. //
  370. // NOTE: The Timeout value equal to zero would cause the counter
  371. // to NEVER timeout. The only way that such a request could
  372. // be killed at that point would be issue another write, or
  373. // to purge the WRITE queue.
  374. //
  375. typedef struct _SERIAL_XOFF_COUNTER {
  376. ULONG Timeout; // Zero based. In milliseconds
  377. LONG Counter; // Must be greater than zero.
  378. UCHAR XoffChar;
  379. } SERIAL_XOFF_COUNTER,*PSERIAL_XOFF_COUNTER;
  380. //
  381. // The following structure (and defines) are passed back by
  382. // the serial driver in response to the get properties ioctl.
  383. //
  384. #define SERIAL_SP_SERIALCOMM ((ULONG)0x00000001)
  385. //
  386. // Provider subtypes
  387. //
  388. #define SERIAL_SP_UNSPECIFIED ((ULONG)0x00000000)
  389. #define SERIAL_SP_RS232 ((ULONG)0x00000001)
  390. #define SERIAL_SP_PARALLEL ((ULONG)0x00000002)
  391. #define SERIAL_SP_RS422 ((ULONG)0x00000003)
  392. #define SERIAL_SP_RS423 ((ULONG)0x00000004)
  393. #define SERIAL_SP_RS449 ((ULONG)0x00000005)
  394. #define SERIAL_SP_MODEM ((ULONG)0X00000006)
  395. #define SERIAL_SP_FAX ((ULONG)0x00000021)
  396. #define SERIAL_SP_SCANNER ((ULONG)0x00000022)
  397. #define SERIAL_SP_BRIDGE ((ULONG)0x00000100)
  398. #define SERIAL_SP_LAT ((ULONG)0x00000101)
  399. #define SERIAL_SP_TELNET ((ULONG)0x00000102)
  400. #define SERIAL_SP_X25 ((ULONG)0x00000103)
  401. //
  402. // Provider capabilities flags.
  403. //
  404. #define SERIAL_PCF_DTRDSR ((ULONG)0x0001)
  405. #define SERIAL_PCF_RTSCTS ((ULONG)0x0002)
  406. #define SERIAL_PCF_CD ((ULONG)0x0004)
  407. #define SERIAL_PCF_PARITY_CHECK ((ULONG)0x0008)
  408. #define SERIAL_PCF_XONXOFF ((ULONG)0x0010)
  409. #define SERIAL_PCF_SETXCHAR ((ULONG)0x0020)
  410. #define SERIAL_PCF_TOTALTIMEOUTS ((ULONG)0x0040)
  411. #define SERIAL_PCF_INTTIMEOUTS ((ULONG)0x0080)
  412. #define SERIAL_PCF_SPECIALCHARS ((ULONG)0x0100)
  413. #define SERIAL_PCF_16BITMODE ((ULONG)0x0200)
  414. //
  415. // Comm provider settable parameters.
  416. //
  417. #define SERIAL_SP_PARITY ((ULONG)0x0001)
  418. #define SERIAL_SP_BAUD ((ULONG)0x0002)
  419. #define SERIAL_SP_DATABITS ((ULONG)0x0004)
  420. #define SERIAL_SP_STOPBITS ((ULONG)0x0008)
  421. #define SERIAL_SP_HANDSHAKING ((ULONG)0x0010)
  422. #define SERIAL_SP_PARITY_CHECK ((ULONG)0x0020)
  423. #define SERIAL_SP_CARRIER_DETECT ((ULONG)0x0040)
  424. //
  425. // Settable baud rates in the provider.
  426. //
  427. #define SERIAL_BAUD_075 ((ULONG)0x00000001)
  428. #define SERIAL_BAUD_110 ((ULONG)0x00000002)
  429. #define SERIAL_BAUD_134_5 ((ULONG)0x00000004)
  430. #define SERIAL_BAUD_150 ((ULONG)0x00000008)
  431. #define SERIAL_BAUD_300 ((ULONG)0x00000010)
  432. #define SERIAL_BAUD_600 ((ULONG)0x00000020)
  433. #define SERIAL_BAUD_1200 ((ULONG)0x00000040)
  434. #define SERIAL_BAUD_1800 ((ULONG)0x00000080)
  435. #define SERIAL_BAUD_2400 ((ULONG)0x00000100)
  436. #define SERIAL_BAUD_4800 ((ULONG)0x00000200)
  437. #define SERIAL_BAUD_7200 ((ULONG)0x00000400)
  438. #define SERIAL_BAUD_9600 ((ULONG)0x00000800)
  439. #define SERIAL_BAUD_14400 ((ULONG)0x00001000)
  440. #define SERIAL_BAUD_19200 ((ULONG)0x00002000)
  441. #define SERIAL_BAUD_38400 ((ULONG)0x00004000)
  442. #define SERIAL_BAUD_56K ((ULONG)0x00008000)
  443. #define SERIAL_BAUD_128K ((ULONG)0x00010000)
  444. #define SERIAL_BAUD_115200 ((ULONG)0x00020000)
  445. #define SERIAL_BAUD_57600 ((ULONG)0x00040000)
  446. #define SERIAL_BAUD_USER ((ULONG)0x10000000)
  447. //
  448. // Settable Data Bits
  449. //
  450. #define SERIAL_DATABITS_5 ((USHORT)0x0001)
  451. #define SERIAL_DATABITS_6 ((USHORT)0x0002)
  452. #define SERIAL_DATABITS_7 ((USHORT)0x0004)
  453. #define SERIAL_DATABITS_8 ((USHORT)0x0008)
  454. #define SERIAL_DATABITS_16 ((USHORT)0x0010)
  455. #define SERIAL_DATABITS_16X ((USHORT)0x0020)
  456. //
  457. // Settable Stop and Parity bits.
  458. //
  459. #define SERIAL_STOPBITS_10 ((USHORT)0x0001)
  460. #define SERIAL_STOPBITS_15 ((USHORT)0x0002)
  461. #define SERIAL_STOPBITS_20 ((USHORT)0x0004)
  462. #define SERIAL_PARITY_NONE ((USHORT)0x0100)
  463. #define SERIAL_PARITY_ODD ((USHORT)0x0200)
  464. #define SERIAL_PARITY_EVEN ((USHORT)0x0400)
  465. #define SERIAL_PARITY_MARK ((USHORT)0x0800)
  466. #define SERIAL_PARITY_SPACE ((USHORT)0x1000)
  467. typedef struct _SERIAL_COMMPROP {
  468. USHORT PacketLength;
  469. USHORT PacketVersion;
  470. ULONG ServiceMask;
  471. ULONG Reserved1;
  472. ULONG MaxTxQueue;
  473. ULONG MaxRxQueue;
  474. ULONG MaxBaud;
  475. ULONG ProvSubType;
  476. ULONG ProvCapabilities;
  477. ULONG SettableParams;
  478. ULONG SettableBaud;
  479. USHORT SettableData;
  480. USHORT SettableStopParity;
  481. ULONG CurrentTxQueue;
  482. ULONG CurrentRxQueue;
  483. ULONG ProvSpec1;
  484. ULONG ProvSpec2;
  485. WCHAR ProvChar[1];
  486. } SERIAL_COMMPROP,*PSERIAL_COMMPROP;
  487. //
  488. // Define masks for the rs-232 input and output.
  489. //
  490. #define SERIAL_DTR_STATE ((ULONG)0x00000001)
  491. #define SERIAL_RTS_STATE ((ULONG)0x00000002)
  492. #define SERIAL_CTS_STATE ((ULONG)0x00000010)
  493. #define SERIAL_DSR_STATE ((ULONG)0x00000020)
  494. #define SERIAL_RI_STATE ((ULONG)0x00000040)
  495. #define SERIAL_DCD_STATE ((ULONG)0x00000080)
  496. // begin_winioctl
  497. //
  498. // The following values follow the escape designator in the
  499. // data stream if the LSRMST_INSERT mode has been turned on.
  500. //
  501. #define SERIAL_LSRMST_ESCAPE ((UCHAR)0x00)
  502. //
  503. // Following this value is the contents of the line status
  504. // register, and then the character in the RX hardware when
  505. // the line status register was encountered.
  506. //
  507. #define SERIAL_LSRMST_LSR_DATA ((UCHAR)0x01)
  508. //
  509. // Following this value is the contents of the line status
  510. // register. No error character follows
  511. //
  512. #define SERIAL_LSRMST_LSR_NODATA ((UCHAR)0x02)
  513. //
  514. // Following this value is the contents of the modem status
  515. // register.
  516. //
  517. #define SERIAL_LSRMST_MST ((UCHAR)0x03)
  518. //
  519. // Bit values for FIFO Control Register
  520. //
  521. #define SERIAL_IOC_FCR_FIFO_ENABLE ((ULONG)0x00000001)
  522. #define SERIAL_IOC_FCR_RCVR_RESET ((ULONG)0x00000002)
  523. #define SERIAL_IOC_FCR_XMIT_RESET ((ULONG)0x00000004)
  524. #define SERIAL_IOC_FCR_DMA_MODE ((ULONG)0x00000008)
  525. #define SERIAL_IOC_FCR_RES1 ((ULONG)0x00000010)
  526. #define SERIAL_IOC_FCR_RES2 ((ULONG)0x00000020)
  527. #define SERIAL_IOC_FCR_RCVR_TRIGGER_LSB ((ULONG)0x00000040)
  528. #define SERIAL_IOC_FCR_RCVR_TRIGGER_MSB ((ULONG)0x00000080)
  529. //
  530. // Bit values for Modem Control Register
  531. //
  532. #define SERIAL_IOC_MCR_DTR ((ULONG)0x00000001)
  533. #define SERIAL_IOC_MCR_RTS ((ULONG)0x00000002)
  534. #define SERIAL_IOC_MCR_OUT1 ((ULONG)0x00000004)
  535. #define SERIAL_IOC_MCR_OUT2 ((ULONG)0x00000008)
  536. #define SERIAL_IOC_MCR_LOOP ((ULONG)0x00000010)
  537. // end_winioctl
  538. //
  539. // Serenum internal ioctl's
  540. //
  541. #undef PHYSICAL_ADDRESS
  542. #define PHYSICAL_ADDRESS LARGE_INTEGER
  543. typedef struct _SERENUM_PORT_DESC
  544. {
  545. IN ULONG Size; // sizeof (struct _PORT_DESC)
  546. OUT PVOID PortHandle;
  547. OUT PHYSICAL_ADDRESS PortAddress;
  548. USHORT Reserved[1];
  549. } SERENUM_PORT_DESC, * PSERENUM_PORT_DESC;
  550. // **************************************************************************
  551. // Internal IOCTL interface for (pdo)
  552. // The HID to legacy serial port minidriver uses this interface to
  553. // find the address of the device.
  554. // **************************************************************************
  555. #define IOCTL_INTERNAL_SERENUM_REMOVE_SELF \
  556. CTL_CODE(FILE_DEVICE_SERENUM, 129, METHOD_NEITHER, FILE_ANY_ACCESS)
  557. // of which IO_STACK_LOCATION->Parameters.Others.Argument1 is set to
  558. // a pointer to struct _SERENUM_SER_PARAMETERS
  559. typedef
  560. UCHAR
  561. (*PSERENUM_READPORT) (
  562. PVOID SerPortAddress
  563. );
  564. typedef
  565. VOID
  566. (*PSERENUM_WRITEPORT) (
  567. PVOID SerPortAddress,
  568. UCHAR Value
  569. );
  570. typedef enum _SERENUM_PORTION {
  571. SerenumFirstHalf,
  572. SerenumSecondHalf,
  573. SerenumWhole
  574. } SERENUM_PORTION;
  575. typedef struct _SERENUM_PORT_PARAMETERS
  576. {
  577. IN ULONG Size; // sizeof (SERENUM_GET_PORT_PARAMETERS)
  578. OUT PSERENUM_READPORT ReadAccessor; // read the serial port
  579. OUT PSERENUM_WRITEPORT WriteAccessor; // write the serial port
  580. OUT PVOID SerPortAddress; // token to read this serial port
  581. OUT PVOID HardwareHandle; // a handle to this particular PDO.
  582. OUT SERENUM_PORTION Portion;
  583. OUT USHORT NumberAxis; // legacy joysticks only
  584. USHORT Reserved [3];
  585. } SERENUM_PORT_PARAMETERS, *PSERENUM_PORT_PARAMETERS;
  586. #ifdef __cplusplus
  587. }
  588. #endif
  589. #endif // _NTDDSER_