一 uboot传递参数'console=ttyXXX'的作用
来源:互联网 发布:混凝土软件 编辑:程序博客网 时间:2024/05/19 21:18
linux启动时uboot传递进console=ttyS0,115200n8的参数
内核中用__setup()宏声明参数处理的方法
关于__setup宏参考 early_param和__setup宏
__setup("console=", console_setup);
console_setup函数处理
1.console_cmdline结构体
struct console_cmdline{charname[8];//驱动名intindex;//次设备号char*options;//选项#ifdef CONFIG_A11Y_BRAILLE_CONSOLEchar*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_CONSOLEif (!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;}#endifif (str[0] >= '0' && str[0] <= '9') {//第一个参数属于[0,9]strcpy(buf, "ttyS");//则将其驱动名设为ttySstrncpy(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");#endiffor (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个consoleif (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_CONSOLEc->brl_options = brl_options;#endifc->index = idx;//填充索引号0return 0;}
整体的作用是根据uboot传递的参数设置全局console_cmdline数组
该数组及全局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
- 数字三角形II
- 短期的学习目标
- 如何把自己的驱动编译进内核或模块
- 帝国cms提交后返回地址变量:ecmsfrom
- 树莓派(raspberry pi)学习18:设置watchdog,防死机
- 一 uboot传递参数'console=ttyXXX'的作用
- linux下ps命令
- volatile 的意义
- linux 启动过程
- 戛古 Kakku Pagodas
- 戛古 Kakku, Kekku-掸邦 shan state
- Yii中使用单选框 activeRadioButtonList
- Kakku Buddhist Stupas, Kakku Buddhist Stupas Myanmar, Kakku Buddhist Stupas Travel Guide & Tours
- ubuntu使用记录-vim配置