|
|
1 jaar geleden | |
|---|---|---|
| .. | ||
| leds-user-defind.c | 1 jaar geleden | |
| readme.md | 1 jaar geleden | |
最基础模块。(注意,这个模块不会在dev文件夹中出现,只有注册字符设备或块设备才会在dev中创建节点) 22.编译成模块(.ko)文件
obj-m+= leds-user-defind.o
将模块导入泰山派的linux系统中
adb push xx\xx.ko /data/xx.ko
23.加载模块
1.进入adb shell
cd /data
2.找到xx.ko文件
lsmod 查看已存在的module
insmod xx.ko
3.lsmod 查看是否加载成功

4.查看模块打印的数据
dmesg | grep "hello"

5.卸载模块
rmmod xx

Unix-based systems expose hardware to user space by means of special files, all created in the /dev directory upon device registration with the system. Programs willing to access a given device must locate its corresponding device file in /dev and perform the appropriate system call on it, which will be redirected to the driver of the underlying device associated with that special file. Though system calls redirection is done by an operating system, what system calls are supported depends on the type of device and the driver implementation.
在基于 Unix 的系统中,硬件设备通过特殊文件的形式暴露给用户空间, 这些特殊文件在设备注册时创建于 /dev 目录下。程序若想访问某个设备, 必须找到其对应的设备文件,并对该文件执行适当的系统调用, 这些调用会被操作系统重定向到与该特殊文件关联的底层设备驱动程序。 虽然系统调用的重定向是由操作系统完成的, 但支持哪些系统调用则取决于设备的类型和驱动程序的实现。