Xinu7/man/man4/tty.doc
TTY(4) Xinu Programmer's Manual TTY(4)
NAME
tty - general-purpose terminal I/O device driver (type tty)
SYNOPSIS
#include <slu.h>
#include <tty.h>
read(device buffer, length)
write(device, buffer, length)
open(device, name)
close(device)
control(device, function, arg1, arg2)
init(device)
DESCRIPTION
The _t_t_y device driver provides input and output for a full-
duplex ascii terminal device. On most Xinu systems, device
_C_O_N_S_O_L_E is of type tty.
Currently implemented on a Digital Equipment Corporation
serial line unit (SLU) like that on the DLV11 and MXV11, the
driver expects one interrupt per character on both input and
output.
The _t_t_y driver operates in one of three modes, with switch-
ing between the modes determined dynamically. In _r_a_w _m_o_d_e,
it passes incoming characters to the reading process without
further processing. In _c_b_r_e_a_k _m_o_d_e, the driver honors XON-
XOFF flow control, character echo, and mapping between car-
riage return and line feed. In _c_o_o_k_e_d _m_o_d_e the driver
behaves like cbreak mode, but also handles line editing with
backspace and line kill keys. Characters are processed
according to the driver mode when they arrive, and are
placed in a queue from which upper-half routines extract
them. Echoing, presentation of control characters, and
editing are controlled by several fields in the driver con-
trol structure, and may be changed dynamically.
The upper-half routines behave as follows:
read(device,buffer,length)
Reads up to one line into the user's _b_u_f_f_e_r, stopping
on an END-OF-FILE or NEWLINE character, or after _l_e_n_g_t_h
characters have been supplied. As a special case, if
_l_e_n_g_t_h is zero, the driver reads whatever characters
are available in the input buffer (possibly zero). In
cooked mode, _r_e_a_d blocks until a line has been typed.
write(device,buffer,length)
Writes _l_e_n_g_t_h characters from the user's _b_u_f_f_e_r, map-
ping CARRIAGE RETURN to NEWLINE as specified by field
_o_c_r_l_f of the driver control structure. Write may block
Version 6b Printed 1/12/87 1
TTY(4) Xinu Programmer's Manual TTY(4)
if the output exceeds the currently available buffer
space.
getc(device)
Reads a single character and returns it as the function
value.
putc(device,char)
Writes character _c_h_a_r.
open(device,name)
Returns _O_K if character string _n_a_m_e is null, and _S_Y_S_E_R_R
otherwise, taking no action except generating a return
value.
close(device)
Returns _O_K without taking any action.
init(device)
Initializes the driver. Note: for historical reasons,
device _C_O_N_S_O_L_E is initialized to cooked mode with echo,
visual control character printing, and line editing
enabled, while other devices are initialized to raw
mode.
control(device,function)
Controls the driver and provides non-transfer opera-
tions. The valid functions are:
TCSETBRK - set the line into the ``break'' state.
TCRSTBRK - reset the line, turning off ``break'' state.
TCNEXTC - lookahead one character without reading it.
TCMODER - change the driver to raw mode.
TCMODEC - change the driver to cooked mode.
TCMODEK - change the driver to cbreak mode.
TCECHO - turn on character echo.
TCNOECHO - turn off character echo.
TCICHARS - return a count of characters in the input buffer.
DIAGNOSTICS
Character errors are reported by turning on the high-order
bit of the character.
NOTES
The version 6 driver used buffer counts as exact requests;
version 7 is line oriented. Error reporting should be
improved.
Version 6b Printed 1/12/87 2