【摘选】linux 设备驱动程序工作的基本原理
来源:互联网 发布:台达plc编程手册 编辑:程序博客网 时间:2024/04/29 21:35
由于用户进程是通过设备文件同硬件打交道,对设备文件的操作方式不外乎就
是一些系统调用,如 open,read,write,close...., 注意,不是fopen, fread.,
但是如何把系统调用和驱动程序关联起来呢?这需要了解一个非常关键的数据
结构:
struct file_operations {
int (*seek) (struct inode * ,struct file *, off_t ,int);
int (*read) (struct inode * ,struct file *, char ,int);
int (*write) (struct inode * ,struct file *, off_t ,int);
int (*readdir) (struct inode * ,struct file *, struct dirent * ,int);
int (*select) (struct inode * ,struct file *, int ,select_table *);
int (*ioctl) (struct inode * ,struct file *, unsined int ,unsigned long);
int (*mmap) (struct inode * ,struct file *, struct vm_area_struct *);
int (*open) (struct inode * ,struct file *);
int (*release) (struct inode * ,struct file *);
int (*fsync) (struct inode * ,struct file *);
int (*fasync) (struct inode * ,struct file *,int);
int (*check_media_change) (struct inode * ,struct file *);
int (*revalidate) (dev_t dev);
}
这个结构的每一个成员的名字都对应着一个系统调用.用户进程利用系统调用
在对设备文件进行诸如read/write操作时,系统调用通过设备文件的主设备号
找到相应的设备驱动程序,然后读取这个数据结构相应的函数指针,接着把控制
权交给该函数.这是linux的设备驱动程序工作的基本原理.既然是这样,则编写
设备驱动程序的主要工作就是编写子函数,并填充file_operations的各个域.
相当简单,不是吗?
- 【摘选】linux 设备驱动程序工作的基本原理
- Linux设备驱动程序工作原理
- LINUX下的设备驱动程序
- Linux设备驱动程序的基本知识
- Linux i2c设备的驱动程序
- 遍历PCI设备的Linux设备驱动程序
- Linux驱动程序的工作原理
- PPP驱动程序的基本原理
- PPP驱动程序的基本原理
- PPP驱动程序的基本原理
- PPP驱动程序的基本原理
- linux设备驱动程序学习(7) tasklet,工作队列,共享队列
- Linux下的设备驱动程序的编写
- Linux设备驱动程序之二 ---- 完善上一节的驱动程序
- Linux设备驱动程序之三 ---- LED驱动程序的实现
- linux最小设备驱动程序-驱动程序代码的基本骨架
- 如何编写Linux的设备驱动程序
- 如何编写Linux的设备驱动程序
- 程序实现定时关机
- 控件开发-扩展自定义验证控件1
- 这是为什么呢?
- 开源如何盈利?
- 鄙视
- 【摘选】linux 设备驱动程序工作的基本原理
- 需求调研步骤和方法
- 23种设计模式学习之东拼西凑-------抽象工厂模式
- 自动设置JAVA环境变量的脚本转自(JAVA中文世界---紫叶)
- 什么是工作流?
- 栽种总结<------2009年第一波
- 如果你遇见一架天秤...
- 一种躲避运行时代码校验的方法
- 关于c# 中的listview隐藏列(回来试试得)