【Linux设备驱动程序(第三版)】----HelloWorld
2011-07-06 10:34
316 查看
【Linux设备驱动程序(第三版)】----HelloWorldHelloWorld.c
Makefile
make
装载模块
卸载模块
查看Log
#include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, World!\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye,world!\n"); } module_init(hello_init); module_exit(hello_exit);
Makefile
obj-m:= HelloWorld.o modules-objs:= HelloWorld.o KDIR:= /usr/src/linux-headers-2.6.31-14-generic/ PWD:= $(shell pwd) default: make -C $(KDIR) M=$(PWD) modules clean: rm -rf *.ko *.mod.c *.mod.o *.o *.markers *.symvers *.order
make
make -C /usr/src/linux-headers-2.6.31-14-generic/ M=/home/wangzhzh/Module/HelloWorld modules make[1]: Entering directory `/usr/src/linux-headers-2.6.31-14-generic' CC [M] /home/wangzhzh/Module/HelloWorld/HelloWorld.o Building modules, stage 2. MODPOST 1 modules CC /home/wangzhzh/Module/HelloWorld/HelloWorld.mod.o LD [M] /home/wangzhzh/Module/HelloWorld/HelloWorld.ko make[1]: Leaving directory `/usr/src/linux-headers-2.6.31-14-generic'
装载模块
insmod HelloWorld.ko
卸载模块
rmmod HelloWorld
查看Log
dmesg [84263.420542] Hello, World! [84272.598899] Goodbye,world!
相关文章推荐
- 【Linux设备驱动程序(第三版)】----Scull
- 【Linux设备驱动程序(第三版)】----阻塞与非阻塞型操作
- 【Linux设备驱动程序(第三版)】----高速缓存
- 2.最基础Linux设备驱动程序:HelloWorld
- Linux设备驱动程序第三版学习(2)-字符设备驱动程序源码分析(续) .
- Linux设备驱动程序第三版学习(4)- 并发和竟态
- 【Linux设备驱动程序(第三版)】----模块参数
- 【Linux设备驱动程序(第三版)】----忙等待
- Linux 设备驱动程序 第三版
- linux设备驱动程序第三版中译版
- Linux设备驱动程序第三版学习(2)-字符设备驱动程序源码分析(续)
- 嵌入式Linux简单字符设备驱动程序---helloworld
- 完整的Linux设备驱动程序 第三版
- 【Linux设备驱动程序(第三版)】----异步通知
- 【Linux设备驱动程序(第三版)】----延迟:让出处理器
- Linux设备驱动程序第三版学习(2)-字符设备驱动程序源码分析(续)
- Linux设备驱动程序第三版学习(6)- 高级字符驱动程序操作(续1) - 进程休眠
- 【Linux设备驱动程序(第三版)】----驱动调试Proc
- Linux设备驱动程序第三版学习(7)- 高级字符驱动程序操作(续2)- poll/select
- Linux设备驱动程序第三版学习(5)- 高级字符驱动程序操作 - ioctl .