]> git.proxmox.com Git - mirror_edk2.git/blobdiff - 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
index b1373dea2b549e83c5c749d24fd9a7245f29a2d2..13e15d2fad4888bcef6ed7ced92ee8a184525f0d 100644 (file)
@@ -1,6 +1,16 @@
-/*  $NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp $  */\r
+/** @file\r
+    Macros and declarations for terminal oriented ioctls and\r
+    I/O discipline.\r
+\r
+    Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
+    This program and the accompanying materials are licensed and made available under\r
+    the terms and conditions of the BSD License that accompanies this distribution.\r
+    The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-/*\r
  * Copyright (c) 1988, 1989, 1993, 1994\r
  *  The Regents of the University of California.  All rights reserved.\r
  *\r
  * SUCH DAMAGE.\r
  *\r
  *  @(#)termios.h 8.3 (Berkeley) 3/28/94\r
- */\r
-\r
+    NetBSD: termios.h,v 1.29 2005/12/11 12:25:21 christos Exp\r
+**/\r
 #ifndef _SYS_TERMIOS_H_\r
 #define _SYS_TERMIOS_H_\r
 \r
 #include <sys/ansi.h>\r
 #include <sys/featuretest.h>\r
 \r
-/*\r
- * Special Control Characters\r
+/*  Special Control Characters\r
  *\r
  * Index into c_cc[] character array.\r
- *\r
- *  Name       Subscript  Enabled by\r
  */\r
-#define VEOF    0 /* ICANON */\r
-#define VEOL    1 /* ICANON */\r
-#if defined(_NETBSD_SOURCE)\r
-#define VEOL2   2 /* ICANON */\r
-#endif\r
-#define VERASE    3 /* ICANON */\r
-#if defined(_NETBSD_SOURCE)\r
-#define VWERASE   4 /* ICANON */\r
-#endif\r
-#define VKILL   5 /* ICANON */\r
-#if defined(_NETBSD_SOURCE)\r
-#define VREPRINT  6 /* ICANON */\r
-#endif\r
-/*      7    spare 1 */\r
-#define VINTR   8 /* ISIG */\r
-#define VQUIT   9 /* ISIG */\r
-#define VSUSP   10  /* ISIG */\r
-#if defined(_NETBSD_SOURCE)\r
-#define VDSUSP    11  /* ISIG */\r
-#endif\r
-#define VSTART    12  /* IXON, IXOFF */\r
-#define VSTOP   13  /* IXON, IXOFF */\r
-#if defined(_NETBSD_SOURCE)\r
-#define VLNEXT    14  /* IEXTEN */\r
-#define VDISCARD  15  /* IEXTEN */\r
-#endif\r
-#define VMIN    16  /* !ICANON */\r
-#define VTIME   17  /* !ICANON */\r
-#if defined(_NETBSD_SOURCE)\r
-#define VSTATUS   18  /* ICANON */\r
-/*      19     spare 2 */\r
-#endif\r
-#define NCCS    20\r
+typedef enum {\r
+/* Name     Enabled by */\r
+  VTABLEN,  /* OXTABS - Length between TAB stops. */\r
+  VEOF,     /* ICANON */\r
+  VEOL,     /* ICANON */\r
+  VERASE,   /* ICANON */\r
+  VKILL,    /* ICANON */\r
+  VINTR,    /* ISIG */\r
+  VQUIT,    /* ISIG */\r
+  VMIN,     /* !ICANON */\r
+  VTIME,    /* !ICANON */\r
+\r
+  /* Extensions from BSD and POSIX -- Not yet implemented for UEFI */\r
+  VWERASE,   /* IEXTEN, ICANON -- Erase the WORD to the left of the cursor */\r
+  VREPRINT,  /* IEXTEN, ICANON -- Re-draw the current line (input buffer) */\r
+  VLNEXT,    /* IEXTEN, ICANON -- Input the next character literally */\r
+  VDISCARD,  /* IEXTEN -- Toggle.  Discards output display until toggled. */\r
+\r
+  /* NCCS must always be the last member of this enum. */\r
+  NCCS      /* Number of control characters in c_cc[]  */\r
+} CCC_INDEX;\r
 \r
 #define _POSIX_VDISABLE ((unsigned char)'\377')\r
 \r
-#if defined(_NETBSD_SOURCE)\r
 #define CCEQ(val, c)  (c == val ? val != _POSIX_VDISABLE : 0)\r
