低级驱动程序和 tty 驱动程序之间的链接
我正在为 Linux 编写一个控制台驱动程序,我遇到了需要为此驱动程序设置的 tty 接口。我对 tty 驱动程序如何与低级驱动程序绑定感到困惑。
很多时候根文件系统已经包含很多tty设备。我想知道低级设备如何绑定到根文件系统上现有的 tty 节点之一。
例如,/dev/tty7
:根文件系统上的节点。
低级设备驱动程序如何与该节点连接?或者该低级设备应该定义一个全新的 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.
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.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
控制台和 tty 驱动程序的主要和次要编号是硬编码的。您可以通过以下方式查找系统上指定的主设备号:
设备文件通过 mknod 实用程序绑定到设备驱动程序,例如,设备文件是在加载设备驱动程序后创建的 - 而不是相反。要创建设备文件 /dev/tty7,您需要输入以下内容
作为内核源代码的参考: drivers/tty/tty_io.c:tty_init 为 /dev/tty 和 /dev/console 分配主编号和次编号。 tty_register_driver 似乎分配主要和次要编号对于一组其他 tty 驱动程序。如果你看看来电者,也许你会找到答案。
如果您想全面了解 tty 子系统的结构,那么 tty 揭秘和 LDD3 第 18 章 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:
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
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.
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.