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

virtual console update



make it compile with 1.11 file.h, and use writeb if you set M111 in Makefile,
then the binaries need a recent kernel...

Index: Makefile
@@ -9,6 +9,9 @@
 LFLAGS = -mshort
 LIBS = -liio16
 
+# MiNT 1.11 version
+#M111 = -DWRITEB111
+
 all: execgem execmtos runtt select0.TOS vconsd
 
 execgem: execgem.c
@@ -50,14 +53,17 @@
 paint.o: paint.c
 	$(CC) $(CFLAGS) -funroll-loops -c $< -o paint.o
 
+vtdev.o: vtdev.c
+	$(CC) $(CFLAGS) $(M111) -c $< -o vtdev.o
+
 vtdevx.o: vtdev.c
-	$(CC) $(CFLAGS) -DVT00XCON -c $< -o vtdevx.o
+	$(CC) $(CFLAGS) -DVT00XCON $(M111) -c $< -o vtdevx.o
 
 screen.o: screen.c
 	$(CC) $(CFLAGS) -DVMODE -c $< -o screen.o
 
 vtdevxd.o: vtdev.c
-	$(CC) $(CFLAGS) -DVT00XCON -DVMODE -c $< -o vtdevxd.o
+	$(CC) $(CFLAGS) -DVT00XCON -DVMODE $(M111) -c $< -o vtdevxd.o
 
 paintx.o: paint.c
 	$(CC) $(CFLAGS) -funroll-loops -DVT00XCON -c $< -o paintx.o
@@ -66,4 +72,4 @@
 	$(CC) $(CFLAGS) -DFORCE1PLANE -DVMODE -c $< -o screen1.o
 
 vtdevx1.o: vtdev.c paint.c
-	$(CC) $(CFLAGS) -DFORCE1PLANE -DVMODE -c $< -o vtdevx1.o
+	$(CC) $(CFLAGS) -DFORCE1PLANE -DVMODE $(M111) -c $< -o vtdevx1.o
Index: README
@@ -15,8 +15,8 @@
  show people that its not MiNT that is slow, only GEM :-)  also the
 screen writing code in vtdev.c + paint.c is mostly based on MiNTs
 fasttext device (including hardware scrolling for all terminals except
-console) so i guess output is faster than any GEM window writing could
-ever get.
+console even on vanilla ST), so i guess output is faster than any GEM
+window writing could ever get.
 
  how to use:
 
Index: daemon.c
@@ -21,6 +21,7 @@
 
 #include <osbind.h>
 #include <sysvars.h>
+#include <stddef.h>
 #undef flock
 #undef	_sysbase
 #define	_sysbase (* ((OSHEADER **) 0x4f2))
@@ -46,16 +47,16 @@
 struct kerinfo *kernel;
 
 struct dev_descr devinfo[] = {
-	{&vcon_device, 0, O_TTY, &ttys[0].tt, {0L, 0L, 0L, 0L}},  /* ttyv0 (console) */
-	{&vcon_device, 1, O_TTY, &ttys[1].tt, {0L, 0L, 0L, 0L}},  /* ttyv1 */
-	{&vcon_device, 2, O_TTY, &ttys[2].tt, {0L, 0L, 0L, 0L}},  /* ttyv2 */
-	{&vcon_device, 3, O_TTY, &ttys[3].tt, {0L, 0L, 0L, 0L}},  /* ttyv3 */
-	{&vcon_device, 4, O_TTY, &ttys[4].tt, {0L, 0L, 0L, 0L}},  /* ttyv4 */
-	{&vcon_device, 5, O_TTY, &ttys[5].tt, {0L, 0L, 0L, 0L}},  /* ttyv5 */
-	{&vcon_device, 6, O_TTY, &ttys[6].tt, {0L, 0L, 0L, 0L}},  /* ttyv6 */
-	{&vcon_device, 7, O_TTY, &ttys[7].tt, {0L, 0L, 0L, 0L}},  /* ttyv7 */
-	{&vcon_device, 8, O_TTY, &ttys[8].tt, {0L, 0L, 0L, 0L}},  /* ttyv8 */
-	{&vcon_device, 9, O_TTY, &ttys[9].tt, {0L, 0L, 0L, 0L}}   /* ttyv9 */
+	{&vcon_device, 0, O_TTY, &ttys[0].tt, 0L, {0L, 0L, 0L}},  /* ttyv0 (console) */
+	{&vcon_device, 1, O_TTY, &ttys[1].tt, 0L, {0L, 0L, 0L}},  /* ttyv1 */
+	{&vcon_device, 2, O_TTY, &ttys[2].tt, 0L, {0L, 0L, 0L}},  /* ttyv2 */
+	{&vcon_device, 3, O_TTY, &ttys[3].tt, 0L, {0L, 0L, 0L}},  /* ttyv3 */
+	{&vcon_device, 4, O_TTY, &ttys[4].tt, 0L, {0L, 0L, 0L}},  /* ttyv4 */
+	{&vcon_device, 5, O_TTY, &ttys[5].tt, 0L, {0L, 0L, 0L}},  /* ttyv5 */
+	{&vcon_device, 6, O_TTY, &ttys[6].tt, 0L, {0L, 0L, 0L}},  /* ttyv6 */
+	{&vcon_device, 7, O_TTY, &ttys[7].tt, 0L, {0L, 0L, 0L}},  /* ttyv7 */
+	{&vcon_device, 8, O_TTY, &ttys[8].tt, 0L, {0L, 0L, 0L}},  /* ttyv8 */
+	{&vcon_device, 9, O_TTY, &ttys[9].tt, 0L, {0L, 0L, 0L}}   /* ttyv9 */
 };
 
 #define MAX_VT ((sizeof devinfo)/sizeof (struct dev_descr))