-#endif\r
 \r
 /*\r
  * Input flags - software input processing\r
- */\r
-#define IGNBRK    0x00000001  /* ignore BREAK condition */\r
-#define BRKINT    0x00000002  /* map BREAK to SIGINTR */\r
-#define IGNPAR    0x00000004  /* ignore (discard) parity errors */\r
-#define PARMRK    0x00000008  /* mark parity and framing errors */\r
-#define INPCK   0x00000010  /* enable checking of parity errors */\r
-#define ISTRIP    0x00000020  /* strip 8th bit off chars */\r
-#define INLCR   0x00000040  /* map NL into CR */\r
-#define IGNCR   0x00000080  /* ignore CR */\r
-#define ICRNL   0x00000100  /* map CR to NL (ala CRMOD) */\r
-#define IXON    0x00000200  /* enable output flow control */\r
-#define IXOFF   0x00000400  /* enable input flow control */\r
-#if defined(_NETBSD_SOURCE)\r
-#define IXANY   0x00000800  /* any char will restart after stop */\r
-#endif\r
-#if defined(_NETBSD_SOURCE)\r
-#define IMAXBEL   0x00002000  /* ring bell on input queue full */\r
-#endif\r
+  c_iflag\r
+*/\r
+#define   INLCR     0x0001  /* map NL into CR */\r
+#define   IGNCR     0x0002  /* ignore CR */\r
+#define   ICRNL     0x0004  /* map CR to NL (ala CRMOD) */\r
+#define   IGNSPEC   0x0008  /* Ignore function, control, and other non-printing special keys. */\r
+#ifdef  HAVE_DA_SERIAL\r
+  #define ISTRIP    0x0010  /* strip 8th bit off chars */\r
+  #define IGNBRK    0x0020  /* ignore BREAK condition */\r
+  #define BRKINT    0x0040  /* map BREAK to SIGINTR */\r
+  #define IRESRV1   0x0080\r
+  #define IGNPAR    0x0100  /* ignore (discard) parity errors */\r
+  #define PARMRK    0x0200  /* mark parity and framing errors */\r
+  #define INPCK     0x0400  /* enable checking of parity errors */\r
+  #define IXON      0x0800  /* enable output flow control */\r
+  #define IXOFF     0x1000  /* enable input flow control */\r
+  #define IXANY     0x2000  /* any char will restart after stop */\r
+#endif  /* HAVE_DA_SERIAL */\r
 \r
 /*\r
  * Output flags - software output processing\r
+  c_oflag\r
  */\r
-#define OPOST   0x00000001  /* enable following output processing */\r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-#define ONLCR   0x00000002  /* map NL to CR-NL (ala CRMOD) */\r
-#endif\r
-#if defined(_NETBSD_SOURCE)\r
-#define OXTABS    0x00000004  /* expand tabs to spaces */\r
-#define ONOEOT    0x00000008  /* discard EOT's (^D) on output */\r
-#endif\r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-#define OCRNL   0x00000010  /* map CR to NL */\r
-#define ONOCR   0x00000020  /* discard CR's when on column 0 */\r
-#define ONLRET    0x00000040  /* move to column 0 on CR */\r
-#endif  /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */\r
+#define OPOST     0x0001  /* enable following output processing */\r
+#define ONLCR     0x0002  /* map NL to CR-NL (ala CRMOD) */\r
+#define OXTABS    0x0004  /* expand tabs to spaces */\r
+#define ONOEOT    0x0008  /* discard EOT's (^D) on output */\r
+#define OCRNL     0x0010  /* map CR to NL */\r
+#define ONOCR     0x0020  /* discard CR's when on column 0 */\r
+#define ONLRET    0x0040  /* move to column 0 on CR */\r
+#define OCTRL     0x0080  /* Map control characters to the sequence ^C */\r
 \r
 /*\r
  * Control flags - hardware control of terminal\r
+  c_cflag\r
  */\r
