利用uboot传递参数进行内核的不同配置
2013-08-23 17:16
387 查看
如果一个硬件有不同的驱动支持,那么每次还得重新编译内核才能重新加载驱动吗?内核提供了一种很方便的机制,可以让我们通过uboot的命令参数来传递,调用不同的内核驱动。
得到不同的内核配置参数,之后依此可选择不同的文件进行驱动加载!
__setup("xxx=", xxx_setup);以内核下的文件Fbmem.c为例!
/** * fb_get_options - get kernel boot parameters * @name: framebuffer name as it would appear in * the boot parameter line * (video=<name>:<options>) * @option: the option will be stored here * * NOTE: Needed to maintain backwards compatibility */ int fb_get_options(char *name, char **option) { char *opt, *options = NULL; int retval = 0; int name_len = strlen(name), i; if (name_len && ofonly && strncmp(name, "offb", 4)) retval = 1; if (name_len && !retval) { for (i = 0; i < FB_MAX; i++) { if (video_options[i] == NULL) continue; if (!video_options[i][0]) continue; opt = video_options[i]; if (!strncmp(name, opt, name_len) && opt[name_len] == ':') options = opt + name_len + 1; } } if (options && !strncmp(options, "off", 3)) retval = 1; if (option) *option = options; return retval; } #ifndef MODULE /** * video_setup - process command line options * @options: string of options * * Process command line options for frame buffer subsystem. * * NOTE: This function is a __setup and __init function. * It only stores the options. Drivers have to call * fb_get_options() as necessary. * * Returns zero. * */ static int __init video_setup(char *options) { int i, global = 0; if (!options || !*options) global = 1; if (!global && !strncmp(options, "ofonly", 6)) { ofonly = 1; global = 1; } if (!global && !strstr(options,"fb:")) { fb_mode_option = options; global = 1; } if (!global) { for (i = 0; i < FB_MAX; i++) { if (video_options[i] == NULL) { video_options[i] = options; break; } } } return 1; } __setup("video=", video_setup);
int fb_get_options(char *name, char **option)
得到不同的内核配置参数,之后依此可选择不同的文件进行驱动加载!
相关文章推荐
- u-boot与Linux内核视频显示接口参数配置及传递方案
- 3种使用不同根文件系统 u-boot传递的内核启动参数
- Linux内核---16.启动分析4uboot与内核的参数传递
- arm-linux之uboot向内核传递参数
- 自己写bootloader笔记6---boot.c分析(u-boot向内核传递参数及跳转到内核)
- u-boot传递给内核的参数bootargs和命令bootcmd(上)
- u-boot向2.6之后的linux内核传递启动参数的方法以及常用的参数
- u-boot与linux内核间的参数传递过程分析
- 利用反射进行xml文件配置参数管理
- uboot内核参数的传递与内核解析uboot传递的内核参数
- 利用js代码:document.forms[0].approval.value='false',当点击 <input type="image"按钮向表单传递不同的参数。
- u-boot与linux内核间的参数传递过程分析
- u-boot与linux内核间的参数传递过程分析
- u-boot与linux内核间的参数传递过程分析
- u-boot与linux内核间的参数传递过程分析
- u-boot与linux内核间的参数传递过程分析
- 转载_uboot传递内核参数全解析
- u-boot与Linux内核间的参数传递过程分析[转载]
- 利用数组名作为函数参数传递排序和用指针进行排序
- SpringMVC_01 SpringMVC五大组件、SpringMVC编程步骤(不使用注解进行配置)、SpringMVC编程步骤(利用注解进行配置)、参数获取、响应数据