Subject: Re: NetBSD-1.3.2 and X-Server Configuration...
To: Feico Dillema <dillema@acm.org>
From: Brighten Godfrey <godfreyb@bigw.org>
List: port-pmax
Date: 11/11/1998 12:59:23
> I successfully installed NetBSD-1.3.2 on a DECstation-5000/240 and a
> DECSTATION-5000/33, and managed to get X running on the latter too.
> Then I installed the wmaker-0.6.3 binary package from netbsd.org
> and it basically runs, but I experience some strange things.
> I get `spontaneous' mouse-clicks now ... [snip] 

This is apparently a bug in the desktop bus driver for MAXINE (5000/xx),
which some of us had noticed recently.  My experience was that the
spontaneous clicks occurred when the system load was high, not in any
specific program.  Michael Hitch saved the day by sending me a patch of
dtop.c which corrects the problem.  Apply the patch to the source file and
rebuild the kernel, and you're done!  I'm appending the patch to this
message.  (If you don't want to rebuild the kernel, I could make my fixed,
generic 1.3.2 kernel available to you upon request.)

Hope this helps!

Brighten Godfrey
      ________________________________________________________________
            Brighten Godfrey                   godfreyb@bigw.org
                       http://www.bigw.org/~godfreyb/
      ________________________________________________________________

--- dtop.c.orig	Wed Sep 30 19:43:28 1998
+++ dtop.c	Wed Sep 30 19:50:38 1998
@@ -137,7 +137,7 @@
 #include <pmax/dev/dtopvar.h>
 
 
-#define	DTOP_MAX_POLL	0x7fff		/* about half a sec */
+#define	DTOP_MAX_POLL	0x70000		/* about half a sec */
 
 typedef volatile unsigned int	*data_reg_t;	/* uC  */
 #define	DTOP_GET_BYTE(data)	(((*(data)) >> 8) & 0xff)
@@ -588,6 +588,8 @@
 	register data_reg_t	data;
 	register int		max, i, len;
 	register unsigned char	c;
+	int state;
+	int escaped;
 
 	poll = dtop->poll;
 	data = dtop->data;
@@ -598,42 +600,50 @@
 	 * else but 0x50.  This is a good thing, it makes
 	 * the average packet exactly one word long, too.
 	 */
-	for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
-		DELAY(1);
-	if (max == DTOP_MAX_POLL)
-		goto bad;
-	pkt->src_address = DTOP_GET_BYTE(data);
-
-	for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
-		DELAY(1);
-	if (max == DTOP_MAX_POLL)
-		goto bad;
-	pkt->code.bits = DTOP_GET_BYTE(data);
-
-	/*
-	 * Now get data and checksum
-	 */
-	len = pkt->code.val.len + 1;
-	c = 0;
-	for (i = 0; i < len; i++) {
-again:
-		for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll); max++)
+	state = 0;		/* input packet state */
+	escaped = 0;		/* getting escaped code */
+	len = 0;		/* packet data length */
+	i = 0;			/* packet data index */
+	while (1) {
+		for (max = 0; (max < DTOP_MAX_POLL) && !DTOP_RX_AVAIL(poll);
+		    max++)
 			DELAY(1);
-		if (max == DTOP_MAX_POLL)
-			goto bad;
-		if (c == DTOP_ESC_CHAR) {
-			c = dtop_escape(DTOP_GET_BYTE(data) & 0xff);
+		if (max == DTOP_MAX_POLL) {
+			++dtop->bad_pkts;
+			return (-1);
+		}
+		c = DTOP_GET_BYTE(data);
+		if (escaped) {
+			c = dtop_escape(c);
+			if (c == 'O') {
+				++dtop->bad_pkts;
+				return (-1);
+			}
+			escaped = 0;
 		} else {
 			c = DTOP_GET_BYTE(data);
-			if (c == DTOP_ESC_CHAR)
-				goto again;
+			if (c == DTOP_ESC_CHAR) {
+				escaped = 1;
+				continue;
+			}
+		}
+		if (state == 0) {
+			pkt->src_address = c;
+			state = 1;
+			continue;
+		}
+		if (state == 1) {
+			pkt->code.bits = c;
+			state = 2;
+			len = pkt->code.val.len + 1;
+			continue;
 		}
 		pkt->body[i] = c;
+		++i;
+		if (i >= len)
+			break;
 	}
 	return (len);
-bad:
-	dtop->bad_pkts++;
-	return (-1);
 }