Subject: Re: Abnormal mouse behavior on MAXINE again
To: Reinhold Huber <Reinhold_Huber@Physik.TU-Muenchen.DE>
From: Brighten Godfrey <godfreyb@bigw.org>
List: port-pmax
Date: 10/28/1998 15:15:13
Hi,

Michael Hitch emailed me his patch for dtop.c when we were last discussing
the mouse problems on MAXINE. I had planned to play around with them right
away, but being a college freshman here at Carnegie Mellon, my time is
limited. ;-)  I did rebuild the kernel with the patch and it compiled
fine, but it wouldn't boot off the new kernel (it said "bad magic" at the
PROM).  I haven't really had time since then to play around with it, so my
lack of immediate success does not mean that the solution doesn't work. 

I'm appending the message that Michael Hitch sent me to this note. Hope
this helps, and if anyone does get it working, please let me know! :-)
I probably won't have time to play with it until winter break. Thanks!

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


>From mhitch@lightning.oscs.montana.edu Thu Oct  1 16:32:11 1998
Date: Wed, 30 Sep 1998 20:00:23 -0600
From: "Michael L. Hitch" <mhitch@lightning.oscs.montana.edu>
To: Brighten Godfrey <godfreyb@Claudius.RES.CMU.EDU>
Subject: Re: Abnormal mouse behaviour on Personal DS

On Sep 30,  9:13pm, Brighten Godfrey wrote:
> Michael,
> 
> Thanks for your note. Given that it occurred on multiple systems, my
> friend and I had thought that it was a driver problem. If you are able to
> dig up your fix, we'd be very interested in trying it out!

  I'm not able to check if these changes even compile, but I think it's
what I was using before I started trying to use DMA for the desktop bus.
It would still lose packets, but it at least would not present corrupt
data to the dtop locator handler.

Michael


--- 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);
 }
 
 /*

-- 
Michael L. Hitch			mhitch@montana.edu
Computer Consultant
Information Technology Center
Montana State University	Bozeman, MT	USA