1.Linux内核模块编程

1.模块加载程序结构

  - 模块加载函数:

    static int _init init_function(void);

    module_init(init_function); 

  - 模块卸载函数:

    static void _exit exit_function(void);  

    module_exit(exit_function);

  - 模块许可证声明:

    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

原文地址:https://www.cnblogs.com/Mr-ox/p/6406184.html