1. scull.h
2. scull.c
3. Makefile
4. make之后生成ko文件,insmod之后要建立节点才能被应用程序读写访问:
在/proc/devices文件里面可以查看到scull的主设备号,假设为251
sudo su
mknod /dev/scull0 c 251 0
mknod /dev/scull1 c 251 1
mknod /dev/scull2 c 251 2
mknod /dev/scull3 c 251 3
chgrp staff /dev/scull[0-3]
chmod 664 /dev/scull[0-3]
5. 测试程序scull_test.c
gcc scull_test.c -o scull_test.o
sudo ./scull_test.o
结果:
Write 8 bytes to scull
Write 8 bytes to scull
Write 8 bytes to scull
Read 8 bytes from scull
Read 8 bytes from scull
Read 8 bytes from scull
Read "Hello, Character driver!" from scull
本文介绍了一个名为scull的字符设备驱动程序的实现细节。该驱动程序使用量子集来存储数据,并通过动态分配内存的方式支持可配置的数据量。文章详细解释了如何编译和安装驱动程序,以及如何创建设备节点以便应用程序进行读写操作。
588

被折叠的 条评论
为什么被折叠?



