[comp.os.minix] Yet another TTY driver, part 1 of 3

evans@ditsyda.oz (Bruce Evans) (01/02/89)

Here are the diffs and new files for my improved TTY driver. My original
intention was just to make RS232 work faster. This involved replacing
rs232.c (I've had a better one for 6 months) and changing the interface
to tty.c. The higher speeds and serependitiously introduced bugs exposed
many other bugs in tty.c, and it ended up with massive changes. Console.c
has minor but bulky changes. The resulting kernel is 2K smaller.

RS232 input works at 2400 baud on a standard 5MHz PC. Input throughput
using cat is 236 chars/sec. Zmodem achieved 235 chars/sec. The system
overhead for input is about 40% at this speed.

I explained in a previous posting how by changing the task switching,
input can be handled 4 times as fast. These changes are not included,
but nothing directly related to RS232 is left out.

Please mail me a report if you try to install it and notice anything
particularly good or bad. I am also interested in what happens for equipment
I don't have to test - AT's and above and modems faster than 2400 baud. I
tested it in both directions for a PC locally connected to a 386 and have
downloaded many megabytes of news to the 386 at 2400 baud.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 3)."
# Contents:  MANIFEST README clock.c.cdif clock.c.notes console.c.note
#   const.h.cdif fs:device.c.cd fs:pipe.c.cdif main.c.cdif
#   main.c.notes makefile.cdif mpx88.s.cdif mpx88.s.notes rs2.s
#   rs2.s.notes rs232.c.notes tty.c.notes tty.crc tty.h.cdif
#   tty.h.notes tty.todo
# Wrapped by sys@besplex on Mon Jan  2 04:34:19 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(858 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X README                     1	
X clock.c.cdif               1	
X clock.c.notes              1	
X console.c.cdif             2	
X console.c.note             1	
X const.h.cdif               1	
X fs:device.c.cd             1	
X fs:pipe.c.cdif             1	
X main.c.cdif                1	
X main.c.notes               1	
X makefile.cdif              1	
X mpx88.s.cdif               1	
X mpx88.s.notes              1	
X rs2.s                      1	
X rs2.s.notes                1	
X rs232.c                    2	
X rs232.c.notes              1	
X tty.c                      3	
X tty.c.notes                1	
X tty.crc                    1	
X tty.h.cdif                 1	
X tty.h.notes                1	
X tty.todo                   1	
END_OF_FILE
if test 858 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2430 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XHere are the diffs and new files for my improved TTY driver. My original
Xintention was just to make RS232 work faster. This involved replacing
Xrs232.c (I've had a better one for 6 months) and changing the interface
Xto tty.c. The higher speeds and serependitiously introduced bugs exposed
Xmany other bugs in tty.c, and it ended up with massive changes. Console.c
Xhas minor but bulky changes. The resulting kernel is 2K smaller.
X
XRS232 input works at 2400 baud on a standard 5MHz PC. Input throughput
Xusing cat is 236 chars/sec. Zmodem achieved 235 chars/sec. The system
Xoverhead for input is about 40% at this speed.
X
XI explained in a previous posting how by changing the task switching,
Xinput can be handled 4 times as fast. These changes are not included,
Xbut nothing directly related to RS232 is left out.
X
XFor machines faster than a PC, and perhaps even a PC used at the limit of
X2400 baud, the WAKEUP_TIMEOUT in tty.c should be reduced from 3 to 1 or 2.
XI chose 3 for the best compromise at 9600 baud. 4, or 5 with a slightly
Xlarger EVENT_THRESHOLD, give a few percent better performance, but input
Xat 2400 is noticeably jerky on a fast machine.
X
XRTS/CTS Hardware handshaking is implemented, but not ioctls to control it.
XTTY drops RTS when its input buffer is nearly full, and refuses to send
Xunless CTS is high. DTR is asserted always. Most devices can handle this,
Xprovided the cable is right. For two PC's, connect CTS on one with RTS on
Xthe other. To make TTY ignore CTS, #define NO_HANDSHAKE (I haven't checked
Xthis setup).
X
XThe methods used in rs232.c and tty_wakeup() could be used to improve
Xprinter.c. Everything is simpler, except a large buffer in the printer may
Xcause too many interrupts close together. Handling this would require
Xdisabling the printer interrupt and filling the buffer from the high-level
Xtask.
X
XThe diffs are relative to 1.3c. I tested the changes by patching 1.3c on a
Xnon-clone PC, but with a hard disk. Space in /tmp may be a problem without
Xthe hard disk.
X
XThe patch to fs/pipe.c has been posted before. It is important to the
Xcorrect operation of do_cancel().
X
XThe patch to fs/device.c allows pre-1.3 programs compiled with the old
Xioctl.c (e.g. the elle binary) to avoid inadvertently changing the baud
Xrate.
X
XMost of the sources files have a ".notes" file for documentation. See
Xtty.c.notes in particular, where many bugs in tty.c are reported. Hannam's
Xdriver fixed some of these too.
END_OF_FILE
if test 2430 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'clock.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'clock.c.cdif'\"
else
echo shar: Extracting \"'clock.c.cdif'\" \(984 characters\)
sed "s/^X//" >'clock.c.cdif' <<'END_OF_FILE'
X*** orig/clock.c	Thu Oct 20 13:14:50 1988
X--- clock.c	Wed Dec 28 08:10:21 1988
X***************
X*** 41,43 ****
X  #define SCHED_RATE (MILLISEC*HZ/1000)	/* number of ticks per schedule */
X- #define FLUSH_MASK        07	/* bit mask used for flushing RS232 input */
X  
X--- 41,42 ----
X***************
X*** 56,58 ****
X  PRIVATE int (*watch_dog[NR_TASKS+1])();	/* watch_dog functions to call */
X- extern int flush_flag;		/* tells clock when to flush the tty buf */
X  
X--- 55,56 ----
X***************
X*** 158,159 ****
X--- 156,158 ----
X    extern int pr_busy, pcount, cum_count, prev_ct;
X+   int old_state;
X  
X***************
X*** 194,200 ****
X  
X!   /* If input characters are accumulating on an RS232 line, process them. */
X!   if (flush_flag) {
X! 	t = (int) realtime;		/* only low-order bits matter */
X! 	if ( (t & FLUSH_MASK) == 0) rs_flush();	/* flush tty input */
X!   }
X  
X--- 193,197 ----
X  
X!   old_state = lock();
X!   tty_wakeup();			/* possibly wake up TTY */
X!   restore(old_state);
X  
END_OF_FILE
if test 984 -ne `wc -c <'clock.c.cdif'`; then
    echo shar: \"'clock.c.cdif'\" unpacked with wrong size!
