Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Jan 1997 06:30:02 -0800 (PST)
From:      Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To:        freebsd-bugs
Subject:   Re: bin/2539: keyboard lock with Toshiba laptop 
Message-ID:  <199701291430.GAA02438@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/2539; it has been noted by GNATS.

From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
To: jbrann@freebie.brann.org
Cc: FreeBSD-gnats-submit@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp
Subject: Re: bin/2539: keyboard lock with Toshiba laptop 
Date: Wed, 29 Jan 1997 23:23:30 +0900

 >>>Number:         2539
 >>>Category:       bin
 >>>Synopsis:       keyboard lock with Toshiba laptop
 >>>Confidential:   no
 >>>Severity:       serious
 >>>Priority:       high
 
 >The `psm' driver in 2.2-BETA is very new, and several problems have
 >been reported and corrected so far.
 >
 >Would you possibly check the following?
 >
 >1. Any error messages logged during the boot process. The lines
 >   you should look for are marked with either "sc0:...", "psm:...", or
 >   "kbdio:...".
 >2. If you can bother, put 
 >       options "PSM_DEBUG=2"
 >       options "KBDIO_DEBUG=2"
 >   in your kernel configuration file, rebuild the kernel and reboot. 
 >   You should see a lot more messages this time.
 >3. Please don't use `moused' for now. The `psm' driver and `moused' in
 >   2.2-BETA just don't work together (this problem has been correced
 >   for the next release.)
 >
 >>The mouse works correctly with 2.1.6 and 2.2-960612-SNAP
 >
 >Hmmm. 
 >
 >Kazu.
 
 Since you reported the problem, I haven't heard from you. I, as the
 programmer of the psm driver, am rather concerned that you may have
 abandoned to use the PS/2 mouse device all together.
 
 Several problems with the psm driver in 2.2-BETA have been reported by
 other people as well, and a fix has been issued. Please find patch at
 the end of this mail. I would be very grateful if you could try this
 patch and see if it works for you. The patch will modify psm.c,
 kbdio.c, and kbdio.h in /usr/src/sys/i386/isa.
 
 Thank you, in advance, for your cooperation.
 
 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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701291430.GAA02438>