Subject: Dial-in and Dial-out tty's
To: None <tech-kern@NetBSD.ORG>
From: Bill Studenmund <>
List: tech-kern
Date: 04/09/1996 23:36:53

I want to give the mac68k serial drivers support for dial-in and
dial-out use of modems a la SunOS, and wanted to bounce my ideas off
y'all (so that we don't end up with different ports doing incompatable

What SunOS does (according to the man pages) is to define two minor 
numbers per tty, offset by 128. The lower-numbered one, the dial-in
port, acts just like the present implimentation of tty's. The
higher-numbered one, the dial-out, behaves as if softcarrier is
always asserted, and can open the port if it's not in use, or if
the dial-in side is waiting for the carrier.

Say I want to make tty minor 2 be the first dial-in line.
/dev/ttyd0, the dial-in device, will point to (major = tty, minor = 2),
and /dev/cua0, the dial-out device, (what a gross name) will point
to (major # = tty, minor # = 130 = 128+2).

To do this seems fairly simple.

1) Replace every minor(tp->t_dev) use with (minor(tp->t_dev) & 0x7f).
	Probably best to use a #define variable for the 0x7f.

2) Add some extra flags to the tty or to the local driver's storage
	to indicate which side is open or trying to open.

3) Change zsopen a bit (or comopen or ...)

a) If we are trying to open the dial-out while the dial-in is
	successfully open, return EBUSY.

b) If we are trying to open the dial-in non-blocking while the
	dial-out is open, return EBUSY.

c) In the loop to look to see if we have carrier, make it something like:
	if (dial-out side is using the port)
	    ttysleep(a little while)
	    Look to see if the carrier's there, or we have softcarrier,
		clocal, or non-block in the flags
	    ttysleep(a little while) if we can't go yet.

d) When one side opens, set a flag indicating that it has opened.

4) Change close so that if we are closing the dial-out side and the dial-in
	side is waiting, the tty state goes from TS_ISOPEN to TS_WOPEN.

Am I missing anything? These changes are fairly simple; they'd be done
if it weren't bedtime.

Also, the close routine for a tty driver is called only when the
last file descriptor is closed, isn't it? Most close routines shut off
the hardware; an illogical thing to do if someone's still open.

As I said before, I'm willing (planning) to add these changes to the
new zs driver for the mac68k port this week, but would appreciate
suggestions on the method. Also, I'd like to dove-tail my efforts with
the other ports. :-)

Also, I could probably be talked into generating proposed diffs for some
of the other drivers, but someone else (familiar with the driver) would
need to check them over.

Take care,