tech-kern archive

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

Re: A simpler tty driver model



On Sat, Jul 27, 2013 at 11:52:20PM -0700, Matt Thomas wrote:
 > I have several SoC targets that I've stalled on due to the need of writing
 > a tty driver.  Sure I could cut & paste from another driver but having to
 > do that 3+ times seems inordinately stupid.  So I've been thinking of 
 > making that c&p'ed code into a common tty driver and exporting a small of
 > h/w specific functions.

Yes please, ttys are a horrible mess currently.

Also can you make these into full drivers so we get something like
"tty00 at ser0", rather than continuing to have all the plumbing
hidden because tty plumbing was invented before device attachments?
This might turn out to have a lot of autoconf-related tentacles and
need to be a separate undertaking though...

 >      int (*t_status)(void *v);
 > if t_getc returns -1, call this to reason for input error.
 > (framing error, parity error, etc.)

This will need a locking interface to make sure I get my error and not
someone else's. (I don't think it's wise to count on the tty layer
code to cope with this on its own.)

Given the complications that would ensue, wouldn't it be better to
drop that and do

   int (*t_getbuf)(void *v, uint8_t *buf, size_t n, size_t *result);
   int (*t_putbuf)(void *v, const uint8_t *buf, size_t n, size_t *result);

or even

   int (*t_read)(void *v, uint8_t *buf, size_t n, size_t *result);
   int (*t_write)(void *v, const uint8_t *buf, size_t n, size_t *result);

and return error codes as normal?

(also I'm not sure about uint8_t but that's less critical)

 >      int (*t_setmode)(void *v, u_int mode);
 > contains the char width, stop bits, speed, partity (even, odd, none)
 > speed is in the low 24 bits and everything else in the top 8.
 > if the top 8 bits are 0, that will mean 8 bit, 1 stop, no parity.
 > bits 24:25 is char size (8-[25:24]), 27:26 stop bits (1 + [27:26]/2)
 > bits 31:30 are parity (3 = odd, 2 = even, 0 = none).

What Martin said...

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index