-#if defined(_NETBSD_SOURCE)\r
-#define CIGNORE   0x00000001  /* ignore control flags */\r
-#endif\r
-#define CSIZE   0x00000300  /* character size mask */\r
-#define     CS5       0x00000000      /* 5 bits (pseudo) */\r
-#define     CS6       0x00000100      /* 6 bits */\r
-#define     CS7       0x00000200      /* 7 bits */\r
-#define     CS8       0x00000300      /* 8 bits */\r
-#define CSTOPB    0x00000400  /* send 2 stop bits */\r
-#define CREAD   0x00000800  /* enable receiver */\r
-#define PARENB    0x00001000  /* parity enable */\r
-#define PARODD    0x00002000  /* odd parity, else even */\r
-#define HUPCL   0x00004000  /* hang up on last close */\r
-#define CLOCAL    0x00008000  /* ignore modem status lines */\r
-#if defined(_NETBSD_SOURCE)\r
-#define CRTSCTS   0x00010000  /* RTS/CTS full-duplex flow control */\r
-#define CRTS_IFLOW  CRTSCTS   /* XXX compat */\r
-#define CCTS_OFLOW  CRTSCTS   /* XXX compat */\r
-#define CDTRCTS   0x00020000  /* DTR/CTS full-duplex flow control */\r
-#define MDMBUF    0x00100000  /* DTR/DCD hardware flow control */\r
-#define CHWFLOW   (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */\r
+#ifdef  HAVE_DA_SERIAL\r
+  #define CIGNORE   0x0001      /* ignore control flags */\r
+  #define CSIZE     0x0300      /* character size mask */\r
+  #define     CS5       0x0000      /* 5 bits (pseudo) */\r
+  #define     CS6       0x0100      /* 6 bits */\r
+  #define     CS7       0x0200      /* 7 bits */\r
+  #define     CS8       0x0300      /* 8 bits */\r
+  #define CSTOPB    0x0400      /* send 2 stop bits, else 1 */\r
+  #define CREAD     0x0800      /* enable receiver */\r
+  #define PARENB    0x1000      /* parity enable */\r
+  #define PARODD    0x2000      /* odd parity, else even */\r
+  #define HUPCL     0x4000      /* hang up on last close */\r
+  #define CLOCAL    0x8000      /* ignore modem status lines */\r
 #endif\r
 \r
 \r
  * the letter "I" and look like they belong in the\r
  * input flag.\r
  */\r
+#define ECHO      0x0001    /* enable echoing */\r
+#define ECHOE     0x0002    /* visually erase chars */\r
+#define ECHOK     0x0004    /* echo NL after line kill */\r
+#define ECHONL    0x0008    /* echo NL even if ECHO is off */\r
+#define ISIG      0x0010    /* enable signals INTR, QUIT, [D]SUSP */\r
+#define ICANON    0x0020    /* canonicalize input lines */\r
+#define IEXTEN    0x0040    /* enable Extensions */\r
+#define SKIP_1    0x0100    /* Currently unused */\r
+#define TOSTOP    0x0200    /* stop background jobs on output */\r
+#define PENDIN    0x0400    /* re-echo input buffer at next read */\r
+#define NOFLSH    0x0800    /* don't flush output on signal */\r
+#define FLUSHO    0x1000    /* output being flushed (state) */\r
 \r
-#if defined(_NETBSD_SOURCE)\r
-#define ECHOKE    0x00000001  /* visual erase for line kill */\r
-#endif\r
-#define ECHOE   0x00000002  /* visually erase chars */\r
-#define ECHOK   0x00000004  /* echo NL after line kill */\r
-#define ECHO    0x00000008  /* enable echoing */\r
-#define ECHONL    0x00000010  /* echo NL even if ECHO is off */\r
-#if defined(_NETBSD_SOURCE)\r
-#define ECHOPRT   0x00000020  /* visual erase mode for hardcopy */\r
-#define ECHOCTL   0x00000040  /* echo control chars as ^(Char) */\r
-#endif  /* defined(_NETBSD_SOURCE) */\r
-#define ISIG    0x00000080  /* enable signals INTR, QUIT, [D]SUSP */\r
-#define ICANON    0x00000100  /* canonicalize input lines */\r
-#if defined(_NETBSD_SOURCE)\r
-#define ALTWERASE 0x00000200  /* use alternate WERASE algorithm */\r
-#endif /* defined(_NETBSD_SOURCE) */\r
-#define IEXTEN    0x00000400  /* enable DISCARD and LNEXT */\r
-#if defined(_NETBSD_SOURCE)\r
-#define EXTPROC         0x00000800      /* external processing */\r
-#endif /* defined(_NETBSD_SOURCE) */\r
-#define TOSTOP    0x00400000  /* stop background jobs on output */\r
-#if defined(_NETBSD_SOURCE)\r
-#define FLUSHO    0x00800000  /* output being flushed (state) */\r
-#define NOKERNINFO  0x02000000  /* no kernel output from VSTATUS */\r
-#define PENDIN    0x20000000  /* re-echo input buffer at next read */\r
-#endif /* defined(_NETBSD_SOURCE) */\r
-#define NOFLSH    0x80000000  /* don't flush output on signal */\r
-\r
-typedef unsigned int  tcflag_t;\r
-typedef unsigned char cc_t;\r
-typedef unsigned int  speed_t;\r
+typedef INT8    cc_t;\r
+typedef UINT16  tcflag_t;\r
+typedef UINT32  speed_t;\r
 \r
 struct termios {\r
-  tcflag_t  c_iflag;  /* input flags */\r
-  tcflag_t  c_oflag;  /* output flags */\r
-  tcflag_t  c_cflag;  /* control flags */\r
-  tcflag_t  c_lflag;  /* local flags */\r
-  cc_t    c_cc[NCCS]; /* control chars */\r
-  int   c_ispeed; /* input speed */\r
-  int   c_ospeed; /* output speed */\r
+  INT32     c_ispeed;   /* input speed    - Use a signed type instead of speed_t */\r
+  INT32     c_ospeed;   /* output speed   - to ease integer promotion when used. */\r
+  tcflag_t  c_iflag;    /* input flags */\r
+  tcflag_t  c_oflag;    /* output flags */\r
+  tcflag_t  c_cflag;    /* control flags */\r
+  tcflag_t  c_lflag;    /* local flags */\r
+  cc_t      c_cc[NCCS]; /* control chars */\r
 };\r
 \r
 /*\r
  * Commands passed to tcsetattr() for setting the termios structure.\r
  */\r
