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);