Initial commit - from Precise source
[freerdp-ubuntu-pcb-backport.git] / channels / rdpdr / serial / serial_constants.h
1 /**
2  * FreeRDP: A Remote Desktop Protocol client.
3  * Serial Port Device Service Virtual Channel
4  *
5  * Copyright 2011 O.S. Systems Software Ltda.
6  * Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #ifndef __SERIAL_CONSTANTS_H
22 #define __SERIAL_CONSTANTS_H
23
24 /* http://www.codeproject.com/KB/system/chaiyasit_t.aspx */
25 #define SERIAL_TIMEOUT_MAX 4294967295u
26
27 /* DR_CONTROL_REQ.IoControlCode */
28 enum DR_PORT_CONTROL_REQ
29 {
30         IOCTL_SERIAL_SET_BAUD_RATE = 0x001B0004,
31         IOCTL_SERIAL_GET_BAUD_RATE = 0x001B0050,
32         IOCTL_SERIAL_SET_LINE_CONTROL = 0x001B000C,
33         IOCTL_SERIAL_GET_LINE_CONTROL = 0x001B0054,
34         IOCTL_SERIAL_SET_TIMEOUTS = 0x001B001C,
35         IOCTL_SERIAL_GET_TIMEOUTS = 0x001B0020,
36
37 /* GET_CHARS and SET_CHARS are swapped in the RDP docs [MS-RDPESP] */
38         IOCTL_SERIAL_GET_CHARS = 0x001B0058,
39         IOCTL_SERIAL_SET_CHARS = 0x001B005C,
40
41         IOCTL_SERIAL_SET_DTR = 0x001B0024,
42         IOCTL_SERIAL_CLR_DTR = 0x001B0028,
43         IOCTL_SERIAL_RESET_DEVICE = 0x001B002C,
44         IOCTL_SERIAL_SET_RTS = 0x001B0030,
45         IOCTL_SERIAL_CLR_RTS = 0x001B0034,
46         IOCTL_SERIAL_SET_XOFF = 0x001B0038,
47         IOCTL_SERIAL_SET_XON = 0x001B003C,
48         IOCTL_SERIAL_SET_BREAK_ON = 0x001B0010,
49         IOCTL_SERIAL_SET_BREAK_OFF = 0x001B0014,
50         IOCTL_SERIAL_SET_QUEUE_SIZE = 0x001B0008,
51         IOCTL_SERIAL_GET_WAIT_MASK = 0x001B0040,
52         IOCTL_SERIAL_SET_WAIT_MASK = 0x001B0044,
53         IOCTL_SERIAL_WAIT_ON_MASK = 0x001B0048,
54         IOCTL_SERIAL_IMMEDIATE_CHAR = 0x001B0018,
55         IOCTL_SERIAL_PURGE = 0x001B004C,
56         IOCTL_SERIAL_GET_HANDFLOW = 0x001B0060,
57         IOCTL_SERIAL_SET_HANDFLOW = 0x001B0064,
58         IOCTL_SERIAL_GET_MODEMSTATUS = 0x001B0068,
59         IOCTL_SERIAL_GET_DTRRTS = 0x001B0078,
60
61 /* according to [MS-RDPESP] it should be 0x001B0084, but servers send 0x001B006C */
62         IOCTL_SERIAL_GET_COMMSTATUS = 0x001B006C,
63
64         IOCTL_SERIAL_GET_PROPERTIES = 0x001B0074,
65         IOCTL_SERIAL_XOFF_COUNTER = 0x001B0070,
66         IOCTL_SERIAL_LSRMST_INSERT = 0x001B007C,
67         IOCTL_SERIAL_CONFIG_SIZE = 0x001B0080,
68         IOCTL_SERIAL_GET_STATS = 0x001B008C,
69         IOCTL_SERIAL_CLEAR_STATS = 0x001B0090,
70         IOCTL_SERIAL_GET_MODEM_CONTROL = 0x001B0094,
71         IOCTL_SERIAL_SET_MODEM_CONTROL = 0x001B0098,
72         IOCTL_SERIAL_SET_FIFO_CONTROL = 0x001B009C,
73 };
74
75 enum SERIAL_PURGE_MASK
76 {
77         SERIAL_PURGE_TXABORT = 0x00000001,
78         SERIAL_PURGE_RXABORT = 0x00000002,
79         SERIAL_PURGE_TXCLEAR = 0x00000004,
80         SERIAL_PURGE_RXCLEAR = 0x00000008,
81 };
82
83 enum SERIAL_WAIT_MASK
84 {
85         SERIAL_EV_RXCHAR = 0x0001,      /* Any Character received */
86         SERIAL_EV_RXFLAG = 0x0002,      /* Received certain character */
87         SERIAL_EV_TXEMPTY = 0x0004,     /* Transmitt Queue Empty */
88         SERIAL_EV_CTS = 0x0008,         /* CTS changed state */
89         SERIAL_EV_DSR = 0x0010,         /* DSR changed state */
90         SERIAL_EV_RLSD = 0x0020,        /* RLSD changed state */
91         SERIAL_EV_BREAK = 0x0040,       /* BREAK received */
92         SERIAL_EV_ERR = 0x0080,         /* Line status error occurred */
93         SERIAL_EV_RING = 0x0100,        /* Ring signal detected */
94         SERIAL_EV_PERR = 0x0200,        /* Printer error occured */
95         SERIAL_EV_RX80FULL = 0x0400,/* Receive buffer is 80 percent full */
96         SERIAL_EV_EVENT1 = 0x0800,      /* Provider specific event 1 */
97         SERIAL_EV_EVENT2 = 0x1000,      /* Provider specific event 2 */
98 };
99
100 enum SERIAL_MODEM_STATUS
101 {
102         SERIAL_MS_DTR = 0x01,
103         SERIAL_MS_RTS = 0x02,
104         SERIAL_MS_CTS = 0x10,
105         SERIAL_MS_DSR = 0x20,
106         SERIAL_MS_RNG = 0x40,
107         SERIAL_MS_CAR = 0x80,
108 };
109
110 enum SERIAL_HANDFLOW
111 {
112         SERIAL_DTR_CONTROL = 0x01,
113         SERIAL_CTS_HANDSHAKE = 0x08,
114         SERIAL_ERROR_ABORT = 0x80000000,
115 };
116
117 enum SERIAL_FLOW_CONTROL
118 {
119         SERIAL_XON_HANDSHAKE = 0x01,
120         SERIAL_XOFF_HANDSHAKE = 0x02,
121         SERIAL_DSR_SENSITIVITY = 0x40,
122 };
123
124 enum SERIAL_CHARS
125 {
126         SERIAL_CHAR_EOF = 0,
127         SERIAL_CHAR_ERROR = 1,
128         SERIAL_CHAR_BREAK = 2,
129         SERIAL_CHAR_EVENT = 3,
130         SERIAL_CHAR_XON = 4,
131         SERIAL_CHAR_XOFF = 5,
132 };
133
134 enum SERIAL_ABORT_IO
135 {
136         SERIAL_ABORT_IO_NONE = 0,
137         SERIAL_ABORT_IO_WRITE = 1,
138         SERIAL_ABORT_IO_READ = 2,
139 };
140
141 enum SERIAL_STOP_BITS
142 {
143         SERIAL_STOP_BITS_1 = 0,
144         SERIAL_STOP_BITS_2 = 2,
145 };
146
147 enum SERIAL_PARITY
148 {
149         SERIAL_NO_PARITY = 0,
150         SERIAL_ODD_PARITY = 1,
151         SERIAL_EVEN_PARITY = 2,
152 };
153
154 #endif