Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the bootloader pick up the command after a "restarting system with command"?

Looking in the android source for the reboot command we find the following line:

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

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

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.

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

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?

like image 630
Bjarke Freund-Hansen Avatar asked Mar 29 '11 12:03

Bjarke Freund-Hansen


1 Answers

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.

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.

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.

like image 102
caf Avatar answered Sep 19 '22 13:09

caf