[gPXE-devel] [PATCHv3 4/7] [core] Keep scheduling while shell banner waiting
cooldavid at cooldavid.org
cooldavid at cooldavid.org
Thu Jul 15 11:58:54 EDT 2010
From: Guo-Fu Tseng <cooldavid at cooldavid.org>
Currently we do nothing while polling user input when shell banner
waiting. I modified it to do something like in shell, scheduling
processes while waiting for user input.
We can have two improvements in this way.
First:
Increase the key response in shell banner. It is much more
likely to successful get into shell then before. By former
experience, I sometimes did pressed the CTRL_B, but fail to get
into shell. It might caused by waiting too long in mdelay(100).
Second:
While using scripts, if the downloaded image is not bootable,
the gPXE exits faster than it have the opportunity to gracefully
closing the TCP connection. Which might lead the TCP state of
remote server not closed.
It actually waits for user to input for 2 seconds by default
before returning control to BIOS. This commit let TCP have the
opportunity to gracefully close while waiting for user to hit
keys in shell banner.
Referenced: Michael Brown <mcb30 at ipxe.org>
Signed-off-by: Guo-Fu Tseng <cooldavid at cooldavid.org>
---
src/core/getkey.c | 2 +-
src/hci/shell_banner.c | 14 ++------------
src/include/console.h | 1 +
3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/src/core/getkey.c b/src/core/getkey.c
index dbd074c..15c57e5 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 dbe3767..c750e00 100644
--- a/src/hci/shell_banner.c
+++ b/src/hci/shell_banner.c
@@ -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;
if ( BANNER_TIMEOUT <= 0 ) {
@@ -48,18 +46,10 @@ int shell_banner ( void ) {
printf ( "\nPress Ctrl-B for the gPXE 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 62fedf5..49a898b 100644
--- a/src/include/console.h
+++ b/src/include/console.h
@@ -112,6 +112,7 @@ struct console_driver {
/* Function prototypes */
extern void putchar ( int character );
+extern int getchar_timeout ( unsigned long timeout );
extern int getchar ( void );
extern int iskey ( void );
extern int getkey ( void );
--
1.7.1
More information about the gPXE-devel
mailing list