开发者

questions about embedded linux device driver by linux newbie

I have been studying linux driver recently, as those articles I read said, the device driver modules are likely to be automatically loaded on demand by kernel, I am therefore wondering about the recipe how kernel figures out which module to load for a specific device(sound card, I2C/spi device, etc), I also cannot thoroughly imagine how the kernel detects each hardware device while boot-time .

开发者_运维百科

answers relevant to embedded linux are prefered , PC linux are also welcome !

3Q


I think you are mixing two different things, which is hardware detection, and on demand module loading.

In some cases, the kernel is explicitely doing a module request. However, in most cases, the kernel itself does not do any "on demand loading".

But wait, you must be mistaken, if I plug my shiny new webcam, isn't the module automagically loaded ?

Yes it is, but not by the kernel. All the kernel does is calling a userspace program with so called "hotplug event" or "uevent" as arguments. On Linux PC, this userspace program is usually udev, but on embedded system, you can use for example mdev. You can find a more detailed explanation here and here

Regarding the second part of your question, the kernel is doing hardware discovery only if the hardware is discoverable. Example of discoverable hardware is USB and PCI. Example of non discoverable harwdare busses is SPI or I2C.

In the latter cases, the presence of a particular device on a given bus is either encoded directly in the kernel, or given to him by the booloader. Google for "device tree" for an example of the latter.

To sum things up : Hardware detection is done by the kernel, and module loading is done by userspace, with information provided by the kernel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