Difference between revisions of "TTY Driver"

From Embedded Xinu
Jump to navigation Jump to search
Line 1: Line 1:
 
{{Update}}
 
{{Update}}
 +
[[Image:TtyDriver.png|right|450px]]The TTY driver is built on top of the UART driver (or another appropriate char-oriented device).  The driver is responsible for sending and receiving character input between a user level application, such as the [[Shell|XINU Shell]], and a char-oriented hardware driver.  The TTY driver uses a line disciple that reads and provides input in lines.  When not in raw mode, the TTY driver also cooks both input and output.
  
[[Image:TtyUartInteraction.png|frame|Diagram of the interaction between hardware, UART driver, TTY driver, and user application.]]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.
+
== Open & Close ==
 
 
== Conceptual structure ==
 
[[Image:TtyDriver.png]]
 
 
 
== Functionality ==
 
=== Initialize ===
 
''This section needs updating''
 
 
 
=== Open ===
 
 
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.
 
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 ===
 
 
Close disasociates a TTY from its underlying device.  It also makes the TTY available to be allocated to other processes.
 
Close disasociates a TTY from its underlying device.  It also makes the TTY available to be allocated to other processes.
  
=== 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.
 
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.
  
Line 25: Line 16:
 
''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.
 
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 ===
 
  /* 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''
 
''This section needs updating''

Revision as of 20:18, 11 July 2007

Clockimportant.png This article or section needs to be updated.
Parts of this article or section have been identified as no longer being up to date.
Please update the article to reflect recent changes, and remove this template when finished.

TtyDriver.png

The TTY driver is built on top of the UART driver (or another appropriate char-oriented device). 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. The TTY driver uses a line disciple that reads and provides input in lines. When not in raw mode, the TTY driver also cooks both input and output.

Open & Close

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 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

See also