main_loop()函数解析(1)
精选 转载文章标签 main_loop() 函数 文章分类 运维
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限制用户重新启动系统。
下一篇: s3c2440下QT的配置
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【linux 系统移植④】uboot 进入 main_loop() 前
uboot 进入 main_loop() 前
linux 运维 服务器 #endif #ifdef -
【linux 系统移植⑤】uboot 进入main_loop() 后
uboot 进入main_loop()后
linux 运维 服务器 #define #endif