u-boot reset命令分析
首先看命令定义:
72 extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);73
74 U_BOOT_CMD(
75 reset, 1, 0, do_reset,
76 "Perform RESET of the CPU",
77 ""
78 );
使用U_BOOT_CMD向系统添加了一条reset命令,当我们输入reset命令时,执行do_reset函数。
42 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])43 {
44 puts ("resetting ...\n");
45
46 udelay (50000); /* wait 50 ms */
47
48 disable_interrupts();
49 reset_cpu(0);
50
51 /*NOTREACHED*/
52 return 0;
53 }
最后调用reset_cpu函数
189 /*190 * reset the cpu by setting up the watchdog timer and let him time out
191 */
192 void reset_cpu (ulong ignored)
193 {
194 volatile S3C24X0_WATCHDOG * watchdog;
195
196 #ifdef CONFIG_TRAB
197 extern void disable_vfd (void);
198
199 disable_vfd();
200 #endif
201
202 watchdog = S3C24X0_GetBase_WATCHDOG();
203
204 /* Disable watchdog */
205 watchdog->WTCON = 0x0000;
206
207 /* Initialize watchdog timer count register */
208 watchdog->WTCNT = 0x0001;
209
210 /* Enable watchdog timer; assert reset at timer timeout */
211 watchdog->WTCON = 0x0021;
212
213 while(1); /* loop forever and wait for reset to happen */
214
215 /*NOTREACHED*/
216 }
最后我们明确了,reset命令是通过S3C2440内部的看门狗电路实现的。