Chinaunix首页 | 论坛 | 博客
  • 博客访问: 104559
  • 博文数量: 31
  • 博客积分: 2292
  • 博客等级: 大尉
  • 技术积分: 310
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-17 23:41
文章分类

全部博文(31)

文章存档

2011年(2)

2010年(29)

分类: LINUX

2010-05-25 21:06:41

 先记一下别人总结的比较好的:
1、牛人写的:系统的介绍了linux设备模型
2、Linux那些事儿之我是Sysfs:语言通俗易懂,但内容不俗
 
 
struct kobject {
 const char  *name;设备名
 struct list_head entry;便于连接到kset中的指针
 struct kobject  *parent;父指针
 struct kset  *kset;所属kset
 struct kobj_type *ktype;指向其对象类型描述符的指针
 struct sysfs_dirent *sd;?
 struct kref  kref;对象引用计数
 unsigned int state_initialized:1;初始化标志
 unsigned int state_in_sysfs:1;?
 unsigned int state_add_uevent_sent:1;
 unsigned int state_remove_uevent_sent:1;移除标志位
 unsigned int uevent_suppress:1;
};
注:红色部分是新内核中新加的,大概是一些标志位
这是位段,用法参见: 位段
 
 
 
struct kobj_type {
 void (*release)(struct kobject *kobj);
 struct sysfs_ops *sysfs_ops;
 struct attribute **default_attrs;
};

Kobj type数据结构包含三个域:一个release方法用于释放kobject占用的资源;一个sysfs ops指针指向sysfs操作表和一个sysfs文件系统缺省属性列表。Sysfs操作表包括两个函数store()和show()。当用户态读取属性时,show()函数被调用,该函数编码指定属性值存入buffer中返回给用户态;而store()函数用于存储用户态传入的属性值。
attribute
struct attribute {
char * name;
struct module * owner;
mode_t mode;
};
attribute, 属性。它以文件的形式输出到sysfs的目录当中。在kobject对应的目录下面。文件
名就是name。文件读写的方法对应于kobj type中的sysfs ops。


 
 
struct kset {
 struct list_head list;
 spinlock_t list_lock;
 struct kobject kobj;
 struct kset_uevent_ops *uevent_ops;
};
原有的struct kset_hotplug_ops * hotplug_ops;已经不存在,被kset_uevent_ops 结构体替换
另外 struct kobj_type    * ktype; 指向该kset对象类型的指针,也没有了
 
 
新的内核已经不再有subsystem数据结构
阅读(1304) | 评论(0) | 转发(0) |
0

上一篇:irq小笔记

下一篇:lkd读书笔记1

给主人留下些什么吧!~~