驱动编写
来源:互联网 发布:人民大学 数据库系统 编辑:程序博客网 时间:2024/04/29 04:00
一,设备注册,首先要将设备添加到虚拟平台总线platform
1,include/linux/platform_device.h打开"platform_device"所在文件
对以上两件结构体实例化是在平台文件arch/arm/mach-exynos/mach-itop4412.c,里头要修改两段语句
2,在menuconfig里添加选项
vim drivers/char/Kconfig在里头添加一段脚本
3,ls /sys/devices/platform/可以虚拟总线上查看到注册设备
二,驱动注册,platform_driver_register/platform_driver_unregister
1,include/linux/platform_device.h打开"platform_driver"
入口:module_init(hello_init)->platform_driver_register(&hello_driver)->hello_driver.hello_probe()就实现了模块对platform_driver的调用出口:hello_driver.hello_remove()->platform_driver_unregister(&hello_driver)->module_exit(hello_init)
三,生成设备节点(杂项设备节点),
1,vim include/linux/miscdevice.h有misc_register()/misc_deregister(),并有miscdevice结构体
在platform_driver.probe函数里调用misc_register()来实现miscdevice结构的调用,实例化这个结构体。
一,四,实现驱动const struct file_operations *fops的成员函数miscdevice结构里有一个const struct file_operations *fops结构体,它在include/linux/fs.h里面,包含它然后实现相关函数功能。
然后ls /dev/就可以看见这个设备节点了。
1,<sys/types.h> <sys/stat.h> <fcntl.h> <unistd.h> <sys/ioctl.h>
就可以使用open/close/ioctl等函数对设备节点进行操作。
*************************************************************
*************************************************************
*************************************************************
*************************************************************
以上是对杂项设备的注册与驱动的介绍
*************************************************************
*************************************************************
*************************************************************
- 驱动编写
- 驱动编写
- LCD驱动编写小节
- LCD驱动编写小节
- WinCE驱动编写 小结
- ra601的驱动编写
- Linux驱动程式编写
- 驱动壳编写总结
- LCD驱动编写小结
- 驱动编写的全过程
- 编写Linux设备驱动
- 驱动编写的全过程
- 阻塞性驱动编写
- LCD驱动编写小节
- v4l2驱动编写篇
- 简单驱动编写
- 字符设备驱动编写
- 块设备驱动编写
- HDOJ 5671-Matrix【矩阵的变换】
- 获取SHA1值
- 美团商家分类菜单
- 解决linux不能上外网的问题
- LeetCode 220 Contains Duplicate III
- 驱动编写
- 反编译文件管理器apk隐藏蓝牙模块
- std::map find 陷阱
- Spring之框架初探
- Maven入门指南④:仓库
- 一名传智播客普通员工的心声:我骄傲,我是传智人
- Unity3D编辑器插件编写
- 获取使用nginx代理后的真实IP地址
- spring mvc 4+ @ResponseBody 中文乱码