bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extra characters generated by faulty hardware


From: Patrick Cipiere
Subject: Extra characters generated by faulty hardware
Date: Mon, 26 Jan 2004 15:55:12 +0100

We have recently experienced a bunch of faulty hardware which generate
an extra character on the keyboard fifo after asking for a reboot.
The result for the box, is that Grub stops the booting sequence and
waits for ever. Very ennoying if the box is far from your office, with
nobody to type the magic phrase on teh keyboard.

I have patched stage2 in order to get rid of this extra character

The behaviour is:

  at the very beginning of stage2
  if we have a character in the keyboard fifo, do not use it, but instead
    if grub_timeout == 0 change it to 15s an dlet it run
    if grub_timeout != 0 let it run

So, if somebody is in front of the keyboard he (or she) can react
    if nobody is in front of the keyboard the box does not get stuck for ever

Maybe the correct patch would be to add a new variable `wait' which
could tell how many seconds we allow stage2 to wait before the user to
enter some real commands

Anyway, my current quick and dirty(?) patch is below

------------------------------------------------------------------------
$ cat grub-0.92/files/patch-stage2.c
--- stage2/stage2.c.orig        Sun Mar 24 13:28:54 2002
+++ stage2/stage2.c     Mon Jan 12 12:00:20 2004
@@ -316,6 +316,8 @@
 #endif /* SUPPORT_SERIAL */
 }
 
+static int keypress; /* address@hidden */
+
 static void
 run_menu (char *menu_entries, char *config_entries, int num_entries,
          char *heap, int entryno)
@@ -466,6 +468,15 @@
   /* XX using RT clock now, need to initialize value */
   while ((time1 = getrtsecs()) == 0xFF);
 
+  /* address@hidden --start-- */
+  if ( checkkey () != -1 ) {
+    getkey();
+    if ( grub_timeout < 10 ) {
+      grub_timeout = 10;
+    }
+  }
+  /* address@hidden --end-- */
+
   while (1)
     {
       /* Initialize to NULL just in case...  */
@@ -500,8 +511,24 @@
         pressed.  
         This avoids polling (relevant in the grub-shell and later on
         in grub if interrupt driven I/O is done).  */
-      if ((checkkey () != -1) || (grub_timeout == -1)) 
+
+   /* if ((checkkey () != -1) || (grub_timeout == -1)) address@hidden */
+
+      if (((keypress = checkkey ()) != -1) || (grub_timeout == -1)) 
        {
+
+         /* address@hidden --start-- */
+         static int last_timeout;
+         static int last_keypress;
+         if ( keypress != -1 ) {
+            last_keypress = keypress;
+           last_timeout = grub_timeout;
+         }
+         gotoxy (3, 22);
+         printf("++ address@hidden : Keypress 0x%x, timeout %d",
+                last_keypress, last_timeout);
+         /* address@hidden --end-- */
+
          /* Key was pressed, show which entry is selected before GETKEY,
             since we're comming in here also on GRUB_TIMEOUT == -1 and
             hang in GETKEY */
------------------------------------------------------------------------

-- 
UDcast: Full IP over Broadcast Media

Phone:  (+33) (0)4 93 00 16 99
Mobile: (+33) (0)6 14 21 55 98
Fax:    (+33) (0)4 93 00 16 61                 http://www.UDcast.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]