Subject: sun3 zs ports
To: None <weisberg@gyrus.neurology.rochester.edu>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: port-sun3
Date: 12/28/1994 10:51:05
> Date: Tue, 27 Dec 1994 13:59:28 -0500
> From: Jeff Weisberg <weisberg@gyrus.neurology.rochester.edu>

> I just recently brought up NetBSD (semi-current) on
> one of my sun3 boxes. Under SunOS, I am able to use the
> kbd and mouse serial lines as regular serial ports (as
> tty[cd] using minors 2 & 3, and the approp' hardware
> adapter). I'd like to do this under NetBSD as well.

Uh oh, I thought this might eventually happen.  There are several
problems with the current zs driver that would need to be solved
before you can use all four lines for any purpose you like.

There is both a long-term, pretty solution, and a short-term,
dirty solution.

The pretty one (briefly) is to divide the zs driver into two layers,
one layer for the chip and one layer for the tty/kbd/ms interface.
The autoconfig might look something like this:

	# Zilog Serial Controller (two channels each)
	device zsc at obio
	zsc0 at obio? addr ?
	zsc1 at obio? addr ?

	# ZS used as a plain tty port (ttya/ttyb)
	device zs at zsc: tty
	zs0 at zsc0 addr 4
	zs1 at zsc0 addr 0

	# ZS used as a keyboard port (kbd)
	device kbd at zsc
	kbd0 at zsc1 addr 4
	# ZS used as a mouse port (ms)
	device ms at zsc
	ms0 at zsc1 addr 0

	# Alternative: use zsc1 for ttys (ttyb,ttyc)
	# zs2 at zsc1 addr 4
	# zs3 at zsc1 addr 0

This would be nice, but will take a while to implement, so
you probably want to hear about the quick-and-dirty way...

> Going thru zs.c, I find (in zsopen):
> 
> 	if (zs >= zscd.cd_ndevs || (zi = zscd.cd_devs[zs]) == NULL ||
> 	    unit == ZS_KBD || unit == ZS_MOUSE)
> 		return (ENXIO);
> 
> bobbitting out the unit == tests, almost works. I can now
> send stuff to terminals on these ports, but I'm having
> trouble getting anything from the terminals.

In zssoft() near line 1016, the input is dispatched off to the
input handler for the type of channel (kbd/ms/tty).  This is
one place where a layered driver should just call an input
handler using a function pointer set during attach...

> I assume that the tests are there for a reason, what else
> ought I be banging on?

Look through zs.c for the macros ZS_KBD or ZS_MOUSE and be
suspicious of any code that uses them...

Have fun!

Gordon