tiny4412 Serial drive analysis of the six---TTY driver architecture

Source: Internet
Author: User

Reprint: http://www.linuxidc.com/Linux/2013-11/92639.htm

Reference:

http://blog.csdn.net/lamdoc/article/details/7685896

Http://www.linuxidc.com/Linux/2011-07/39521.htm

1. TTY Devices

There are serial port, USB to serial port, modem (traditional Winmodem class equipment) and so on. The core of the Linux-tty driver is immediately below the standard character device driver layer and features a series of functions that are used as interfaces by terminal type devices. The kernel is responsible for controlling the flow of data through the TTY device and formatting the data. To control the flow of data, there are many different line codes (lines discipline) that can be "plugged in" to any TTY device, which is implemented by different TTY line procedures drivers. The purpose of TTY line procedures is to use special methods to format data received from users or hardware. This format usually uses some protocol to complete the conversion, such as PPP or bluetooth® Bluetooth.

2. TTY Architecture Diagram Analysis

In the Linux kernel, the TTY hierarchy includes:

A. TTY core

B. TTY line procedures (discipline): Format data received from a user or hardware, such as PPP protocols or Bluetooth protocols, in a protocol-based manner.

C. TTY Driver

TTY devices send data flow: The TTY core obtains data from the user that it wants to send to a TTY device, the TTY core transmits the data to the TTY line discipline driver, and then the data is passed to the TTY driver, and the TTY driver converts the data into a format that can be sent to the hardware.

The TTY device receives the data flow: The data received from the hardware is forwarded to the TTY driver, then into the TTY line procedure, then into the TTY core, where it is acquired by a user.

Although most of the time the data transfer between the TTY core and the TTY undergoes the conversion of the TTY line protocol, the data can also be transferred directly between the TTY driver and the TTY core.

User space is mainly through the device files and tty_core interaction. Tty_core interacts with line discipline and tty_driver depending on the type of space operation. For example, the IOCTL instructions for setting up the hardware are given directly to tty_driver processing. The read and write operations will be handed to line discipline for processing. Line discipline is the meaning of the wiring procedure. As its name indicates, it represents the input and output specification settings for this terminal "thread". Used primarily for preprocessing of input/output data. After processing. The data will be given to Tty_driver. Tty_driver is the driver of the terminal. It converts the character into a string that can be understood by the terminal and transmits it to the end device.

It is important to note that this architecture does not provide read operations for Tty_driver. That is to say Tty_core and line discipline have no way to read terminal information directly from Tty_driver. This is because the corresponding hardware of the tty_driver is not necessarily the common load of input data and output data. For example, the control terminal, the output device is a monitor. The input device is the keyboard. Based on this principle. There is an input buffer in line discipline. An interface function called RECEIVE_BUF () is provided. The corresponding terminal equipment as long as the call line Discipine receiver_buf function, the data will be written to the input buffer.

If a device is both an input device and an output device. That calls Receive_buf () in the interrupt processing of the device to write the data.

tiny4412 serial Drive Analysis Six---TTY driver architecture

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.