2.1 设备驱动 设备驱动程序将复杂的硬件抽象成一个结构
良好的设备,并通过提供统一的程序接口为 系统的其它部分提供使用设备的能力和方法。 设备驱动程序(应该只是)为系统的其它部分 提供各种使用设备的能力,使用设备的方法 应该由应用程序决定。
精品课件
4
二、知识储备
2.1 设备驱动
Linux下对外设的访问只能通过驱动程序
Linux对于驱动程序有统一的接口,以文件 的形式定义系统的驱动程序:
Open、Release、read、write、ioctl…
驱动程序是内核的一部分,可以使用中断、 DMA等操作
驱动程序需要在用户态和内核态之间传递 数据
精品课件
5
二、知识储备
2.1 设备驱动 驱动程序与应用程序的区别 应用程序以main函数开始,驱动程序则没
精品课件
14
二、知识储备
2.2 设备驱动案例分析(LED驱动)
精品课件
15
二、知识储备
2.2 设备驱动案例分析(LED驱动)
驱动程序分析:
#include <linux/module.h> /*Dynamic loading of modules into the kernel */
#include <linux/kernel.h> /*与printk()等函数有关的头 文件*/
供了一种区分它们的方法 系统增加一个驱动程序就要赋予它一个主设备号。
这一赋值过程在驱动程序的初始化过程中
int register_chrdev(unsigned int major, const char*name,struct file_operations *fops);
精品课件