fi
# end of 'clock.c.cdif'
fi
if test -f 'clock.c.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'clock.c.notes'\"
else
echo shar: Extracting \"'clock.c.notes'\" \(284 characters\)
sed "s/^X//" >'clock.c.notes' <<'END_OF_FILE'
XFLUSH_MASK and flush_flag are removed. tty_wakeup() is called (every tick)
Xto decide if TTY has anything worth doing. Since tty_wakeup is designed to
Xbe called from my low-level clock interrupt handler, it must be protected
Xby a lock here.
X
XThe printer should use the same mechanism.
END_OF_FILE
if test 284 -ne `wc -c <'clock.c.notes'`; then
    echo shar: \"'clock.c.notes'\" unpacked with wrong size!
fi
# end of 'clock.c.notes'
fi
if test -f 'console.c.note' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'console.c.note'\"
else
echo shar: Extracting \"'console.c.note'\" \(1800 characters\)
sed "s/^X//" >'console.c.note' <<'END_OF_FILE'
XLINE_CMP was already obsolete
X
XCURSOR_SHAPE was hard-code as 31 instead of 15, and 31 doesn't always work
Xfor VGA's.
X
Xkeybd_mess is no longer needed.
X
Xkb_addr() is the (kludged) mapping line number --> kb structure. The kb
Xstructure provides fast buffering for the keyboard.
X
XKB_IBUFSIZE replaces MAX_OVERRUN.
X
Xkeyboard() is rewritten for speed. It used to give too much latency. The
Xmain improvement is not to send an interrupt immediately. There is no
Xpoint in checking for CTRL-ALT-DEL at the low level, since CTRL and ALT
Xare set at the task level. The same might be said about CTRL-S. The 8259
Xwas reeanbled in a cumbersome way, with too many exit points. This is
Xnow done in mpx88.s. The port i/o is still slow. It could be done in
Xklib88.s as already for PS's.
X
XThe keyboard buffer handling is now simpler and faster, and has the same
Xinterface as RS232 input. kb_read() is a clone of rs_read().
X
XConsole() is rewritten to avoid using get_byte(). get_byte() is non-portable
X(failed above 1M on a 386) and much slower than phys_copy() on all but
Xsmall blocks. A suspension bug in console() is commented here and fixed in
Xtty.c. Console output CAN be suspended in the middle. The old tty.c left
XFS hanging when no reply was sent.
X
Xtp->tty_attribute is replaced globally by one_con_attribute. This got a
Xbit out of hand. The attribute belongs to console.c, not tty.c, and
Xinitialization was a minor problem. The attribute really depends on the
Xconsole number, like many other variables.
X
Xtty_init() is renamed con_init() and everywhere it referenced the tty
Xstructure is moved to a real tty_init in tty.c. The LEDs are set at the
Xend since the BIOS state could be random. The keyboard interrupt
Xis enabled here instead of unsafely in main().
X
XNote console numbers are negative but never indexed.
END_OF_FILE
if test 1800 -ne `wc -c <'console.c.note'`; then
    echo shar: \"'console.c.note'\" unpacked with wrong size!
fi
# end of 'console.c.note'
fi
if test -f 'const.h.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'const.h.cdif'\"
else
echo shar: Extracting \"'const.h.cdif'\" \(435 characters\)
sed "s/^X//" >'const.h.cdif' <<'END_OF_FILE'
X*** orig/const.h	Thu Oct  6 21:07:12 1988
X--- const.h	Thu Dec 29 08:54:31 1988
X***************
X*** 34,35 ****
X--- 34,42 ----
X  
X+ /* Hardware interrupt numbers. These are fundamental, the vectors are
X+  * derived by adding a (8259-programmable) base.
X+  */
X+ #define KEYBOARD_IRQ       1
X+ #define SECONDARY_IRQ      3
X+ #define RS232_IRQ          4
X+ 
X  /* The 8259A interrupt controller has to be re-enabled after each interrupt. */
END_OF_FILE
if test 435 -ne `wc -c <'const.h.cdif'`; then
    echo shar: \"'const.h.cdif'\" unpacked with wrong size!
fi
# end of 'const.h.cdif'
fi
if test -f 'fs:device.c.cd' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fs:device.c.cd'\"
else
echo shar: Extracting \"'fs:device.c.cd'\" \(299 characters\)
sed "s/^X//" >'fs:device.c.cd' <<'END_OF_FILE'
X*** /user/sys/fs/device.c	Wed Aug  3 21:05:11 1988
X--- device.c	Sun Dec 18 04:34:36 1988
X***************
X*** 125,126 ****
X--- 125,127 ----
X    m1.TTY_FLAGS = dev_mess.TTY_FLAGS;	/* flags */
X+   m1.TTY_SPEED = dev_mess.TTY_FLAGS >> 16;	/* kludge for V1.2 TIOCGETP */
X    return(dev_mess.REP_STATUS);
END_OF_FILE
if test 299 -ne `wc -c <'fs:device.c.cd'`; then
    echo shar: \"'fs:device.c.cd'\" unpacked with wrong size!
fi
# end of 'fs:device.c.cd'
fi
if test -f 'fs:pipe.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fs:pipe.c.cdif'\"
else
echo shar: Extracting \"'fs:pipe.c.cdif'\" \(736 characters\)
sed "s/^X//" >'fs:pipe.c.cdif' <<'END_OF_FILE'
X*** /user/sys/fs/pipe.c	Wed Aug  3 21:05:15 1988
X--- pipe.c	Wed Oct 26 21:08:12 1988
X***************
X*** 23,24 ****
X--- 23,25 ----
X  #include "type.h"
X+ #include "dev.h"
X  #include "file.h"
X***************
X*** 247,251 ****
X  	mess.PROC_NR = proc_nr;
X! 	mess.COUNT = f->filp_mode;	/* tell kernel whether R or W */
X  	mess.m_type = CANCEL;
X! 	rw_dev(task, &mess);
X  	revive(proc_nr, EINTR);	/* signal interrupted call */
X--- 248,253 ----
X  	mess.PROC_NR = proc_nr;
X! 	/* Tell kernel whether R or W. Mode is from current call, not open. */
X! 	mess.COUNT = (rfp->fp_fd & BYTE) == READ ? R_BIT : W_BIT;
X  	mess.m_type = CANCEL;
X! 	(*dmap[(dev >> MAJOR) & BYTE].dmap_rw)(task, &mess);
X  	revive(proc_nr, EINTR);	/* signal interrupted call */
END_OF_FILE
if test 736 -ne `wc -c <'fs:pipe.c.cdif'`; then
    echo shar: \"'fs:pipe.c.cdif'\" unpacked with wrong size!
