linux 内核驱动编译简单示例
hello.c
#include <linux/module.h> #include <linux/init.h> static int __init hello_init(void) { printk(KERN_ALERT "Hello,world!\n"); return 0; } static void __exit helo_exit(void) { printk(KERN_ALERT "GoodBye,cruel world!\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("codingbug"); MODULE_DESCRIPTION("STUDY_MODULE");
Makefile
View Code
1 obj-m += hello.o 2 KDIR:=/lib/modules/$(shell uname -r)/build 3 all: 4 make -C $(KDIR) M=$(PWD) modules 5 clean: 6 make -C $(KDIR) M=$(PWD) clean
我要那天再遮不住我眼
我要那地再埋不了我心
我要这众生都明白我意
我要那诸佛都烟消云散
--- 今何在《悟空传》