2.3: Designing a better serial subsystem.

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Thu, 5 Nov 1998 14:28:47 +0100 (MET)


Hi everyone.

Every now and then the issue comes up: a serial driver does a lot of
stuff that could've been in generic code. The serial subsystem needs
a rework.

The best thing would be if a device driver for a serial card would
only export a few simple functions. On the other hand we'd like to be
able to handle high performance cards efficiently.

struct ll_serial_driver {
bhandle *opencard ();
int *closecard (bhandle, ...);
phandle *openport (bhandle, my_handle, ...);
int *closeport (phandle, ...);
int *writechar (phandle, ...);
int *writechars (phandle, ...);
int *setmodemlines (phandle, ...);
int *getmodemlines (phandle, ...);
int *setbaud (phandle, ...);
int *getbaud (phandle, ...);
int *setotherstuff (phandle, ...);
int *getotherstuff (phandle, ...);
};

The low_level_serial driver calls

serial_recieved_char (void *my_handle, char ch)

if it has a character. But it can also call one of a few other
"got a char" functions. For example:

serial_recieved_chars (void *my_handle, int nchars, char *buf)

means that the driver has prepared a bunch of characters at *buf.
Another one could be:

serial_recieved_chars_io (void *my_handle, int nchars, int ioaddr)

which allows a tight loop reading bytes from ioaddr, and storing them
into the system buffer. (CD1865 based cards would benefit from this).

Similar things go for transmitting characters:

a simple card might not be able to benefit from getting many chars at
once. So, the driver need only implement writechar. If the driver
leaves writechars NULL, the system will provide a generic
writechars that calls writechar repeatedly.

Similarly, a generic writechar can call writechars (..., 1, &ch) if
the driver doesn't provide one.

The system should be able to tell the low level driver (if it wants to
know) what the stop/start chars are for instance, to allow the
hardware to handle that, should the hardware be capable of stuff like
that.

Also the system should be able to request "I don't need to know
anything until there is an xx character in the data stream". Thats a
feature some cards support, and should be usable by the PPP line
discipline (there is a fixed end-of-packet character in PPP right?).

I'm not good at thinking up good names. Feel free to suggest
others. I'm sure I forgot a few things that the system might want from
a serial driver.

Roger.

-- 
| Most people would die sooner than think....  |    R.E.Wolff@BitWizard.nl 
| in fact, most do.  -- Bertrand Russsell      |     phone: +31-15-2137555 
We write Linux device drivers for any device you may have! fax: ..-2138217

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/