阅读背景:

嵌入式Linux简单字符设备驱动程序---helloworld_dongliang的博客

来源:互联网 
 /*
**$ gcc -DMODULE -D__KERNEL__ -I /usr/src/linux-2.4.20/include -c hello.c
**$ insmod hello.o   如果成功加载到内核将在终端上显示:Hello world, Linux Driver!
**$ rmmod hello.o    卸载成功的话将终端显示:             Goodbye, Linux Driver!
*/
#include <linux/module.h>
#include <linux/init.h>/* Tell the kernel I can do what */

static int __init hello_init(void)
{
     printk(KERN_ALERT"Hello world, Linux Driver!\n");
     return 0;
}

/* Tell the kernel stop me doing */
static void __exit hello_exit(void)
{
     printk(KERN_ALERT"Goodbye, Linux Driver!\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("Dual BSD/GPL"); /* All modules need to define the LICENCE */

 /*
**$ gcc -DMODULE -D__KERNEL__ -I /usr/src/l



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: