2 * DDK definitions for serial port
4 * Copyright (C) 2006 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #define IOCTL_SERIAL_CLEAR_STATS \
30 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 36, METHOD_BUFFERED, FILE_ANY_ACCESS)
31 #define IOCTL_SERIAL_CLR_DTR \
32 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
33 #define IOCTL_SERIAL_CLR_RTS \
34 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
35 #define IOCTL_SERIAL_CONFIG_SIZE \
36 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 32, METHOD_BUFFERED, FILE_ANY_ACCESS)
37 #define IOCTL_SERIAL_GET_BAUD_RATE \
38 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
39 #define IOCTL_SERIAL_GET_CHARS \
40 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
41 #define IOCTL_SERIAL_GET_COMMSTATUS \
42 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 27, METHOD_BUFFERED, FILE_ANY_ACCESS)
43 #define IOCTL_SERIAL_GET_DTRRTS \
44 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
45 #define IOCTL_SERIAL_GET_HANDFLOW \
46 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 24, METHOD_BUFFERED, FILE_ANY_ACCESS)
47 #define IOCTL_SERIAL_GET_LINE_CONTROL \
48 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
49 #define IOCTL_SERIAL_GET_MODEM_CONTROL \
50 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 37, METHOD_BUFFERED, FILE_ANY_ACCESS)
51 #define IOCTL_SERIAL_GET_MODEMSTATUS \
52 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 26, METHOD_BUFFERED, FILE_ANY_ACCESS)
53 #define IOCTL_SERIAL_GET_PROPERTIES \
54 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 29, METHOD_BUFFERED, FILE_ANY_ACCESS)
55 #define IOCTL_SERIAL_GET_STATS \
56 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 35, METHOD_BUFFERED, FILE_ANY_ACCESS)
57 #define IOCTL_SERIAL_GET_TIMEOUTS \
58 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
59 #define IOCTL_SERIAL_GET_WAIT_MASK \
60 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 16, METHOD_BUFFERED, FILE_ANY_ACCESS)
61 #define IOCTL_SERIAL_IMMEDIATE_CHAR \
62 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
63 #ifndef IOCTL_SERIAL_LSRMST_INSERT
64 /* it's already defined in winioctl.h */
65 #define IOCTL_SERIAL_LSRMST_INSERT \
66 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 31, METHOD_BUFFERED, FILE_ANY_ACCESS)
68 #define IOCTL_SERIAL_PURGE \
69 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 19, METHOD_BUFFERED, FILE_ANY_ACCESS)
70 #define IOCTL_SERIAL_RESET_DEVICE \
71 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
72 #define IOCTL_SERIAL_SET_BAUD_RATE \
73 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
74 #define IOCTL_SERIAL_SET_BREAK_ON \
75 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
76 #define IOCTL_SERIAL_SET_BREAK_OFF \
77 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
78 #define IOCTL_SERIAL_SET_CHARS \
79 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
80 #define IOCTL_SERIAL_SET_DTR \
81 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
82 #define IOCTL_SERIAL_SET_FIFO_CONTROL \
83 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 39, METHOD_BUFFERED, FILE_ANY_ACCESS)
84 #define IOCTL_SERIAL_SET_HANDFLOW \
85 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
86 #define IOCTL_SERIAL_SET_LINE_CONTROL \
87 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
88 #define IOCTL_SERIAL_SET_MODEM_CONTROL \
89 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 38, METHOD_BUFFERED, FILE_ANY_ACCESS)
90 #define IOCTL_SERIAL_SET_QUEUE_SIZE \
91 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
92 #define IOCTL_SERIAL_SET_RTS \
93 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
94 #define IOCTL_SERIAL_SET_TIMEOUTS \
95 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
96 #define IOCTL_SERIAL_SET_WAIT_MASK \
97 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
98 #define IOCTL_SERIAL_SET_XOFF \
99 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 14, METHOD_BUFFERED, FILE_ANY_ACCESS)
100 #define IOCTL_SERIAL_SET_XON \
101 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
102 #define IOCTL_SERIAL_WAIT_ON_MASK \
103 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 18, METHOD_BUFFERED, FILE_ANY_ACCESS)
104 #define IOCTL_SERIAL_XOFF_COUNTER \
105 CTL_CODE (FILE_DEVICE_SERIAL_PORT, 28, METHOD_BUFFERED, FILE_ANY_ACCESS)
107 typedef struct _SERIAL_BAUD_RATE
110 } SERIAL_BAUD_RATE
, *PSERIAL_BAUD_RATE
;
112 /* SERIAL_BAUD_RATE.BaudRate constants */
113 #define SERIAL_BAUD_075 0x00000001
114 #define SERIAL_BAUD_110 0x00000002
115 #define SERIAL_BAUD_134_5 0x00000004
116 #define SERIAL_BAUD_150 0x00000008
117 #define SERIAL_BAUD_300 0x00000010
118 #define SERIAL_BAUD_600 0x00000020
119 #define SERIAL_BAUD_1200 0x00000040
120 #define SERIAL_BAUD_1800 0x00000080
121 #define SERIAL_BAUD_2400 0x00000100
122 #define SERIAL_BAUD_4800 0x00000200
123 #define SERIAL_BAUD_7200 0x00000400
124 #define SERIAL_BAUD_9600 0x00000800
125 #define SERIAL_BAUD_14400 0x00001000
126 #define SERIAL_BAUD_19200 0x00002000
127 #define SERIAL_BAUD_38400 0x00004000
128 #define SERIAL_BAUD_56K 0x00008000
129 #define SERIAL_BAUD_128K 0x00010000
130 #define SERIAL_BAUD_115200 0x00020000
131 #define SERIAL_BAUD_57600 0x00040000
132 #define SERIAL_BAUD_USER 0x10000000
134 typedef struct _SERIAL_CHARS
142 } SERIAL_CHARS
, *PSERIAL_CHARS
;
144 typedef struct _SERIAL_STATUS
148 ULONG AmountInInQueue
;
149 ULONG AmountInOutQueue
;
151 BOOLEAN WaitForImmediate
;
152 } SERIAL_STATUS
, *PSERIAL_STATUS
;
154 typedef struct _SERIAL_HANDFLOW
156 ULONG ControlHandShake
;
160 } SERIAL_HANDFLOW
, *PSERIAL_HANDFLOW
;
162 #define SERIAL_DTR_MASK 0x00000003
163 #define SERIAL_DTR_CONTROL 0x00000001
164 #define SERIAL_DTR_HANDSHAKE 0x00000002
165 #define SERIAL_CTS_HANDSHAKE 0x00000008
166 #define SERIAL_DSR_HANDSHAKE 0x00000010
167 #define SERIAL_DCD_HANDSHAKE 0x00000020
168 #define SERIAL_OUT_HANDSHAKEMASK 0x00000038
169 #define SERIAL_DSR_SENSITIVITY 0x00000040
170 #define SERIAL_ERROR_ABORT 0x80000000
171 #define SERIAL_CONTROL_INVALID 0x7fffff84
172 #define SERIAL_AUTO_TRANSMIT 0x00000001
173 #define SERIAL_AUTO_RECEIVE 0x00000002
174 #define SERIAL_ERROR_CHAR 0x00000004
175 #define SERIAL_NULL_STRIPPING 0x00000008
176 #define SERIAL_BREAK_CHAR 0x00000010
177 #define SERIAL_RTS_MASK 0x000000c0
178 #define SERIAL_RTS_CONTROL 0x00000040
179 #define SERIAL_RTS_HANDSHAKE 0x00000080
180 #define SERIAL_TRANSMIT_TOGGLE 0x000000c0
181 #define SERIAL_XOFF_CONTINUE 0x80000000
182 #define SERIAL_FLOW_INVALID 0x7fffff20
184 typedef struct _SERIAL_LINE_CONTROL
189 } SERIAL_LINE_CONTROL
, *PSERIAL_LINE_CONTROL
;
191 /* SERIAL_LINE_CONTROL.StopBits constants */
192 #define STOP_BIT_1 0x00
193 #define STOP_BITS_1_5 0x01
194 #define STOP_BITS_2 0x02
196 /* SERIAL_LINE_CONTROL.Parity constants */
197 #define NO_PARITY 0x00
198 #define ODD_PARITY 0x01
199 #define EVEN_PARITY 0x02
200 #define MARK_PARITY 0x03
201 #define SPACE_PARITY 0x04
203 /* IOCTL_SERIAL_(GET_MODEM_CONTROL, SET_MODEM_CONTROL) flags */
204 #define SERIAL_IOC_MCR_DTR 0x00000001
205 #define SERIAL_IOC_MCR_RTS 0x00000002
206 #define SERIAL_IOC_MCR_OUT1 0x00000004
207 #define SERIAL_IOC_MCR_OUT2 0x00000008
208 #define SERIAL_IOC_MCR_LOOP 0x00000010
210 typedef struct _SERIAL_COMMPROP
213 USHORT PacketVersion
;
220 ULONG ProvCapabilities
;
221 ULONG SettableParams
;
224 USHORT SettableStopParity
;
225 ULONG CurrentTxQueue
;
226 ULONG CurrentRxQueue
;
230 } SERIAL_COMMPROP
, *PSERIAL_COMMPROP
;
232 /* SERIAL_COMMPROP.SettableParams flags */
233 #define SERIAL_SP_PARITY 0x0001
234 #define SERIAL_SP_BAUD 0x0002
235 #define SERIAL_SP_DATABITS 0x0004
236 #define SERIAL_SP_STOPBITS 0x0008
237 #define SERIAL_SP_HANDSHAKING 0x0010
238 #define SERIAL_SP_PARITY_CHECK 0x0020
239 #define SERIAL_SP_CARRIER_DETECT 0x0040
241 /* SERIAL_COMMPROP.ProvCapabilities flags */
242 #define SERIAL_PCF_DTRDSR 0x00000001
243 #define SERIAL_PCF_RTSCTS 0x00000002
244 #define SERIAL_PCF_CD 0x00000004
245 #define SERIAL_PCF_PARITY_CHECK 0x00000008
246 #define SERIAL_PCF_XONXOFF 0x00000010
247 #define SERIAL_PCF_SETXCHAR 0x00000020
248 #define SERIAL_PCF_TOTALTIMEOUTS 0x00000040
249 #define SERIAL_PCF_INTTIMEOUTS 0x00000080
250 #define SERIAL_PCF_SPECIALCHARS 0x00000100
251 #define SERIAL_PCF_16BITMODE 0x00000200
253 /* SERIAL_COMMPROP.SettableData flags */
254 #define SERIAL_DATABITS_5 0x0001
255 #define SERIAL_DATABITS_6 0x0002
256 #define SERIAL_DATABITS_7 0x0004
257 #define SERIAL_DATABITS_8 0x0008
258 #define SERIAL_DATABITS_16 0x0010
259 #define SERIAL_DATABITS_16X 0x0020
261 /* SERIAL_COMMPROP.SettableStopParity flags */
262 #define SERIAL_STOPBITS_10 0x0001
263 #define SERIAL_STOPBITS_15 0x0002
264 #define SERIAL_STOPBITS_20 0x0004
265 #define SERIAL_PARITY_NONE 0x0100
266 #define SERIAL_PARITY_ODD 0x0200
267 #define SERIAL_PARITY_EVEN 0x0400
268 #define SERIAL_PARITY_MARK 0x0800
269 #define SERIAL_PARITY_SPACE 0x1000
271 typedef struct _SERIALPERF_STATS
274 ULONG TransmittedCount
;
275 ULONG FrameErrorCount
;
276 ULONG SerialOverrunErrorCount
;
277 ULONG BufferOverrunErrorCount
;
278 ULONG ParityErrorCount
;
279 } SERIALPERF_STATS
, *PSERIALPERF_STATS
;
281 typedef struct _SERIAL_TIMEOUTS
283 ULONG ReadIntervalTimeout
;
284 ULONG ReadTotalTimeoutMultiplier
;
285 ULONG ReadTotalTimeoutConstant
;
286 ULONG WriteTotalTimeoutMultiplier
;
287 ULONG WriteTotalTimeoutConstant
;
288 } SERIAL_TIMEOUTS
, *PSERIAL_TIMEOUTS
;
290 /* IOCTL_SERIAL_(GET_WAIT_MASK, SET_WAIT_MASK, WAIT_ON_MASK) flags */
291 #define SERIAL_EV_RXCHAR 0x0001
292 #define SERIAL_EV_RXFLAG 0x0002
293 #define SERIAL_EV_TXEMPTY 0x0004
294 #define SERIAL_EV_CTS 0x0008
295 #define SERIAL_EV_DSR 0x0010
296 #define SERIAL_EV_RLSD 0x0020
297 #define SERIAL_EV_BREAK 0x0040
298 #define SERIAL_EV_ERR 0x0080
299 #define SERIAL_EV_RING 0x0100
300 #define SERIAL_EV_PERR 0x0200
301 #define SERIAL_EV_RX80FULL 0x0400
302 #define SERIAL_EV_EVENT1 0x0800
303 #define SERIAL_EV_EVENT2 0x1000
305 /* IOCTL_SERIAL_LSRMST_INSERT constants */
306 #define SERIAL_LSRMST_LSR_DATA 0x01
307 #define SERIAL_LSRMST_LSR_NODATA 0x02
308 #define SERIAL_LSRMST_MST 0x03
309 #define SERIAL_LSRMST_ESCAPE 0x00
311 /* IOCTL_SERIAL_PURGE constants */
312 #define SERIAL_PURGE_TXABORT 0x00000001
313 #define SERIAL_PURGE_RXABORT 0x00000002
314 #define SERIAL_PURGE_TXCLEAR 0x00000004
315 #define SERIAL_PURGE_RXCLEAR 0x00000008
317 /* IOCTL_SERIAL_SET_FIFO_CONTROL constants */
318 #define SERIAL_IOC_FCR_FIFO_ENABLE 0x00000001
319 #define SERIAL_IOC_FCR_RCVR_RESET 0x00000002
320 #define SERIAL_IOC_FCR_XMIT_RESET 0x00000004
321 #define SERIAL_IOC_FCR_DMA_MODE 0x00000008
322 #define SERIAL_IOC_FCR_RES1 0x00000010
323 #define SERIAL_IOC_FCR_RES2 0x00000020
324 #define SERIAL_IOC_FCR_RCVR_TRIGGER_LSB 0x00000040
325 #define SERIAL_IOC_FCR_RCVR_TRIGGER_MSB 0x00000080
327 typedef struct _SERIAL_QUEUE_SIZE
331 } SERIAL_QUEUE_SIZE
, *PSERIAL_QUEUE_SIZE
;
333 typedef struct _SERIAL_XOFF_COUNTER
338 } SERIAL_XOFF_COUNTER
, *PSERIAL_XOFF_COUNTER
;
340 typedef struct _SERIAL_BASIC_SETTINGS
342 SERIAL_TIMEOUTS Timeouts
;
343 SERIAL_HANDFLOW HandFlow
;
346 } SERIAL_BASIC_SETTINGS
, *PSERIAL_BASIC_SETTINGS
;
348 #define SERIAL_ERROR_BREAK 0x00000001
349 #define SERIAL_ERROR_FRAMING 0x00000002
350 #define SERIAL_ERROR_OVERRUN 0x00000004
351 #define SERIAL_ERROR_QUEUEOVERRUN 0x00000008
352 #define SERIAL_ERROR_PARITY 0x00000010
354 #define SERIAL_SP_UNSPECIFIED 0x00000000
355 #define SERIAL_SP_RS232 0x00000001
356 #define SERIAL_SP_PARALLEL 0x00000002
357 #define SERIAL_SP_RS422 0x00000003
358 #define SERIAL_SP_RS423 0x00000004
359 #define SERIAL_SP_RS449 0x00000005
360 #define SERIAL_SP_MODEM 0X00000006
361 #define SERIAL_SP_FAX 0x00000021
362 #define SERIAL_SP_SCANNER 0x00000022
363 #define SERIAL_SP_BRIDGE 0x00000100
364 #define SERIAL_SP_LAT 0x00000101
365 #define SERIAL_SP_TELNET 0x00000102
366 #define SERIAL_SP_X25 0x00000103
367 #define SERIAL_SP_SERIALCOMM 0x00000001
369 #define SERIAL_TX_WAITING_FOR_CTS 0x00000001
370 #define SERIAL_TX_WAITING_FOR_DSR 0x00000002
371 #define SERIAL_TX_WAITING_FOR_DCD 0x00000004
372 #define SERIAL_TX_WAITING_FOR_XON 0x00000008
373 #define SERIAL_TX_WAITING_XOFF_SENT 0x00000010
374 #define SERIAL_TX_WAITING_ON_BREAK 0x00000020
375 #define SERIAL_RX_WAITING_FOR_DSR 0x00000040
377 #define SERIAL_DTR_STATE 0x00000001
378 #define SERIAL_RTS_STATE 0x00000002
379 #define SERIAL_CTS_STATE 0x00000010
380 #define SERIAL_DSR_STATE 0x00000020
381 #define SERIAL_RI_STATE 0x00000040
382 #define SERIAL_DCD_STATE 0x00000080
384 typedef struct _SERIALCONFIG
391 WCHAR ProviderData
[1];
392 } SERIALCONFIG
,*PSERIALCONFIG
;
398 #endif /* _NTDDSER_H_ */