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>
* @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 ) {
#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
* @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 */
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 );
}
extern void putchar ( int character );
extern int getchar ( void );
+extern int getchar_timeout ( unsigned long timeout );
extern int iskey ( void );
extern int getkey ( void );