- 4
- 0
- 约1.44万字
- 约 8页
- 2017-04-13 发布于江苏
- 举报
inux设备模型(总线、设备、驱动程序和类)
2014年7月3日 Linux设备模型(总线、设备、驱动程序和类) - 天不会黑 - 博客园
/yuanfang/archive/2010/12/24/1916232.html 1/8
之一:bus_type
总线是处理器和一个或多个设备之间的通道,在设备模型中,所有的设备都通过总线相连,甚至是内部的虚
拟platform总线。可以通过ls -l /sys/bus看到系统加载的所有总线。
drwxr-xr-x root root 1970-01-01 00:02 platform
drwxr-xr-x root root 1970-01-01 00:02 spi
drwxr-xr-x root root 1970-01-01 00:02 scsi
drwxr-xr-x root root 1970-01-01 00:02 usb
drwxr-xr-x root root 1970-01-01 00:02 serio
drwxr-xr-x root root 1970-01-01 00:02 i2c
drwxr-xr-x root root 1970-01-01 00:02 mmc
drwxr-xr-x root root 1970-01-01 00:02 sdio
drwxr-xr-x root root 1970-01-01 00:02 ac97
总线可以相互插入。设备模型展示了总线和它们所控制的设备之间的实际连接。在Linux 设备模型中,总线由
bus_type 结构表示,定义在 linux/device.h :
struct bus_type {
const char *name; /*总线类型名称*/
struct bus_attribute *bus_attrs; /*总线属性*/
struct device_attribute *dev_attrs; /*设备属性,指为每个加入总线的设备建立的默认属性链表*/
struct driver_attribute *drv_attrs; /*驱动程序属性*/
int (*match)(struct device *dev, struct device_driver *drv); /*总线操作函数*/
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
int (*probe)(struct device *dev);
int (*remove)(struct device *dev);
void (*shutdown)(struct device *dev);
int (*suspend)(struct device *dev, pm_message_t state); /*电源管理函数*/
int (*suspend_late)(struct device *dev, pm_message_t state);
int (*resume_early)(struct device *dev);
int (*resume)(struct device *dev);
struct pm_ext_ops *pm;
struct bus_type_private *p;
};
1,总线的注册和删除,总线的主要注册步骤:
(1)申明和初始化bus_type 结构体。只有很少的bus_type 成员需要初始化,大部分都由设备模型核心控制。
但必须为总线指定名字及一些必要的方法。例如:
struct bus_type ldd_bus_type = {
.name = ldd,
.match = ldd_match,
.uevent = ldd_uevent,
};
(2)调用bus_register函数注册总线。int bus_register(struct bus_type *bus),该调用可能失败,所以必须
始终检查返回值。
ret = bus_register(ldd_bus_type);
if (ret)
return ret;
若成功,新的总线子
您可能关注的文档
- ICO Handbook for Medical Students Learning Ophthalmology.pdf
- ICEM-Intro_13.0_WS5.2a_Wingbody_Prism.pdf
- ICHQ2(R1)中英文对照.pdf
- ican’09 the third prize Automated Barbecue based on sensors presentation ican automated barbecue.pdf
- ICF introduction.pdf
- ICPR 2012 会议总结.pdf
- ICP刻蚀原理:气体、功率的选择--ICP操作流程.pdf
- Icosahedral quasicrystals by optical interference holography.pdf
- ID-Based cryptography from composite degree residuosity,” IACR Cryptology ePrint Archive,.pdf
- IDC_Cloud_Computing.pdf
最近下载
- 2025年军考提干题目及答案.doc VIP
- 桥门式起重机检验规程.doc
- 文字汉字结构汉字结构现代汉语教案.docx VIP
- 全口义齿特殊颌型.pdf VIP
- 学堂在线 雨课堂 学堂云 研究生的压力应对与健康心理 期末考试答案.docx VIP
- 学堂在线 雨课堂 学堂云 研究生的压力应对与健康心理 章节测试答案.docx VIP
- 在线网课学习课堂《现代农业创新与乡村振兴战略(扬州)》单元测试考核答案.docx VIP
- 学堂在线 雨课堂 学堂云 艺术的启示 章节测试答案.docx VIP
- 2026年中考语文一轮专题复习:现代文阅读.docx VIP
- 计算机基础知识试题(答案_).docx VIP
原创力文档

文档评论(0)