Basic tty architecture knowledge

Source: Internet
Author: User

I. Structure of terminal Devices

The tty hierarchy chart in the Linux kernel contains the TTY core, tty line rules, and tty drivers. The core of tty is the abstraction of the entire tty device. It provides a unified interface for users. tty line rules are the formatting of transmitted data, while tty drivers are driver for tty devices, this is the driver for the device, which should be implemented by us. But we can see later that for the serial port driver Linux, We need to abstract and encapsulate the commonalities, so that the entire driver can be layered and simplified. Make the driver modifications only need to design the hardware differences of the device, but this makes the structure of the device driver more complex, too many process layers, it is difficult to understand.

The process of sending data from a tty device is as follows: the TTY core obtains the data to be sent to a tty device from a user, and the TTY core transmits the data to the TTY line rule driver, the data is then transmitted to the TTY driver, which converts the data into a format that can be sent to the hardware.

The process of receiving data is: Hand over the data received from the TTY hardware to the TTY driver, go to the TTY line rule driver, and then enter the TTY core, where it is obtained by a user. Although the data transmission between the TTY core and the TTY core usually goes through the TTY line procedure conversion, the TTY driver and the TTY core can also directly transmit data.


2. tty device driver structure

The figure shows the flow of the main source files and data related to TTY. Tty_io.c defines the file_operations struct common to TTY devices and implements the interface function tty_register_driver () to register tty devices. It will use the interface functions provided by fs/char_dev.c to register character devices, the tty driver corresponding to a specific device implements the member function in the tty_driver struct. At the same time, tty_io.c also provides the tty_register_ldisc () interface function for registering line rules. The n_tty.c file implements the members in the tty_disc struct. The main task of the driver of a specific tty device is to fill the members in the tty_driver struct and implement the member functions.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.