VT TTY Driver¶
The Virtual Terminal TTY driver, providing Virtual Terminal TTY devices, is
implemented in
os/drivers/tty/vt_tty.c.
Overview¶
For a high-level perspective/introduction to tty drivers, see TTY Drivers.
A virtual terminal tty (vt tty) device is a tty device that is managed by the virtual terminal subsystem. Like any other tty device, it provides a file interface to higher-level components, e.g., user-space processes. It takes output from the higher-level component by writing. It provides input to the higher-level component for reading, which has been passed from the tty subsystem. This part is handled entirely by the tty frontend, which is provided by the tty subsystem.
The vt tty driver implements the tty operations that the tty frontend is using for passing output from the higher-level component and echoed input to the tty backend. In case of the vt tty driver, the tty backend just consists of the set of implemented tty operations.
The backend then passes the output further down to the console that has been attached to the respective vt tty device, using the respective console’s console operations.
Initialization¶
This driver is initialized by calling
-
void vt_tty_init(void)¶
Initialize the vt tty driver.
Allocating a VT TTY Device¶
A vt tty device is allocated by calling
-
tty_t *vt_tty_alloc(void)¶
Allocate and return a new instance of a virtual terminal device.
Allocating a virtual terminal device in turn allocates
a new vt acting as the device
a new tty serving as the tty frontend
Register the standard line discipline to that virtual terminal device
- Returns:
A pointer to the newly allocated virtual terminal device
Writing Output to a VT TTY Device¶
Output is written via the write file operation
-
static ssize_t __vt_tty_write(tty_t *tty, const char *buf, size_t count)¶
Write characters to a lower-level console. To be used by tty.
By calling this function a
ttycan writecountcharacters from the bufferbufto the attached lower-level console.- Parameters:
tty – The tty calling this function
buf – The buffer containing the characters to be written
count – The number of characters to be written
- Returns:
The number of characters that has been written.