From: http://blog.csdn.net/yahoozhuo/article/details/6403140
===== Application process =====
====> Frameworks/base/services/Java/COM/Android/Server/masterclearjavaser. Java
Recoverysystem. rebootwipeuserdata (context );
====> Framesworks/base/CORE/Java/Android/OS/recoverysystem. Java
Rebootwipeuserdata ==> bootcommand (context, "-- wipe_data ");
After bootcommand writes the parameter "-- wipe_data" to/Cache/recovery/command,
Call pm. Reboot ("recovery ");
====> Frameworks/base/CORE/Java/Android/OS/power. Java
Reboot ==> rebootnative
====> Frameworks/base/CORE/JNI/android_ OS _power.cpp
JNI ing
{"Rebootnative", "(ljava/lang/string;) V", (void *) android_ OS _power_reboot },
Android_ OS _power_reboot ==>__ reboot
====> Bionic/libc/arch-arm/syscils/_ reboot. s
LDR R7, =__ nr_reboot // bionic/libc/include/sys/linux-syscalls.h
B _ set_syscall_errno
# DEFINE _ nr_reboot (_ nr_syscall_base + 88)
===== Kernel process =====
====> Kernel/ARCH/ARM/kernel/CILS. s
/* 88 */call (sys_reboot)
Http://blog.csdn.net/yahoozhuo/article/details/6403140
====> Kernel/sys. c
Sys_reboot is defined in kernel/include/Linux/syscils. H, and is implemented in kernel/sys. c
Here, determine the buffer content and use a register to record whether it is the recovery mode, so that the boot loader can query it.
Sys_reboot will call kernel_restart
Kernel_restart calls each Schema-specific machine_restart, that is, machine_restart executes each Schema-specific function.
====> Kernel/ARCH/ARM/kernel/process. c
Machine_restart ==> arm_pm_restart ==> arm_machine_restart ==> arch_reset
====> Kernel/ARCH/ARM/Mach-tegra/include/Mach/system. h
Arch_reset
===== Bootloader process ====
Restart the machine and re-enter the bootloader. Bootloader first reads the register content and determines whether to enter the recovery mode or other mode based on this value.
Bootloader then loads the recovery kernel.
===== Recovery application process ====
The init. RC in the recovery kernel runs the recovery
The recovery application reads cache, recovery, and command.
Read the parameter and perform the corresponding operation. Here the parameter is -- wipe_data, which is placed in cache/recovery/command.
After clearing data and cache, restart the system. At this time, the register parameter rb_autoboot written during kernel restart is different from the previous one.
Bionic/libc/include/sys/reboot. h
# Define rb_autoboot linux_reboot_assist_restart
The bootloader will not be started in recovery mode, but will be started normally.