150 likes | 294 Views
Add My Code into Kernel Source Tree. # cd # cd src # cd linux-2.6.30.4 # make i386_defconfig # ls # more . config ... CONFIG_ARCH_DEFCONFIG ="arch/x86/ configs /i386_defconfig". #1. 1. arch/x86/ Kconfig ... source " init/ Kconfig " menu "Processor type and features". #2.
E N D
# cd # cdsrc # cd linux-2.6.30.4 # make i386_defconfig # ls # more .config ... CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig" ...
#1 1. arch/x86/Kconfig ... source "init/Kconfig" menu "Processor type and features" ...
#2 2. init/Kconfig ... menu "My Menu ..." config MYMENU bool "Hello ..." defualt y endmenu menu "General setup" ...
... menu "General setup" config MYTEST bool "Add My Test menu ..." config EXPERIMENTAL ...
#3 3. arch/Kconfig ... # General architecture dependent options config MYGENARCH bool "Add My General Arch Menu" default n config OPROFILE ...
1. arch/x86/Kconfig ... source "net/Kconfig" source "drivers/Kconfig" ... 2. net/Kconfig ... if INET source "net/ipv4/Kconfig" ... endif # if INET ...
3. net/ipv4/Kconfig ... config MYPROTOCOLTEST bool "My protrocol test ..." config IP_MULTICAST bool "IP: multicasting" ...
# make menuconfig ... [*] Networking support ---> Networking support Networking options ---> ... [*] TCP/IP networking [ ] My protocol test ... (NEW) [*] IP: multicasting Device Drivers --->
net/ipv4/Makefile # # Makefile for the Linux TCP/IP (INET) layer. # obj-y := route.oinetpeer.oprotocol.o \ ... \ inet_fragment.o obj-$(CONFIG_MYPROTOCOLTEST) += myprotocol.o obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o ...
net/ipv4/myprotcol.c #include <autoconf.h> myprotocol () { #ifdefCONFIG_MYPROTOCOLTEST printk(“Wired communications ...\n”); #endif }
net/ipv4/route.c #include <autoconf.h> ... #ifdefCONFIG_MYPROTOCOLTEST myprotocol(); #endif ...
include/linux/autoconf.h # make menuconfig # ls –a # more .config # make bzImage // include/linux/autoconf.h ... CC arch/x86/boot/video-bios.o LD arch/x86/boot/setup.elf OBJCOPY arch/x86/boot/setup.bin OBJCOPY arch/x86/boot/vmlinux.bin HOSTCC arch/x86/boot/tools/build BUILD arch/x86/boot/bzImage Kernel: arch/x86/boot/bzImage is ready (#1)
Procedure • 추가하려고 하는 기능이 어느 곳에 있는가 ? Kconfig • 기능 항목을 추가 config MYTEST default y • # make menuconfig .config CONFIG_MYTEST=y • 소스코드 작성 및 저장 => 해당되는 디렉토리에서 mytest.c • 내가 작성한 커널함수를 어디에서 호출할 것인지 결정 후 코딩 #include <linux/autoconf.h> #ifdef CONFIG_MYTEST mytest(); #endif • Makefile에 나의 파일이 추가되도록 obj-$(CONFIG_MYTEST) += mytest.o • # make bzImage arch/x86/boot/bzImage생성된다