menu "CaoJiangfeng hello Test"
config HELLO_TEST
tristate "hello test support"
endmenu
4 向ceagleDriver中加入hello.c文件,文件内容如下:
#include<linux/module.h> #include<linux/kernel.h> #include<linux/init.h> #include<linux/proc_fs.h> int add(int i,int j) { return(i+j); } void fun() {
printk("This is in fun() function\n"); }
staticint __init hello_init(void) {
fun();
printk(KERN_INFO"<1>Hello module!\n");
printk(KERN_INFO"<1>This is my first time compile a module in kernel!\n");
printk(KERN_INFO"<2>5+6=%d\n",add(5,6)); return 0; }
staticvoid __exit hello_exit(void) {
printk(KERN_INFO"Leaving the kernel!Byebye!\n"); }
MODULE_LICENSE("BSD/GPL");//Check if the code support the protocol