Subject: Gross pccons hacks for GW2K machines
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Mike Long <mike.long@analog.com>
List: current-users
Date: 04/05/1994 23:28:11
I just played a bit with pccons.c (1.60 from 3/19 sys.tar.gz), and
applying the following diffs totally eliminated my keyboard lockup
problems (knock wood).  No more pounding on the keyboard during
autoconfig!

There are almost certainly more modifications here than are needed to
solve the problem, and they're totally gross.  I will eliminate as
much grossness as I can without reintroducing the lockups, but these
changes should get my fellow sufferers up and running for now.
Changes with /*jwh*/ comments are from John Hayward's experimentation,
while the /*mwl*/ lines are mine.

*** pccons.c.orig	Sat Mar 12 06:05:00 1994
--- pccons.c	Tue Apr  5 22:05:56 1994
***************
*** 326,350 ****
  
  #if 1
  	/* Flush any garbage. */
! 	while (inb(KBSTATP) & KBS_DIB)
  		(void) inb(KBDATAP);
  	/* Reset the keyboard. */
  	if (!kbd_cmd(KBC_RESET, 1)) {
  		printf("pcprobe: reset error %d\n", 1);
  		goto lose;
  	}
! 	while ((inb(KBSTATP) & KBS_DIB) == 0);
  	if (inb(KBDATAP) != KBR_RSTDONE) {
  		printf("pcprobe: reset error %d\n", 2);
  		goto lose;
  	}
  	/*
  	 * Some keyboards seem to leave a second ack byte after the reset.
  	 * This is kind of stupid, but we account for them anyway by just
  	 * flushing the buffer.
  	 */
! 	while (inb(KBSTATP) & KBS_DIB)
  		(void) inb(KBDATAP);
  	/* Just to be sure. */
  	if (!kbd_cmd(KBC_ENABLE, 1)) {
  		printf("pcprobe: reset error %d\n", 3);
--- 326,362 ----
  
  #if 1
  	/* Flush any garbage. */
! 	while (inb(KBSTATP) & KBS_DIB) {
! 		printf("pcprobe: flushing KB before reset\n");
  		(void) inb(KBDATAP);
+ 		delay(6); /*mwl*/
+ 	}
  	/* Reset the keyboard. */
  	if (!kbd_cmd(KBC_RESET, 1)) {
  		printf("pcprobe: reset error %d\n", 1);
  		goto lose;
  	}
! 	while ((inb(KBSTATP) & KBS_DIB) == 0)
! 		delay(6); /*mwl*/
! 	delay(6); /*mwl*/
! 	if ((inb(KBSTATP) & KBS_DIB) == 0)
! 		printf("pcprobe: status changed\n"); /* jch XXX */
! 	delay(6); /*mwl*/
  	if (inb(KBDATAP) != KBR_RSTDONE) {
  		printf("pcprobe: reset error %d\n", 2);
  		goto lose;
  	}
+ /*	printf("pcprobe: past reset check\n");*/ /* jch XXX */
+ #if 0
  	/*
  	 * Some keyboards seem to leave a second ack byte after the reset.
  	 * This is kind of stupid, but we account for them anyway by just
  	 * flushing the buffer.
  	 */
! 	while (inb(KBSTATP) & KBS_DIB) {
! 		printf("pcprobe: purging ack byte\n"); /* mwl */
  		(void) inb(KBDATAP);
+ 	}
  	/* Just to be sure. */
  	if (!kbd_cmd(KBC_ENABLE, 1)) {
  		printf("pcprobe: reset error %d\n", 3);
***************
*** 377,383 ****
  			goto lose;
  		}
  	}
! 
  lose:
  	/*
  	 * Technically, we should probably fail the probe.  But we'll be nice
--- 389,395 ----
  			goto lose;
  		}
  	}
! #endif
  lose:
  	/*
  	 * Technically, we should probably fail the probe.  But we'll be nice


-- 
Mike Long                                         Mike.Long@Analog.com
VLSI Design Engineer                              voice: (617)461-4030
Analog Devices, SPD Div.                            FAX: (617)461-3010
Norwood, MA 02062                            *this = !opinion(Analog);

------------------------------------------------------------------------------