diff --git a/src/core/getkey.c b/src/core/getkey.c index b159656e..d93ba1e6 100644 --- a/src/core/getkey.c +++ b/src/core/getkey.c @@ -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 ) { diff --git a/src/hci/shell_banner.c b/src/hci/shell_banner.c index 07c0fa4a..dbfa8edf 100644 --- a/src/hci/shell_banner.c +++ b/src/hci/shell_banner.c @@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include -#include #include #include +#include #include /** @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 ); } diff --git a/src/include/console.h b/src/include/console.h index 9ecf9d44..271b4f36 100644 --- a/src/include/console.h +++ b/src/include/console.h @@ -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 );