]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/sys/termios.h
2 Macros and declarations for terminal oriented ioctls and
5 Copyright (c) 2016, Daryl McDaniel. All rights reserved.<BR>
6 Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials are licensed and made available under
8 the terms and conditions of the BSD License that accompanies this distribution.
9 The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 * Copyright (c) 1988, 1989, 1993, 1994
16 * The Regents of the University of California. All rights reserved.
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * 3. Neither the name of the University nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * @(#)termios.h 8.3 (Berkeley) 3/28/94
43 NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp
45 #ifndef _SYS_TERMIOS_H_
46 #define _SYS_TERMIOS_H_
49 #include <sys/featuretest.h>
51 /* Special Control Characters
53 * Index into c_cc[] character array.
57 VTABLEN
, /* OXTABS - Length between TAB stops. */
67 /* Extensions from BSD and POSIX -- Not yet implemented for UEFI */
68 VWERASE
, /* IEXTEN, ICANON -- Erase the WORD to the left of the cursor */
69 VREPRINT
, /* IEXTEN, ICANON -- Re-draw the current line (input buffer) */
70 VLNEXT
, /* IEXTEN, ICANON -- Input the next character literally */
71 VDISCARD
, /* IEXTEN -- Toggle. Discards output display until toggled. */
73 /* NCCS must always be the last member of this enum. */
74 NCCS
/* Number of control characters in c_cc[] */
77 #define _POSIX_VDISABLE ((unsigned char)'\377')
79 #define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0)
82 * Input flags - software input processing
85 #define INLCR 0x0001 /* map NL into CR */
86 #define IGNCR 0x0002 /* ignore CR */
87 #define ICRNL 0x0004 /* map CR to NL (ala CRMOD) */
88 #define IGNSPEC 0x0008 /* Ignore function, control, and other non-printing special keys. */
90 #define ISTRIP 0x0010 /* strip 8th bit off chars */
91 #define IGNBRK 0x0020 /* ignore BREAK condition */
92 #define BRKINT 0x0040 /* map BREAK to SIGINTR */
93 #define IRESRV1 0x0080
94 #define IGNPAR 0x0100 /* ignore (discard) parity errors */
95 #define PARMRK 0x0200 /* mark parity and framing errors */
96 #define INPCK 0x0400 /* enable checking of parity errors */
97 #define IXON 0x0800 /* enable output flow control */
98 #define IXOFF 0x1000 /* enable input flow control */
99 #define IXANY 0x2000 /* any char will restart after stop */
100 #endif /* HAVE_DA_SERIAL */
103 * Output flags - software output processing
106 #define OPOST 0x0001 /* enable following output processing */
107 #define ONLCR 0x0002 /* map NL to CR-NL (ala CRMOD) */
108 #define OXTABS 0x0004 /* expand tabs to spaces */
109 #define ONOEOT 0x0008 /* discard EOT's (^D) on output */
110 #define OCRNL 0x0010 /* map CR to NL */
111 #define ONOCR 0x0020 /* discard CR's when on column 0 */
112 #define ONLRET 0x0040 /* move to column 0 on CR */
113 #define OCTRL 0x0080 /* Map control characters to the sequence ^C */
116 * Control flags - hardware control of terminal
119 #ifdef HAVE_DA_SERIAL
120 #define CIGNORE 0x0001 /* ignore control flags */
121 #define CSIZE 0x0300 /* character size mask */
122 #define CS5 0x0000 /* 5 bits (pseudo) */
123 #define CS6 0x0100 /* 6 bits */
124 #define CS7 0x0200 /* 7 bits */
125 #define CS8 0x0300 /* 8 bits */
126 #define CSTOPB 0x0400 /* send 2 stop bits, else 1 */
127 #define CREAD 0x0800 /* enable receiver */
128 #define PARENB 0x1000 /* parity enable */
129 #define PARODD 0x2000 /* odd parity, else even */
130 #define HUPCL 0x4000 /* hang up on last close */
131 #define CLOCAL 0x8000 /* ignore modem status lines */
136 * "Local" flags - dumping ground for other state
138 * Warning: some flags in this structure begin with
139 * the letter "I" and look like they belong in the
142 #define ECHO 0x0001 /* enable echoing */
143 #define ECHOE 0x0002 /* visually erase chars */
144 #define ECHOK 0x0004 /* echo NL after line kill */
145 #define ECHONL 0x0008 /* echo NL even if ECHO is off */
146 #define ISIG 0x0010 /* enable signals INTR, QUIT, [D]SUSP */
147 #define ICANON 0x0020 /* canonicalize input lines */
148 #define IEXTEN 0x0040 /* enable Extensions */
149 #define SKIP_1 0x0100 /* Currently unused */
150 #define TOSTOP 0x0200 /* stop background jobs on output */
151 #define PENDIN 0x0400 /* re-echo input buffer at next read */
152 #define NOFLSH 0x0800 /* don't flush output on signal */
153 #define FLUSHO 0x1000 /* output being flushed (state) */
156 typedef UINT16 tcflag_t
;
157 typedef UINT32 speed_t
;
160 INT32 c_ispeed
; /* input speed - Use a signed type instead of speed_t */
161 INT32 c_ospeed
; /* output speed - to ease integer promotion when used. */
162 tcflag_t c_iflag
; /* input flags */
163 tcflag_t c_oflag
; /* output flags */
164 tcflag_t c_cflag
; /* control flags */
165 tcflag_t c_lflag
; /* local flags */
166 cc_t c_cc
[NCCS
]; /* control chars */
170 * Commands passed to tcsetattr() for setting the termios structure.
172 #define TCSANOW 0 /* make change immediate */
173 #define TCSADRAIN 1 /* drain output, then change */
174 #define TCSAFLUSH 2 /* drain output, flush input */
175 #define TCSASOFT 0x10 /* flag - don't alter h.w. state */
197 // Extended speed definitions
203 #define B115200 115200
204 #define B230400 230400
205 #define B460800 460800
206 #define B921600 921600
216 #include <sys/EfiCdefs.h>
220 /** Get input baud rate.
222 Extracts the input baud rate from the termios structure pointed to by the
225 @param[in] pTermios A pointer to the termios structure from which to extract
228 @return The value of the input speed is returned exactly as it is contained
229 in the termios structure, without interpretation.
231 speed_t
cfgetispeed (const struct termios
*);
233 /** Get output baud rate.
235 Extracts the output baud rate from the termios structure pointed to by the
238 @param[in] pTermios A pointer to the termios structure from which to extract
239 the output baud rate.
241 @return The value of the output speed is returned exactly as it is contained
242 in the termios structure, without interpretation.
244 speed_t
cfgetospeed (const struct termios
*);
246 /** Set input baud rate.
248 Replaces the input baud rate, in the termios structure pointed to by the
249 pTermios argument, with the value of NewSpeed.
251 @param[out] pTermios A pointer to the termios structure into which to set
253 @param[in] NewSpeed The new input baud rate.
255 @retval 0 The operation completed successfully.
256 @retval -1 An error occured and errno is set to indicate the error.
257 * EINVAL - The value of NewSpeed is outside the range of
258 possible speed values as specified in <sys/termios.h>.
260 int cfsetispeed (struct termios
*, speed_t
);
262 /** Set output baud rate.
264 Replaces the output baud rate, in the termios structure pointed to by the
265 pTermios argument, with the value of NewSpeed.
267 @param[out] pTermios A pointer to the termios structure into which to set
268 the output baud rate.
269 @param[in] NewSpeed The new output baud rate.
271 @retval 0 The operation completed successfully.
272 @retval -1 An error occured and errno is set to indicate the error.
273 * EINVAL - The value of NewSpeed is outside the range of
274 possible speed values as specified in <sys/termios.h>.
276 int cfsetospeed (struct termios
*, speed_t
);
278 /** Get the parameters associated with an interactive IO device.
280 Get the parameters associated with the device referred to by
281 fd and store them into the termios structure referenced by pTermios.
283 @param[in] fd The file descriptor for an open interactive IO device.
284 @param[out] pTermios A pointer to a termios structure into which to store
285 attributes of the interactive IO device.
287 @retval 0 The operation completed successfully.
288 @retval -1 An error occured and errno is set to indicate the error.
289 * EBADF - The fd argument is not a valid file descriptor.
290 * ENOTTY - The file associated with fd is not an interactive IO device.
292 int tcgetattr (int fd
, struct termios
*pTermios
);
294 /** Set the parameters associated with an interactive IO device.
296 Set the parameters associated with the device referred to by
297 fd to the values in the termios structure referenced by pTermios.
299 Behavior is modified by the value of the OptAct parameter:
300 * TCSANOW: The change shall occur immediately.
301 * TCSADRAIN: The change shall occur after all output written to fd is
302 transmitted. This action should be used when changing parameters which
304 * TCSAFLUSH: The change shall occur after all output written to fd is
305 transmitted, and all input so far received but not read shall be
306 discarded before the change is made.
308 @param[in] fd The file descriptor for an open interactive IO device.
309 @param[in] OptAct Currently has no effect.
310 @param[in] pTermios A pointer to a termios structure into which to retrieve
311 attributes to set in the interactive IO device.
313 @retval 0 The operation completed successfully.
314 @retval -1 An error occured and errno is set to indicate the error.
315 * EBADF - The fd argument is not a valid file descriptor.
316 * ENOTTY - The file associated with fd is not an interactive IO device.
318 int tcsetattr (int fd
, int OptAct
, const struct termios
*pTermios
);
320 /** Transmit pending output.
323 @param[in] fd The file descriptor for an open interactive IO device.
325 @retval 0 The operation completed successfully.
326 @retval -1 An error occured and errno is set to indicate the error.
327 * EBADF - The fd argument is not a valid file descriptor.
328 * ENOTTY - The file associated with fd is not an interactive IO device.
329 * EINTR - A signal interrupted tcdrain().
330 * ENOTSUP - This function is not supported.
332 int tcdrain (int fd
);
334 /** Suspend or restart the transmission or reception of data.
336 This function will suspend or resume transmission or reception of data on
337 the file referred to by fd, depending on the value of Action.
339 @param[in] fd The file descriptor of an open interactive IO device (terminal).
340 @param[in] Action The action to be performed:
341 * TCOOFF - Suspend output.
342 * TCOON - Resume suspended output.
343 * TCIOFF - If fd refers to an IIO device, transmit a
344 STOP character, which is intended to cause the
345 terminal device to stop transmitting data.
346 * TCION - If fd refers to an IIO device, transmit a
347 START character, which is intended to cause the
348 terminal device to start transmitting data.
350 @retval 0 The operation completed successfully.
351 @retval -1 An error occured and errno is set to indicate the error.
352 * EBADF - The fd argument is not a valid file descriptor.
353 * ENOTTY - The file associated with fd is not an interactive IO device.
354 * EINVAL - The Action argument is not a supported value.
355 * ENOTSUP - This function is not supported.
357 int tcflow (int fd
, int Action
);
359 /** Discard non-transmitted output data, non-read input data, or both.
362 @param[in] fd The file descriptor for an open interactive IO device.
363 @param[in] QueueSelector The IO queue to be affected:
364 * TCIFLUSH - If fd refers to a device open for input, flush
365 pending input. Otherwise error EINVAL.
366 * TCOFLUSH - If fd refers to a device open for output,
367 flush pending output. Otherwise error EINVAL.
368 * TCIOFLUSH - If fd refers to a device open for both
369 input and output, flush pending input and output.
370 Otherwise error EINVAL.
372 @retval 0 The operation completed successfully.
373 @retval -1 An error occured and errno is set to indicate the error.
374 * EBADF - The fd argument is not a valid file descriptor.
375 * ENOTTY - The file associated with fd is not an interactive IO device.
376 * EINVAL - The QueueSelector argument is not a supported value.
377 * ENOTSUP - This function is not supported.
379 int tcflush (int fd
, int QueueSelector
);
381 //int tcsendbreak (int, int);
382 //pid_t tcgetsid (int);
384 //void cfmakeraw (struct termios *);
385 //int cfsetspeed (struct termios *, speed_t);
388 /* Input values for UEFI Keyboard Scan Codes.
390 The UEFI Keyboard Scan Codes are mapped into the upper range of the Unicode
391 Private Use Area so that the characters can be inserted into the input stream
392 and treated the same as any other character.
394 These values are only used for input. If these codes are output to the
395 console, or another interactive I/O device, the behavior will depend upon
396 the current locale and UEFI character set loaded.
399 TtySpecKeyMin
= 0xF7F0,
400 /* This area is reserved for use by internal I/O software.
401 At least 4 values must exist between TtySpecKeyMin and TtyFunKeyMin.
403 TtyFunKeyMin
= 0xF7FA,
404 TtyKeyEject
= 0xF7FA,
405 TtyRecovery
, TtyToggleDisplay
, TtyHibernate
,
406 TtySuspend
, TtyBrightnessDown
, TtyBrightnessUp
,
407 TtyVolumeDown
= 0xF87F,
408 TtyVolumeUp
, TtyMute
,
410 TtyF23
, TtyF22
, TtyF21
, TtyF20
,
411 TtyF19
, TtyF18
, TtyF17
, TtyF16
,
412 TtyF15
, TtyF14
, TtyF13
,
414 TtyF12
, TtyF11
, TtyF10
, TtyF9
,
415 TtyF8
, TtyF7
, TtyF6
, TtyF5
,
416 TtyF4
, TtyF3
, TtyF2
, TtyF1
,
417 TtyPageDown
, TtyPageUp
, TtyDelete
, TtyInsert
,
418 TtyEnd
, TtyHome
, TtyLeftArrow
, TtyRightArrow
,
421 TtyFunKeyMax
= 0xF900
424 // Non-UEFI character definitions
425 #define CHAR_EOT 0x0004 /* End of Text (EOT) character -- Unix End-of-File character */
426 #define CHAR_SUB 0x001a /* MSDOS End-of-File character */
427 #define CHAR_ESC 0x001b /* Escape (ESC) character */
429 #endif /* !_SYS_TERMIOS_H_ */