__setup、early_param的解析
内核初始化时根据字符串匹配获得相应的处理函数,查找的时候有些麻烦。
写个脚本对将内核中的__setup和early_param显式做了解析:
__setup
#! /bin/bash grep '\<__setup\>' ./ -rn --include='*.c' | awk 'BEGIN{FS=":"}{$1="";$2="";print $0}' | grep '^ *__setup' | sed -n -e 's/.*\(__setup\).*"\(.*\)" *, *\(.*\));/__setup_param \2 \3 \3 0/p' | awk '{printf("static const char __setup_str_%s[] __initconst __aligned(1) \n= \"%s\";\n\nstatic struct obs_kernel_param __setup_%s \n__used __section(.init.setup) \n__attribute__((aligned((sizeof(long))))) \n= \n{\n _setup_str_%s, %s, %s\n};\n\n\n\n"),$3, $2, $3, $3, $4, $5}'
early_param
#! /bin/bash grep '\<early_param\>' ./ -rn --include='*.c' | awk 'BEGIN{FS=":"}{$1="";$2="";print $0}' | grep '^ *early_param' | sed -n -e 's/.*\(early_param\).*"\(.*\)" *, *\(.*\));/__setup_param \2 \3 \3 1/p' | awk '{printf("static const char \n__setup_str_%s[] \n__initconst __aligned(1) \n= \"%s\";\n\nstatic struct obs_kernel_param __setup_%s \n__used __section(.init.setup) \n__attribute__((aligned((sizeof(long))))) \n= \n{\n _setup_str_%s, %s, %s\n};\n\n\n\n"),$3, $2, $3, $3, $4, $5}'
附:
__tagtable
grep '__tagtable(ATAG_.*,.*)' ./ -rn | awk 'BEGIN{FS=":"}{$1="";$2="";print $0}' | grep '^ *__tagtable' | sed -n -e 's/.*\(__tagtable\).*( *\(.*\) *, *\(.*\) *).*/\1 \2 \3/p' | awk '{printf("static struct tagtable\n__tagtable_%s\n__used __attribute__((__section__(\".taglist.init\")))\n= \n{\n %s, %s\n}\n\n\n"),$3,$2,$3}'