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