# linux-device-driver **Repository Path**: lishan666/linux-device-driver ## Basic Information - **Project Name**: linux-device-driver - **Description**: Linux device driver sample code,,only for learning - **Primary Language**: C++ - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-02-05 - **Last Updated**: 2023-02-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # linux-device-driver #### 介绍 学习linux设备驱动的示例代码 01. 最简单的驱动模块 02. 符号导出 03. 模块传参 04. 直接注册设备号 05. 动态注册设备号 06. 注册设备号,注册设备 07. 注册设备号,注册设备,需要手动创建设备文件 08. 注册设备号,注册设备,自动创建设备文件 09. 支持read、write 10. 支持ioctl 11. 支持多个次设备,需要手动创建设备文件 12. 原子操作 13. 互斥锁 14. 信号量 15. 自旋锁 16. 读写锁(等待队列,阻塞I/O,非阻塞I/O) 17. select、poll、epoll 18. sigio 19. 设备总线 20. 内核定时器 #### 软件架构 1. Operation System: Ubuntu 18.04.6 LTS x64 2. make: GNU Make 4.1 3. gcc: gcc version 7.5.0 #### 安装教程 1. 安装虚拟机: [VirtualBox-7.0.6](https://download.virtualbox.org/virtualbox/7.0.6/VirtualBox-7.0.6-155176-Win.exe) 2. 安装Ubuntu操作系统: [ubuntu-18.04.6](https://releases.ubuntu.com/18.04/ubuntu-18.04.6-desktop-amd64.iso) 3. 安装VsCode: [code_1.75.0](https://az764295.vo.msecnd.net/stable/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/code_1.75.0-1675266613_amd64.deb) 4. 下载代码: git clone https://gitee.com/lishan666/linux-device-driver.git 5. 更新代码: git pull #### 使用说明 01. 编译模块: make 02. 列出模块: lsmod 03. 加载模块: insmod xxx.ko(hello.ko) 04. 卸载模块: rmmod xxx.ko(hello.ko) 05. 显示模块信息: modinfo xxx.ko(hello.ko) 06. 创建设备文件: mknod "/dev/xxx"("/dev/test") c xxx(101) xxx(0) 07. 查看设备文件: ls -al /dev/ | grep xxx(test) 08. 显示系统信息: dmesg 09. 清除系统信息: dmesg -c 10. 编译测试程序: gcc xxx.c(test.c) -o xxx.out(a.out) 11. 运行可执行文件: ./xxx.out(a.out) #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)