Linux内核如何从设备树中获取数据? [英] How linux kernel get data from the Device tree?

查看:64
本文介绍了Linux内核如何从设备树中获取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Linux内核的初学者.
据我所知,在较早版本的内核中,有一个特定于电路板的文件,其中注册了所有设备(通过使用诸如 platform_get_register 之类的一些API).
并且在较新版本的内核中,设备所需的信息通过设备树传递.
我的问题是内核如何从设备树中获取驱动程序的信息?设备如何通过设备树在内核中注册?

I am a beginner to the Linux Kernel.
In my knowledge, in the older versions of the Kernel there was a board specific file, in which all the devices were registered (by using some API s like platform_get_register, etc).
And in newer versions of the kernel the information needed for the devices are passed through the Device Tree.
My Questions are how the Kernel take the information for the drivers from device tree? How devices get registered in kernel through Device Tree?

推荐答案

如果您是指OpenFirmware设备树,则将它们打包成一种特殊格式(dtb映像),并由引导程序和内核映像放入RAM中.然后,引导程序调用内核入口点,将RAM中dtb映像的地址作为参数之一传递.

If you mean the OpenFirmware device trees, those are packed into a special format (dtb image) and put in RAM by the bootloader, together with the kernel image. Bootloader then invokes the kernel entry point passing the address of the dtb image in RAM as one of the parameters.

位于< kernel>/drivers/of 子目录中的内核子系统随后将遍历树,并且对于受支持的每个设备条目,它将尝试通过 device_add()创建所需的设备.和朋友(在Linux中创建设备的通常过程).如果驱动程序子系统可以找到合适的驱动程序,则该驱动程序的 * _ probe()回调将能够从(可能是子类化的) device获取在OF设备条目中找到的参数.对象传递给它.

A kernel subsystem located in <kernel>/drivers/of subdirectory will then walk the tree and for each device entry supported it will attempt to create the required device via device_add() and friends (the usual process for creating devices in Linux). If the driver subsystem can find a suitable driver, that driver's *_probe() call back will be able to obtain the parameters found in the OF device entry from the (possibly sub-classed) device object passed to it.

这篇关于Linux内核如何从设备树中获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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