从Android R(kernel-4.19)开始使用common kernel,一些旧的接口逐步丢弃,如get_boot_mode采用新的方式,Get bootmode from device tree property “atag,boot”
Android R 获取启动模式的接口可以使用如下方法:
int get_boot_mode(void)
{
struct device_node *np_chosen;
struct tag_bootmode *tag = NULL;
np_chosen = of_find_node_by_path("/chosen");
if (!np_chosen)
np_chosen = of_find_node_by_path("/chosen@0");
tag = (struct tag_bootmode *)of_get_property(np_chosen, "atag,boot",NULL);
if (!tag) {
pr_notice("%s: fail to get atag,boot\n", __func__);
} else {
pr_notice("%s: boot_mode: 0x%x\n",__func__,tag->bootmode);
return tag->bootmode;
}
return -1;
}