]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/sys/termios.h
13e15d2fad4888bcef6ed7ced92ee8a184525f0d
[mirror_edk2.git] / StdLib / Include / sys / termios.h
1 /** @file
2 Macros and declarations for terminal oriented ioctls and
3 I/O discipline.
4
5 Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 * Copyright (c) 1988, 1989, 1993, 1994
15 * The Regents of the University of California. All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * @(#)termios.h 8.3 (Berkeley) 3/28/94
42 NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp
43 **/
44 #ifndef _SYS_TERMIOS_H_
45 #define _SYS_TERMIOS_H_
46
47 #include <sys/ansi.h>
48 #include <sys/featuretest.h>
49
50 /* Special Control Characters
51 *
52 * Index into c_cc[] character array.
53 */
54 typedef enum {
55 /* Name Enabled by */
56 VTABLEN, /* OXTABS - Length between TAB stops. */
57 VEOF, /* ICANON */
58 VEOL, /* ICANON */
59 VERASE, /* ICANON */
60 VKILL, /* ICANON */
61 VINTR, /* ISIG */
62 VQUIT, /* ISIG */
63 VMIN, /* !ICANON */
64 VTIME, /* !ICANON */
65
66 /* Extensions from BSD and POSIX -- Not yet implemented for UEFI */
67 VWERASE, /* IEXTEN, ICANON -- Erase the WORD to the left of the cursor */
68 VREPRINT, /* IEXTEN, ICANON -- Re-draw the current line (input buffer) */
69 VLNEXT, /* IEXTEN, ICANON -- Input the next character literally */
70 VDISCARD, /* IEXTEN -- Toggle. Discards output display until toggled. */
71
72 /* NCCS must always be the last member of this enum. */
73 NCCS /* Number of control characters in c_cc[] */
74 } CCC_INDEX;
75
76 #define _POSIX_VDISABLE ((unsigned char)'\377')
77
78 #define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0)
79
80 /*
81 * Input flags - software input processing
82 c_iflag
83 */
84 #define INLCR 0x0001 /* map NL into CR */
85 #define IGNCR 0x0002 /* ignore CR */
86 #define ICRNL 0x0004 /* map CR to NL (ala CRMOD) */
87 #define IGNSPEC 0x0008 /* Ignore function, control, and other non-printing special keys. */
88 #ifdef HAVE_DA_SERIAL
89 #define ISTRIP 0x0010 /* strip 8th bit off chars */
90 #define IGNBRK 0x0020 /* ignore BREAK condition */
91 #define BRKINT 0x0040 /* map BREAK to SIGINTR */
92 #define IRESRV1 0x0080
93 #define IGNPAR 0x0100 /* ignore (discard) parity errors */
94 #define PARMRK 0x0200 /* mark parity and framing errors */
95 #define INPCK 0x0400 /* enable checking of parity errors */
96 #define IXON 0x0800 /* enable output flow control */
97 #define IXOFF 0x1000 /* enable input flow control */
98 #define IXANY 0x2000 /* any char will restart after stop */
99 #endif /* HAVE_DA_SERIAL */
100
101 /*
102 * Output flags - software output processing
103 c_oflag
104 */
105 #define OPOST 0x0001 /* enable following output processing */
106 #define ONLCR 0x0002 /* map NL to CR-NL (ala CRMOD) */
107 #define OXTABS 0x0004 /* expand tabs to spaces */
108 #define ONOEOT 0x0008 /* discard EOT's (^D) on output */
109 #define OCRNL 0x0010 /* map CR to NL */
110 #define ONOCR 0x0020 /* discard CR's when on column 0 */
111 #define ONLRET 0x0040 /* move to column 0 on CR */
112 #define OCTRL 0x0080 /* Map control characters to the sequence ^C */
113
114 /*
115 * Control flags - hardware control of terminal
116 c_cflag
117 */
118 #ifdef HAVE_DA_SERIAL
119 #define CIGNORE 0x0001 /* ignore control flags */
120 #define CSIZE 0x0300 /* character size mask */
121 #define CS5 0x0000 /* 5 bits (pseudo) */
122 #define CS6 0x0100 /* 6 bits */
123 #define CS7 0x0200 /* 7 bits */
124 #define CS8 0x0300 /* 8 bits */
125 #define CSTOPB 0x0400 /* send 2 stop bits, else 1 */
126 #define CREAD 0x0800 /* enable receiver */
127 #define PARENB 0x1000 /* parity enable */
128 #define PARODD 0x2000 /* odd parity, else even */
129 #define HUPCL 0x4000 /* hang up on last close */
130 #define CLOCAL 0x8000 /* ignore modem status lines */
131 #endif
132
133
134 /*
135 * "Local" flags - dumping ground for other state
136 *
137 * Warning: some flags in this structure begin with
138 * the letter "I" and look like they belong in the
139 * input flag.
140 */
141 #define ECHO 0x0001 /* enable echoing */
142 #define ECHOE 0x0002 /* visually erase chars */
143 #define ECHOK 0x0004 /* echo NL after line kill */
144 #define ECHONL 0x0008 /* echo NL even if ECHO is off */
145 #define ISIG 0x0010 /* enable signals INTR, QUIT, [D]SUSP */
146 #define ICANON 0x0020 /* canonicalize input lines */
147 #define IEXTEN 0x0040 /* enable Extensions */
148 #define SKIP_1 0x0100 /* Currently unused */
149 #define TOSTOP 0x0200 /* stop background jobs on output */
150 #define PENDIN 0x0400 /* re-echo input buffer at next read */
151 #define NOFLSH 0x0800 /* don't flush output on signal */
152 #define FLUSHO 0x1000 /* output being flushed (state) */
153
154 typedef INT8 cc_t;
155 typedef UINT16 tcflag_t;
156 typedef UINT32 speed_t;
157
158 struct termios {
159 INT32 c_ispeed; /* input speed - Use a signed type instead of speed_t */
160 INT32 c_ospeed; /* output speed - to ease integer promotion when used. */
161 tcflag_t c_iflag; /* input flags */
162 tcflag_t c_oflag; /* output flags */
163 tcflag_t c_cflag; /* control flags */
164 tcflag_t c_lflag; /* local flags */
165 cc_t c_cc[NCCS]; /* control chars */
166 };
167
168 /*
169 * Commands passed to tcsetattr() for setting the termios structure.
170 */
171 #define TCSANOW 0 /* make change immediate */
172 #define TCSADRAIN 1 /* drain output, then change */
173 #define TCSAFLUSH 2 /* drain output, flush input */
174 #define TCSASOFT 0x10 /* flag - don't alter h.w. state */
175
176 /*
177 * Standard speeds
178 */
179 #define B0 0
180 #define B50 50
181 #define B75 75
182 #define B110 110
183 #define B134 134
184 #define B150 150
185 #define B200 200
186 #define B300 300
187 #define B600 600
188 #define B1200 1200
189 #define B1800 1800
190 #define B2400 2400
191 #define B4800 4800
192 #define B9600 9600
193 #define B19200 19200
194 #define B38400 38400
195
196 // Extended speed definitions
197 #define B7200 7200
198 #define B14400 14400
199 #define B28800 28800
200 #define B57600 57600
201 #define B76800 76800
202 #define B115200 115200
203 #define B230400 230400
204 #define B460800 460800
205 #define B921600 921600
206
207 #define TCIFLUSH 1
208 #define TCOFLUSH 2
209 #define TCIOFLUSH 3
210 #define TCOOFF 1
211 #define TCOON 2
212 #define TCIOFF 3
213 #define TCION 4
214
215 #include <sys/EfiCdefs.h>
216
217 __BEGIN_DECLS
218 speed_t cfgetispeed (const struct termios *);
219 speed_t cfgetospeed (const struct termios *);
220 int cfsetispeed (struct termios *, speed_t);
221 int cfsetospeed (struct termios *, speed_t);
222 int tcgetattr (int, struct termios *);
223 int tcsetattr (int, int, const struct termios *);
224 int tcdrain (int);
225 int tcflow (int, int);
226 int tcflush (int, int);
227 //int tcsendbreak (int, int);
228 //pid_t tcgetsid (int);
229
230
231 //void cfmakeraw (struct termios *);
232 //int cfsetspeed (struct termios *, speed_t);
233 __END_DECLS
234
235 /* Input values for UEFI Keyboard Scan Codes.
236
237 The UEFI Keyboard Scan Codes are mapped into the upper range of the Unicode
238 Private Use Area so that the characters can be inserted into the input stream
239 and treated the same as any other character.
240
241 These values are only used for input. If these codes are output to the
242 console, or another interactive I/O device, the behavior will depend upon
243 the current locale and UEFI character set loaded.
244 */
245 typedef enum {
246 TtySpecKeyMin = 0xF7F0,
247 /* This area is reserved for use by internal I/O software.
248 At least 4 values must exist between TtySpecKeyMin and TtyFunKeyMin.
249 */
250 TtyFunKeyMin = 0xF7FA,
251 TtyKeyEject = 0xF7FA,
252 TtyRecovery, TtyToggleDisplay, TtyHibernate,
253 TtySuspend, TtyBrightnessDown, TtyBrightnessUp,
254 TtyVolumeDown = 0xF87F,
255 TtyVolumeUp, TtyMute,
256 TtyF24 = 0xF88D,
257 TtyF23, TtyF22, TtyF21, TtyF20,
258 TtyF19, TtyF18, TtyF17, TtyF16,
259 TtyF15, TtyF14, TtyF13,
260 TtyEscape = 0xF8E9,
261 TtyF12, TtyF11, TtyF10, TtyF9,
262 TtyF8, TtyF7, TtyF6, TtyF5,
263 TtyF4, TtyF3, TtyF2, TtyF1,
264 TtyPageDown, TtyPageUp, TtyDelete, TtyInsert,
265 TtyEnd, TtyHome, TtyLeftArrow, TtyRightArrow,
266 TtyDownArrow,
267 TtyUpArrow = 0xF8FF,
268 TtyFunKeyMax = 0xF900
269 } TtyFunKey;
270
271 // Non-UEFI character definitions
272 #define CHAR_EOT 0x0004 /* End of Text (EOT) character */
273
274 #endif /* !_SYS_TERMIOS_H_ */