linux newbie有关嵌入式linux设备驱动程序的问题 [英] questions about embedded linux device driver by linux newbie

查看:61
本文介绍了linux newbie有关嵌入式linux设备驱动程序的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在研究linux驱动程序, 就像我读过的那些文章所说,设备驱动程序模块很可能会由内核按需自动加载,因此我想知道内核如何确定特定设备(声卡,I2C/spi设备,等),我也无法完全想象内核在启动时如何检测到每个硬件设备.

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 .

首选与嵌入式linux相关的答案,也欢迎PC linux!

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 ?

是的,但不是内核.内核所做的全部工作就是使用所谓的"hotplug event"或"uevent"作为参数来调用用户空间程序.在Linux PC上,此用户空间程序通常是udev,但是在嵌入式系统上,可以使用例如mdev.您可以在此处

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

关于问题的第二部分,仅当硬件可发现时,内核才会进行硬件发现.可发现硬件的示例是USB和PCI. SPI或I2C是不可发现的骚扰巴士的例子.

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.

在后一种情况下,给定总线上特定设备的存在或者直接在内核中编码,或者由booloader提供给他. Google以设备树"为例.

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.

这篇关于linux newbie有关嵌入式linux设备驱动程序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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