printk 中console_cmdline数组的填充
来源:互联网 发布:底层软件开发 编辑:程序博客网 时间:2024/05/22 00:32
在printk.c 中有定义一个数组
static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];其中MAX_CMDLINECONSOLES等于8,表示cmdline最多可以传递8个console
要填充这个数组有两种方式,
一种是在console driver中主动调用add_preferred_console
例如 add_preferred_console("hvc", index, NULL);
第二种是通过传递console 这个commmand line,这个参数可以传递多个,例如console=tty0,console=ttyS0等
static int __init console_setup(char *str)
{
char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for "ttyS" */
char *s, *options, *brl_options = NULL;
int idx;
if (_braille_console_setup(&str, &brl_options))
return 1;
/*
* Decode str into name, index, options.
*/
if (str[0] >= '0' && str[0] <= '9') {
strcpy(buf, "ttyS");
strncpy(buf + 4, str, sizeof(buf) - 5);
} else {
strncpy(buf, str, sizeof(buf) - 1);
}
buf[sizeof(buf) - 1] = 0;
options = strchr(str, ',');
if (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 (isdigit(*s) || *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;
}
如果传递console的话,主要通过这个函数解析的,可以看到如果传递的是ttyS0的话,可以简写成console=0.这个数字是0~9
这个函数最终也是调用__add_preferred_console 将自己添加到console_cmdline 数组中。console_set_on_cmdline 这个参数只在suncore.c中有使用
if (!console_set_on_cmdline) {
con->index = line;
add_preferred_console(con->name, line, NULL);
}
static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];其中MAX_CMDLINECONSOLES等于8,表示cmdline最多可以传递8个console
要填充这个数组有两种方式,
一种是在console driver中主动调用add_preferred_console
例如 add_preferred_console("hvc", index, NULL);
第二种是通过传递console 这个commmand line,这个参数可以传递多个,例如console=tty0,console=ttyS0等
static int __init console_setup(char *str)
{
char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for "ttyS" */
char *s, *options, *brl_options = NULL;
int idx;
if (_braille_console_setup(&str, &brl_options))
return 1;
/*
* Decode str into name, index, options.
*/
if (str[0] >= '0' && str[0] <= '9') {
strcpy(buf, "ttyS");
strncpy(buf + 4, str, sizeof(buf) - 5);
} else {
strncpy(buf, str, sizeof(buf) - 1);
}
buf[sizeof(buf) - 1] = 0;
options = strchr(str, ',');
if (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 (isdigit(*s) || *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;
}
如果传递console的话,主要通过这个函数解析的,可以看到如果传递的是ttyS0的话,可以简写成console=0.这个数字是0~9
这个函数最终也是调用__add_preferred_console 将自己添加到console_cmdline 数组中。console_set_on_cmdline 这个参数只在suncore.c中有使用
if (!console_set_on_cmdline) {
con->index = line;
add_preferred_console(con->name, line, NULL);
}
0 0
- printk 中console_cmdline数组的填充
- __add_preferred_console的作用是添加console到console_cmdline 数组
- linux中printk的使用方法
- 关于linux中printk的显示等级
- linux中printk显示信息的级别
- linux驱动中printk的使用注意事项
- 填充数组
- fedora 中printk
- linux中printk()实例
- Linux中printk()实例
- ubuntu中printk终端无打印的问题
- Linux中printk和strace命令调试的一些技巧
- 如何查看Linux内核中printk打印的信息?
- Excel中使用填充命令填充数据的方法
- 数组的最佳练习题,二维数组的填充
- php 用给定的值填充数组| 使用指定的键和值填充数组
- printk()函数的总结
- printk()函数的使用
- qt 使用第三方库
- VB.NET中四舍五入
- 让Lua支持Linq吧
- LeetCode 95. Unique Binary Search Trees II
- caffe windows学习:第一个测试程序
- printk 中console_cmdline数组的填充
- 观察者模式
- 不停止主数据库操作,只操作从数据库,实现快速恢复的方法和局限性
- 【UGUI】制作艺术字体
- 谈谈DB2的db2fmp进程
- 【Java学习之旅】——Java如何实现像c#的#region实现代码折叠
- Eclipse 推荐书籍列表
- 常用工具类(8/14)
- WPF生成dll,以及从dll中恢复exe