android 在kernel中获取启动kernel命令行的参数

  • Post author:
  • Post category:其他



比如说要获取project_id这个参数


首先在kernel/init目录下的main.c中


int asus_PRJ_ID = 0;


EXPORT_SYMBOL(asus_PRJ_ID);


static int set_project_id(char *str)


{ printk(“prj_id = %s\n”, str);


if( strcmp(“0”, str) == 0 ){


asus_PRJ_ID = ASUS_ZE550KL;


}else if( strcmp(“1”, str) == 0 ){


asus_PRJ_ID = ASUS_ZE600KL;


}else if( strcmp(“2”, str) == 0 ){


asus_PRJ_ID = ASUS_ZX550KL;


}else if( strcmp(“3”, str) == 0 ){


asus_PRJ_ID = ASUS_ZD550KL;


} return 0;


}


__setup(“PRJ_ID=”, set_project_id);这样就可以在kernel中全局使用asus_PRJ_ID这个变量



版权声明:本文为u013308744原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。