字符设备驱动程序框架.docxVIP

  • 1
  • 0
  • 约5.52千字
  • 约 6页
  • 2019-09-27 发布于广东
  • 举报
1、 写出open、wri te函数 2、 告诉内核 、定义一个struct file. operations结构并填充好 static struct file operations first drv fops =( .owner = THIS_MODULE, /*这是一个宏,推向编译模块时口动创建的_this_modulo变量*/ .open = first_drv_open, .write = first_drv_write, }; 、把struct f订e operations结构体告诉内核 major = register chrdev (0, first drv, first drv fops) ; // 注册,告诉内核 相关参数:第一个,设备号,0口动分配主设备号,否则为主设备号0-255 第二个:设备名 第二个:struct file operations 结构体 、register chrdev由谁调用(入口函数调用) static int first drv init(void) 、入口函数须使用内核宏來修饰 module init (first drv init); module_init会定义一个结构体,这个结构体里面有一个函数指针指向first drv init这个函数,当我们 加载或安装一个驱动时,内核会自动找到这个结构体,然后调川里面的函数指针,这个

文档评论(0)

1亿VIP精品文档

相关文档