From nsayer@quack.kfu.com  Thu Mar 27 10:52:22 1997
Received: from quack.kfu.com (0@quack.kfu.com [204.147.226.1])
          by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id KAA09645
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 27 Mar 1997 10:52:20 -0800 (PST)
Received: from ceres.kfu.com (ceres.kfu.com [204.147.226.5]) by quack.kfu.com (8.6.12/8.6.12) with ESMTP id KAA06298 for <FreeBSD-gnats-submit@freebsd.org>; Thu, 27 Mar 1997 10:52:17 -0800
Received: by ceres.kfu.com 
        (8.8.5//ident-1.0) id KAA00336; Thu, 27 Mar 1997 10:52:16 -0800 (PST) 
Message-Id: <199703271852.KAA00336@ceres.kfu.com>
Date: Thu, 27 Mar 1997 10:52:16 -0800 (PST)
From: nsayer@quack.kfu.com
Reply-To: nsayer@quack.kfu.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: BOOT_PROBE_KEYBOARD hangs system in bootblocks
X-Send-Pr-Version: 3.2

>Number:         3124
>Category:       i386
>Synopsis:       BOOT_PROBE_KEYBOARD hangs system in bootblocks
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 27 11:00:04 PST 1997
>Closed-Date:    Sat Aug 23 18:06:09 MEST 1997
>Last-Modified:  Sat Aug 23 18:06:32 MEST 1997
>Originator:     Nick Sayer
>Release:        FreeBSD 2.2-RELEASE i386
>Organization:
Just me
>Environment:

Award BIOS, 486, no keyboard

>Description:

If you set BOOT_PROBE_KEYBOARD=true in /etc/make.conf and rebuild and
install the resulting boot blocks, the system will hang on reboot.
If you plug in a keyboard while it is hanging, it will instantly
start booting as if a keyboard was plugged in. The probe is obviously
hanging when no keyboard is present.

Let me be clear.... It is hanging _after_ the boot blocks are loaded
from disk. It is not actually hanging in the bios itself. I know this
because I was testing with a VGA monitor hooked up and watching the
disk light.

>How-To-Repeat:

>Fix:

The workaround is BOOT_FORCE_COMCONSOLE, but that is less desirable,
obviously.

>Release-Note:
>Audit-Trail:

From: j@uriah.heep.sax.de (J Wunsch)
To: nsayer@quack.kfu.com
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: i386/3124: BOOT_PROBE_KEYBOARD hangs system in bootblocks
Date: Thu, 27 Mar 1997 20:24:56 +0100

 As nsayer@quack.kfu.com wrote:
 
 > >Synopsis:       BOOT_PROBE_KEYBOARD hangs system in bootblocks
 
 That's why it is an option, and not the default.  We _knew_ that it
 tends to hang some odd machine (after hard experience when making this
 the default case in some release), and had to back it out again.
 
 Unless you find a way that works for your BIOS/keyboard combination
 without breaking some other combination, it is not likely to be fixed
 by somebody ever (since it's impossible without a machine that
 experiences the problem).
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: nsayer@quack.kfu.com
Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: i386/3124: BOOT_PROBE_KEYBOARD hangs system in bootblocks 
Date: Fri, 28 Mar 1997 09:23:28 +0900

 >>Number:         3124
 >>Category:       i386
 >>Synopsis:       BOOT_PROBE_KEYBOARD hangs system in bootblocks
 >>Confidential:   no
 >>Severity:       serious
 >>Priority:       high
 >>Responsible:    freebsd-bugs
 >>State:          open
 >>Class:          sw-bug
 >>Submitter-Id:   current-users
 >>Arrival-Date:   Thu Mar 27 11:00:04 PST 1997
 >>Last-Modified:
 >>Originator:     Nick Sayer
 >>Organization:
 >Just me
 >>Release:        FreeBSD 2.2-RELEASE i386
 >>Environment:
 >
 >Award BIOS, 486, no keyboard
 >
 >>Description:
 >
 >If you set BOOT_PROBE_KEYBOARD=true in /etc/make.conf and rebuild and
 >install the resulting boot blocks, the system will hang on reboot.
 >If you plug in a keyboard while it is hanging, it will instantly
 >start booting as if a keyboard was plugged in. The probe is obviously
 >hanging when no keyboard is present.
 
 AFAIK, BOOT_PROBE_KEYBOARD didn't work well in the past and nobody is
 actively working on it nowadays. That's why it is currently an option. 
 The problem is that probe_keyboard() (in
 /sys/i386/boot/biosboot/probe_keyboard.c) doesn't work as expected in
 some systems.
 
 I once wrote a replacement routine. It worked in my systems, but I
 abandoned the project because I had other, more urgent code to work
 on.
 
 I don't know if it is good for you, but if you are interested, here
 goes.  Save the following code as probe_keyboard.c (of course you had
 better save the original copy of probe_keyboard.c somewhere), and
 rebuild the boot block.
 
 Please remember that I don't guarantee anything; this code may or may
 not work in your system. To test the boot block, you had better have
 the `install' and `fixit' floppy handy; a broken boot block and an
 unbootable system are too bad.
 
 Kazu
 
 ----8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---
 /*-
  * $Id:$
  */
 
 #ifdef PROBE_KEYBOARD
 
 #include <i386/include/cpufunc.h>
 #include <i386/isa/isa.h>
 #include <i386/isa/ic/i8042.h>
 #include <i386/isa/kbdio.h>
 
 #include "boot.h"
 
 #define PROBE_MAXRETRY	5
 #define PROBE_MAXWAIT	500
 
 #define IO_DUMMY	0x84
 
 /* 7 microsec delay necessary for some keyboard controllers */
 static void
 delay7(void)
 {
     /* 
      * I know this is broken, but no timer is avaiable yet at this stage...
      * See also comments in `delay1ms()' in `io.c'.
      */
     inb(IO_DUMMY); inb(IO_DUMMY);
     inb(IO_DUMMY); inb(IO_DUMMY);
     inb(IO_DUMMY); inb(IO_DUMMY);
 }
 
 /* 
  * Perform a simple test on the keyboard; issue the ECHO command and see
  * if the right answer is returned. We don't do anything as drastic as
  * full keyboard reset; it will be too troublesome and take too much time.
  */
 int
 probe_keyboard(void)
 {
     int retry = PROBE_MAXRETRY;
     int wait;
     int i;
 
     while (--retry >= 0) {
 	/* flush any noise */
 	while (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) {
 	    delay7();
 	    inb(IO_KBD + KBD_DATA_PORT);
 	    delay1ms();
 	}
 
 	/* wait until the controller can accept a command */
 	for (wait = PROBE_MAXWAIT; wait > 0; --wait) {
 	    if (((i = inb(IO_KBD + KBD_STATUS_PORT)) 
                 & (KBDS_INPUT_BUFFER_FULL | KBDS_ANY_BUFFER_FULL)) == 0)
 		break;
 	    if (i & KBDS_ANY_BUFFER_FULL) {
 		delay7();
 	        inb(IO_KBD + KBD_DATA_PORT);
 	    }
 	    delay1ms();
 	}
 	if (wait <= 0)
 	    continue;
 
 	/* ECHO command */
 	outb(IO_KBD + KBD_DATA_PORT, KBDC_ECHO);
 
 	/* wait for a response */
 	for (wait = PROBE_MAXWAIT; wait > 0; --wait) {
 	     if (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL)
 		 break;
 	     delay1ms();
 	}
 	if (wait <= 0)
 	    continue;
 
 	delay7();
 	i = inb(IO_KBD + KBD_DATA_PORT);
 #ifdef PROBE_KBD_BEBUG
         printf("probe_keyboard: got 0x%x.\n", i);
 #endif
 	if (i == KBD_ECHO) {
 	    /* got the right answer */
 #ifdef PROBE_KBD_BEBUG
             printf("probe_keyboard: succeeded.\n");
 #endif
 	    return (0);
 	}
     }
 
 #ifdef PROBE_KBD_BEBUG
     printf("probe_keyboard: failed.\n");
 #endif
     return (1);
 }
 
 #endif /* PROBE_KEYBOARD */
 

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: nsayer@quack.kfu.com
Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: i386/3124: BOOT_PROBE_KEYBOARD hangs system in bootblocks 
Date: Wed, 02 Apr 1997 19:36:38 +0900

 >>Description:
 >
 >If you set BOOT_PROBE_KEYBOARD=true in /etc/make.conf and rebuild and
 >install the resulting boot blocks, the system will hang on reboot.
 >If you plug in a keyboard while it is hanging, it will instantly
 >start booting as if a keyboard was plugged in. The probe is obviously
 >hanging when no keyboard is present.
 >
 >Let me be clear.... It is hanging _after_ the boot blocks are loaded
 >from disk. It is not actually hanging in the bios itself. I know this
 >because I was testing with a VGA monitor hooked up and watching the
 >disk light.
 
 Here is a patch to src/sys/i386/isa/syscons.c to guard against system
 hang-up after the keyboard probe routine (probe_keyboard()) in the
 boot block may screw up the keyboard. Unlike the previous patch I sent
 to you, this patch doesn't make the BOOT_PROBE_KEYBOARD option work,
 but rather it makes the system slightly more robust (I hope :-).
 
 Kazu
 
 --- syscons.c-dist	Wed Apr  2 11:13:57 1997
 +++ syscons.c	Wed Apr  2 11:20:27 1997
 @@ -312,8 +312,10 @@
          return ((dev->id_flags & DETECT_KBD) ? 0 : IO_KBDSIZE);
      }
  
 -    /* discard anything left after UserConfig */
 +    /* guard against the broken probe_keyboard() in the boot block */
      empty_both_buffers(sc_kbdc, 10);
 +    test_controller(sc_kbdc);
 +    test_kbd_port(sc_kbdc);
  
      /* save the current keyboard controller command byte */
      m = kbdc_get_device_mask(sc_kbdc) & ~KBD_KBD_CONTROL_BITS;
 @@ -1444,6 +1446,10 @@
      cp->cn_pri = CN_INTERNAL;
  
      sc_kbdc = kbdc_open(sc_port);
 +    /* guard against the broken probe_keyboard() in the boot block */
 +    empty_both_buffers(sc_kbdc, 10);
 +    test_controller(sc_kbdc);
 +    test_kbd_port(sc_kbdc);
  }
  
  void

