Difference between revisions of "TTY Driver"
Line 20: | Line 20: | ||
=== Read === | === Read === | ||
+ | The TTY driver reads input in lines. Input is buffered in a secondary buffer and cooked (if not in RAW mode) until the secondary buffer is full or a carriage return (CR or '\r') or line feed (LF or '\n') is encountered. When pressing the 'Enter' key on the keyboard, xinu-console is configured to send '\n' to the backend. | ||
+ | |||
+ | When not in RAW input mode, the TTY driver cooks backspace (BS or '\b') and delete (DEL or ASCII character 0x7F). BS and DEL remove the last character from the secondary buffer, and decrease the secondary buffer count by one. When in RAW mode, set using "control(device id, TTC_IRAW, TRUE, NULL)," and BS and DEL are ignored. | ||
+ | |||
+ | The TTY driver sets a flag if EOF (EOT or Control-D) or CBREAK (ETX or Control-C) are seen in the input ready from the secondary buffer. The flags can be checked using "control(device id, TTC_EOF, NULL NULL)" or "control(device id, TTC_CBREAK, NULL NULL)" for EOF and CBREAK, respectively. When not in RAW mode the EOT character is converted to the EOF constant (-2) defined in XINU. | ||
+ | |||
''This section needs updating'' | ''This section needs updating'' | ||
=== Write === | === Write === | ||
+ | When not in RAW output mode, the TTY driver cooks line feeds (also known as LF, \n, or ASCII character 0x0A) and carriage returns (also known as CR, \r, or ASCII character 0x0D). The ttyWrite function always ensures CRLF is written to the output buffer when any of the following escape sequences are to be written: \r, \n, or \r\n. When in RAW mode, set using "control(device id, TTC_ORAW, TRUE, NULL)", CR and LF are not cooked. | ||
+ | |||
''This section needs updating'' | ''This section needs updating'' | ||
Revision as of 17:30, 20 June 2007
The TTY driver is built on top of the UART driver (or other TTY appropriate hardware). The driver is responsible for sending and receiving character input between a user level application, such as the XINU Shell, and a char-oriented hardware driver. Line buffering and cooking are the two primary responsibilities for the new TTY driver.
Contents
Conceptual structure
Functionality
Initialize
This section needs updating
Open
struct tty *ttyAlloc(void) DEVCALL ttyOpen(struct dentry *pdev, va_list ap)
Open associates a TTY with an underlying char-oriented hardware driver. The underlying device should already be initialized. A TTY is allocated from the available TTY devices and its circular buffers are initialized.
Close
DEVCALL ttyClose(struct dentry *pdev)
Close disasociates a TTY from its underlying device. It also makes the TTY available to be allocated to other processes.
Read
The TTY driver reads input in lines. Input is buffered in a secondary buffer and cooked (if not in RAW mode) until the secondary buffer is full or a carriage return (CR or '\r') or line feed (LF or '\n') is encountered. When pressing the 'Enter' key on the keyboard, xinu-console is configured to send '\n' to the backend.
When not in RAW input mode, the TTY driver cooks backspace (BS or '\b') and delete (DEL or ASCII character 0x7F). BS and DEL remove the last character from the secondary buffer, and decrease the secondary buffer count by one. When in RAW mode, set using "control(device id, TTC_IRAW, TRUE, NULL)," and BS and DEL are ignored.
The TTY driver sets a flag if EOF (EOT or Control-D) or CBREAK (ETX or Control-C) are seen in the input ready from the secondary buffer. The flags can be checked using "control(device id, TTC_EOF, NULL NULL)" or "control(device id, TTC_CBREAK, NULL NULL)" for EOF and CBREAK, respectively. When not in RAW mode the EOT character is converted to the EOF constant (-2) defined in XINU.
This section needs updating
Write
When not in RAW output mode, the TTY driver cooks line feeds (also known as LF, \n, or ASCII character 0x0A) and carriage returns (also known as CR, \r, or ASCII character 0x0D). The ttyWrite function always ensures CRLF is written to the output buffer when any of the following escape sequences are to be written: \r, \n, or \r\n. When in RAW mode, set using "control(device id, TTC_ORAW, TRUE, NULL)", CR and LF are not cooked.
This section needs updating
Control
DEVCALL ttyControl(struct dentry *pdev, int func, unsigned char arg1, unsigned char arg2)
/* ttyControl() functions */ #define TTY_IOC_SETIFLAG 0x0020 /* set input flags */ #define TTY_IOC_CLRIFLAG 0x0021 /* clear input flags */ #define TTY_IOC_GETIFLAG 0x0022 /* get input flags */ #define TTY_IOC_SETOFLAG 0x0023 /* set output flags */ #define TTY_IOC_CLROFLAG 0x0024 /* clear output flags */ #define TTY_IOC_GETOFLAG 0x0025 /* get output flags */ #define TTY_IOC_EOF 0x0026 /* check if EOF in input */ #define TTY_IOC_CBREAK 0x0027 /* check if CBREAK in input */
/* TTY input flags */ #define TTY_IFLAG_RAW 0x0001 /* do raw input */ #define TTY_IFLAG_ECHO 0x0002 /* echo input */ #define TTY_IFLAG_CBREAK 0x0004 /* have seen Break (Control-C) */ #define TTY_IFLAG_EOF 0x0008 /* have seen EOF (Control-D) */ /* TTY output flags */ #define TTY_OFLAG_RAW 0x0001 /* do raw output */
This section needs updating