将设备驱动程序模块源码添加到Linux内核模块源码中
1、将设备驱动程序模块globalmem添加到内核源码中,存放路径是kernel/drivers/mydriver/globalmem;
2、globalmem模块包含源码文件:globalmem.h和globalmem.c;
3、将globalmem.h和globalmem.c放到kernel/drivers/mydriver/globalmem路径下;
4、在kernel/drivers/mydriver/globalmem下添加Kconfig和Makefile文件用于内核配置和源码编译,
Kconfig文件内容:
menu "Global Memory Support"
config GLOBAL_MEMORY
bool "Global Memory Support"
help
Global Memory Support
default y
endmenu
Makefile文件内容:
bj-$(CONFIG_GLOBAL_MEMORY) += globalmem.o
5、同时也需要修改kernel/drivers/mydriver下的Kconfig和Makefile文件,将globalmem目录下
的Kconfig和Makefile文件分别在其中注册:
Kconfig文件:
menu "My Driver"
comment "My Drivers"
source "drivers/mydriver/globalmem/Kconfig"
endmenu
Makefile文件:
obj-y += globalmem/
6、添加完成后,执行make menuconfig,就可以在Device Drivers--->My Driver--->
Global Memory Support--->Global Memory Support看到新添加的globalmem项了;
(kernel/drivers/mydriver中的Kconfig文件在kernel/drivers中的Kconfig文件中注册:
menu "Device Drivers"
source "drivers/mydriver/Kconfig"
)
(kernel/drivers/mydriver/globalmem中的Kconfig文件在kernel/drivers/mydriver中的
Kconfig文件中注册:
menu "My Driver"
comment "My Drivers"
source "drivers/mydriver/globalmem/Kconfig"
endmenu
)
(kernel/drivers/mydriver/globalmem中的Kconfig文件中的内容生成的配置项,
默认配置是built-in的,因此*表示选中编译:
menu "Global Memory Support"
config GLOBAL_MEMORY
bool "Global Memory Support"
help
Global Memory Support
default y
endmenu
)