From: Ari Suutari <ari@ps.carel.fi>
To: freebsd-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Cc:  Subject: Re: i386/3124: BOOT_PROBE_KEYBOARD hangs system in bootblocks
Date: Thu, 03 Jul 1997 09:57:42 +0300

 Hi,
 
 	The reason for boot probe_keyboard hanging on my 486 is 
 	this piece of code in beginning of function:
 
 /* flush any noise in the buffer */
    while (inb(IO_KBD + KBD_STATUS_PORT) & KBDS_BUFFER_FULL) {
             delay1ms();
             (void) inb(IO_KBD + KBD_DATA_PORT);
     }
 
 	Apparently, there is an endless amount of noise on 
 	my machine. Adding a retry counter to this should 
 	fix the	problem (I'm willing to test if someone
 	makes the change).
 
 		Ari S.
 
 
 
 -- 
 ------------------------------------------------------
 Hei! Puhumme myos suomea!
 Carelcomp Forest Oy        Ari Suutari                   
 53850 Lappeenranta         mailto:ari.suutari@carel.fi         
 FINLAND                    +358 5 669 5012
State-Changed-From-To: open->feedback 
State-Changed-By: joerg 
State-Changed-When: Sat Aug 23 15:01:53 MEST 1997 
State-Changed-Why:  
Still valid? 
State-Changed-From-To: feedback->closed 
State-Changed-By: joerg 
State-Changed-When: Sat Aug 23 18:06:09 MEST 1997 
State-Changed-Why:  

Originator confirms problem solved. 
>Unformatted:
