The shutdown procedure within Linux (based on BSP v13.05):
1. Android call __reboot( LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2,
mode,
NULL);
/bionic/libc/unistd/reboot.c
to pass parameters and target mode to Linux.
2. Linux receivs parameters and mode(cmd) in
/kernel/kernel/sys.c
SYSCALL_DEFINE4(reboot,
int, magic1,
int, magic2,
unsigned int, cmd, //cmd is the mode in Android
void __user *, arg)
if the cmd is LINUX_REBOOT_CMD_POWER_OFF, call:
3. kernel_power_off() in /kernel/kernel/sys.c
this function will call below functions in a row:
a. kernel_shutdown_prepare() ///kernel/kernel/sys.c
--> device_shutdown() ///kernel/drivers/base/core.c
b. machine_power_off() ///arch/arm/kernel/process.c
To understand the complete shutdown procedure, reference:
http//blog.youkuaiyun.com/hufik/article/details/8964674
1. Android call __reboot( LINUX_REBOOT_MAGIC1,
LINUX_REBOOT_MAGIC2,
mode,
NULL);
/bionic/libc/unistd/reboot.c
to pass parameters and target mode to Linux.
2. Linux receivs parameters and mode(cmd) in
/kernel/kernel/sys.c
SYSCALL_DEFINE4(reboot,
int, magic1,
int, magic2,
unsigned int, cmd, //cmd is the mode in Android
void __user *, arg)
if the cmd is LINUX_REBOOT_CMD_POWER_OFF, call:
3. kernel_power_off() in /kernel/kernel/sys.c
this function will call below functions in a row:
a. kernel_shutdown_prepare() ///kernel/kernel/sys.c
--> device_shutdown() ///kernel/drivers/base/core.c
b. machine_power_off() ///arch/arm/kernel/process.c
To understand the complete shutdown procedure, reference:
http//blog.youkuaiyun.com/hufik/article/details/8964674
本文详细介绍了基于BSPv13.05的Linux系统中从Android层面调用到内核层面的关机过程。主要步骤包括:Android通过__reboot函数发送关机指令至Linux内核;Linux内核接收到指令后,根据指定模式执行相应操作;最终通过kernel_power_off函数完成系统关闭。文章深入剖析了关键函数及其实现路径。
3514

被折叠的 条评论
为什么被折叠?