@@ -258,7 +259,6 @@
 main()
 {
 	int i;
-	char *s;
 	volatile char *pkbshift = getpkbshift();
 	long cbuf[0x80], *bufp;
 	extern int __mint;
@@ -320,6 +320,8 @@
 		char name[] = "u:\\dev\\ttyv0";
 
 		name[sizeof "u:\\dev\\ttyv"-1] = i+'0';
+		if (vcon_device.writeb)
+			devinfo[i].drvsize = offsetof (DEVDRV, writeb) + sizeof (long);
 		kernel = (struct kerinfo *)Dcntl(DEV_INSTALL, name, devinfo+i);
 		if (!kernel || ((long)kernel) == -32) {
 			con_sane();
@@ -458,8 +460,10 @@
 		} else	if ((ttys[vcurrent].tt.state & TS_COOKED) ||
 			    (cshift & 0xc) == 0xc) {
 			char ch = (char) l;
-			int sig = 0;
+			int xfd = cfd, sig = 0;
+			char xname[] = "u:\\dev\\ttyv0";
 
+			xname[sizeof "u:\\dev\\ttyv"-1] = vcurrent+'0';
 			if (!ch)
 				;	/* do nothing */
 			else if (ch == ttys[vcurrent].tt.tc.t_intrc)
@@ -469,15 +473,30 @@
 			else if (ch == ttys[vcurrent].tt.ltc.t_suspc)
 				sig = SIGTSTP;
 			else if (ch == ttys[vcurrent].tt.tc.t_stopc) {
-				ttys[vcurrent].tt.state |= TS_HOLD;
+				if (!vcurrent ||
+				    (xfd = Fopen (xname, O_RDONLY)) >= 0) {
+					Fcntl (xfd, (char *) 0, TIOCSTOP);
+					if (vcurrent)
+						Fclose (xfd);
+				}
 				continue;
 			}
 			else if (ch == ttys[vcurrent].tt.tc.t_startc) {
-				ttys[vcurrent].tt.state &= ~TS_HOLD;
+				if (!vcurrent ||
+				    (xfd = Fopen (xname, O_RDONLY)) >= 0) {
+					Fcntl (xfd, (char *) 0, TIOCSTART);
+					if (vcurrent)
+						Fclose (xfd);
+				}
 				continue;
 			}
 			if (sig) {
-				ttys[vcurrent].tt.state &= ~TS_HOLD;
+				if (!vcurrent ||
+				    (xfd = Fopen (xname, O_RDONLY)) >= 0) {
+					Fcntl (xfd, (char *) 0, TIOCSTART);
+					if (vcurrent)
+						Fclose (xfd);
+				}
 				if (!(ttys[vcurrent].tt.sg.sg_flags & T_NOFLSH))
 					Fcntl (fd, (char *) 0, TIOCFLUSH);
 				else
Index: execgem.c
@@ -58,6 +58,12 @@
 #define F_PROT_I	0x40		/* invalid page */
 #endif
 
+#ifndef F_ALLOCZERO
+#define F_ALLOCZERO	0x2000		/* zero mem, for bugged (GEM...) programs */
+#endif
+
+long GEM_memflags = F_ALLOCZERO | F_ALTLOAD | F_ALTALLOC | F_PROT_G;
+
 int
 main(argc, argv)
 	int argc;
@@ -108,7 +114,7 @@
 			r = errno;
 		} else {
 			bp = (BASEPAGE *)Pexec(7,
-			  (char *)((long)F_FASTLOAD | F_ALTLOAD | F_ALTALLOC | F_PROT_S),
+			  (char *)GEM_memflags,
 			  (char *)"\0", init_env);
 			bp->p_tbase = *((char **) EXEC_OS );
 			r = -Pexec(206, (char *)"GEM", bp, 0L);
Index: vcon.h
@@ -1,7 +1,14 @@
 #ifdef __GNUC__
-#define EXITING volatile	/* function never returns */
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)
+#  define EXITING
+#  define NORETURN __attribute__ ((noreturn))
+# else
+#  define EXITING volatile	/* function never returns */
+#  define NORETURN
+# endif
 #else
-#define EXITING
+# define EXITING
+# define NORETURN
 #endif
 
 /* define how to call functions with stack parameter passing */
@@ -53,6 +60,17 @@
 #define TOSTOP T_TOSTOP
 #define XKEY T_XKEY
 #endif
+
+#ifndef READY_Q
+#define CURPROC_Q	0
+#define READY_Q		1
+#define WAIT_Q		2
+#define IO_Q		3
+#define ZOMBIE_Q	4
+#define TSR_Q		5
+#define STOP_Q		6
+#define SELECT_Q	7
+#endif
 
 extern struct kerinfo *kernel;
 
Index: vtdev.c
@@ -1135,9 +1135,16 @@
 
 static long ARGS_ON_STACK screen_datime	P_((FILEPTR *f, short *time, int rwflag));
 
+static long ARGS_ON_STACK screen_writeb P_((FILEPTR *f, const char *buf, long nbytes));
+
 DEVDRV vcon_device = {
 	screen_open, screen_write, screen_read, screen_lseek, screen_ioctl,
-	screen_datime, screen_close, screen_select, screen_unselect
+	screen_datime, screen_close, screen_select, screen_unselect,
+#ifdef WRITEB111
+	screen_writeb
+#else
+	0
+#endif
 };
 
 static long ARGS_ON_STACK 
@@ -1218,14 +1225,41 @@
 
 #define _hz_200 (*((long *)0x4baL))
 
+#ifdef WRITEB111
+#define CHECKSLEEP (tick != _hz_200 && !(tick & 3))
+
+static long ARGS_ON_STACK 
+screen_write(f, buf, bytes)
+	FILEPTR *f; const char *buf; long bytes;
+{
+	if (!bytes)
+		return bytes;
+	if (bytes != 4)
+		ALERT("ttyv%c write bytes != 4, use MiNT >= 1.11 or recompile without -DWRITEB111",
+			(char)f->fc.aux+'0');
+	screen_writeb(f, buf+3, 1);
+	return 4L;
+}
+
+static long ARGS_ON_STACK 
+screen_writeb(f, buf, bytes)
+	FILEPTR *f; const char *buf; long bytes;
+#else
+#define CHECKSLEEP 0
+
 static long ARGS_ON_STACK 
 screen_write(f, buf, bytes)
 	FILEPTR *f; const char *buf; long bytes;
+#endif
 {
 	int vt = f->fc.aux;
 	SCREEN *v;
-	long *r;
-	long ret = 0;
+#ifdef WRITEB111
+	unsigned char *r = (unsigned char *)buf;
+#else
+	long *r = (long *)buf;
+#endif
+	long ret = bytes;
 	int c;
 	long tick;
 	static long lastw;
@@ -1240,22 +1274,63 @@
 	   while we were writing (there are 50 of them in a second)
 	   and yield() when found one.  (comments?)
 	*/
+	v = TT_SCREEN((struct tty *)f->devinfo);
+	while (bytes > 0) {
+#ifdef WRITEB111
+		while (((struct tty *)f->devinfo)->state & TS_HOLD)
+			SLEEP(IO_Q, (long)&((struct tty *)f->devinfo)->state);
+#endif
 #if 0
-	(void)checkkeys();
+		(void)checkkeys();
 #else
-	tick = _hz_200;
+		tick = _hz_200;
 #endif
-	r = (long *)buf;
-	v = TT_SCREEN((struct tty *)f->devinfo);
 #ifdef VT00XCON
-	if (vt) {
+		if (vt) {
+			v->hidecnt++;
+			v->flags |= CURS_UPD;		/* for TOS 1.0 */
+			curs_off(v);
+			do {
+				c = (int) *r++;
+				put_ch0x(v, c);
+			} while ((bytes -= sizeof *r) > 0 && !CHECKSLEEP);
+			if (v->hidecnt > 0)
+				--v->hidecnt;
+			else
+				v->hidecnt = 0;
+			curs_on(v);
+			v->flags &= ~CURS_UPD;
+		} else {
+			if (xconout_start) {
+				do {
+					c = (int) *r++;
+					(void) xcon_exec (xconout[CONDEV], (unsigned char) c);
+				} while ((bytes -= sizeof *r) > 0 && !CHECKSLEEP);
+			} else {
+				do {
+					c = (int) *r++;
+					(void) bconout(CONDEV, (unsigned char) c);
+				} while ((bytes -= sizeof *r) > 0 && !CHECKSLEEP);
+			}
+		}
+#else
 		v->hidecnt++;
 		v->flags |= CURS_UPD;		/* for TOS 1.0 */
-		curs_off(v);
-		while (bytes > 0) {
-			c = (int) *r++;
-			put_ch0x(v, c);
-			bytes -= 4; ret+= 4;
+		if (vt) {
+			curs_off(v);
+			do {
+				c = (int) *r++;
+				put_ch0x(v, c);
+			} while ((bytes -= sizeof *r) > 0 && !CHECKSLEEP);
+		} else {
+			if (v->cheight != v0x->cheight ||
+			    V_USEDPLANES(v) != v0x->v.t.usedplanes)
+				vpaint = paint;
+			curs_off(v);
+			do {
+				c = (int) *r++;
+				put_ch00(v, c);
+			} while ((bytes -= sizeof *r) > 0 && !CHECKSLEEP);
 		}
 		if (v->hidecnt > 0)
 			--v->hidecnt;
@@ -1263,47 +1338,12 @@
 			v->hidecnt = 0;
 		curs_on(v);
 		v->flags &= ~CURS_UPD;
-	} else {
-		if (xconout_start) while (bytes > 0) {
-			c = (int) *r++;
-			(void) xcon_exec (xconout[CONDEV], (unsigned char) c);
-			bytes -= 4; ret+= 4;
-		} else while (bytes > 0) {
-			c = (int) *r++;
-			(void) bconout(CONDEV, (unsigned char) c);
-			bytes -= 4; ret+= 4;
-		}
-	}
-#else
-	v->hidecnt++;
-	v->flags |= CURS_UPD;		/* for TOS 1.0 */
-	if (vt) {
-		curs_off(v);
-		while (bytes > 0) {
-			c = (int) *r++;
-			put_ch0x(v, c);
-			bytes -= 4; ret+= 4;
-		}
-	} else {
-		if (v->cheight != v0x->cheight ||
-		    V_USEDPLANES(v) != v0x->v.t.usedplanes)
-			vpaint = paint;
-		curs_off(v);
-		while (bytes > 0) {
-			c = (int) *r++;
-			put_ch00(v, c);
-			bytes -= 4; ret+= 4;
-		}
-	}
-	if (v->hidecnt > 0)
-		--v->hidecnt;
-	else
-		v->hidecnt = 0;
-	curs_on(v);
-	v->flags &= ~CURS_UPD;
-	vpaint = vpaint0x;
+		vpaint = vpaint0x;
 #endif
-#if 1
+		if (bytes && !(((struct tty *)f->devinfo)->state & TS_HOLD))
+			yield();
+	}
+#ifndef WRITEB111
 	if (tick != _hz_200 && !(tick & 3))
 		yield();
 #endif

 have fun,
	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