1) 是否可以访问/proc/iomem 中未定义的物理地址?
2)如果一个设备的物理地址范围没有出现在/proc/iomem中,是否意味着这个设备还没有被使用/初始化?
最佳答案
1) Is it possible to access a physical address which is not defined in /proc/iomem?
是的。
假设内存映射所有直接连接的外设的 ARM 处理器,驱动程序可以执行 ioremap()
操作以将物理内存映射到虚拟内存以供访问。
但是正确编写的驱动程序会首先调用 request_mem_region()
以确保它可以使用(并声称)该物理地址空间。
/proc/iomem
中的信息来自调用 request_mem_region()
的驱动程序。
2) If the physical address range of a device does not appear in /proc/iomem, does it mean that the device has not been utilized/initialized yet?
您必须检查驱动程序代码以确定驱动程序的编写情况。
ioremap()
之前是否有request_mem_region()
?
使用dmesg
命令检查系统日志;可能驱动程序初始化失败。
假设这是一个静态链接的驱动程序而不是一个可加载的模块,那么当每个内核设备驱动程序调用其 init()
例程时,您可以通过添加选项“initcall_debug”来获得跟踪输出“在内核命令行上。如果您使用的是 U-Boot,则应将此选项添加到“bootargs”变量(用于内核命令行)。
关于linux -/proc/iomem 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18580469/