一 uboot传递参数'console=ttyXXX'的作用
来源:互联网 发布:java多维数组初始化 编辑:程序博客网 时间:2024/05/07 15:12
linux启动时uboot传递进console=ttyS0,115200n8的参数
内核中用__setup()宏声明参数处理的方法
关于__setup宏参考 early_param和__setup宏
- __setup("console=", console_setup);
console_setup函数处理
1.console_cmdline结构体
- struct console_cmdline
- {
- char name[8]; //驱动名
- int index; //次设备号
- char *options; //选项
- #ifdef CONFIG_A11Y_BRAILLE_CONSOLE
- char *brl_options;
- #endif
- };
2.console_setup
- static int __init console_setup(char *str)
- {
- char buf[sizeof(console_cmdline[0].name) + 4]; //分配驱动名+index的缓冲区
- char *s, *options, *brl_options = NULL;
- int idx;
- #ifdef CONFIG_A11Y_BRAILLE_CONSOLE
- if (!memcmp(str, "brl,", 4)) {
- brl_options = "";
- str += 4;
- } else if (!memcmp(str, "brl=", 4)) {
- brl_options = str + 4;
- str = strchr(brl_options, ',');
- if (!str) {
- printk(KERN_ERR "need port name after brl=\n");
- return 1;
- }
- *(str++) = 0;
- }
- #endif
- if (str[0] >= '0' && str[0] <= '9') { //第一个参数属于[0,9]
- strcpy(buf, "ttyS"); //则将其驱动名设为ttyS
- strncpy(buf + 4, str, sizeof(buf) - 5);//将次设备号放其后面
- } else {
- strncpy(buf, str, sizeof(buf) - 1); //放设备号到其后面
- }
- buf[sizeof(buf) - 1] = 0;
- if ((options = strchr(str, ',')) != NULL) //获取options
- *(options++) = 0;
- #ifdef __sparc__
- if (!strcmp(str, "ttya"))
- strcpy(buf, "ttyS0");
- if (!strcmp(str, "ttyb"))
- strcpy(buf, "ttyS1");
- #endif
- for (s = buf; *s; s++)
- if ((*s >= '0' && *s <= '9') || *s == ',')
- break;
- idx = simple_strtoul(s, NULL, 10); //获取次设备号
- *s = 0;
- __add_preferred_console(buf, idx, options, brl_options);
- console_set_on_cmdline = 1;
- return 1;
- }
__add_preferred_console函数
- static int __add_preferred_console(char *name, int idx, char *options,char *brl_options)
- {
- struct console_cmdline *c;
- int i;
- for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++) //可以最多8个console
- if (strcmp(console_cmdline[i].name, name) == 0 && console_cmdline[i].index == idx) {
- //比较已注册的console_cmdline数组中的项的名字及次设备号,若console_cmdline已经存在
- if (!brl_options)
- selected_console = i; //设置全局selected_console索引号
- return 0; //则返回
- }
- if (i == MAX_CMDLINECONSOLES) //判断console_cmdline数组是否满了
- return -E2BIG;
- if (!brl_options)
- selected_console = i; //设置全局selected_console索引号
- c = &console_cmdline[i]; //获取全局console_cmdline数组的第i项地址
- strlcpy(c->name, name, sizeof(c->name)); //填充全局console_cmdline的驱动名
- c->options = options; //填充配置选项115200n8
- #ifdef CONFIG_A11Y_BRAILLE_CONSOLE
- c->brl_options = brl_options;
- #endif
- c->index = idx; //填充索引号0
- return 0;
- }
该数组及全局selected_console,在register_console中会使用到
二 console 设备驱动
- 一 uboot传递参数'console=ttyXXX'的作用
- 一 uboot传递参数'console=ttyXXX'的作用
- uboot与linux之间参数的传递
- uBoot和Linux的参数传递关系
- uboot与linux的参数传递
- Uboot与Linux之间的参数传递
- uboot中背光的启动参数传递
- uboot中给kernel参数的传递
- Uboot与Linux之间的参数传递
- uboot移植之uboot和kernel的参数传递
- uboot移植之uboot和kernel的参数传递
- uboot移植之uboot和kernel的参数传递
- UBOOT传递内核参数
- uboot参数传递问题
- uboot内核参数的传递与内核解析uboot传递的内核参数
- uboot内核参数的传递与内核解析uboot传递的内核参数
- uboot和kernel传递参数
- Uboot--Linux参数传递--ATAG
- android多分辨率适配以及apk小工具及相关源码
- HTTP深入浅出 http请求
- Tomcat配置文件
- c++中指针与引用的区别
- windows下安装openmeetings
- 一 uboot传递参数'console=ttyXXX'的作用
- 算法系列之十二:多边形区域填充算法--改进的扫描线填充算法
- javax.el.ELException: expression factory class not found ---jbpm4.4和tomcat6中包冲突问题
- 三 printk如何打印信息
- QT中 窗口部件的 背景图片 的设置
- WebRTC将如何影响当前的移动互联网?
- xenserver虚拟机hang住解决办法
- PowerDesigner 实际当中应用
- 四 linux tty驱动