]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hci] Continue processing while prompting for shell banner
authorMichael Brown <mcb30@ipxe.org>
Wed, 14 Jul 2010 11:37:29 +0000 (12:37 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 14 Jul 2010 11:43:10 +0000 (12:43 +0100)
Continue calling step() while displaying the shell banner.  This
potentially allows TCP connections to close gracefully after a failed
boot attempt.

Inspired-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/getkey.c
src/hci/shell_banner.c
src/include/console.h

index b159656ec1e5998b68b5806da2d4e1854550aa54..d93ba1e6471fff7f6ed594e75767f41b8c9e14b1 100644 (file)
@@ -38,7 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
  * @v timeout          Timeout period, in ticks
  * @ret character      Character read from console
  */
-static int getchar_timeout ( unsigned long timeout ) {
+int getchar_timeout ( unsigned long timeout ) {
        unsigned long expiry = ( currticks() + timeout );
 
        while ( currticks() < expiry ) {
index 07c0fa4aab7b8996fa2713209c0d802e276222b5..dbfa8edfeb1e49ba095614f0b767dc70e840a74c 100644 (file)
@@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 
 #include <stdio.h>
 #include <console.h>
-#include <unistd.h>
 #include <config/general.h>
 #include <ipxe/keys.h>
+#include <ipxe/timer.h>
 #include <ipxe/shell_banner.h>
 
 /** @file
@@ -37,8 +37,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
  * @ret        enter_shell             User wants to enter shell
  */
 int shell_banner ( void ) {
-       int enter_shell = 0;
-       int wait_count;
        int key;
 
        /* Skip prompt if timeout is zero */
@@ -49,18 +47,10 @@ int shell_banner ( void ) {
        printf ( "\nPress Ctrl-B for the iPXE command line..." );
 
        /* Wait for key */
-       for ( wait_count = 0 ; wait_count < BANNER_TIMEOUT ; wait_count++ ) {
-               if ( iskey() ) {
-                       key = getchar();
-                       if ( key == CTRL_B )
-                               enter_shell = 1;
-                       break;
-               }
-               mdelay(100);
-       }
+       key = getchar_timeout ( ( BANNER_TIMEOUT * TICKS_PER_SEC ) / 10 );
 
        /* Clear the "Press Ctrl-B" line */
        printf ( "\r                                         \r" );
 
-       return enter_shell;
+       return ( key == CTRL_B );
 }
index 9ecf9d4401f96e989daff526654e32ac54bcb81b..271b4f365519bb97f30b696277b2821fa8342cfe 100644 (file)
@@ -102,6 +102,7 @@ struct console_driver {
 
 extern void putchar ( int character );
 extern int getchar ( void );
+extern int getchar_timeout ( unsigned long timeout );
 extern int iskey ( void );
 extern int getkey ( void );