上一页 1 ··· 136 137 138 139 140 141 142 143 144 ··· 280 下一页
摘要: 设备结构包含设备模型核心需要的来模型化系统的信息. 大部分子系统, 但是, 跟踪关于 它们驻留的设备的额外信息. 结果, 对设备很少由空设备结构所代表; 相反, 这个结构, 如同 kobject 结构, 常常是嵌入一个更高级的设备表示中. 如果你查看 struct pci_dev 设备结构包含设备模 阅读全文
posted @ 2019-07-07 21:35 樊伟胜 阅读(185) 评论(0) 推荐(0) 编辑
摘要: sysfs 中的设备入口可有属性. 相关的结构是: struct device_attribute { struct attribute attr; ssize_t (*show)(struct device *dev, char *buf); ssize_t (*store)(struct dev 阅读全文
posted @ 2019-07-07 21:34 樊伟胜 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 通常的注册和注销函数在: int device_register(struct device *dev); void device_unregister(struct device *dev); 我们已经见到 lddbus 代码如何注册它的总线类型. 但是, 一个实际的总线是一个设备并 且必须单独注 阅读全文
posted @ 2019-07-07 21:08 樊伟胜 阅读(935) 评论(0) 推荐(0) 编辑
摘要: 在最低层, Linux 系统中的每个设备由一个 struct device 代表: struct device { struct device *parent; struct kobject kobj; char bus_id[BUS_ID_SIZE]; struct bus_type *bus; 阅读全文
posted @ 2019-07-07 21:01 樊伟胜 阅读(2650) 评论(0) 推荐(0) 编辑
摘要: 如果你在编写总线级别的代码, 你可能不得不对所有已经注册到你的总线的设备或驱动进 行一些操作. 它可能会诱惑人直接进入 bus_type 结构中的各种结构, 但是最好使用已经 提供的帮助函数. 为操作每个对总线已知的设备, 使用: int bus_for_each_dev(struct bus_ty 阅读全文
posted @ 2019-07-07 20:56 樊伟胜 阅读(549) 评论(0) 推荐(0) 编辑
摘要: 几乎 Linux 驱动模型中的每一层都提供一个添加属性的接口, 并且总线层不例外. bus_attribute 类型定义在 <linux/device.h> 如下: struct bus_attribute { struct attribute attr; ssize_t (*show)(struc 阅读全文
posted @ 2019-07-07 20:56 樊伟胜 阅读(522) 评论(0) 推荐(0) 编辑
摘要: 有几个给 bus_type 结构定义的方法; 它们允许总线代码作为一个设备核心和单独驱动之 间的中介. 在 2.6.10 内核中定义的方法是: int (*match)(struct device *device, struct device_driver *driver); 这个方法被调用, 大概 阅读全文
posted @ 2019-07-07 20:53 樊伟胜 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 如同我们提过的, 例子源码包含一个虚拟总线实现称为 lddbus. 这个总线建立它的 bus_type 结构, 如下: struct bus_type ldd_bus_type = { .name = "ldd", .match = ldd_match, .hotplug = ldd_hotplug 阅读全文
posted @ 2019-07-07 20:51 樊伟胜 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 一个总线是处理器和一个或多个设备之间的通道. 为设备模型的目的, 所有的设备都通过 一个总线连接, 甚至当它是一个内部的虚拟的,"平台"总线. 总线可以插入另一个 - 一个 USB 控制器常常是一个 PCI 设备, 例如. 设备模型表示在总线和它们控制的设备之间的 实际连接. 在 Linux 设备模 阅读全文
posted @ 2019-07-07 20:50 樊伟胜 阅读(949) 评论(0) 推荐(0) 编辑
摘要: 热插拔事件的实际控制是通过一套存储于 kset_hotplug_ops 结构的方法完成. struct kset_hotplug_ops { int (*filter)(struct kset *kset, struct kobject *kobj); char *(*name)(struct ks 阅读全文
posted @ 2019-07-07 20:40 樊伟胜 阅读(1061) 评论(0) 推荐(0) 编辑
上一页 1 ··· 136 137 138 139 140 141 142 143 144 ··· 280 下一页