1.模块加载程序结构编程
- 模块加载函数:函数
static int _init init_function(void);it
module_init(init_function); io
- 模块卸载函数:function
static void _exit exit_function(void); 变量
module_exit(exit_function);module
- 模块许可证声明:file
MODULE_LICENSE("GPL");引用
2.多模块编程程序
- 模块符号导出:对于模块内定义的函数和变量,若是想让其余模块引用,必须使用:EXPORT_SYMBOL(X)导出,而后使用extern声明
- 模块传参:module_param(), module_param_array()
- 多个c文件模块:其中一个不能写成模块的形式,makefile有所不一样,obj-m=hello.o hello-objs:=hello.o world.o