低级驱动程序和tty驱动程序之间的链接 [英] Link between low level drivers and tty drivers

查看:95
本文介绍了低级驱动程序和tty驱动程序之间的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Linux编写一个控制台驱动程序,遇到了我需要为此驱动程序设置的tty接口.我对tty驱动程序与低级驱动程序的绑定感到困惑.

I was writing a console driver for linux and I came across the tty interface that I need to set up for this driver. I got confused as to how tty drivers are bound with low-level drivers.

很多时候,根文件系统已经包含很多tty设备.我想知道底层设备如何绑定到根文件系统上现有的tty节点之一.

Many times the root file system already contains a lot of tty devices. I am wondering how low-level devices can bind to one of the existing tty nodes on the root file system.

例如,/dev/tty7:根文件系统上的节点.
低级设备驱动程序如何与此节点连接?还是该低级设备应该定义一个全新的tty设备?

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

推荐答案

低级设备如何绑定到根文件系统上现有的tty节点之一?

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

控制台和tty驱动程序的主要和次要编号是硬编码的.您可以使用以下方法在系统上查找分配的主号码:

The major and minor numbers of the console and tty drivers are hardcoded. You can look up the assigned major numbers on your system with:

$ cat /proc/devices

设备文件通过mknod实用程序绑定到设备驱动程序,例如设备文件是在加载设备驱动程序后创建的-并非相反.要创建设备文件/dev/tty7,请输入

The device files binds to the device driver throgh the mknod utility, e.g. the device file is created after the device driver is loaded - not the other way around. To create the device file /dev/tty7 you'd type

$ mknod /dev/tty7 c 4 7

对于内核源中的参考:drivers/tty/tty_io.c: tty_register_driver 似乎是在分配主号和副号一组其他tty驱动程序.看看来电者,也许您会找到答案的.

For a reference 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 appears to allocate major and minor numbers for a group of other tty drivers. Perhaps you'll find the answer if you look at the callers.

如果您想全面了解tty子系统的结构,请 tty神秘化 LDD3第18章TTY驱动程序是很好的资源.

If you want a high level overview of how the tty subsystem is structured then tty demystified and LDD3 Chapter 18 TTY drivers are good resources.

这篇关于低级驱动程序和tty驱动程序之间的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