岁月联盟 · 中国技术网 本站主页 | 安全认证 | 用户服务 | 技术论坛
新闻快报 | 新手学堂 | 黑客特区 | 程序语言 | 数 据 库 | 防 火 墙 | 路由交换 | 系统集成 | 服 务 器 | 存储备份 | 考试认证
Windows | Linux | Java | 协议分析 | 问题解答 | 进程大全 | 网页设计 | 多 媒 体 | 图库资料 | 软件下载 | 站内下载
  您现在的位置: 岁月联盟 >> Linux频道 >> 系统管理 >> 内核技术 >> Linux频道正文
内核操作 Linux2.6内核驱动移植参考
作者:未知 文章来源:本站整理 点击数: 更新时间:2007-12-18 17:31:56
field2: value,

..

};

 

[1] [2] [3] [4] [5] [6] 下一页  

11、 用户模式帮助器

int call_usermodehelper(char *path, char **argv, char **envp,int wait);

新增wait参数

12、 request_module()

request_module("foo-device-%d", number);

老版本:

char module_name[32];

printf(module_name, "foo-device-%d", number);

request_module(module_name);

13、 dev_t引发的字符设备的变化

1、取主次设备号为

unsigned iminor(struct inode *inode);

unsigned imajor(struct inode *inode);

2、老的register_chrdev()用法没变,保持向后兼容,但不能访问设备号大于256的设备。

3、新的接口为

a)注册字符设备范围

int register_chrdev_region(dev_t from, unsigned count, char *name);

b)动态申请主设备号

int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, char

*name);

看了这两个函数郁闷吧^_^!怎么和file_operations结构联系起来啊?别急!

c)包含 <linux/cdev.h>,利用struct cdev和file_operations连接

struct cdev *cdev_alloc(void);

void cdev_init(struct cdev *cdev, struct file_operations *fops);

int cdev_add(struct cdev *cdev, dev_t dev, unsigned count);

(分别为,申请cdev结构,和fops连接,将设备加入到系统中!好复杂啊!)

d)void cdev_del(struct cdev *cdev);

只有在cdev_add执行成功才可运行。

e)辅助函数

kobject_put(&cdev->kobj);

struct kobject *cdev_get(struct cdev *cdev);

void cdev_put(struct cdev *cdev);

这一部分变化和新增的/sys/dev有一定的关联。

14、 新增对/proc的访问操作

<linux/seq_file.h>

以前的/proc中只能得到string, seq_file操作能得到如long等多种数据。

相关函数:

static struct seq_operations 必须实现这个类似file_operations得数据中得各个成

员函数。

seq_printf();

int seq_putc(struct seq_file *m, char c);

int seq_puts(struct seq_file *m, const char *s);

int seq_escape(struct seq_file *m, const char *s, const char *esc);

int seq_path(struct seq_file *m, struct vfsmount *mnt,

struct dentry *dentry, char *esc);

seq_open(file, &ct_seq_ops);

等等

15、 底层内存分配

上一页  [1] [2] [3] [4] [5] [6] [7] [8] 下一页


  • 上一个Linux频道:
  • 下一个Linux频道: 没有了
  •  
    热门文章
    推荐文章
    关于我们 | 发展历程 | 网站地图 | 广告服务 | 招贤纳士 | 战略合作 | 友情链接 | 著作声明 | 联系我们
    Copyright © 2002-2007 SYUE All rights reserved.
    E_mail:WebSyue@163.Com 皖ICP备05004589号
    未经授权禁止转载、摘编、复制或建立镜像.如有违反,追究法律责任.
    惊天动地私服 天龙八部私服 天龙八部私服 热血江湖私服 天龙八部私服 bet365 bet365 传世私服 传奇世界私服