Linux设备模型之总线设备和驱动

Linux设备模型之总线设备和驱动

ID:43515592

大小:74.00 KB

页数:8页

时间:2019-10-09

Linux设备模型之总线设备和驱动_第1页
Linux设备模型之总线设备和驱动_第2页
Linux设备模型之总线设备和驱动_第3页
Linux设备模型之总线设备和驱动_第4页
Linux设备模型之总线设备和驱动_第5页
资源描述:

《Linux设备模型之总线设备和驱动》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、Linux设备模型之总线设备和驱动《Linux内核修炼之道》读书笔记1、设备模型的上层建筑由总线(bus)、设备(device)、驱动(device_driver)这3个数据结构构成,设备模型表示了它们之间的连接关系。在设备模型中,所有的设备都通过总线连接。总线可以是物理存在的,也可以是虚拟的。比如内部的platform总线。设备是连接到某条物理或虚拟总线上的对象。可能是真正的物理对象,也可能的是虚拟对象。驱动是用来和设备通信的软件程序。驱动可以从设备获得数据,也可以把相应数据发给设备进行处理。2、数据结构(1)、总线structbus_type{constchar*name;总线类型的名称s

2、tructbus_attribute*bus_attrs;structdevice_attribute*dev_attrs;struct8driver_attribute*drv_attrs;int(*match)(structdevice*dev,structdevice_driver*drv);设备和驱动能否对应,就是有该总线的match方式决定。不同总线的match方式不一样。int(*uevent)(structdevice*dev,structkobj_uevent_env*env);int(*probe)(structdevice*dev);int(*remove)(structd

3、evice*dev);void(*shutdown)(structdevice*dev);int(*suspend)(structdevice*dev,pm_message_tstate);int(*suspend_late)(structdevice*dev,pm_message_tstate);int(*resume_early)(structdevice*dev);int(*resume)(structdevice*dev);structpm_ext_ops*pm;structbus_type_private*p;};现在如上数据结构和书中讲的有所不同,只不过有包装了一层数据结构stru

4、ctbus_type_private*p,源码如下:/** *structbus_type_private-structuretoholdtheprivatetothe8drivercoreportionsofthebus_typestructure. * * @subsys-thestructksetthatdefinesthisbus. Thisisthemainkobjectsubsys描述该总线的子系统,它连接到全局量ksetbus_subsys中。 *@drivers_kset-thelistofdriversassociatedwiththisbus该总线系统里所有驱动的集合 *@

5、devices_kset-thelistofdevicesassociatedwiththisbus该总线系统里所有设备的集合 *@klist_devices-theklisttoiterateoverthe@devices_kset该总线里的设备用klist指针连成一个链表 *@klist_drivers-theklisttoiterateoverthe@drivers_kset驱动链表 *@bus_notifier-thebusnotifierlistforanythingthatcaresaboutthings *onthisbus. *@bus-pointerbacktothestru

6、ctbus_typethatthisstructureisassociated *with. *8 *Thisstructureistheonethatistheactualkobjectallowingstruct *bus_typetobestaticallyallocatedsafely. Nothingoutsideofthedriver *coreshouldevertouchthesefields. */structbus_type_private{structksetsubsys;structkset*drivers_kset;structkset*devices_kset;st

7、ructklistklist_devices;structklistklist_drivers;structblocking_notifier_headbus_notifier;unsignedintdrivers_autoprobe:1;structbus_type*bus;};在sysfs文件系统中,我们可以清晰地看到它们之间的联系。ksetbus_subsys对应于/sys/bus这个目录。

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。