本文介绍了引导加载程序如何在“使用命令重新启动系统"之后选择命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android源文件中找到重启命令,找到以下行:

__reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, \
         LINUX_REBOOT_CMD_RESTART2, argv[optind]);

这是使用特定命令重新引导系统的标准Linux系统调用,请参见 Unix系统调用重新启动.

Which is the standard Linux system call to reboot the system with a specific command, see Unix System Call Reboot.

在Android中,此命令用于告诉引导加载程序以恢复模式启动内核,或在引导加载程序中进入快速引导模式.

In Android this command is used to tell the bootloader to start either the kernel in recovery mode or to go to the fastboot mode within the bootloader.

我的问题是:引导程序如何选择命令?这项功能是在U-Boot中实现的吗?(我无法通过Google或U-Boot源进行搜索找到它.)

My question is: How does the bootloader pick up the command? And is this functionality implemented in U-Boot? (I am unable to find it searching either through Google or in the U-Boot source.)

此外,这似乎并非特定于Android,而是Linux执行使用命令重新引导"的方式.关于在Linux中如何正常"处理/使用此信息的任何信息?

Additionally it seems this is not specific to Android, but is the way Linux performs a "reboot with a command". Any information on how this is "normally" handled/used in Linux?

推荐答案

使用LINUX_REBOOT_CMD_RESTART2重新引导系统时,提供的命令字符串将传递给在register_reboot_notifer()中注册的所有通知程序,最后传递到machine_restart() -实际执行系统重启的特定于体系结构的功能.

When the system is rebooted using LINUX_REBOOT_CMD_RESTART2, the supplied command string is passed to all of the notifiers registered with register_reboot_notifer(), and finally to machine_restart() - the architecture-specific function that actually performs system restart.

大多数体系结构完全忽略传递的命令-有关不传递的命令的示例,请参见SPARC. machine_restart() SPARC实现会传递提供的字符串到PROM的boot命令.

Most architectures ignore the passed command entirely - for an example of one that doesn't, see SPARC. The SPARC implementation of machine_restart() passes the supplied string to the boot command of the PROM.

machine_restart() ARM实现结束向上传递提供的命令到arch_reset(),该命令在每个ARM平台上单独实现-从我的看到,至少在上游内核中,大多数(如果不是全部)实现忽略传递的命令.这可能不是您要寻找的机器人.

The ARM implementation of machine_restart() ends up passing the supplied command to arch_reset() which is implemented separately on each ARM platform - from what I can see, most if not all of those implementations ignore the passed command, at least in the upstream kernel. This may not be the droid you're looking for.

这篇关于引导加载程序如何在“使用命令重新启动系统"之后选择命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!