abortboot

//在bootdelay时长内循环检测是否有任意键按下,如果有则立即退出

static __inline__ int abortboot(int bootdelay)  
{
int abort = 0;

#ifdef CONFIG_MENUPROMPT
printf(CONFIG_MENUPROMPT, bootdelay);
#else
printf("Hit any key to stop autoboot: %2d ", bootdelay); //打印提示信息
#endif

#if defined CONFIG_ZERO_BOOTDELAY_CHECK
/*
* Check if key already pressed
* Don't check if bootdelay < 0
*/
if (bootdelay >= 0) {
   if (tstc()) { /* we got a key press */     //有键被按下
    (void) getc(); /* consume input */    //读按键,清缓冲区,以便下次使用
    puts ("\b\b\b 0");
    abort = 1; /* don't auto boot */     //退出,不自启动
   }
}
#endif

while ((bootdelay > 0) && (!abort)) {     //没有键按下,循环等待bootdelay时长
   int i;

   --bootdelay;
   /* delay 100 * 10ms */
   for (i=0; !abort && i<100; ++i) {
    if (tstc()) { /* we got a key press */     //有键按下
     abort = 1; /* don't auto boot */           //终止循环
     bootdelay = 0; /* no more delay */
# ifdef CONFIG_MENUKEY
     menukey = getc();
# else
     (void) getc(); /* consume input */   //清缓存
# endif
     break;
    }
    udelay(10000);      //没有键被按下,延时10ms
   }

   printf("\b\b\b%2d ", bootdelay);    //打印剩余时间
}

putc('\n');

#ifdef CONFIG_SILENT_CONSOLE
if (abort)
   gd->flags &= ~GD_FLG_SILENT;
#endif

return abort;
}

你可能感兴趣的:(abortboot)