免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1578 | 回复: 2
打印 上一主题 下一主题

[内核入门] 关于x86/boot/main.c中一个函数的疑问 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-08-11 02:09 |只看该作者 |倒序浏览
我看到int __cmdline_find_option(u32 cmdline_ptr, const char *option, char *buffer, int bufsize)这个函数..

我想问下他到底是干嘛的- -.....

/*
* Find a non-boolean option, that is, "option=argument".  In accordance
* with standard Linux practice, if this option is repeated, this returns
* the last instance on the command line.
*
* Returns the length of the argument (regardless of if it was
* truncated to fit in the buffer), or -1 on not found.
*/


这是英文注释- -我在看资料的时候,,他说找option?..

比如这里
     if (cmdline_find_option("console", optstr, sizeof optstr) <= 0)
                return;

        options = optstr;

        if (!strncmp(options, "uart8250,io,", 12))
我有点想不明白- - 因为我看到__cmdline_find_option中的

                case st_wordcmp:
                        if (c == '=' && !*opptr) {
                                len = 0;
                                bufptr = buffer;
                                state = st_bufcpy;
                        } else if (myisspace(c)) {
                                state = st_wordstart;
                        } else if (c != *opptr++) {
                                state = st_wordskip;
                        }
                        break;
这一段,,,他好像是比较读取出来的字符c 和option进行比较?  如果不一样的话就跳过...这是什么意思? ..查找option的字符?  然后复制到buffer?

论坛徽章:
0
2 [报告]
发表于 2012-08-11 13:15 |只看该作者
就是把cmd取出来 没别的意思了

论坛徽章:
0
3 [报告]
发表于 2012-08-11 13:40 |只看该作者
回复 2# kgn28


    我困惑的是他是取什么出来?  cmd的什么?...

   if (cmdline_find_option("earlyprintk", arg, sizeof arg) > 0) {
  51                char *e;
  52
  53                if (!strncmp(arg, "serial", 6)) {
  54                        port = DEFAULT_SERIAL_PORT;
  55                        pos += 6;
  56                }
  57


比如这个....他的option参数是"earlyprintk"。。 那他的 arg是就是buffer, ...这样的话从cmdline中取出的选项是什么??...

不好意思- - 我才刚开始看内核...有点困惑..>!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP