From nobody  Fri Jan 31 17:42:31 1997
Received: (from nobody@localhost)
          by freefall.freebsd.org (8.8.5/8.8.5) id RAA27655;
          Fri, 31 Jan 1997 17:42:31 -0800 (PST)
Message-Id: <199702010142.RAA27655@freefall.freebsd.org>
Date: Fri, 31 Jan 1997 17:42:31 -0800 (PST)
From: epv@panix.com
To: freebsd-gnats-submit@freebsd.org
Subject: enabling psm mouse causes keyboard to not work on Toshiba 115CS laptop
X-Send-Pr-Version: www-1.0

>Number:         2632
>Category:       kern
>Synopsis:       enabling psm mouse causes keyboard to not work on Toshiba 115CS laptop
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 31 17:50:01 PST 1997
>Closed-Date:    Wed Nov 5 19:45:39 PST 1997
>Last-Modified:  Wed Nov  5 19:54:31 PST 1997
>Originator:     Eric Volpe
>Release:        2.2-BETA
>Organization:
>Environment:
FreeBSD lemur.snysel.com 2.20-BETA_A #1	
>Description:
if psm mouse driver is enabled (either from boot floppy or a kernel 
built on the machine from 2.2-BETA source) the kernel correctly 
identifies the mouse when booting, but does not respond to the keyboard
at all. If the psm device is disabled in userconfig or not compiled into
the kernel, the keyboard responds properly. 	
>How-To-Repeat:
boot boot floppy on toshiba laptop.
enter userconfig. 
disable microsoft busmouse driver (mse) 
enable ps/2 mouse support (psm)
try to use keyboard

>Fix:
unknown
>Release-Note:
>Audit-Trail:

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: epv@panix.com
Cc: freebsd-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: kern/2632: enabling psm mouse causes keyboard to not work on Toshiba
	 115CS laptop 
Date: Sun, 02 Feb 1997 14:19:53 +0900

 >>Number:         2632
 >>Category:       kern
 >>Synopsis:       enabling psm mouse causes keyboard to not work on Toshiba 115
 >CS laptop
 >>Confidential:   no
 >>Severity:       serious
 >>Priority:       medium
 >>Responsible:    freebsd-bugs
 >>State:          open
 >>Class:          sw-bug
 >>Submitter-Id:   current-users
 >>Arrival-Date:   Fri Jan 31 17:50:01 PST 1997
 >>Last-Modified:
 >>Originator:     Eric Volpe
 >>Organization:
 >>Release:        2.2-BETA
 >>Environment:
 >FreeBSD lemur.snysel.com 2.20-BETA_A #1	
 >>Description:
 >if psm mouse driver is enabled (either from boot floppy or a kernel 
 >built on the machine from 2.2-BETA source) the kernel correctly 
 >identifies the mouse when booting, but does not respond to the keyboard
 >at all. If the psm device is disabled in userconfig or not compiled into
 >the kernel, the keyboard responds properly. 	
 >>How-To-Repeat:
 >boot boot floppy on toshiba laptop.
 >enter userconfig. 
 >disable microsoft busmouse driver (mse) 
 >enable ps/2 mouse support (psm)
 >try to use keyboard
 
 Several problems have already been reported and fixed, regarding 
 the `psm' driver in 2.2-BETA. Would you please try the following
 patch and see if it works on your system. The patch will modify
 psm.c, kbdio.c, and kbdio.h in /usr/src/sys/i386/isa.
 
 Kazu
 
 ===================================================================
 RCS file: /home/ncvs/src/sys/i386/isa/psm.c,v
 retrieving revision 1.25.2.3
 retrieving revision 1.25.2.5
 diff -u -r1.25.2.3 -r1.25.2.5
 --- src/sys/i386/isa/psm.c	1996/12/03 10:47:24	1.25.2.3
 +++ src/sys/i386/isa/psm.c	1997/01/15 12:03:33	1.25.2.5
 @@ -19,7 +19,7 @@
   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
 - * $Id: psm.c,v 1.25.2.3 1996/12/03 10:47:24 phk Exp $
 + * $Id: psm.c,v 1.25.2.5 1997/01/15 12:03:33 sos Exp $
   */
  
  /*
 @@ -435,6 +435,11 @@
      int i;
  
      switch((i = test_aux_port(port))) {
 +    case 1:	/* ignore this error */
 +	if (verbose)
 +	    log(LOG_DEBUG, "psm%d: strange result for test aux port (%d).\n",
 +	        PSM_UNIT(dev), i);
 +	/* fall though */
      case 0:	/* no error */
      	break;
      case -1: 	/* time out */
 @@ -478,10 +483,14 @@
      }
  
      /* just check the status of the mouse */
 +    i = get_mouse_status(port, stat);
      if (verbose) {
 -        get_mouse_status(port, stat);
 -        log(LOG_DEBUG, "psm%d: status %02x %02x %02x (reinitialized)\n",
 -            PSM_UNIT(dev), stat[0], stat[1], stat[2]);
 +	if (i)
 +            log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
 +                PSM_UNIT(dev), stat[0], stat[1], stat[2]);
 +	else
 +	    log(LOG_DEBUG, "psm%d: failed to get mouse status\n", 
 +		PSM_UNIT(dev));
      }
  
      return TRUE;
 @@ -508,6 +517,8 @@
      if (unit >= NPSM)
          return (0);
  
 +    psm_softc[unit] = NULL; 
 +
      sc =  malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
  
      bzero(sc, sizeof *sc);
 @@ -556,6 +567,7 @@
       */
  
      /* save the current command byte; it will be used later */
 +    empty_both_buffers(ioport, 20);	
      if (!write_controller_command(ioport,KBDC_GET_COMMAND_BYTE)) {
          /* CONTROLLER ERROR */
          printf("psm%d: failed to get the current command byte value.\n",
 @@ -604,8 +616,18 @@
       * supporsed to return with an error code or simply time out. In any
       * case, we have to continue probing the port even when the controller
       * passes this test.
 +     *
 +     * XXX: some controllers erroneously return the error code 1 when
 +     * it has the perfectly functional aux port. We have to ignore this
 +     * error code. Even if the controller HAS error with the aux port,
 +     * it will be detected later...
       */
      switch ((i = test_aux_port(ioport))) {
 +    case 1:	   /* ignore this error */
 +        if (verbose)
 +	    printf("psm%d: strange result for test aux port (%d).\n",
 +	        unit, i);
 +	/* fall though */
      case 0:        /* no error */
          break;
      case -1:        /* time out */
 @@ -693,6 +715,7 @@
  
      /* set mouse parameters */
      /* FIXME:XXX should we set them in `psmattach()' rather than here? */
 +#if 0
      if (setparams) {
          if (sc->mode.rate > 0)
              sc->mode.rate = set_mouse_sampling_rate(ioport, sc->mode.rate);
 @@ -703,12 +726,25 @@
      /* FIXME:XXX I don't know if these parameters are reasonable */
      set_mouse_scaling(ioport);    /* 1:1 scaling */
      set_mouse_mode(ioport);    /* stream mode */
 +#else
 +    i = send_aux_command(ioport, PSMC_SET_DEFAULTS);
 +    if (verbose >= 2)
 +	log(LOG_DEBUG, "psm%d: SET_DEFAULTS return code:%04x\n", unit, i);
 +#endif
  
      /* just check the status of the mouse */
 +    /* 
 +     * XXX there are some arcane controller/mouse combinations out there,
 +     * which hung the controller unless there is data transmission 
 +     * after ACK from the mouse.
 +     */
 +    i = get_mouse_status(ioport, stat);
      if (verbose) {
 -        get_mouse_status(ioport, stat);
 -        log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
 -            unit, stat[0], stat[1], stat[2]);
 +	if (i)
 +            log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
 +                unit, stat[0], stat[1], stat[2]);
 +	else
 +	    log(LOG_DEBUG, "psm%d: failed to get mouse status\n", unit);
      }
  
      /* disable the aux port for now... */
 @@ -745,6 +781,9 @@
      int unit = dvp->id_unit;
      struct psm_softc *sc = psm_softc[unit];
  
 +    if (sc == NULL)    /* shouldn't happen */ 
 +	return (0); 
 +
      /* initial operation mode */
      sc->mode.accelfactor = PSM_ACCEL;
      sc->mode.protocol = MOUSE_PROTO_PS2;
 @@ -763,8 +802,11 @@
          DV_CHR, 0, 0, 0666, "npsm%d", unit);
  #endif
  
 -    printf("psm%d: device ID %d, %d buttons?\n",
 -        unit, sc->hw.hwid, sc->hw.buttons);
 +    if (verbose)
 +        printf("psm%d: device ID %d, %d buttons?\n",
 +            unit, sc->hw.hwid, sc->hw.buttons);
 +    else
 +        printf("psm%d: device ID %d\n", unit, sc->hw.hwid);
  
      if (bootverbose)
          --verbose;
 @@ -779,6 +821,7 @@
      int ioport;
      struct psm_softc *sc;
      int stat[3];
 +    int ret;
  
      /* Validate unit number */
      if (unit >= NPSM)
 @@ -786,7 +829,7 @@
  
      /* Get device data */
      sc = psm_softc[unit];
 -    if ((sc->state & PSM_VALID) == 0)
 +    if ((sc == NULL) || (sc->state & PSM_VALID) == 0)
  	/* the device is no longer valid/functioning */
          return (ENXIO);
      ioport = sc->addr;
 @@ -849,10 +892,14 @@
          return (EIO);
      }
  
 +    ret = get_mouse_status(ioport, stat);
      if (verbose >= 2) {
 -        get_mouse_status(ioport, stat);
 -        log(LOG_DEBUG, "psm%d: status %02x %02x %02x\n",
 -            unit, stat[0], stat[1], stat[2]);
 +	if (ret)
 +            log(LOG_DEBUG, "psm%d: status %02x %02x %02x (psmopen)\n",
 +                unit, stat[0], stat[1], stat[2]);
 +	else
 +	    log(LOG_DEBUG, "psm%d: failed to get mouse status (psmopen).\n",
 +		unit);
      }
  
      /* enable the aux port and interrupt */
 @@ -877,6 +924,8 @@
  {
      struct psm_softc *sc = psm_softc[PSM_UNIT(dev)];
      int ioport = sc->addr;
 +    int stat[3];
 +    int ret;
  
      /* disable the aux interrupt */
      if (!set_controller_command_byte(ioport, sc->command_byte,
 @@ -905,6 +954,17 @@
  	log(LOG_ERR, "psm%d: failed to disable the device (psmclose).\n",
  	    PSM_UNIT(dev));
      }
 +
 +    ret = get_mouse_status(ioport, stat);
 +    if (verbose >= 2) {
 +	if (ret)
 +            log(LOG_DEBUG, "psm%d: status %02x %02x %02x (psmclose)\n",
 +                PSM_UNIT(dev), stat[0], stat[1], stat[2]);
 +	else
 +	    log(LOG_DEBUG, "psm%d: failed to get mouse status (psmclose).\n",
 +		PSM_UNIT(dev));
 +    }
 +
      if (!set_controller_command_byte(ioport, sc->command_byte,
  	KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
  	/* CONTROLLER ERROR; 
 
 ===================================================================
 RCS file: /home/ncvs/src/sys/i386/isa/kbdio.c,v
 retrieving revision 1.1.2.2
 retrieving revision 1.1.2.3
 diff -u -r1.1.2.2 -r1.1.2.3
 --- src/sys/i386/isa/kbdio.c	1996/12/04 16:11:39	1.1.2.2
 +++ src/sys/i386/isa/kbdio.c	1997/01/15 12:03:38	1.1.2.3
 @@ -26,7 +26,7 @@
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
 - * $Id: kbdio.c,v 1.1.2.2 1996/12/04 16:11:39 phk Exp $
 + * $Id: kbdio.c,v 1.1.2.3 1997/01/15 12:03:38 sos Exp $
   */
  
  #include <sys/param.h>
 @@ -295,64 +295,76 @@
  
  /* discard data from the keyboard */
  void
 -empty_kbd_buffer(int port, int t)
 +empty_kbd_buffer(int port, int wait)
  {
 +    int t;
      int b;
      int c = 0;
      int delta = 2;
  
 -    for (; t > 0; t -= delta) { 
 +    for (t = wait; t > 0; ) { 
          if ((inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
      	   == KBDS_KBD_BUFFER_FULL) {
  	    DELAY(KBDD_DELAYTIME);
 -        b = inb(port + KBD_DATA_PORT);
 -        ++c;
 -    }
 +            b = inb(port + KBD_DATA_PORT);
 +            ++c;
 +	    t = wait;
 +	} else {
 +	    t -= delta;
 +        }
          DELAY(delta*1000);
      }
      if ((verbose >= 2) && (c > 0))
 -    log(LOG_DEBUG,"kbdio: %d char read (empty_kbd_buffer)\n",c);
 +        log(LOG_DEBUG,"kbdio: %d char read (empty_kbd_buffer)\n",c);
  }
  
  /* discard data from the aux device */
  void
 -empty_aux_buffer(int port, int t)
 +empty_aux_buffer(int port, int wait)
  {
 +    int t;
      int b;
      int c = 0;
      int delta = 2;
  
 -    for (; t > 0; t -= delta) { 
 +    for (t = wait; t > 0; ) { 
          if ((inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
      	    == KBDS_AUX_BUFFER_FULL) {
  	    DELAY(KBDD_DELAYTIME);
 -        b = inb(port + KBD_DATA_PORT);
 -        ++c;
 -    }
 +            b = inb(port + KBD_DATA_PORT);
 +            ++c;
 +	    t = wait;
 +	} else {
 +	    t -= delta;
 +        }
  	DELAY(delta*1000);
      }
      if ((verbose >= 2) && (c > 0))
 -    log(LOG_DEBUG,"kbdio: %d char read (empty_aux_buffer)\n",c);
 +        log(LOG_DEBUG,"kbdio: %d char read (empty_aux_buffer)\n",c);
  }
  
  /* discard any data from the keyboard or the aux device */
  void
 -empty_both_buffers(int port, int t)
 +empty_both_buffers(int port, int wait)
  {
 +    int t;
      int b;
      int c = 0;
      int delta = 2;
  
 -    for (; t > 0; t -= delta) { 
 +    for (t = wait; t > 0; ) { 
          if (inb(port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) {
  	    DELAY(KBDD_DELAYTIME);
 -        b = inb(port + KBD_DATA_PORT);
 -        ++c;
 -    }
 +            b = inb(port + KBD_DATA_PORT);
 +            ++c;
 +	    t = wait;
 +	} else {
 +	    t -= delta;
 +        }
  	DELAY(delta*1000);
      }
      if ((verbose >= 2) && (c > 0))
 -    log(LOG_DEBUG,"kbdio: %d char read (empty_both_buffers)\n",c);
 +        log(LOG_DEBUG,"kbdio: %d char read (empty_both_buffers)\n",c);
  }
  
  /* keyboard and mouse device control */
 
 ===================================================================
 RCS file: /home/ncvs/src/sys/i386/isa/kbdio.h,v
 retrieving revision 1.1.2.2
 retrieving revision 1.1.2.3
 diff -u -r1.1.2.2 -r1.1.2.3
 --- src/sys/i386/isa/kbdio.h	1996/12/04 16:11:45	1.1.2.2
 +++ src/sys/i386/isa/kbdio.h	1997/01/15 12:03:41	1.1.2.3
 @@ -26,7 +26,7 @@
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   *
 - * $Id: kbdio.h,v 1.1.2.2 1996/12/04 16:11:45 phk Exp $
 + * $Id: kbdio.h,v 1.1.2.3 1997/01/15 12:03:41 sos Exp $
   */
  
  #ifndef _I386_ISA_KBDIO_H_
 @@ -93,6 +93,7 @@
  #define PSMC_RESET_DEV	     	0x00ff
  #define PSMC_ENABLE_DEV      	0x00f4
  #define PSMC_DISABLE_DEV     	0x00f5
 +#define PSMC_SET_DEFAULTS	0x00f6
  #define PSMC_SEND_DEV_ID     	0x00f2
  #define PSMC_SEND_DEV_STATUS 	0x00e9
  #define PSMC_SEND_DEV_DATA	0x00eb

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: epv@panix.com
Cc: freebsd-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: kern/2632: enabling psm mouse causes keyboard to not work on Toshiba
	 115CS laptop 
Date: Tue, 08 Apr 1997 09:45:21 +0900

 >>Number:         2632
 >>Category:       kern
 >>Synopsis:       enabling psm mouse causes keyboard to not work on Toshiba 115
 >CS laptop
 >>Confidential:   no
 >>Severity:       serious
 >>Priority:       medium
 >>Responsible:    freebsd-bugs
 >>State:          open
 >>Class:          sw-bug
 >>Submitter-Id:   current-users
 >>Arrival-Date:   Fri Jan 31 17:50:01 PST 1997
 >>Last-Modified:
 >>Originator:     Eric Volpe
 >>Organization:
 >>Release:        2.2-BETA
 >>Environment:
 >FreeBSD lemur.snysel.com 2.20-BETA_A #1	
 >>Description:
 >if psm mouse driver is enabled (either from boot floppy or a kernel 
 >built on the machine from 2.2-BETA source) the kernel correctly 
 >identifies the mouse when booting, but does not respond to the keyboard
 >at all. If the psm device is disabled in userconfig or not compiled into
 >the kernel, the keyboard responds properly. 	
 
 Do you still see the above problem with 2.2-RELEASE? If not, I would
 close this PR.
 
 Kazu
State-Changed-From-To: open->closed 
State-Changed-By: yokota 
State-Changed-When: Wed Nov 5 19:45:39 PST 1997 
State-Changed-Why:  

The originator doesn't respond. The problem is believed to be fixed 
in 2.2-RELEASE. 
>Unformatted:
