main_loop()函数解析(1)
2013-04-01 10:43
441 查看
main_loop()函数做的都是与具体平台无关的工作,主要包括初始化启动次数限制机制、设置软件版本号、打印启动信息、解析命令等。(1)设置启动次数有关参数。在进入main_loop()函数后,首先是根据配置加载已经保留的启动次数,并且根据配置判断是否超过启动次数。代码如下:
1 295 void main_loop (void) 2 296 { 3 297 #ifndef CFG_HUSH_PARSER 4 298 static char lastcommand[CFG_CBSIZE] = { 0, }; 5 299 int len; 6 300 int rc = 1; 7 301 int flag; 8 302 #endif 9 303 10 304 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) 11 305 char *s; 12 306 int bootdelay; 13 307 #endif 14 308 #ifdef CONFIG_PREBOOT 15 309 char *p; 16 310 #endif 17 311 #ifdef CONFIG_BOOTCOUNT_LIMIT 18 312 unsigned long bootcount = 0; 19 313 unsigned long bootlimit = 0; 20 314 char *bcs; 21 315 char bcs_set[16]; 22 316 #endif /* CONFIG_BOOTCOUNT_LIMIT */ 23 317 24 318 #if defined(CONFIG_VFD) && defined(VFD_TEST_LOGO) 25 319 ulong bmp = 0; /* default bitmap */ 26 320 extern int trab_vfd (ulong bitmap); 27 321 28 322 #ifdef CONFIG_MODEM_SUPPORT 29 323 if (do_mdm_init) 30 324 bmp = 1; /* alternate bitmap */ 31 325 #endif 32 326 trab_vfd (bmp); 33 327 #endif /* CONFIG_VFD && VFD_TEST_LOGO */ 34 328 35 329 #ifdef CONFIG_BOOTCOUNT_LIMIT 36 330 bootcount = bootcount_load(); // 加载保存的启动次数 37 331 bootcount++; // 启动次数加1 38 332 bootcount_store (bootcount); // 更新启动次数 39 333 sprintf (bcs_set, "%lu", bootcount); // 打印启动次数 40 334 setenv ("bootcount", bcs_set); 41 335 bcs = getenv ("bootlimit"); 42 336 bootlimit = bcs ? simple_strtoul (bcs, NULL, 10) : 0; 43 // 转换启动次数字符串为UINT类型 44 337 #endif /* CONFIG_BOOTCOUNT_LIMIT */ 第329~337行是启动次数限制功能,启动次数限制可以被用户设置一个启动次数,然后保存在Flash存储器的特定位置,当到达启动次数后,U-Boot无法启动。该功能适合一些商业产品,通过配置不同的License限制用户重新启动系统。
1 295 void main_loop (void) 2 296 { 3 297 #ifndef CFG_HUSH_PARSER 4 298 static char lastcommand[CFG_CBSIZE] = { 0, }; 5 299 int len; 6 300 int rc = 1; 7 301 int flag; 8 302 #endif 9 303 10 304 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) 11 305 char *s; 12 306 int bootdelay; 13 307 #endif 14 308 #ifdef CONFIG_PREBOOT 15 309 char *p; 16 310 #endif 17 311 #ifdef CONFIG_BOOTCOUNT_LIMIT 18 312 unsigned long bootcount = 0; 19 313 unsigned long bootlimit = 0; 20 314 char *bcs; 21 315 char bcs_set[16]; 22 316 #endif /* CONFIG_BOOTCOUNT_LIMIT */ 23 317 24 318 #if defined(CONFIG_VFD) && defined(VFD_TEST_LOGO) 25 319 ulong bmp = 0; /* default bitmap */ 26 320 extern int trab_vfd (ulong bitmap); 27 321 28 322 #ifdef CONFIG_MODEM_SUPPORT 29 323 if (do_mdm_init) 30 324 bmp = 1; /* alternate bitmap */ 31 325 #endif 32 326 trab_vfd (bmp); 33 327 #endif /* CONFIG_VFD && VFD_TEST_LOGO */ 34 328 35 329 #ifdef CONFIG_BOOTCOUNT_LIMIT 36 330 bootcount = bootcount_load(); // 加载保存的启动次数 37 331 bootcount++; // 启动次数加1 38 332 bootcount_store (bootcount); // 更新启动次数 39 333 sprintf (bcs_set, "%lu", bootcount); // 打印启动次数 40 334 setenv ("bootcount", bcs_set); 41 335 bcs = getenv ("bootlimit"); 42 336 bootlimit = bcs ? simple_strtoul (bcs, NULL, 10) : 0; 43 // 转换启动次数字符串为UINT类型 44 337 #endif /* CONFIG_BOOTCOUNT_LIMIT */ 第329~337行是启动次数限制功能,启动次数限制可以被用户设置一个启动次数,然后保存在Flash存储器的特定位置,当到达启动次数后,U-Boot无法启动。该功能适合一些商业产品,通过配置不同的License限制用户重新启动系统。
相关文章推荐
- main_loop()函数解析
- 处理--->错误 error LNK2019: 无法解析的外部符号"~~~~" | 该符号"~~~"在函数 _main 中被引用
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
- error LNK2019: 无法解析的外部符号 _main,该符号在函数___tmainCRTStartup 中被引用
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- 无法解析的外部符号 _mysql_init@4,该符号在函数 _main 中被引用
- error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- 1>MSVCRTD.lib(exe_main.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 "int __cdecl invoke_main(void)"
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用 LIBCMT.lib
- uboot下函数run_main_loop分析
- 无法解析的外部符号 WinMain,该符号在函数 "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 中被引用
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- 错误 1 error LNK2019: 无法解析的外部符号 __imp__pthread_create,该符号在函数 _main 中被引用 解决方法
- MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStart
- 错误 1 error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
- opengl glut glutMainLoop()函数
- 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用(转)