Linux驱动
rbin_yao
这个作者很懒,什么都没留下…
展开
-
Linux字符设备驱动(三)自动创建设备节点
Linux字符设备驱动(三)自动创建设备节点在前面的字符设备中需要手动运行mknod创建设备节点,但其实linux中可以通过udev自动创建设备节点,通过下面两步即可实现。class_createdevice_createstruct class *class_create(struct module *owner, const char *name);struct dev...原创 2020-02-28 20:31:48 · 429 阅读 · 0 评论 -
Linux字符驱动(二)
Linux字符驱动(二)Linux下有个直接注册字符设备的方法,register_chrdev和unregister_chrdev:static inline int register_chrdev(unsigned int major, const char *name, const struct file_operations *fops){ return __regist...原创 2020-02-28 19:52:38 · 120 阅读 · 0 评论 -
Linux字符设备(一)
Linux字符驱动linux系统将设备分为3类:字符设备、块设备、网络设备。Linux系统框架如下图:字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据。字符设备按照字符流的方式被有序访问。字符设备是面向流的设备,常见的字符设备有鼠标、键盘、串口、控制台和LED设备等。块设备:是指可以从设备的任意位置读取一定长度数据的设备。块设备包括硬盘、磁盘、U盘和SD卡等...原创 2020-02-27 19:37:14 · 4491 阅读 · 0 评论 -
Linux内核模块参数
Linux内核模块参数1传递单个参数module_param(name, type, perm); name 既是用户看到的参数名,又是模块内接受参数的变量; type 表示参数的数据类型,是下列之一:byte, short, ushort, int, uint, long, ulong, charp, bool, invbool; perm 指定了在sysfs中相应文...原创 2020-02-26 20:00:26 · 451 阅读 · 0 评论 -
Linux内核模块
Linux内核模块Linux内核模块通过module_init指定入口初始化函数,module_exit指定卸载时执行的函数。#include <linux/init.h>#include <linux/module.h>static int __init mymodule_init(void){ printk("mymodule init.\r\n"); ...原创 2020-02-26 12:00:57 · 161 阅读 · 0 评论