资源预览内容
第1页 / 共3页
第2页 / 共3页
第3页 / 共3页
亲,该文档总共3页全部预览完了,如果喜欢就下载吧!
资源描述
reboot 的实现机制在以前的2410板子上,我们在shell下面,运行reboot,系统将重新启动,这是CPU自带的看门狗起的作用,下面我们对这个进行分析,首先我们介绍一下相应的寄存器。RegisterAddressR/WDescriptionReset ValueV;TCON0x53000000R,WWatchdog timer control register0x8021WTCONBitDescriptionInitial StatePrescaler Value15:8Prescaler value.The valid range is from 0 to (2a-1).0x80Resen/ed【了Reserved.These two bits must be 00 in normal operation.00Watchdog Timer5Enable or disable bit of Watchdog timer. 0 = Disable1 = Enable1Clock Select4:3Determine the clock division factor.00:1601: 3210: 6411: 12800In 怕 it u pt Generation2Enable or disable bit of the interrupt. 0 = Disable1 = Enable0Resen/ed1Reserved.This bit must be 0 in normal operation.0ResetEna ble;Di sable0Enable or disable bit of Watchdog timer output for reset signal. 1: Assert reset signal of the S3C2410X at watchdog time-out 0: Disable the reset function of the watchdog timer.1图 2 看门狗控制定时器RegisterAddressR/WDescriptionReset ValueWTDAT0x53000004RAYWatchdog timer data register0x8000WTDATBitDescri ptionInitial StateCount ReloadValue15:0Watchdog timer count value for reload.0x8000图 3 看门狗数据寄存器RegisterAddressR/WDescriptionReset ValueWTCNT0x53000008R/WWatchdog timer count register0x8000WTCNTBitDescriptionInitial StateCount Value15:0The current count value of the watchdog timer0x8000图 4 看门狗计数寄存器 第一步:当系统上电后,第一件事就是调用 ppcboot, ppcboot 中相应的代码如下 /下面才是真正的上电复位的启动代码:/* the actual reset code*/reset:/* turn off the watchdog */#if defined(CONFIG_S3C2400) #define pWTCON 0x15300000 /* Interupt-Controller base addresses */ #define INTMSK0x14400008/* clock divisor register */ #define CLKDIVN0x14800014#elif defined(CONFIG_S3C2410) #define pWTCON 0x53000000/Watchdog timer control register/* Interupt-Controller base addresses */ #define INTMSK 0x4A000008 #define INTSUBMSK 0x4A00001C/* clock divisor register */#define CLKDIVN 0x4C000014#define MPLLCON 0x4C000004#define CLK_CTL_BASE 0x4C000000 #endifldr r0, =pWTCONmov r1, #0x0/Disable the reset function of the watchdog timerstr r1, r0 可以看出,在系统以上电做的第一件事情就是使看门狗不起作用。第二步:当我们运行 reboot ,实际是调用了 application/busybox/init/init.c 里的 init_reboot 函数,该函数如下:if(pid = fork() = =0)message(CONSOLE | LOG reboot(magic=%08x n).”,magic); reboot(magic);_exit(0); 可以看出,该函数又调用了 reboot 函数。第三步:该reboot会调用/kernel/kernel/sys.c里的sys_reboot函数,magic传递的参数是 01234567 和 LINUX_REBOOT_CMD_RESTART相同,见下面代码: switch(cmd)case LINUX_REBOOT_CMD_RESTART:pirntk(KERN_EMERG “Restarting system.n”); machine_restart(NULL);_break;可以看出,现在接着调用 machine_restart 函数。第 四 步 : 下 面 我 们 看 一 下 machine_restart 函 数 , 该 函 数 定 义 在 kernel/arch/arm/kernel/process.c 文件里,该函数又调用了 arch_reset(reboot_mode)函数;第五步:archeset 函数是定义在 kernel/include/asm-arm/arch-s3c2410/system.h 文件里, 该函数如下:if(mode = = s)cpu_reset(0);elseWTCNT = 0x100;WTDAT = 0x100;WTCON = 0x8021 ;/使看门狗使能
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号