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
)