fi
# end of 'fs:pipe.c.cdif'
fi
if test -f 'main.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'main.c.cdif'\"
else
echo shar: Extracting \"'main.c.cdif'\" \(1638 characters\)
sed "s/^X//" >'main.c.cdif' <<'END_OF_FILE'
X*** orig/main.c	Thu Oct  6 21:07:39 1988
X--- main.c	Wed Dec 28 04:13:07 1988
X***************
X*** 32,36 ****
X  #define EM_VEC          0x15	/* vector for extended memory BIOS calls */
X! #define CMASK1          0x00	/* interrupt mask: ptr, dsk, keybd, clk, PIC */
X  #define CMASK2          0xBF	/* interrupt mask for secondary PIC */
X! #define CMASK3          0x3C	/* interrupt mask for PS/2 */
X  #define CMASK4          0x9E	/* Planar Control Register */
X--- 32,36 ----
X  #define EM_VEC          0x15	/* vector for extended memory BIOS calls */
X! #define CMASK1          0x1A	/* interrupt mask: not ptr, dsk, clk, PIC */
X  #define CMASK2          0xBF	/* interrupt mask for secondary PIC */
X! #define CMASK3          0x3E	/* interrupt mask for PS/2 */
X  #define CMASK4          0x9E	/* Planar Control Register */
X***************
X*** 186,188 ****
X  
X!   /* Mask out interupts except ptr, disk, clock, keyboard, PIC */
X    if (ps) {
X--- 186,188 ----
X  
X!   /* Mask out interupts except printer, disk, clock, PIC */
X    if (ps) {
X***************
X*** 260,261 ****
X--- 260,274 ----
X  #ifdef i8088
X+ /*==========================================================================*
X+  *				enable_irq				    *
X+  *==========================================================================*/
X+ PUBLIC void enable_irq(irq_nr)
X+ unsigned irq_nr;
X+ {
X+   /* Clear the corresponding 8259 register bit */
X+   if (irq_nr < 8)
X+ 	port_out(INT_CTLMASK, inportb(INT_CTLMASK) & ~(1 << irq_nr));
X+   else 
X+ 	port_out(INT2_MASK, inportb(INT2_MASK) & ~(1 << (irq_nr - 8)));
X+ }
X+ 
X  /*===========================================================================*
END_OF_FILE
if test 1638 -ne `wc -c <'main.c.cdif'`; then
    echo shar: \"'main.c.cdif'\" unpacked with wrong size!
fi
# end of 'main.c.cdif'
fi
if test -f 'main.c.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'main.c.notes'\"
else
echo shar: Extracting \"'main.c.notes'\" \(573 characters\)
sed "s/^X//" >'main.c.notes' <<'END_OF_FILE'
XIt is very important that the interrupts NOT be enabled before the device
Xinitialization routines are called. 1.3 was lucky to get away with this.
XAll the new routines have null pointers and worse before being initialized.
X
XSetting bits in the CMASKs task care of this. Later, the drivers call
Xenable_irq() when they are ready. The non-TTY drivers should do the same.
XThen the magic CMASKs would not be needed.
X
XThis probably works for PS's but the CMASK was already partly set.
X
XThe comment is still not quite right, there are 5 interrupts unmasked and
Xonly 4 documented.
END_OF_FILE
if test 573 -ne `wc -c <'main.c.notes'`; then
    echo shar: \"'main.c.notes'\" unpacked with wrong size!
fi
# end of 'main.c.notes'
fi
if test -f 'makefile.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile.cdif'\"
else
echo shar: Extracting \"'makefile.cdif'\" \(1070 characters\)
sed "s/^X//" >'makefile.cdif' <<'END_OF_FILE'
X*** at_makefile	Thu Oct 20 13:14:49 1988
X--- makefile	Sat Dec 31 02:12:59 1988
X***************
X*** 18,20 ****
X  obj =	mpx88.s main.s tty.s floppy.s wini.s system.s proc.s clock.s memory.s \
X! 	console.s rs232.s printer.s table.s klib88.s dmp.s
X  
X--- 18,20 ----
X  obj =	mpx88.s main.s tty.s floppy.s wini.s system.s proc.s clock.s memory.s \
X! 	console.s rs232.s printer.s table.s klib88.s dmp.s inportb.s rs2.s
X  
X***************
X*** 24,29 ****
X  kernel:	makefile $(obj) $l/libc.a
X! 	@echo "Start linking Kernel."
X! 	@asld -o kernel -T. $(obj) $l/libc.a $l/end.s
X! 	@echo "Kernel done.  "
X! 
X  clean:
X--- 24,26 ----
X  kernel:	makefile $(obj) $l/libc.a
X! 	asld -s -i -o kernel -T. $(obj) $l/libc.a $l/end.s > kernel.sym
X  clean:
X***************
X*** 92,101 ****
X  
X! rs232.s:	const.h type.h $h/const.h $h/type.h
X! rs232.s:	$h/callnr.h
X! rs232.s:	$h/com.h
X! rs232.s:	$h/error.h
X  rs232.s:	$h/sgtty.h
X- rs232.s:	$h/signal.h
X- rs232.s:	glo.h
X- rs232.s:	proc.h
X  rs232.s:	tty.h
X--- 89,92 ----
X  
X! rs232.s:	const.h $h/const.h $h/type.h
X  rs232.s:	$h/sgtty.h
X  rs232.s:	tty.h
END_OF_FILE
if test 1070 -ne `wc -c <'makefile.cdif'`; then
    echo shar: \"'makefile.cdif'\" unpacked with wrong size!
fi
# end of 'makefile.cdif'
fi
if test -f 'mpx88.s.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mpx88.s.cdif'\"
else
echo shar: Extracting \"'mpx88.s.cdif'\" \(2741 characters\)
sed "s/^X//" >'mpx88.s.cdif' <<'END_OF_FILE'
X*** orig/mpx88.s	Thu Oct  6 21:20:22 1988
X--- mpx88.s	Thu Dec 29 04:41:06 1988
X***************
X*** 34,36 ****
X  .globl _tty_int, _rs232_int, _lpr_int, _clock_int, _disk_int, _wini_int
X! .globl _eth_int, _s_call, _trp, _restart, _secondary_int
X  .globl _int00, _int01, _int02, _int03, _int04, _int05, _int06, _int07
X--- 34,36 ----
X  .globl _tty_int, _rs232_int, _lpr_int, _clock_int, _disk_int, _wini_int
X! .globl _eth_int, _s_call, _trp, save, _restart, _secondary_int
X  .globl _int00, _int01, _int02, _int03, _int04, _int05, _int06, _int07
X***************
X*** 40,42 ****
X  .globl _main, _sys_call, _interrupt, _keyboard, _panic, _unexpected_int, _trap
X! .globl _pr_char, _rs232
X  
X--- 40,42 ----
X  .globl _main, _sys_call, _interrupt, _keyboard, _panic, _unexpected_int, _trap
X! .globl _pr_char
X  
X***************
X*** 58,59 ****
X--- 58,65 ----
X  
X+ | The following is PC hardware-specific
X+ EOI		=	0x20	| magic to reenable 8259 int controller
X+ 
X+ | The following are PC hardware-specific and also defined in C
X+ INT_CTL		=	0x20	| PC int controller
X+ 
X  .text
X***************
X*** 100,101 ****
X--- 106,109 ----
X  	call _keyboard		| process a keyboard interrupt
X+ 	movb al,#EOI		| reenable int controller - was cumbersome C
X+ 	out INT_CTL		| better done for all in save()
X  	jmp _restart		| continue execution
X***************
X*** 106,112 ****
X  |*============================================================================
X! _rs232_int:			| Interrupt routine for rs232 I/O.
X  	call save		| save the machine state
X! 	mov ax,#1		| which unit caused the interrupt
X! 	push ax			| pass it as a parameter
X! 	call _rs232		| process a rs232 interrupt
X  	jmp _restart		| continue execution
X--- 114,120 ----
X  |*============================================================================
X! |_rs232_int:			| Interrupt routine for rs232 I/O.
X  	call save		| save the machine state
X! |	call _rs232_1handler	| process a rs232 interrupt
X! 	movb al,#EOI		| reenable int controller
X! 	out INT_CTL
X  	jmp _restart		| continue execution
X***************
X*** 117,123 ****
X  |*============================================================================
X! _secondary_int:			| Interrupt routine for rs232 port 2
X  	call save		| save the machine state
X! 	mov ax,#2		| which unit caused the interrupt
X! 	push ax			| pass it as a parameter
X! 	call _rs232		| process a rs232 interrupt
X  	jmp _restart		| continue execution
X--- 125,131 ----
X  |*============================================================================
X! |_secondary_int:			| Interrupt routine for rs232 port 2
X  	call save		| save the machine state
X! |	call _rs232_2handler	| process a rs232 interrupt
X! 	movb al,#EOI		| reenable int controller
X! 	out INT_CTL
X  	jmp _restart		| continue execution
END_OF_FILE
if test 2741 -ne `wc -c <'mpx88.s.cdif'`; then
    echo shar: \"'mpx88.s.cdif'\" unpacked with wrong size!
fi
# end of 'mpx88.s.cdif'
fi
if test -f 'mpx88.s.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mpx88.s.notes'\"
else
echo shar: Extracting \"'mpx88.s.notes'\" \(255 characters\)
sed "s/^X//" >'mpx88.s.notes' <<'END_OF_FILE'
XThe keyboard interrupt is reenabled better.
X
Xrs232_int and secondary_int are commented out so the ones in rs2.s can
Xbe used. To use the C interrupt handlers, delete the comment character
Xon each and also on the calls to rs232_1handler and rs232_2handler.
END_OF_FILE
if test 255 -ne `wc -c <'mpx88.s.notes'`; then
    echo shar: \"'mpx88.s.notes'\" unpacked with wrong size!
fi
# end of 'mpx88.s.notes'
fi
if test -f 'rs2.s' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rs2.s'\"
else
echo shar: Extracting \"'rs2.s'\" \(4678 characters\)
sed "s/^X//" >'rs2.s' <<'END_OF_FILE'
XKERNEL_DSEG		=	4
X
XENABLE			=	0x20
XFALSE			=	0
XINT_CTL			=	0x20
X
XEVENT_THRESHOLD		=	64
XRS_IBUFSIZE		=	128
XRS_IHIGHWATER		=	3 * RS_IBUFSIZE / 4
X
XIS_LINE_STATUS_CHANGE	=	6
XIS_MODEM_STATUS_CHANGE	=	0
XIS_NO_INTERRUPT		=	1
XIS_RECEIVER_READY	=	4
XIS_TRANSMITTER_READY	=	2
XLS_OVERRUN_ERR		=	2
XLS_PARITY_ERR		=	4
XLS_FRAMING_ERR		=	8
XLS_BREAK_INTERRUPT	=	0x10
XLS_TRANSMITTER_READY	=	0x20
XMC_DTR			=	1
XMC_OUT2			=	8
XMS_CTS			=	0x10
X
XODEVREADY		=	MS_CTS
XNOT_ODEVREADY		=	0xE0	| do complements by hand for asld
XODONE			=	1
XOQUEUED			=	0x20
XORAW			=	2
XOSWREADY		=	0x40
XNOT_OSWREADY		=	0xBF
XOWAKEUP			=	4
XNOT_OWAKEUP		=	0xFB
X
XXMIT_OFFSET		=	0
XRECV_OFFSET		=	0
XINT_ID_OFFSET		=	2
XMODEM_CTL_OFFSET	=	4
XLINE_STATUS_OFFSET	=	5
XMODEM_STATUS_OFFSET	=	6
X
XMINOR			=	0
XIDEVREADY		=	MINOR + 2
XITTYREADY		=	IDEVREADY + 1
XIBUF			=	ITTYREADY + 1	| (ITTYREADY + 2) & 0xFFFE
XIBUFEND			=	IBUF + 2
XIHIGHWATER		=	IBUFEND + 2
XIPTR			=	IHIGHWATER + 2
XOSTATE			=	IPTR + 2
XOXOFF			=	OSTATE + 1
XOBUFEND			=	OXOFF + 1	| (OXOFF + 2) & 0xFFFE
XOPTR			=	OBUFEND + 2
XXMIT_PORT		=	OPTR + 2
XRECV_PORT		=	XMIT_PORT + 2
XDIV_LOW_PORT		=	RECV_PORT + 2
XDIV_HI_PORT		=	DIV_LOW_PORT + 2
XINT_ENAB_PORT		=	DIV_HI_PORT + 2
XINT_ID_PORT		=	INT_ENAB_PORT + 2
XLINE_CTL_PORT		=	INT_ID_PORT + 2
XU8_MODEM_CTL_PORT	=	LINE_CTL_PORT + 2
XU8_LINE_STATUS_PORT	=	U8_MODEM_CTL_PORT + 2
XUU8_MODEM_STATUS_PORT	=	U8_LINE_STATUS_PORT + 2
XLSTATUS			=	UU8_MODEM_STATUS_PORT + 2
XFRAMING_ERRORS		=	LSTATUS + 2	| (LINE_STATUS + 2) & 0xFFFE
XOVERRUN_ERRORS		=	FRAMING_ERRORS + 2
XPARITY_ERRORS		=	OVERRUN_ERRORS + 2
XBREAK_INTERRUPTS	=	PARITY_ERRORS + 2
XIBUF1			=	BREAK_INTERRUPTS + 2
XIBUF2			=	IBUF1 + RS_IBUFSIZE + 1
XSIZEOF_STRUCT_RS232_S	=	IBUF2 + RS_IBUFSIZE + 1
X
X	.text
X	.define	_rs232_int
X	.define	_secondary_int
X	.extern	_restart
X	.extern	save
X	.extern	_tty_wakeup
X
X	.bss
X	.extern	_rs_lines
X	.extern	_tty_events
X
X| PUBLIC void interrupt _secondary_int();
X
X	.text
X	.even
X_secondary_int:
X	push	ds
X	push	si
X	mov	si,#_rs_lines + SIZEOF_STRUCT_RS232_S
X	j	common
X
X| input interrupt
X
X	.even
Xinint:
X	addb	dl,#RECV_OFFSET - INT_ID_OFFSET
X	in
X	mov	bx,IPTR(si)
X	movb	(bx),al
X	cmp	bx,IBUFEND(si)
X	jge	checkxoff
X	inc	_tty_events
X	inc	bx
X	mov	IPTR(si),bx
X	cmp	bx,IHIGHWATER(si)
X	jne	checkxoff
X	addb	dl,#MODEM_CTL_OFFSET - RECV_OFFSET
X	movb	al,#MC_OUT2 + MC_DTR
X	out
X	movb	IDEVREADY(si),#FALSE
Xcheckxoff:
X	testb	ah,#ORAW
X	jne	rsnext
X	cmpb	al,OXOFF(si)
X	je	gotxoff
X	testb	ah,#OSWREADY
X	jne	rsnext
X	orb	ah,#OSWREADY
X	mov	dx,U8_LINE_STATUS_PORT(si)
X	in
X	testb	al,#LS_TRANSMITTER_READY
X	je	rsnext
X	addb	dl,#XMIT_OFFSET - LINE_STATUS_OFFSET
X	j	outint1
X
X	.even
Xgotxoff:
X	andb	ah,#NOT_OSWREADY
X	j	rsnext
X
X| PUBLIC void interrupt rs232_int();
X
X	.even
X_rs232_int:
X	push	ds
X	push	si
X	mov	si,#_rs_lines
Xcommon:
X	seg	cs
X	mov	ds,KERNEL_DSEG
X	push	ax
X	push	bx
X	push	dx
X	movb	ah,OSTATE(si)
X	mov	dx,INT_ID_PORT(si)
X	in
Xrsmore:
X	cmpb	al,#IS_RECEIVER_READY
X	je	inint
X	cmpb	al,#IS_TRANSMITTER_READY
X	je	outint
X	cmpb	al,#IS_MODEM_STATUS_CHANGE
X	je	modemint
X	cmpb	al,#IS_LINE_STATUS_CHANGE
X	jne	rsdone		| fishy
X
X| line status change interrupt
X
X	addb	dl,#LINE_STATUS_OFFSET - INT_ID_OFFSET
X	in
X	testb	al,#LS_FRAMING_ERR
X	je	over_framing_error
X	inc	FRAMING_ERRORS(si)	
Xover_framing_error:
X	testb	al,#LS_OVERRUN_ERR
X	je	over_overrun_error
X	inc	OVERRUN_ERRORS(si)	
Xover_overrun_error:
X	testb	al,#LS_PARITY_ERR
X	je	over_parity_error
X	inc	PARITY_ERRORS(si)
Xover_parity_error:
X	testb	al,#LS_BREAK_INTERRUPT
X	je	over_break_interrupt
X	inc	BREAK_INTERRUPTS(si)
Xover_break_interrupt:
X
Xrsnext:
X	mov	dx,INT_ID_PORT(si)
X	in
X	cmpb	al,#IS_NO_INTERRUPT
X	jne	rsmore
Xrsdone:
X	movb	al,#ENABLE
X	out	INT_CTL
X	testb	ah,#OWAKEUP
X	jne	owakeup
X	movb	OSTATE(si),ah
X	pop	dx
X	pop	bx
X	pop	ax
X	pop	si
X	pop	ds
X	iret
X
X| output interrupt
X
X	.even
Xoutint:
X	addb	dl,#XMIT_OFFSET - INT_ID_OFFSET
Xoutint1:
X	cmpb	ah,#ODEVREADY + OQUEUED + OSWREADY
X	jb	rsnext		| not all are set
X	mov	bx,OPTR(si)
X	movb	al,(bx)
X	out
X	inc	bx
X	mov	OPTR(si),bx
X	cmp	bx,OBUFEND(si)
X	jb	rsnext
X	add	_tty_events,#EVENT_THRESHOLD
X	xorb	ah,#ODONE + OQUEUED + OWAKEUP	| OQUEUED off, others on
X	j	rsnext			| direct exit might lose interrupt
X
X| modem status change interrupt
X
X	.even
Xmodemint:
X	addb	dl,#MODEM_STATUS_OFFSET - INT_ID_OFFSET
X	in
X	testb	al,#MS_CTS
X	jne	m_devready
X	andb	ah,#NOT_ODEVREADY
X	j	rsnext
X
X	.even
Xm_devready:
X	testb	ah,#ODEVREADY
X	jne	rsnext
X	orb	ah,#ODEVREADY
X	addb	dl,#LINE_STATUS_OFFSET - MODEM_STATUS_OFFSET
X	in
X	testb	al,#LS_TRANSMITTER_READY
X	je	rsnext
X	addb	dl,#XMIT_OFFSET - LINE_STATUS_OFFSET
X	j	outint1
X
X| special exit for output just completed
X
X	.even
Xowakeup:
X	andb	ah,#NOT_OWAKEUP
X	movb	OSTATE(si),ah
X
X| rearrange context to call tty_wakeup()
X
X	pop	dx
X	pop	bx
X	pop	ax
X	pop	si
X	pop	ds
X	call	save
X	call	_tty_wakeup
X	jmp	_restart
END_OF_FILE
if test 4678 -ne `wc -c <'rs2.s'`; then
    echo shar: \"'rs2.s'\" unpacked with wrong size!
fi
# end of 'rs2.s'
fi
if test -f 'rs2.s.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rs2.s.notes'\"
else
echo shar: Extracting \"'rs2.s.notes'\" \(455 characters\)
sed "s/^X//" >'rs2.s.notes' <<'END_OF_FILE'
XSee rs232.c for comments. The main advantage of assembler over C here is
Xthat the save/restart overhead is usually eliminated. The function calls
Xin the C handler are expensive but could be eliminated easily. With the
XMinix compiler, the C code is about 5 times slower than the assembler,
Xcompared with 2 times slower for more usual code.
X
XBe careful to maintain the structure offsets and sizes in rs232.c and
Xrs2.s together.
X
XThis is mutilated for asld.
END_OF_FILE
if test 455 -ne `wc -c <'rs2.s.notes'`; then
    echo shar: \"'rs2.s.notes'\" unpacked with wrong size!
fi
# end of 'rs2.s.notes'
fi
if test -f 'rs232.c.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rs232.c.notes'\"
else
echo shar: Extracting \"'rs232.c.notes'\" \(609 characters\)
sed "s/^X//" >'rs232.c.notes' <<'END_OF_FILE'
XThis is mostly new, so doesn't need defending :-).
X
Xrs_config() is based on the old one. A bad BUG involving changing modes
Xis documented.
X
Xrs_ioctl() is based on set_uart().
X
XOther parts are based on the driver by Paradis early in 1988 and 3 other
Xdrivers I've written (for 6850, 8250, 6551). My other drivers were all
Xmuch easier to make work well since the program had complete control.
XHowever, the hardware scroll in Minix makes it a much faster terminal
Xthan anything else I've seen on a PC. With this rs232.c and rs2.s and my
Xproc.c mods, it can keep up with 9600 baud, scrolling without flow control.
END_OF_FILE
if test 609 -ne `wc -c <'rs232.c.notes'`; then
    echo shar: \"'rs232.c.notes'\" unpacked with wrong size!
fi
# end of 'rs232.c.notes'
fi
if test -f 'tty.c.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.c.notes'\"
else
echo shar: Extracting \"'tty.c.notes'\" \(4465 characters\)
sed "s/^X//" >'tty.c.notes' <<'END_OF_FILE'
XThe tty structure offsets are precomputed. This saves lots of slow indexing.
XMacros are used to hide implementation details.
X
XInitialization is reorganised.
X
XBUG 1. The TTY_LINE argument in tty_task() was not checked, so bad pointers
Xwere generated and followed for unsupported tty numbers.
X
Xtty_reply() had 2 arguments which were used in only one case of 11 or 12.
X
Xdo_int() is rewritten and the voluminous comments for it updated, to fix
Xbugs and make non-cooked cases faster. A fancy form of polling is used
Xinstead of the unreliable message pointer and cumbersome buffering.
X
XBUG 2. After an early exit in do_int() (to avoid replying twice), there was
Xnothing to generate another wakeup of TTY (except external events).
X
XBUG 3. The locked copy loop in charint() was potentially
X
X	500 chars * 10 instructions * 3 microseconds = 15 milliseconds.
X
XBUG 4. charint() returned after the 1st new character received in non-cooked
Xmodes, so would always return 1 except for congestion.
X
XBUG 5. charint() could reply more than once after a signal character via
Xsig_char() and finish(). The signalled line is safe since it gets cancelled,
Xbut not other lines.
X
XBUG 6. in_char() returned early when the buffer was full, even when the
Xnew character was a backspace, erase or signal.
X
XBUG 7. The check for a full buffer in in_char() was inadequate, since
Xcertain keys get expanded.
X
XBackspace-erasing is needed twice and made a function backover().
X
XFor escaped characters (erase and kill) the backslash is backspaced over.
XThis looks better and keeps the column straight. I don't think escaping
Xbelongs in the kernel.
X
XThe xon character is not allowed into the input stream.
X
XCTRL-ALT-DEL is checked for in make_break since it was pointless in
Xkeyboard(). See console.c notes.
X
Xrd_chars() is rewritten to eliminate the transfer buffer and make non-cooked
Xmodes faster.
X
Xfinish() now checks the tty_waiting type to see if a REVIVE or TASK_REPLY
Xreply is required. Previously it never revived for the console, which was
Xunecessary only because of other bugs.
X
XBUG 8. After console output is xoff-ed in the middle, TTY did not reply to
XFS. This is fixed by a suspension reply in do_write(), just as for RS232,
Xand required the SUSPENDED tty_waiting state.
X
XBUG 9. tty_lfct could be wrong after mode changes, e.g. MARKERs received
Xin non-cooked modes were not counted, though line feeds were. This
Xdestroys the assumptions made by rd_chars(). The new code saves time
Xby not maintaining tty_lfct in non-cooked modes, and recovers by
Xrecalculating tty_lfct after a mode change.
X
XBUG 10. A switch to RAW mode with tty_inhibited set used to hang the terminal.
X
XThe TIOCFLUSH ioctl is added. This requires a simple update to sgtty.h and
Xa messy update to ioctl.c. I plan to rewrite the ioctl interface so ioctl.c
Xwith all the intelligence transferred to the drivers (except stuff for
Xcompatibility) rather than adding more junk.
X
Xdo_ioctl() now sends a reply directly, rather than loading every call to
Xtty_reply() with unnecessary parameters.
X
XBUG 11. do_cancel() didn't reply when its job had already been done. It
Xcan't afford this. Bugs in FS showed the problem. Always sending a
XTASK_REPLY works well. Slight changes elsewhere result in the critical
Xcase being exercised more often.
X
XBUG 12. sigchar() didn't cancel input in tty_driver_buf. This was nontrivial
Xwith the streams merged.
X
Xoprocess() should be used for the console as well as RS232, possibly
Xsimplifying console.c. I don't think column counting belongs in the kernel
X(except it does in console.c which is simulating an external terminal). The
Xcolumn after an escape sequence is unknown.
X
Xtty_icancel() and tty_ocancel() do common functions previously scattered.
XThese cancellations are simple at the task level but tricky at the device
Xlevel. Lower level routines handle the details of maintaining the integrity
Xof their buffers and the tty_events counter.
X
Xtty_wakeup() is a more general replacement for rs_flush(), with a simpler
Xinterface to the clock task. It takes the simple approach of always waking
Xup TTY if there is something to do. Fancier delay methods gained little
Xand increase the response time. However, user programs not requiring an
Ximmediate response would be helped by a RAW mode which does not return
Xas soon there is input. 
X
XIt was tricky to do accurate timing because of the sync with the clock.
XResults directly reported by time(1) were misleading, so a background task
Xwas timed instead.
END_OF_FILE
if test 4465 -ne `wc -c <'tty.c.notes'`; then
    echo shar: \"'tty.c.notes'\" unpacked with wrong size!
fi
# end of 'tty.c.notes'
fi
if test -f 'tty.crc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.crc'\"
else
echo shar: Extracting \"'tty.crc'\" \(1243 characters\)
sed "s/^X//" >'tty.crc' <<'END_OF_FILE'
Xcrc's for the files posted (except tty.crc :-))
X
X00489   2430 README
X51529    984 clock.c.cdif
X22082    284 clock.c.notes
X40050  13395 console.c.cdif
X04589   1800 console.c.note
X12238    435 const.h.cdif
X15704    299 fs:device.c.cd
X47228    736 fs:pipe.c.cdif
X07925   1638 main.c.cdif
X21381    573 main.c.notes
X36315   1070 makefile.cdif
X21142   2741 mpx88.s.cdif
X26834    255 mpx88.s.notes
X32062   4678 rs2.s
X25237    455 rs2.s.notes
X65263  19504 rs232.c
X01717    609 rs232.c.notes
X16498  37486 tty.c
X03160   4465 tty.c.notes
X53298   6562 tty.h.cdif
X40337   1359 tty.h.notes
X16135   1124 tty.todo
X
Xcrc's for the new system files
X
X01465   9080 clock.c
X57278  34367 console.c
X41961   3091 const.h
X28661   8604 /usr/sys/fs/device.c
X19890   8581 /usr/sys/fs/pipe.c
X59501  11587 main.c
X15304   3048 makefile
X53524  14095 mpx88.s
X32062   4678 rs2.s
X65263  19504 rs232.c
X16498  37486 tty.c
X40473   8522 tty.h
X
Xcrc's for the old system files (what I think is 1.3c)
X
X11053   9335 orig/clock.c
X01201  33549 orig/console.c
X46559   2880 orig/const.h
X54203   8530 ../fs/device.c
X08656   8462 ../fs/pipe.c
X01335  11156 orig/main.c
X50110   3188 at_makefile
X09331  13834 orig/mpx88.s
X59321  19053 orig/rs232.c
X03407  28073 orig/tty.c
X34455   7485 orig/tty.h
END_OF_FILE
if test 1243 -ne `wc -c <'tty.crc'`; then
    echo shar: \"'tty.crc'\" unpacked with wrong size!
fi
# end of 'tty.crc'
fi
if test -f 'tty.h.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.h.cdif'\"
else
echo shar: Extracting \"'tty.h.cdif'\" \(6562 characters\)
sed "s/^X//" >'tty.h.cdif' <<'END_OF_FILE'
X*** orig/tty.h	Thu Oct 20 13:15:37 1988
X--- tty.h	Mon Jan  2 03:09:16 1989
X***************
X*** 2,4 ****
X  #define	NR_RS_LINES	   1	/* how many rs232 terminals can system handle*/
X! #define TTY_IN_BYTES    1000	/* input queue size */
X  #define TTY_RAM_WORDS    320	/* ram buffer size */
X--- 2,5 ----
X  #define	NR_RS_LINES	   1	/* how many rs232 terminals can system handle*/
X! #define KB_IN_BYTES      200   	/* keyboard input queue size */
X! #define RS_IN_BYTES   (1024 + 2 * RS_IBUFSIZE)	/* RS232 input queue size */
X  #define TTY_RAM_WORDS    320	/* ram buffer size */
X***************
X*** 7,11 ****
X  #define TAB_MASK          07	/* mask for tty_column when tabbing */
X- #define WORD_MASK     0xFFFF	/* mask for 16 bits */
X- #define OFF_MASK      0x000F	/* mask for  4 bits */
X- #define MAX_OVERRUN      500	/* size of overrun input buffer */
X  #define MAX_ESC_PARMS      2	/* number of escape sequence params allowed */
X--- 8,9 ----
X***************
X*** 50,61 ****
X  
X  EXTERN struct tty_struct {
X    /* Input queue.  Typed characters are stored here until read by a program. */
X!   char tty_inqueue[TTY_IN_BYTES];    /* array used to store the characters */
X    char *tty_inhead;		/* pointer to place where next char goes */
X    char *tty_intail;		/* pointer to next char to be given to prog */
X    int tty_incount;		/* # chars in tty_inqueue */
X    int tty_lfct;			/* # line feeds in tty_inqueue */
X  
X    /* Output section. */
X!   int tty_ramqueue[TTY_RAM_WORDS];	/* buffer for video RAM */
X    int tty_rwords;		/* number of WORDS (not bytes) in outqueue */
X--- 48,68 ----
X  
X+ #define EVENT_THRESHOLD   64	/* events to accumulate before waking TTY */
X+ #define RS_IBUFSIZE      128	/* RS232 input buffer size */
X+ 
X  EXTERN struct tty_struct {
X    /* Input queue.  Typed characters are stored here until read by a program. */
X!   char *tty_inbuf;		/* pointer to input buffer */
X!   char *tty_inbufend;		/* pointer to place after last in buffer */
X    char *tty_inhead;		/* pointer to place where next char goes */
X+   int tty_ihighwater;		/* threshold for queue too full */
X+   int tty_ilow_water;		/* threshold for queue not too full */
X+   int tty_insize;		/* size of buffer */
X    char *tty_intail;		/* pointer to next char to be given to prog */
X+   phys_bytes tty_inphys;	/* physical address of input buffer */
X    int tty_incount;		/* # chars in tty_inqueue */
X    int tty_lfct;			/* # line feeds in tty_inqueue */
X+   int (*tty_devread)();		/* routine to read from low level buffers */
X  
X    /* Output section. */
X!   phys_bytes tty_outphys;	/* physical address of output buffer */
X    int tty_rwords;		/* number of WORDS (not bytes) in outqueue */
X***************
X*** 67,71 ****
X    int *tty_esc_parmp;		/* pointer to current escape parameter */
X-   int tty_attribute;		/* current attribute byte << 8 */
X    int (*tty_devstart)();	/* routine to start actual device output */
X  
X    /* Terminal parameters and status. */
X--- 74,81 ----
X    int *tty_esc_parmp;		/* pointer to current escape parameter */
X    int (*tty_devstart)();	/* routine to start actual device output */
X  
X+   /* Echo buffer. Echoing is also delayed by output in progress. */
X+   char *tty_ebufend;		/* end of echo buffer */
X+   char *tty_etail;		/* tail of echo buffer (head is fixed) */
X+ 
X    /* Terminal parameters and status. */
X***************
X*** 80,81 ****
X--- 90,92 ----
X    char tty_waiting;		/* 1 when output process waiting for reply */
X+   int tty_pgrp;			/* slot number of controlling process */
X  
X***************
X*** 99,107 ****
X    phys_bytes tty_phys;		/* physical address where data comes from */
X!   int tty_outleft;		/* # chars yet to be copied to tty_outqueue */
X!   int tty_cum;			/* # chars copied to tty_outqueue so far */
X!   int tty_pgrp;			/* slot number of controlling process */
X  
X!   /* Miscellaneous. */
X!   int tty_ioport;		/* I/O port number for this terminal */
X  
X  } tty_struct[NR_CONS+NR_RS_LINES];
X--- 110,120 ----
X    phys_bytes tty_phys;		/* physical address where data comes from */
X!   int tty_outleft;		/* # chars yet to be output */
X!   int tty_cum;			/* # chars output so far */
X  
X!   /* Cross reference to avoid slow pointer subtraction. */
X!   int tty_line;			/* line number of this tty less NR_CONS */
X  
X+   /* Large arrays moved to end for shorter addresses. */
X+   int tty_ramqueue[TTY_RAM_WORDS];	/* buffer for video RAM */
X+   char tty_ebuf[32];		/* echo buffer */
X  } tty_struct[NR_CONS+NR_RS_LINES];
X***************
X*** 120,128 ****
X  #define WAITING            1	/* an output process is waiting for a reply */
X! #define COMPLETED          2	/* output done; send a completion message */
X  
X- EXTERN char tty_driver_buf[2*MAX_OVERRUN+4]; /* driver collects chars here */
X- #define tty_buf_count(p) (((int *)(p))[0])
X- #define tty_buf_max(p) (((int *)(p))[1])
X- EXTERN char tty_copy_buf[2*MAX_OVERRUN];  /* copy buf used to avoid races */
X  EXTERN char tty_buf[TTY_BUF_SIZE];	/* scratch buffer to/from user space */
X  EXTERN int shift1, shift2, capslock, numlock;	/* keep track of shift keys */
X--- 133,138 ----
X  #define WAITING            1	/* an output process is waiting for a reply */
X! #define SUSPENDED          2	/* like WAITING but different reply type */
X  
X  EXTERN char tty_buf[TTY_BUF_SIZE];	/* scratch buffer to/from user space */
X+ 
X  EXTERN int shift1, shift2, capslock, numlock;	/* keep track of shift keys */
X***************
X*** 132,135 ****
X  EXTERN int softscroll;		/* 1 = software scrolling, 0 = hardware */
X- EXTERN int output_done;		/* number of RS232 output messages to be sent*/
X- EXTERN int char_height;		/* number of scan lines for a char */
X  EXTERN int keyb_type;		/* type of keyboard attached */
X--- 142,143 ----
X***************
X*** 137 ****
X--- 145,165 ----
X  EXTERN int num_slash;		/* scan code of numeric slash */
X+ EXTERN unsigned tty_events;	/* weighted input chars + output completions*/
X+ EXTERN phys_bytes tty_bphys;	/* physical address of tty_buf buffer */
X+ EXTERN message wakeup_mess;	/* message for tty wakeups */
X+ 
X+ /* Appropiately sized buffers for keyboard and RS232 lines. */
X+ EXTERN char kb_inbuf[NR_CONS][KB_IN_BYTES];
X+ EXTERN char rs_inbuf[NR_RS_LINES][RS_IN_BYTES];
X+ 
X+ /* These (void or addressed) functions interface between TTY and CONSOLE. */
X+ extern /* void */ console();
X+ extern int kb_read();
X+ 
X+ /* These (void or addressed) functions interface between TTY and RS232. */
X+ extern void rs_inhibit();
X+ extern void rs_istop();
X+ extern void rs_istart();
X+ extern void rs_ocancel();
X+ extern int rs_read();
X+ extern void rs_setc();
X+ extern void rs_write();
END_OF_FILE
if test 6562 -ne `wc -c <'tty.h.cdif'`; then
    echo shar: \"'tty.h.cdif'\" unpacked with wrong size!
fi
# end of 'tty.h.cdif'
fi
if test -f 'tty.h.notes' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.h.notes'\"
else
echo shar: Extracting \"'tty.h.notes'\" \(1359 characters\)
sed "s/^X//" >'tty.h.notes' <<'END_OF_FILE'
XTTY_IN_BYTES is replaced by KB_IN_BYTES, RS_IN_BYTES and tty_insize.
X
XWORD_MASK and OFF_MASK are obsolete (no segment arithmetic).
X
Xtty_inqueue is replaced by externally allocated kb_inbuf and rs_inbuf
Xwith pointers tty_inbuf and tty_inbufend.
X
Xtty_ramqueue is put at end for smaller offsets.
X
XRS_IBUFSIZE is added. Better hidden from tty.c (mainly used for strategy).
X
XTIOCFLUSH is added. Belongs in sgtty.h.
X
XWatermarks tty_ihighwater and tty_ilow_water let TTY attempt to control RS232.
X
Xtty_inphys and tty_outphys and tty_bphys save lots of slow umap()s.
X
Xtty_devread provides a uniform interface to reading device buffers.
X
Xtty_attribute is now one_con_attribute in console.c.
X
Xtty_ebuf, tty_ebufend and tty_etail provide an echo queue.
X
Xtty_ioport and char_height were already obsolete.
X
Xtty_line provides fast calculation of the line number by avoiding divisions.
X
XCOMPLETED is no longer used, but its number is used for SUSPENDED. COMPLETED
Xis now handled by the the odone argument to tty_devread(). The SUSPENDED
Xstate was not properly handled before.
X
Xtty_driver_buf, tty_buf_count, tty_buf_max and tty_copy_buf are replaced by
Ximproved buffering in console.c.
X
Xtty_events is the count of low-level i/o events waiting to be processed by
Xthe TTY task. output_done is subsumed by tty_events.
X
Xwakeup_mess is a constant message for all tty interrupts.
END_OF_FILE
if test 1359 -ne `wc -c <'tty.h.notes'`; then
    echo shar: \"'tty.h.notes'\" unpacked with wrong size!
fi
# end of 'tty.h.notes'
fi
if test -f 'tty.todo' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tty.todo'\"
else
echo shar: Extracting \"'tty.todo'\" \(1124 characters\)
sed "s/^X//" >'tty.todo' <<'END_OF_FILE'
XThings to fix in tty.c, console.c and rs232.c:
X
XNR_CONS > 1 is not really supported.
X
XThe console should be made more independent of TTY. Output processing
Xfor it should be done in TTY. Ioctls should not be allowed directly to
Xthe screen - screen capabilities should be controlled by escape sequences.
X
XBackspacing over tabs doesn't work. Backspacing from columns > 80 fails.
Xeven for the console where it is easy enough to do right.
X
XKeyboard() really needs to do complete scan code interpretation at
Xinterrupt time to handle all special chars. Makebreak() is too
Xdevice-dependent to belong in tty.c - the translation is OK, but not
Xthe state handling.
X
XReads and writes on lines doing i/o should be delayed instead of disallowed.
X
XIoctls on lines doing i/o should perhaps be disallowed or delayed.
X
XThere should be a way to stop raw mode input being given to the user in
Xtoo small chunks.
X
XThere should be lots more ioctls. The ioctl interface is too specialized,
Xwith lib/ioctl.c having to know about all devices. The compiler does a
Xpoor job with shifts and masks of longs, so the interface is also
Xunnecessarily bulky.
END_OF_FILE
if test 1124 -ne `wc -c <'tty.todo'`; then
    echo shar: \"'tty.todo'\" unpacked with wrong size!
fi
# end of 'tty.todo'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

Bruce Evans
evans@ditsyda.oz.au
D