The relationship between low-level drivers and tty drivers

I wrote a console driver for Linux, and I came across the tty interface that I need to configure for this driver. I was confused about how tty drivers relate to low-level drivers.

Many times, the root file system already contains many tty devices. I am wondering how low-level devices can communicate with one of the existing tty nodes in the root file system.

For example, /dev/tty7 : Node on the root file system.
How does a low-level device driver connect with this node? Or should a low-level device identify a completely new tty device?

+4
source share
1 answer

How can low-level devices bind to one of the existing tty nodes in the root file system?

Major and minor console and tty-driver numbers are hard-coded. You can find the assigned primary numbers in your system with:

 $ cat /proc/devices 

Device files are attached to the device driver, supporting the mknod utility, for example, a device file is created after loading the device driver, and not vice versa. To create the device file / dev / tty7, you must enter

 $ mknod /dev/tty7 c 4 7 

For a link in the kernel source: drivers / tty / tty_io.c: tty_init allocates the major and minor numbers for / dev / tty and / dev / console. tty_register_driver seems to highlight the major and minor numbers for a group of other tty drivers. You may find the answer if you look at the callers.

If you need a high level overview of the structure of the tty subsystem , then tty demystified and LDD3 Chapter 18 TTY drivers are good resources.

+5
source

Source: https://habr.com/ru/post/1398116/


All Articles