/proc/io *如何填充? [英] How is /proc/io* populated?

查看:112
本文介绍了/proc/io *如何填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,如果我正确理解,cat /proc/iomem会列出映射到该地址和该设备寄存器的内存地址,并且与ioports类似.如果您拿起有关Linux设备驱动程序的书,它会指出驱动程序调用request_region()填充iomem之类的内容.

So if I understand things correctly, cat /proc/iomem lists the memory addresses that are mapped to this and that device register and similarily for ioports. If you pick up some book on Linux device drivers, it will state something about iomem being populated by the driver calling request_region() or something like that.

但是设备驱动程序如何从一开始就知道硬件寄存器的位置?例如,对于大多数人来说,rtc0似乎占据了0070:0071的地位-Linux/设备驱动程序如何知道我的系统的晶体管和电线已连接,以便准确地翻转那些位对应于从RTC读取信号?

But how does the device driver know where the hardware register is located at from the get-go? For example, rtc0 seems to occupy 0070:0071 for most people - how does Linux/the device driver know that the transistors and wires of my system are hooked up so that flipping exactly those bits corresponds to reading a signal from the RTC?

推荐答案

如果您找到有关Linux设备驱动程序的书,它将说明由驱动程序request_region()填充的iomem或类似内容.

If you pick up some book on Linux device drivers, it will state something about iomem being populated by the driver calling request_region() or something like that.

/proc/iomem中的信息来自调用 request_mem_region()的驱动程序.
参见/proc/iomem的内容.

The information in /proc/iomem comes from drivers calling request_mem_region().
See Content of /proc/iomem.

设备驱动程序如何知道硬件寄存器的位置

how does the device driver know where the hardware register is located

设备寄存器的地址通常由板(用于外部外围设备)或SoC设计器(用于集成外围设备)指定,然后在板或SoC文档中提供.某些板(例如PC ISA适配器板)可能允许某些DIP开关指定地址.

The address of a device register is typically specified by either the board (for an external peripheral) or SoC designer (for an integrated peripheral), and then conveyed in the board or SoC documentation. Some boards (e.g. PC ISA adapter boards) may allow address specification by some DIP switches.

然后,设备驱动程序的编写者可以
(a)在驱动程序本身或板文件中对设备地址进行硬编码,或者
(b)使用某种总线配置方法(例如PCI配置空间)来检索设备地址,或者
(c)使用(手写)配置列表(例如设备树,FEX,ATAG)或
来获取设备地址 (d)尝试在运行时探测设备.

The writer of the device driver then can
(a) hardcode the device address in the driver itself or a board file, or
(b) retrieve the device address using some bus configuration method (e.g. PCI configuration space), or
(c) retrieve the device address using a (handwritten) configuration list (e.g. Device Tree, FEX, ATAGs), or
(d) try to probe the device at runtime.

请注意,将系统配置和设备地址传达给设备驱动程序是一个长期存在的问题.
IBM PC的分配地址方法随后进行了硬编码,最终导致即插即用计划x86 PC.
每个ARM板都有独特的Linux内核版本的问题导致采用设备树(来自PowerPC).

Note that conveying the system configuration and device addresses to device drivers is a longstanding issue.
The IBM PC's method of assigned addresses that were then hardcoded eventually led to the plug and play initiative for x86 PCs.
Issues with unique Linux kernel builds for each and every ARM board led to the adoption of Device Tree (from PowerPC) for that architecture.

这篇关于/proc/io *如何填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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