I'm currently trying to write a serial device driver using the io-char
library. So far I'm able to read and write data but there are still
some things unclear to me. Maybe someone that has already done this
can help me...
1) tte()-function:
Can this function directly be used by the driver or is it just a
io-char internal event handler (the documentation is a bit unclear at
this but i assume the latter)?
2) Sending events:
This question is related to question 1) and assumes that tte() is a
io-char internal handler. So how does the driver sends events to
io-char?
I can see that the structure TTYCTRL has an "event"-member
and also TTYDEV's "flags"-member is used for events (at
least in the 8250 example). But just setting the flags in TTYDEV
will, of course, not do anything. As I see it only makes sense doing
this inside the tto()-function, as the function that is calling it (
kick() in io_write.c ) will queue the event in "ttyctrl"
and send a message. How can it be done on other places?
Btw: Whats the difference, regarding EVENT_*, between the TTYCTRL
"event" and the TTYDEV "flags" member ?
3) Event queue:
TTYCTRL also contains an event queue
("num_events"+"event_queue"). It is written in
the documentation that this is used by io-char AND the driver to
queue events. How is this related to sending events as desribed in 2)
? It seems conflicting to me.
I see that it is used in the interrupt-handler of the 8250-example.
4) Blocking read:
When read() is called on the character-device then it blocks when
there is no data in the "ibuf" of the device. How can the
driver indicate when data has been written to the "ibuf",
so io-char will process it and deliver it to the caller ?
5) Drain:
What is the meaning of EVENT_DRAIN and the
"waiting_drain"-queue in TTYDEF ? What is the driver
supposed to do with that information ?
6) Instances:
This is a more general question regarding resource managers. How do I
distinguish between different instances of the serial device (two
processes call open() on the same device). I assume it will create
two instances in this case, will it ?!
Quick help on these issues would be appreciated