-#define TCSANOW   0   /* make change immediate */\r
-#define TCSADRAIN 1   /* drain output, then change */\r
-#define TCSAFLUSH 2   /* drain output, flush input */\r
-#if defined(_NETBSD_SOURCE)\r
-#define TCSASOFT  0x10    /* flag - don't alter h.w. state */\r
-#endif\r
+#define TCSANOW     0       /* make change immediate */\r
+#define TCSADRAIN   1       /* drain output, then change */\r
+#define TCSAFLUSH   2       /* drain output, flush input */\r
+#define TCSASOFT    0x10    /* flag - don't alter h.w. state */\r
 \r
 /*\r
  * Standard speeds\r
  */\r
-#define B0  0\r
-#define B50 50\r
-#define B75 75\r
-#define B110  110\r
-#define B134  134\r
-#define B150  150\r
-#define B200  200\r
-#define B300  300\r
-#define B600  600\r
-#define B1200 1200\r
-#define B1800 1800\r
-#define B2400 2400\r
-#define B4800 4800\r
-#define B9600 9600\r
-#define B19200  19200\r
-#define B38400  38400\r
-#if defined(_NETBSD_SOURCE)\r
-#define B7200 7200\r
-#define B14400  14400\r
-#define B28800  28800\r
-#define B57600  57600\r
-#define B76800  76800\r
-#define B115200 115200\r
-#define B230400 230400\r
-#define B460800 460800\r
-#define B921600 921600\r
-#define EXTA  19200\r
-#define EXTB  38400\r
-#endif  /* defined(_NETBSD_SOURCE) */\r
+#define B0            0\r
+#define B50          50\r
+#define B75          75\r
+#define B110        110\r
+#define B134        134\r
+#define B150        150\r
+#define B200        200\r
+#define B300        300\r
+#define B600        600\r
+#define B1200      1200\r
+#define B1800      1800\r
+#define B2400      2400\r
+#define B4800      4800\r
+#define B9600      9600\r
+#define B19200    19200\r
+#define B38400    38400\r
 \r
-#ifndef _KERNEL\r
+// Extended speed definitions\r
+#define B7200      7200\r
+#define B14400    14400\r
+#define B28800    28800\r
+#define B57600    57600\r
+#define B76800    76800\r
+#define B115200  115200\r
+#define B230400  230400\r
+#define B460800  460800\r
+#define B921600  921600\r
 \r
 #define TCIFLUSH  1\r
 #define TCOFLUSH  2\r
 #define TCIOFLUSH 3\r
 #define TCOOFF    1\r
-#define TCOON   2\r
+#define TCOON     2\r
 #define TCIOFF    3\r
-#define TCION   4\r
+#define TCION     4\r
 \r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-#ifndef pid_t\r
-typedef __pid_t   pid_t;\r
-#define pid_t   __pid_t\r
-#endif\r
-#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */\r
 #include <sys/EfiCdefs.h>\r
 \r
 __BEGIN_DECLS\r
