summaryrefslogtreecommitdiffstats
path: root/src/core/console.c
diff options
context:
space:
mode:
authorMichael Brown2008-06-11 13:06:10 +0200
committerMichael Brown2008-06-11 13:06:10 +0200
commit50810955e97cf704548c84d38194f8ef0a45d8d4 (patch)
treeefd581e4349201acbff396b95775b7c034ac6306 /src/core/console.c
parent[slam] Implement SLAM flow control (diff)
downloadipxe-50810955e97cf704548c84d38194f8ef0a45d8d4.tar.gz
ipxe-50810955e97cf704548c84d38194f8ef0a45d8d4.tar.xz
ipxe-50810955e97cf704548c84d38194f8ef0a45d8d4.zip
[console] Call cpu_nap() only if there is no input waiting
Avoid calling cpu_nap() until after we have determined that there is no input ready to read. This avoids delaying for one timer interrupt (~50ms) in the case of if ( iskey() ) char = getkey() which happens to be present in monojob.c, which is where we spend most of our time looping (e.g. during any download). This should eliminate the irritating tendency of gPXE to lose keypresses. Discovered on a Dell system where the serial port seems to send in a constant stream of 0xff characters; this wouldn't be a problem in itself except that each one triggers the 50ms delay (as mentioned above), which really kills performance.
Diffstat (limited to 'src/core/console.c')
-rw-r--r--src/core/console.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/core/console.c b/src/core/console.c
index 6f55d558..653f689d 100644
--- a/src/core/console.c
+++ b/src/core/console.c
@@ -88,9 +88,15 @@ static struct console_driver * has_input ( void ) {
*/
int getchar ( void ) {
struct console_driver *console;
- int character = 256;
+ int character;
+
+ while ( 1 ) {
+ console = has_input();
+ if ( console && console->getchar ) {
+ character = console->getchar ();
+ break;
+ }
- while ( character == 256 ) {
/* Doze for a while (until the next interrupt). This works
* fine, because the keyboard is interrupt-driven, and the
* timer interrupt (approx. every 50msec) takes care of the
@@ -105,10 +111,6 @@ int getchar ( void ) {
* input.
*/
step();
-
- console = has_input();
- if ( console && console->getchar )
- character = console->getchar ();
}
/* CR -> LF translation */