Embededlinux之reboot

 reboot命令

//kernel\sys.c

magic1、magic2,两个int类型的“魔力数”,用于防止误操作。具体在“include/ua     pi   /     linux   /reboot.h”中定义。

cmd,reboot方式。

//include\linux\reboot.h

#define LINUX_REBOOT_CMD_RESTART 0x01234567
#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
#define LINUX_REBOOT_CMD_KEXEC 0x45584543

arg,其它的额外参数。

SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, void __user *, arg)

{

...

switch (cmd)

{

case LINUX_REBOOT_CMD_RESTART:
kernel_restart(NULL);
break;

case LINUX_REBOOT_CMD_CAD_ON:
C_A_D = 1;
break;

case LINUX_REBOOT_CMD_CAD_OFF:
C_A_D = 0;
break;

case LINUX_REBOOT_CMD_HALT:
kernel_halt();
do_exit(0);
panic("     can   not halt");

case LINUX_REBOOT_CMD_POWER_OFF:
kernel_power_off();
do_exit(0);
break;

case LINUX_REBOOT_CMD_RESTART2:
if (strncpy_f     rom   _user(&buffer[0], arg, sizeof(buffer) - 1) < 0)

{

ret = -EFAULT;
break;
}
buffer[sizeof(buffer) - 1] = '\0';

kernel_restart(buffer);
break;

#ifdef CONFIG_KEXEC
case LINUX_REBOOT_CMD_KEXEC:
ret = kernel_kexec();
break;
#endif

#ifdef CONFIG_HIBERNA     TI   ON
case LINUX_REBOOT_CMD_SW_SUSPEND:
ret = hiberna     te   ();
break;
#endif

default:
ret = -EINVAL;
break;

...

}

//kernel\sys.c

void kernel_restart(char *cmd)

{

...

machine_restart(cmd);

}

//arch\     arm   \kernel\process.c

void machine_restart(char *cmd)

{

...

arm_pm_restart(reboot_mode, cmd);

...

}

//arch\arm\kernel\setup.c

void __init setup_arch(char **cmdline_p)

{

struct machine_desc *mdesc;

...

mdesc = setup_machine_fdt(__atags_pointer);

...

if (mdesc->restart)

arm_pm_restart = mdesc->restart;

...

}

//arch\arm\mach-hi3516a\core.c

MACHINE_START(HI3516A, "hi3516a")

.atag_offset = 0x100,
.map_io = hi3516a_map_io,
.init_early = hi3516a_init_early,
.init_irq = hi3516a_gic_init_irq,
.handle_irq = gic_handle_irq,
.  TI mer = &hi3516a_sys_  TI mer,
.init_machine = hi3516a_init,
.reserve = hi3516a_reserve,
.restart = hi3516a_restart,
MACHINE_END

//arch\arm\mach-hi3516a\core.c

void hi3516a_restart(char mode, const char *cmd)

{
__raw_writel(~0, IO_ADDRESS(SYS_CTRL_BASE) + REG_SC_SYSRES);
}

//drive     rs   \mtd\devices\hisfc350\hisfc350_hi3516a.c

#define SYS_CTRL_BASE (0x20050000)

//arch\arm\mach-hi3535\include\mach\platform.h

#define REG_SC_SYSRES 0x4

 Embededlinux之reboot_设计制作_模拟技术

 Embededlinux之reboot_设计制作_模拟技术



59
169
0
69

相关资讯

  1. 1、HCK哈士奇复古冰箱开启《我的时代,你的时代》胡一天、李一桐的甜蜜爱情!524
  2. 2、这五位80后演员总让人觉得他们是70后,网友:我看他像60后2094
  3. 3、《女编辑》成北漂励志宝典正能量语录被疯传487
  4. 4、杨紫又躺枪!肖战关注新剧女演员,遭“紫米”故意挑事!2527
  5. 5、《中华英雄》将要翻拍,谁能接替郑伊健出演华英雄?4007
  6. 6、张艺谋《影》首发预告超50个正片镜头曝光邓超孙俪怒目而视2910
  7. 7、荧屏暑期档火爆各卫视推“舌尖上的消暑菜”4127
  8. 8、《甄嬛传》前蒋欣被定为曹贵人,她想试镜华妃,导演说不够跋扈521
  9. 9、成龙和李小龙年轻时穿搭到底有多潮?这组照片告诉你1388
  10. 10、好奇怪的混搭!佟丽娅和张亮演情侣,重蹈《完美关系》的覆辙?348
全部评论(0)
我也有话说
0
收藏
点赞
顶部