Difference between revisions of "TTY Driver"
|Line 8:||Line 8:|
== Read ==
== Read ==
The TTY driver reads
The TTY driver reads . Input is buffered in buffer() or carriage return (CR or '\r') line or 'is .
When the ''the , '\'.
When the () character . the from the buffer, . The TTY driver sets a flag if EOF (EOT or Control-D) or CBREAK (ETX or Control-C) are seen in the input the . The flags can be checked using control(device id, , NULL NULL)or control(device id, , NULL NULL)for EOF and CBREAK, respectively.
The TTY driver sets a flag if EOF (EOT or Control-D) or CBREAK (ETX or Control-C) are seen in the input
== Write ==
== Write ==
Revision as of 20:26, 11 July 2007
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.
The TTY driver reads characters from an underlying device, normally a UART. Input is read from the underlying device in lines and buffered in the TTY's input buffer. Lines may be terminated with the line feed (LF or '\n') or carriage return (CR or
'\r') characters. Read requests are not satsified until a full line has been read, or the TTY's buffer is full.
When the TTY is not in raw input mode, lines of input are cooked. Backspace (BS or
'\b') and delete (DEL or ASCII character 0x7F) remove the last character from the TTY's input buffer, and decrease the secondary buffer count by one. Escape sequences and the null character (NUL or
'\0') are ignored.
When the end of file (Control+D) character is read, the tty stops reading from the underlying device. Subsquent calls to
ttyRead will attempt to staisfy the request from the TTY's input buffer, otherwise
EOF will be returned. The TTY driver sets a flag if EOF (EOT or Control-D) or CBREAK (ETX or Control-C) are seen in the input that satisfies the read request. The flags can be checked using
control(device id, TTY_IOC_EOF, NULL NULL) or
control(device id, TTY_IOC_CBREAK, NULL NULL) for EOF and CBREAK, respectively.
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