Procházet zdrojové kódy

[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 před 14 roky
rodič
revize
3338a03982
3 změnil soubory, kde provedl 5 přidání a 14 odebrání
  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 Zobrazit soubor

@@ -38,7 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
38 38
  * @v timeout		Timeout period, in ticks
39 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 42
 	unsigned long expiry = ( currticks() + timeout );
43 43
 
44 44
 	while ( currticks() < expiry ) {

+ 3
- 13
src/hci/shell_banner.c Zobrazit soubor

@@ -20,9 +20,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
20 20
 
21 21
 #include <stdio.h>
22 22
 #include <console.h>
23
-#include <unistd.h>
24 23
 #include <config/general.h>
25 24
 #include <ipxe/keys.h>
25
+#include <ipxe/timer.h>
26 26
 #include <ipxe/shell_banner.h>
27 27
 
28 28
 /** @file
@@ -37,8 +37,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
37 37
  * @ret	enter_shell		User wants to enter shell
38 38
  */
39 39
 int shell_banner ( void ) {
40
-	int enter_shell = 0;
41
-	int wait_count;
42 40
 	int key;
43 41
 
44 42
 	/* Skip prompt if timeout is zero */
@@ -49,18 +47,10 @@ int shell_banner ( void ) {
49 47
 	printf ( "\nPress Ctrl-B for the iPXE command line..." );
50 48
 
51 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 52
 	/* Clear the "Press Ctrl-B" line */
63 53
 	printf ( "\r                                         \r" );
64 54
 
65
-	return enter_shell;
55
+	return ( key == CTRL_B );
66 56
 }

+ 1
- 0
src/include/console.h Zobrazit soubor

@@ -102,6 +102,7 @@ struct console_driver {
102 102
 
103 103
 extern void putchar ( int character );
104 104
 extern int getchar ( void );
105
+extern int getchar_timeout ( unsigned long timeout );
105 106
 extern int iskey ( void );
106 107
 extern int getkey ( void );
107 108
 

Načítá se…
Zrušit
Uložit