-speed_t cfgetispeed(const struct termios *);\r
-speed_t cfgetospeed(const struct termios *);\r
-int cfsetispeed(struct termios *, speed_t);\r
-int cfsetospeed(struct termios *, speed_t);\r
-int tcgetattr(int, struct termios *);\r
-int tcsetattr(int, int, const struct termios *);\r
-int tcdrain(int);\r
-int tcflow(int, int);\r
-int tcflush(int, int);\r
-int tcsendbreak(int, int);\r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-pid_t tcgetsid(int);\r
-#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */\r
+speed_t cfgetispeed (const struct termios *);\r
+speed_t cfgetospeed (const struct termios *);\r
+int     cfsetispeed (struct termios *, speed_t);\r
+int     cfsetospeed (struct termios *, speed_t);\r
+int     tcgetattr   (int, struct termios *);\r
+int     tcsetattr   (int, int, const struct termios *);\r
+int     tcdrain     (int);\r
+int     tcflow      (int, int);\r
+int     tcflush     (int, int);\r
+//int     tcsendbreak (int, int);\r
+//pid_t   tcgetsid    (int);\r
 \r
 \r
-#if defined(_NETBSD_SOURCE)\r
-void  cfmakeraw(struct termios *);\r
-int cfsetspeed(struct termios *, speed_t);\r
-#endif /* defined(_NETBSD_SOURCE) */\r
+//void    cfmakeraw   (struct termios *);\r
+//int     cfsetspeed  (struct termios *, speed_t);\r
 __END_DECLS\r
 \r
-#endif /* !_KERNEL */\r
+/*  Input values for UEFI Keyboard Scan Codes.\r
 \r
-#if defined(_NETBSD_SOURCE)\r
+    The UEFI Keyboard Scan Codes are mapped into the upper range of the Unicode\r
+    Private Use Area so that the characters can be inserted into the input stream\r
+    and treated the same as any other character.\r
 \r
-/*\r
- * Include tty ioctl's that aren't just for backwards compatibility\r
- * with the old tty driver.  These ioctl definitions were previously\r
- * in <sys/ioctl.h>.\r
- */\r
-//#include <sys/ttycom.h>\r
-#endif\r
+    These values are only used for input.  If these codes are output to the\r
+    console, or another interactive I/O device, the behavior will depend upon\r
+    the current locale and UEFI character set loaded.\r
+*/\r
+typedef enum {\r
+  TtySpecKeyMin = 0xF7F0,\r
+  /* This area is reserved for use by internal I/O software.\r
+      At least 4 values must exist between TtySpecKeyMin and TtyFunKeyMin.\r
+  */\r
+  TtyFunKeyMin  = 0xF7FA,\r
+  TtyKeyEject   = 0xF7FA,\r
+  TtyRecovery,         TtyToggleDisplay,    TtyHibernate,\r
+  TtySuspend,          TtyBrightnessDown,   TtyBrightnessUp,\r
+  TtyVolumeDown = 0xF87F,\r
+  TtyVolumeUp,         TtyMute,\r
+  TtyF24        = 0xF88D,\r
+  TtyF23,              TtyF22,              TtyF21,              TtyF20,\r
+  TtyF19,              TtyF18,              TtyF17,              TtyF16,\r
+  TtyF15,              TtyF14,              TtyF13,\r
+  TtyEscape     = 0xF8E9,\r
+  TtyF12,              TtyF11,              TtyF10,              TtyF9,\r
+  TtyF8,               TtyF7,               TtyF6,               TtyF5,\r
+  TtyF4,               TtyF3,               TtyF2,               TtyF1,\r
+  TtyPageDown,         TtyPageUp,           TtyDelete,           TtyInsert,\r
+  TtyEnd,              TtyHome,             TtyLeftArrow,        TtyRightArrow,\r
+  TtyDownArrow,\r
+  TtyUpArrow    = 0xF8FF,\r
+  TtyFunKeyMax  = 0xF900\r
+} TtyFunKey;\r
 \r
-/*\r
- * END OF PROTECTED INCLUDE.\r
- */\r
-#endif /* !_SYS_TERMIOS_H_ */\r
+// Non-UEFI character definitions\r
+#define CHAR_EOT    0x0004        /* End of Text (EOT) character */\r
 \r
-#if defined(_NETBSD_SOURCE)\r
-//#include <sys/ttydefaults.h>\r
-#endif\r
+#endif /* !_SYS_TERMIOS_H_ */\r