[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

misc kernel patches... (mostly tty stuff)



hi!

 now that i'm on the list :) here are a few MiNT 1.07 patches for you
to try out, and for eric to look at when he's back from holiday...

1. blocking writes to a serial port can stop everything, and because of
that may also cause deadlocks like when you do IO with more than one
process (one reading, one writing...)  according to Changes this was
done for Speedo GDOS, so keep it that way for the printer port. :-(
(i already had a similar patch that tried to check for being called from
supervisor mode, that didn't seem to work. Eric?)

 it also turns off that hardcoded 10 second timeout on ttys, i think it
only causes trouble...  (think of a user hitting ^S on a terminal, or a
V32 modem doing a retrain...)

diff -uw ../bios.c ./bios.c
--- ./bios.c	Sat Jun 26 00:55:22 1993
+++ ./bios.c	Thu Jun 24 21:34:54 1993
@@ -253,8 +253,20 @@
 		statdev = dev;
 	}
 
+#if 1 /* blocking write()s to a tty shouldn't time out and also should
+	 not halt the whole system while they're waiting IMHO.	-nox
+	*/
+	if (dev != PRNDEV && !BCOSTAT(statdev)) {
+		do {
+			yield();
+		} while (!BCOSTAT(statdev));
+
+/* provide a 10 second time out only for the printer device */
+	} else if (!BCOSTAT(statdev)) {
+#else
 /* provide a 10 second time out */
 	if (!BCOSTAT(statdev)) {
+#endif
 		endtime = curtime + 10*200L;
 		do {
 #if 0

2. improved fasttext ESC Y patch, only strip bit 7 on args when the
screen is smaller :)

diff -uw ../fasttext.c ./fasttext.c
--- ./fasttext.c	Thu Jun 24 20:36:16 1993
+++ ./fasttext.c	Sat Jun 26 02:09:56 1993
@@ -1058,7 +1058,15 @@
 	SCREEN *v;
 	int c;
 {
+#if 0
 	gotoxy(v, c - ' ', escy1 - ' ');
+#else
+	/* some (un*x) termcaps seem to always set the hi bit on
+	   cm args (cm=\EY%+ %+ :) -> drop that unless the screen
+	   is bigger.	-nox
+	*/
+	gotoxy(v, (c - ' ') & (v->maxx|0x7f), (escy1 - ' ') & (v->maxy|0x7f));
+#endif
 	state = normal_putch;
 }
 
3. intresting one: reportedly some(?) 68000 CPUs have a bug that
causes interrupts sometimes to get lost when a rte instruction follows a
movem...  i don't have a logic analyzer here :-) but i seem to get less
unexplained protocol errors in uucps log file since i patched that here
and in my serial driver.  (of course there are still a few of this left
in TOS itself too...)

diff -uw ../intr.spp ./intr.spp
--- ./intr.spp	Sat Jun 26 01:08:18 1993
+++ ./intr.spp	Sat Jun 26 01:20:54 1993
@@ -272,6 +272,10 @@
 	move.l	_sig_routine,a1		; get handler
 	jsr	(a1)			; go do it
 	movem.l	(sp)+,d0-d2/a0-a2
+; 68000 processor bug: rte right after movem can eat interrupts...
+%ifndef ONLY030
+	nop
+%endif
 	rte
 
 ;

and...  4. finally get select, ioctl FIONREAD etc work with XKEY!  side
effect of this is that Cconin etc now have to return a second character
of an escape sequence etc too, i.e. whether you get a key code or the
full expanded sequence now only depends on how the _first_ character was
read. (anyway i would say this is more a feature than a bug...)

diff -ru ../console.c ./console.c
--- ../console.c	Tue May  4 17:42:38 1993
+++ ./console.c	Sun Jul 11 02:08:50 1993
@@ -7,6 +7,8 @@
 
 #include "mint.h"
 
+extern char vt52xkey[];
+
 /*
  * These routines are what Cconout, Cauxout, etc. ultimately call.
  * They take an integer argument which is the user's file handle,
@@ -28,6 +30,13 @@
 	r = 1;		/* default is to assume input waiting (e.g. TOS files)*/
 	(void)(*f->dev->ioctl)(f, FIONREAD, &r);
 
+	if (!r && is_terminal(f)) {
+		struct tty *tty = (struct tty *)f->devinfo;
+		int scan = tty->state & TS_ESC;
+
+		if (scan && (tty->xkey ? tty->xkey[scan] : vt52xkey[scan]))
+			r = 1;
+	}
 	return r;
 }
 
diff -ru ../dosfile.c ./dosfile.c
--- ../dosfile.c	Thu Jun 24 20:36:08 1993
+++ ./dosfile.c	Sun Jul 11 03:01:02 1993
@@ -9,6 +9,7 @@
 #include "mint.h"
 
 extern char temp1[];	/* see filesys.c */
+extern char vt52xkey[];
 
 static long do_dup P_((int,int));
 static void unselectme P_((PROC *));
@@ -925,6 +926,14 @@
 		r = (*f->dev->ioctl)(f, cmd, (void *)arg);
 		if (r == EINVFN && is_terminal(f)) {
 			r = tty_ioctl(f, cmd, (void *)arg);
+		} else if (cmd == FIONREAD && !r && !(*(long *)arg) &&
+				is_terminal(f)) {
+			struct tty *tty = (struct tty *)f->devinfo;
+			int scan = tty->state & TS_ESC;
+
+			if (scan && (tty->xkey ? tty->xkey[scan] :
+					vt52xkey[scan]))
+				*(long *)arg = 1;
 		}
 		return r;
 	}
@@ -1007,8 +1016,15 @@
 
 	for (i = 0; i < MAX_OPEN; i++) {
 		if (rfd & mask) {
+			struct tty *tty;
+			int scan;
+
 			f = p->handle[i];
-			if ((*f->dev->select)(f, (long)p, O_RDONLY)) {
+			if ((*f->dev->select)(f, (long)p, O_RDONLY) ||
+			    (is_terminal(f) &&
+				(scan = (tty=(struct tty *)f->devinfo)->state & TS_ESC) &&
+				(tty->xkey ? tty->xkey[scan] :
+					vt52xkey[scan]))) {
 				count++;
 				*rfdp |= mask;
 			}
diff -ru ../tty.c ./tty.c
--- ../tty.c	Thu Jun 24 20:37:28 1993
+++ ./tty.c	Sun Jul 11 01:49:02 1993
@@ -233,7 +233,7 @@
 
 /* for RAW mode, if there are no more characters then break */
 		if ( (mode & (T_RAW|T_CBREAK)) &&
-		    !((rdmode & ESCSEQ) && (tty->state & TS_ESC))) {
+		    !(tty->state & TS_ESC)) {
 			r = 1;
 			(void)(*f->dev->ioctl)(f, FIONREAD, &r);
 			if (r <= 0) break;
@@ -375,7 +375,7 @@
  *		28-31 are shift+cursor up, down, right, and left
  */
 
-static char vt52xkey[256] = {
+char vt52xkey[256] = {
 '\033', 'P', 0, 0, 0, 0, 0, 0,
 '\033', 'Q', 0, 0, 0, 0, 0, 0,
 '\033', 'R', 0, 0, 0, 0, 0, 0,
@@ -665,19 +665,15 @@
 /* we may be in the middle of an escape sequence */
 	scan = (tty->state & TS_ESC);
 	if (scan != 0) {
-		if (mode & ESCSEQ) {
-			tab = tty->xkey ? tty->xkey : vt52xkey;
-			r = (unsigned char) tab[scan++];
-			if (r) {
-				c = UNDEF;
-				if (tab[scan] == 0) scan = 0;
-			}
-			else
-				scan = 0;
-			tty->state = (tty->state & ~TS_ESC) | scan;
+		tab = tty->xkey ? tty->xkey : vt52xkey;
+		r = (unsigned char) tab[scan++];
+		if (r) {
+			c = UNDEF;
+			if (tab[scan] == 0) scan = 0;
 		}
 		else
-			tty->state &= ~TS_ESC;
+			scan = 0;
+		tty->state = (tty->state & ~TS_ESC) | scan;
 	}
 
 	while (c != UNDEF) {
 
 btw how are you guys do kernel debugging?  has someone hacked gdb for
that already?  i just found a version of templmon with symbol table
support, thats at least better than nothing... (filename was templ202.zip,
don't know if its on atari.archive already)

 and i still think that MiNT needs better ways to do fast RAW serial IO,
access modem control lines and speeds >19200, change Iorec buffer sizes,
etc.. but i'll repeat that only if you want it. :-)

 cheers
	Juergen
-- 
J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
								...ohne Gewehr
PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA 

When you block on a socket call in a Windows application, no activity can
proceed in any windows application, nor will you be able to change the
active Window.  No scheduling cann occur between Windows applications
                            Microsoft TCP/IP Sockets Developer's Kit