Linux
驱动程序入门(hello world)
首先,确保linux内核源码放在/usr/src下面,安装好编译器,接下来就是程序员代码,具体如下:
#ifndef __KERNEL__
#include <linux/config.h>
MODULE_LICENSE("GPL"); #include <linux/kernel.h>
static int init_module()
static void cleanup_module() 保存hello.c,接下来编译源码,方法如下:gcc -c -DMODULE -DDEBUG_PRINTK -I/usr/src/linux/include hello.c 编译通过产生hello.o文件,然后即可加载hello模块:insmod hello.o,卸载模块:rmmd hello |