[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
A simpler tty driver model
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.
int (*t_enable)(void *); // powerup device
int (*t_disable)(void *); // powerdown device
int (*t_detach)(void *); // detach device
int (*t_status)(void *v);
if t_getc returns -1, call this to reason for input error.
(framing error, parity error, etc.)
int (*t_getbuf)(void *v, uint8_t *buf, size_t n);
returns up to n characters at a time into buf. returns # of characters
returned (0..n) or -1 if an error happened.
int (*t_putbuf)(void *v, const uint8_t *buf, size_t n);
write n characters to tty, if there is no space for n, return the number
of characters placed in the fifo.
int (*t_flush)(void *v, u_int mask);
flush the receive and/or/transmit fifo depending on mask.
int (*t_active)(void *v, u_int signals);
Set the following signal(s) in sigmals to active (CTS,RTS,DTR,DTS,CD,etc).
int (*t_inactive)(void *v), u_int signals);
Set the following signal(s) in sigmals to inactive (CTS,RTS,DTR,DTS,CD,etc).
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).
I would like to be able to make the h/w driver < 200 lines if possible.
This is only a rough guess at what it would take.
Main Index |
Thread Index |