Re: questions of a kernel-newbie, simple ISA driver

From: Timur Tabi (ttabi@interactivesi.com)
Date: Thu Sep 13 2001 - 12:53:47 EST


Timothy Hamlin wrote:

> Driver polls for the 1/2 full FIFO flag, when found transfer 16k words out
> of the FIFO and place this in a larger buffer, say 320k or something.

The driver should instead poll the device at regular, adjustable intervals,
and read ALL the data it can at each interval. Assuming the hardware allows
that, of couse.

> How would I maintain this buffer? Reads to the /dev entry need to be able
> to get a continuous stream from the device, how do I keep the buffer both
> filling, and being read out at the same time? Should I make the buffer a
> FIFO as well? How? How do I keep track of what has been read from the
> buffer, so that subsequent reads get new data, not data that is lower down
> in the buffer?

This is a basic, first-year computer science question. Just use a circular
buffer. You can get the algorithm from any CS book.

> Can I allow multiple processes to be reading from this
> /dev entry without loosing data to any of them?

Sure, just use one circular buffer per process.

> Also, when I read for a device like a serial port I can just do cat
> /dev/ttyS0 and watch the stream coming in. So far in my driver, a read
> performs one operation, outputs whatever, and then stops. So a cat of my
> device only transfers the current data, and then just sits there. How do
> I keep that steam going so that a cat will continually update?

Increase the rate at which you read the hardware FIFO. Or perhaps, use the
reads to your /dev device as a trigger to get more data from the HW.

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



This archive was generated by hypermail 2b29 : Sat Sep 15 2001 - 21:00:42 EST