Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2959011
  • 博文数量: 685
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5303
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-19 14:17
个人简介

文章分类

全部博文(685)

文章存档

2015年(116)

2014年(569)

分类: 嵌入式

2014-11-01 11:05:37

原文地址:http://blog.csdn.net/ecbtnrt/article/details/6630160

在这里我们断续前面的故事。

首先看到是调用了函数abortboot,判断是否在规定的时间内按下了键。

如果没有按下就调用bootcmd了,也就是nand read.i c0008000 80000 500000;bootm c0008000,这样直接就可使启动内核了。

要是按下了就读入命令,并查找命令列表中找到相应的命令并执行。

  1. void main_loop (void)  
  2. {  
  3.   
  4. #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)  
  5.     s = getenv ("bootdelay");  
  6.     bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;  
  7.   
  8.     debug ("### main_loop entered: bootdelay=%d\n\n", bootdelay);  
  9.   
  10. # ifdef CONFIG_BOOT_RETRY_TIME  
  11.     init_cmd_timeout ();  
  12. # endif /* CONFIG_BOOT_RETRY_TIME */  
  13.   
  14.         s = getenv ("bootcmd");  
  15.   
  16.     debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "");  
  17.   
  18.     if (bootdelay >= 0 && s && !abortboot (bootdelay)) {  
  19. # ifdef CONFIG_AUTOBOOT_KEYED  
  20.         int prev = disable_ctrlc(1);    /* disable Control C checking */  
  21. # endif  
  22.   
  23. # ifndef CFG_HUSH_PARSER  
  24.         run_command (s, 0);  
  25. # else  
  26.         parse_string_outer(s, FLAG_PARSE_SEMICOLON |  
  27.                     FLAG_EXIT_FROM_LOOP);  
  28. # endif  
  29.   
  30. # ifdef CONFIG_AUTOBOOT_KEYED  
  31.         disable_ctrlc(prev);    /* restore Control C checking */  
  32. # endif  
  33.     }  
  34.   
  35. # ifdef CONFIG_MENUKEY  
  36.     if (menukey == CONFIG_MENUKEY) {  
  37.         s = getenv("menucmd");  
  38.         if (s) {  
  39. # ifndef CFG_HUSH_PARSER  
  40.         run_command (s, 0);  
  41. # else  
  42.         parse_string_outer(s, FLAG_PARSE_SEMICOLON |  
  43.                     FLAG_EXIT_FROM_LOOP);  
  44. # endif  
  45.         }  
  46.     }  
  47. #endif /* CONFIG_MENUKEY */  
  48. #endif  /* CONFIG_BOOTDELAY */  
  49.   
  50. #ifdef CONFIG_AMIGAONEG3SE  
  51.     {  
  52.         extern void video_banner(void);  
  53.         video_banner();  
  54.     }  
  55. #endif  
  56.   
  57.     FriendlyARMMenu();  
  58.     /* 
  59.      * Main Loop for Monitor Command Processing 
  60.      */  
  61. #ifdef CFG_HUSH_PARSER  
  62.     parse_file_outer();  
  63.     /* This point is never reached */  
  64.     for (;;);  
  65. #else  
  66.     for (;;) {  
  67. #ifdef CONFIG_BOOT_RETRY_TIME  
  68.         if (rc >= 0) {  
  69.             /* Saw enough of a valid command to 
  70.              * restart the timeout. 
  71.              */  
  72.             reset_cmd_timeout();  
  73.         }  
  74. #endif  
  75.         len = readline (CFG_PROMPT);  
  76.   
  77.         flag = 0;   /* assume no special flags for now */  
  78.         if (len > 0)  
  79.             strcpy (lastcommand, console_buffer);  
  80.         else if (len == 0)  
  81.             flag |= CMD_FLAG_REPEAT;  
  82. #ifdef CONFIG_BOOT_RETRY_TIME  
  83.         else if (len == -2) {  
  84.             /* -2 means timed out, retry autoboot 
  85.              */  
  86.             puts ("\nTimed out waiting for command\n");  
  87. # ifdef CONFIG_RESET_TO_RETRY  
  88.             /* Reinit board to run initialization code again */  
  89.             do_reset (NULL, 0, 0, NULL);  
  90. # else  
  91.             return;     /* retry autoboot */  
  92. # endif  
  93.         }  
  94. #endif  
  95.   
  96.         if (len == -1)  
  97.             puts ("\n");  
  98.         else  
  99.             rc = run_command (lastcommand, flag);  
  100.   
  101.         if (rc <= 0) {  
  102.             /* invalid command or not repeatable, forget it */  
  103.             lastcommand[0] = 0;  
  104.         }  
  105.     }  
  106. #endif /*CFG_HUSH_PARSER*/  
  107. }  


阅读(964) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~