StdLib: Add terminal type line editing (Interactive IO) for console devices.

Adds a subset of the terminal I/O capabilities described in the Single Unix Specification, V4.
Supports:
    Erase previous character.  Default is Backspace or ^H
    Erase line.  Default is ^U
TAB characters are supported and, by default, are rendered as 8 spaces.  They will still be read as a single TAB character.
Both Canonical and Non-Canonical modes are supported.
If a terminal device is opened with O_TTY_INIT in the mode, the device will be initialized to "sane" values for interactive use.  It will be in Canonical mode, Enter will be translated to NewLine and on output, a NewLine is translated to CRLF.  Echoing will be on, control characters are output as ^X, and TABs are expanded.
See the new <sys/termios.h> file for more information.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by:  daryl.mcdaniel@intel.com
Reviewed-by:    erik.c.bjorge@intel.com
Reviewed-by:    leroy.p.leahy@intel.com
Reviewed-by:    lee.g.rosenbaum@intel.com
Reviewed-by:    jaben.carsey@intel.com





git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13989 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503
2012-12-11 21:19:14 +00:00
parent e575c101d8
commit 6c6c850ad6
23 changed files with 3404 additions and 218 deletions

View File

@@ -215,19 +215,171 @@ struct termios {
#include <sys/EfiCdefs.h>
__BEGIN_DECLS
/** Get input baud rate.
Extracts the input baud rate from the termios structure pointed to by the
pTermios argument.
@param[in] pTermios A pointer to the termios structure from which to extract
the input baud rate.
@return The value of the input speed is returned exactly as it is contained
in the termios structure, without interpretation.
**/
speed_t cfgetispeed (const struct termios *);
/** Get output baud rate.
Extracts the output baud rate from the termios structure pointed to by the
pTermios argument.
@param[in] pTermios A pointer to the termios structure from which to extract
the output baud rate.
@return The value of the output speed is returned exactly as it is contained
in the termios structure, without interpretation.
**/
speed_t cfgetospeed (const struct termios *);
/** Set input baud rate.
Replaces the input baud rate, in the termios structure pointed to by the
pTermios argument, with the value of NewSpeed.
@param[out] pTermios A pointer to the termios structure into which to set
the input baud rate.
@param[in] NewSpeed The new input baud rate.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EINVAL - The value of NewSpeed is outside the range of
possible speed values as specified in <sys/termios.h>.
**/
int cfsetispeed (struct termios *, speed_t);
/** Set output baud rate.
Replaces the output baud rate, in the termios structure pointed to by the
pTermios argument, with the value of NewSpeed.
@param[out] pTermios A pointer to the termios structure into which to set
the output baud rate.
@param[in] NewSpeed The new output baud rate.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EINVAL - The value of NewSpeed is outside the range of
possible speed values as specified in <sys/termios.h>.
**/
int cfsetospeed (struct termios *, speed_t);
/** Get the parameters associated with an interactive IO device.
Get the parameters associated with the device referred to by
fd and store them into the termios structure referenced by pTermios.
@param[in] fd The file descriptor for an open interactive IO device.
@param[out] pTermios A pointer to a termios structure into which to store
attributes of the interactive IO device.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EBADF - The fd argument is not a valid file descriptor.
* ENOTTY - The file associated with fd is not an interactive IO device.
**/
int tcgetattr (int, struct termios *);
/** Set the parameters associated with an interactive IO device.
Set the parameters associated with the device referred to by
fd to the values in the termios structure referenced by pTermios.
Behavior is modified by the value of the OptAct parameter:
* TCSANOW: The change shall occur immediately.
* TCSADRAIN: The change shall occur after all output written to fd is
transmitted. This action should be used when changing parameters which
affect output.
* TCSAFLUSH: The change shall occur after all output written to fd is
transmitted, and all input so far received but not read shall be
discarded before the change is made.
@param[in] fd The file descriptor for an open interactive IO device.
@param[in] OptAct Currently has no effect.
@param[in] pTermios A pointer to a termios structure into which to retrieve
attributes to set in the interactive IO device.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EBADF - The fd argument is not a valid file descriptor.
* ENOTTY - The file associated with fd is not an interactive IO device.
**/
int tcsetattr (int, int, const struct termios *);
/** Transmit pending output.
@param[in] fd The file descriptor for an open interactive IO device.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EBADF - The fd argument is not a valid file descriptor.
* ENOTTY - The file associated with fd is not an interactive IO device.
* EINTR - A signal interrupted tcdrain().
* ENOTSUP - This function is not supported.
**/
int tcdrain (int);
/** Suspend or restart the transmission or reception of data.
This function will suspend or resume transmission or reception of data on
the file referred to by fd, depending on the value of Action.
@param[in] fd The file descriptor of an open interactive IO device (terminal).
@param[in] Action The action to be performed:
* TCOOFF - Suspend output.
* TCOON - Resume suspended output.
* TCIOFF - If fd refers to an IIO device, transmit a
STOP character, which is intended to cause the
terminal device to stop transmitting data.
* TCION - If fd refers to an IIO device, transmit a
START character, which is intended to cause the
terminal device to start transmitting data.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EBADF - The fd argument is not a valid file descriptor.
* ENOTTY - The file associated with fd is not an interactive IO device.
* EINVAL - The Action argument is not a supported value.
* ENOTSUP - This function is not supported.
**/
int tcflow (int, int);
/** Discard non-transmitted output data, non-read input data, or both.
@param[in] fd The file descriptor for an open interactive IO device.
@param[in] QueueSelector The IO queue to be affected:
* TCIFLUSH - If fd refers to a device open for input, flush
pending input. Otherwise error EINVAL.
* TCOFLUSH - If fd refers to a device open for output,
flush pending output. Otherwise error EINVAL.
* TCIOFLUSH - If fd refers to a device open for both
input and output, flush pending input and output.
Otherwise error EINVAL.
@retval 0 The operation completed successfully.
@retval -1 An error occured and errno is set to indicate the error.
* EBADF - The fd argument is not a valid file descriptor.
* ENOTTY - The file associated with fd is not an interactive IO device.
* EINVAL - The QueueSelector argument is not a supported value.
* ENOTSUP - This function is not supported.
**/
int tcflush (int, int);
//int tcsendbreak (int, int);
//pid_t tcgetsid (int);
//void cfmakeraw (struct termios *);
//int cfsetspeed (struct termios *, speed_t);
__END_DECLS