__add_preferred_console的作用是添加console到console_cmdline 数组
来源:互联网 发布:win10查看图片软件 编辑:程序博客网 时间:2024/06/01 09:52
在printk.c 中有定义一个数组static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
在程序中调用__add_preferred_console 会将kernel commandline 或者 通过acpi的scpr 表传递过来的console参数添加到console_cmdline 中
static int __add_preferred_console(char *name, int idx, char *options,
char *brl_options)
{
struct console_cmdline *c;
int i;
/*
* See if this tty is not yet registered, and
* if we have a slot free.
*/
for (i = 0, c = console_cmdline;
i < MAX_CMDLINECONSOLES && c->name[0];
i++, c++) {
if (strcmp(c->name, name) == 0 && c->index == idx) {
if (!brl_options)
selected_console = i;
return 0;
}
}
if (i == MAX_CMDLINECONSOLES)
return -E2BIG;
if (!brl_options)
selected_console = i;
strlcpy(c->name, name, sizeof(c->name));
c->options = options;
braille_set_options(c, brl_options);
c->index = idx;
return 0;
}
这样当个个console driver 调用register_console的时候,就会通过下面的code 来匹配注册的console 和 保存在console_cmdline 中的console是否匹配
for (i = 0, c = console_cmdline;
i < MAX_CMDLINECONSOLES && c->name[0];
i++, c++) {
if (!newcon->match ||
newcon->match(newcon, c->name, c->index, c->options) != 0) {
/* default matching */
BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
if (strcmp(c->name, newcon->name) != 0)
continue;
if (newcon->index >= 0 &&
newcon->index != c->index)
continue;
if (newcon->index < 0)
newcon->index = c->index;
if (_braille_register_console(newcon, c))
return;
if (newcon->setup &&
newcon->setup(newcon, c->options) != 0)
break;
}
newcon->flags |= CON_ENABLED;
if (i == selected_console) {
newcon->flags |= CON_CONSDEV;
preferred_console = selected_console;
}
break;
}
从这段code中console driver 要么提供match函数,要么提供setup函数,或者两者都提供。在__add_preferred_console 中会设置selected_console 来选择用哪个console driver,这样的话,如果在调用register_console的时候发现当前调用的console driver 和selected_console 相等,就或上CON_CONSDEV,并让preferred_console = selected_console
在程序中调用__add_preferred_console 会将kernel commandline 或者 通过acpi的scpr 表传递过来的console参数添加到console_cmdline 中
static int __add_preferred_console(char *name, int idx, char *options,
char *brl_options)
{
struct console_cmdline *c;
int i;
/*
* See if this tty is not yet registered, and
* if we have a slot free.
*/
for (i = 0, c = console_cmdline;
i < MAX_CMDLINECONSOLES && c->name[0];
i++, c++) {
if (strcmp(c->name, name) == 0 && c->index == idx) {
if (!brl_options)
selected_console = i;
return 0;
}
}
if (i == MAX_CMDLINECONSOLES)
return -E2BIG;
if (!brl_options)
selected_console = i;
strlcpy(c->name, name, sizeof(c->name));
c->options = options;
braille_set_options(c, brl_options);
c->index = idx;
return 0;
}
这样当个个console driver 调用register_console的时候,就会通过下面的code 来匹配注册的console 和 保存在console_cmdline 中的console是否匹配
for (i = 0, c = console_cmdline;
i < MAX_CMDLINECONSOLES && c->name[0];
i++, c++) {
if (!newcon->match ||
newcon->match(newcon, c->name, c->index, c->options) != 0) {
/* default matching */
BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
if (strcmp(c->name, newcon->name) != 0)
continue;
if (newcon->index >= 0 &&
newcon->index != c->index)
continue;
if (newcon->index < 0)
newcon->index = c->index;
if (_braille_register_console(newcon, c))
return;
if (newcon->setup &&
newcon->setup(newcon, c->options) != 0)
break;
}
newcon->flags |= CON_ENABLED;
if (i == selected_console) {
newcon->flags |= CON_CONSDEV;
preferred_console = selected_console;
}
break;
}
从这段code中console driver 要么提供match函数,要么提供setup函数,或者两者都提供。在__add_preferred_console 中会设置selected_console 来选择用哪个console driver,这样的话,如果在调用register_console的时候发现当前调用的console driver 和selected_console 相等,就或上CON_CONSDEV,并让preferred_console = selected_console
0 0
- __add_preferred_console的作用是添加console到console_cmdline 数组
- printk 中console_cmdline数组的填充
- SEO 101:添加到Google Search Console的URL版本
- 数字添加到字符数组的函数
- iOS 数组~把创建的字典添加到数组中
- 给你的网站添加 console.js
- 给你的网站添加 console.js
- console.log是异步的吗?
- console.log是异步的吗
- 将带有逗号的字符串转变为数组添加到添加到ListBox中
- list中对象的属性添加到数组中
- Console.ReadKey()作用
- 将对象添加到List集合中添加的是对象的引用
- 往页面添加悬浮在底部的悬浮图片,作用是回到顶部
- 数组的作用
- 一 uboot传递参数'console=ttyXXX'的作用
- 一 uboot传递参数'console=ttyXXX'的作用
- javascript 中的console.log有什么作用啊?是做什么的呢?谢谢大家
- List集合
- Rstudio中建立包含Rcpp的R包
- struts2 验证框架原理及实例
- byx创建一个功能的流程
- Scala + Intellij IDEA 环境搭建及编译、打包
- __add_preferred_console的作用是添加console到console_cmdline 数组
- Python 实用第三方库
- kmp
- cloudstack+kvm关于虚拟机的终极处理方法
- cocos2d-x基础概念介绍——导演、场景、层、精灵
- 滑动控件起飞的另一种方式
- 性能最好的序列化反序列化,Protobuf的用法(maven项目)
- 撸代码记录篇1.3-奔跑的皮皮熊
- 正则表达式中参数g、i、m的作用