bootargs 及其解析流程

1.kernel中的 dtsi里面可以设置启动参数

// msm8717.dtsi
chosen {
        bootargs = "sched_enable_hmp=1 mem=2G";
    };


2.bootargs参数解析 demo


2.1 关键字:early_param



static int __init early_mem(char *p)                    // mem=2G
{
    phys_addr_t limit;

    if (!p)
        return 1;

    limit = memparse(p, &p) & PAGE_MASK;
    pr_notice("Memory limited to %lldMB\n", limit >> 20);

    memblock_enforce_memory_limit(limit);

    return 0;
}
early_param("mem", early_mem);


----------


static int __init early_ecc(char *p)  //  ecc = on/off
{
    if (memcmp(p, "on", 2) == 0)
        ecc_mask = PMD_PROTECTION;
    else if (memcmp(p, "off", 3) == 0)
        ecc_mask = 0;
    return 0;
}
early_param("ecc", early_ecc);

2.2 关键字 __setup


static int __init get_boot_rease(char *str)
{
    if (strcmp("boot_with_factory", str) == 0) {
        boot_into_factory = 1;
    }
    return 0;
}

__setup("androidboot.boot_reason=", get_boot_rease);

3.boot_command_line (init/main.c)

——直接使用现成的command line

static int __init boot_mode_init(void)
{
    char *substr = strstr(boot_command_line, "androidboot.ftm_mode=");

    if(NULL == substr)
    return 0;

    substr += strlen("androidboot.ftm_mode=");
    if(substr) {
        if(strncmp(substr, "ftm_at", 6) == 0)
            boot_mode = MSM_BOOT_MODE__FACTORY;
        else if(strncmp(substr, "ftm_rf", 6) == 0)
            boot_mode = MSM_BOOT_MODE__RF;
        else if(strncmp(substr, "ftm_wlan", 8) == 0)
            boot_mode = MSM_BOOT_MODE__WLAN;
        else if(strncmp(substr, "ftm_mos", 7) == 0)
            boot_mode = MSM_BOOT_MODE__MOS;
        else if(strncmp(substr, "ftmrecovery", 11) == 0)
            boot_mode = MSM_BOOT_MODE__RECOVERY;
        else if(strncmp(substr, "ftm_aging", 9) == 0)     //shankai@bsp ,add for aging mode support 2016-1-14
            boot_mode = MSM_BOOT_MODE__AGING;

   }

    pr_info("kernel boot_mode = %s[%d]\n",enum_ftm_mode[boot_mode],boot_mode);
    return 0;
}
arch_initcall(boot_mode_init);
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值