Browse Source

[hci] Continue processing while prompting for shell banner

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>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
3338a03982
3 changed files with 5 additions and 14 deletions
  1. 1
    1
      src/core/getkey.c
  2. 3
    13
      src/hci/shell_banner.c
  3. 1
    0
      src/include/console.h

+ 1
- 1
src/core/getkey.c View File

38
  * @v timeout		Timeout period, in ticks
38
  * @v timeout		Timeout period, in ticks
39
  * @ret character	Character read from console
39
  * @ret character	Character read from console
40
  */
40
  */
41
-static int getchar_timeout ( unsigned long timeout ) {
41
+int getchar_timeout ( unsigned long timeout ) {
42
 	unsigned long expiry = ( currticks() + timeout );
42
 	unsigned long expiry = ( currticks() + timeout );
43
 
43
 
44
 	while ( currticks() < expiry ) {
44
 	while ( currticks() < expiry ) {

+ 3
- 13
src/hci/shell_banner.c View File

20
 
20
 
21
 #include <stdio.h>
21
 #include <stdio.h>
22
 #include <console.h>
22
 #include <console.h>
23
-#include <unistd.h>
24
 #include <config/general.h>
23
 #include <config/general.h>
25
 #include <ipxe/keys.h>
24
 #include <ipxe/keys.h>
25
+#include <ipxe/timer.h>
26
 #include <ipxe/shell_banner.h>
26
 #include <ipxe/shell_banner.h>
27
 
27
 
28
 /** @file
28
 /** @file
37
  * @ret	enter_shell		User wants to enter shell
37
  * @ret	enter_shell		User wants to enter shell
38
  */
38
  */
39
 int shell_banner ( void ) {
39
 int shell_banner ( void ) {
40
-	int enter_shell = 0;
41
-	int wait_count;
42
 	int key;
40
 	int key;
43
 
41
 
44
 	/* Skip prompt if timeout is zero */
42
 	/* Skip prompt if timeout is zero */
49
 	printf ( "\nPress Ctrl-B for the iPXE command line..." );
47
 	printf ( "\nPress Ctrl-B for the iPXE command line..." );
50
 
48
 
51
 	/* Wait for key */
49
 	/* Wait for key */
52
-	for ( wait_count = 0 ; wait_count < BANNER_TIMEOUT ; wait_count++ ) {
53
-		if ( iskey() ) {
54
-			key = getchar();
55
-			if ( key == CTRL_B )
56
-				enter_shell = 1;
57
-			break;
58
-		}
59
-		mdelay(100);
60
-	}
50
+	key = getchar_timeout ( ( BANNER_TIMEOUT * TICKS_PER_SEC ) / 10 );
61
 
51
 
62
 	/* Clear the "Press Ctrl-B" line */
52
 	/* Clear the "Press Ctrl-B" line */
63
 	printf ( "\r                                         \r" );
53
 	printf ( "\r                                         \r" );
64
 
54
 
65
-	return enter_shell;
55
+	return ( key == CTRL_B );
66
 }
56
 }

+ 1
- 0
src/include/console.h View File

102
 
102
 
103
 extern void putchar ( int character );
103
 extern void putchar ( int character );
104
 extern int getchar ( void );
104
 extern int getchar ( void );
105
+extern int getchar_timeout ( unsigned long timeout );
105
 extern int iskey ( void );
106
 extern int iskey ( void );
106
 extern int getkey ( void );
107
 extern int getkey ( void );
107
 
108
 

Loading…
Cancel
Save