国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Linux啟動(dòng)參數(shù)及實(shí)現(xiàn)
#define __setup_param(str, unique_id, fn, early)            /
    static char __setup_str_##unique_id[] __initdata = str;    /
    static struct obs_kernel_param __setup_##unique_id    /
        __attribute_used__                /
        __attribute__((__section__(".init.setup")))    /
        __attribute__((aligned((sizeof(long)))))    /
        = { __setup_str_##unique_id, fn, early }
        
#define __setup(str, fn)                    /
    __setup_param(str, fn, fn, 0)
    
#define early_param(str, fn)                    /

    __setup_param(str, fn, fn, 1)


__setup與early_param不同的是,early_param 宏注冊(cè)的內(nèi)核選項(xiàng)必須要在其他內(nèi)核選項(xiàng)之前被處理。

在函數(shù)start_kernel中,parse_early_param處理early_param定義的參數(shù),parse_args處理__setup定義的參數(shù)。


 parse_early_param();
 parse_args("Booting kernel", static_command_line, __start___param,
     __stop___param - __start___param,
     &unknown_bootoption);

    
1,所有的系統(tǒng)啟動(dòng)參數(shù)都是由形如 static int __init foo(char *str);的函數(shù)來支持的
注:#define __init        __attribute__ ((__section__ (".init.text")))
申明所有的啟動(dòng)參數(shù)支持函數(shù)都放入.init.text段


2.1,用__setup宏來導(dǎo)出參數(shù)的支持函數(shù)
__setup("foo=" , foo);
展開后就是如下的形式

static char __setup_str_foo[] __initdata = "foo=";    
static struct obs_kernel_param __setup_foo    
        __attribute_used__                
        __attribute__((__section__(".init.setup")))    
        __attribute__((aligned((sizeof(long)))))    
        = { __setup_str_foo, foo, 0 };//"foo=",foo,0
也就是說,啟動(dòng)參數(shù)(函數(shù)指針)被封裝到obs_kernel_param結(jié)構(gòu)中,
所有的內(nèi)核啟動(dòng)參數(shù)形成內(nèi)核映像.init.setup段中的一個(gè)
obs_kernel_param數(shù)組

2.2用early_param宏來申明需要'早期'處理的啟動(dòng)參數(shù),例如在
arch/i386/kernel/setup.c就有如下的申明:
early_param("mem", parse_mem);
展開后和__setup是一樣的只是early參數(shù)不一樣,因此會(huì)在do_early_param
中被處理

3,內(nèi)核對(duì)啟動(dòng)參數(shù)的解析:下面函數(shù)歷遍obs_kernel_param數(shù)組,調(diào)用
支持函數(shù)
static int __init do_early_param(char *param, char *val)
{
    struct obs_kernel_param *p;

    for (p = __setup_start; p < __setup_end; p++) {
        if (p->early && strcmp(param, p->str) == 0) {
            if (p->setup_func(val) != 0)
                printk(KERN_WARNING
                       "Malformed early option '%s'/n", param);
        }
    }
    /* We accept everything at this stage. */
    return 0;
}
這個(gè)函數(shù)在parse_early_param中被調(diào)用,而parse_early_param在start_kernel
中被調(diào)用,parse_early_param之后的parse_args會(huì)調(diào)用下面函數(shù)
static int __init obsolete_checksetup(char *line)
{
    struct obs_kernel_param *p;
    int had_early_param = 0;

    p = __setup_start;
    do {
        int n = strlen(p->str);
        if (!strncmp(line, p->str, n)) {
            if (p->early) {
                /* Already done in parse_early_param?
                 * (Needs exact match on param part).
                 * Keep iterating, as we can have early
                 * params and __setups of same names 8( */
                if (line[n] == '/0' || line[n] == '=')
                    had_early_param = 1;
            } else if (!p->setup_func) {
                printk(KERN_WARNING "Parameter %s is obsolete,"
                       " ignored/n", p->str);
                return 1;
            } else if (p->setup_func(line + n))//調(diào)用支持函數(shù)
                return 1;
        }
        p++;
    } while (p < __setup_end);

    return had_early_param;
}

init/main.c中啟動(dòng)參數(shù)申明列表:
__setup("nosmp", nosmp);
__setup("maxcpus=", maxcpus);
__setup("reset_devices", set_reset_devices);

__setup("debug", debug_kernel);
__setup("quiet", quiet_kernel);

__setup("loglevel=", loglevel);

__setup("init=", init_setup);
__setup("rdinit=", rdinit_setup);

__setup("initcall_debug", initcall_debug_setup);

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
linux內(nèi)核組件初始化體系 - 但行好事 莫問前程 - JavaEye技術(shù)網(wǎng)站
Linux Command Line 詳細(xì)解析
17. 內(nèi)核參數(shù)解析
rk3188
linux kernel的cmdline參數(shù)解析原理分析
Linux啟動(dòng)流程
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服