main_loop()分析
来源:互联网 发布:免费2级域名注册永久 编辑:程序博客网 时间:2024/06/06 13:16
main_loop()函数做的都是与具体平台无关的工作,主要包括初始化启动次数限制机制、设置软件版本号、打印启动信息、解析命令等。
(1)设置启动次数有关参数。在进入main_loop()函数后,首先是根据配置加载已经保留的启动次数,并且根据配置判断是否超过启动次数。代码如下:
295 void main_loop (void) 296 { 297 #ifndef CFG_HUSH_PARSER 298 static char lastcommand[CFG_CBSIZE] = { 0, }; 299 int len; 300 int rc = 1; 301 int flag; 302 #endif 303 304 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) 305 char *s; 306 int bootdelay; 307 #endif 308 #ifdef CONFIG_PREBOOT 309 char *p; 310 #endif 311 #ifdef CONFIG_BOOTCOUNT_LIMIT 312 unsigned long bootcount = 0; 313 unsigned long bootlimit = 0; 314 char *bcs; 315 char bcs_set[16]; 316 #endif 317 318 #if defined(CONFIG_VFD) && defined(VFD_TEST_LOGO) 319 ulong bmp = 0; 320 extern int trab_vfd (ulong bitmap); 321 322 #ifdef CONFIG_MODEM_SUPPORT 323 if (do_mdm_init) 324 bmp = 1; 325 #endif 326 trab_vfd (bmp); 327 #endif 328 329 #ifdef CONFIG_BOOTCOUNT_LIMIT 330 bootcount = bootcount_load(); // 加载保存的启动次数 331 bootcount++; // 启动次数加1 332 bootcount_store (bootcount); // 更新启动次数 333 sprintf (bcs_set, "%lu", bootcount); // 打印启动次数 334 setenv ("bootcount", bcs_set); 335 bcs = getenv ("bootlimit");