[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: interacting with serial driver



Sharad Joshi wrote:
> 
> On Fri, 9 Jun 2000, Kedar Patankar wrote:
> 
> + > Well, the case is, i want to do, what "open" or "write" or "read" does at
> + > the lowest level, just above the driver.
> +
> + At the very core "open" just turns on the DTR on the serial port.
> + "Write" essentially just does a outb(SERIAL_DATA_PORT) and a status check,
> + and "read" is tricky. It will block you till enough chars are available
> + (depending on whether you have non-blocking mode set in "open"), and when
> + the serial interrupt occurs the driver will actually read the chars and
> + put them in the buffer. Eventually waking up your prog when enough are
> + accumulated.
> 
> While that is true, i need to do that myself, w/o relying on "open" etc.
> :( for some reasons. Also, i am not doing this at the user level, but in
> kernel proper.
> 
> Yeah, writing my own serial driver is another option, but again, due to
> certain restraints, i _have_ to use the underlying one :(

I don't know what your reasons are, but I would suggest: use the kernel
driver. It would make code more portable. Also use the POSIX calls.
Check out Richard W. Stevens "Advanced Programming in the Unix
Environment", chapter 10, I think.

If u *really* must do it on your own, u need to go down and talk
directly to the hardware.

For a normal PC, u would need to get the specs of the UART. U would also
need to register your open(), read(), write() and close() calls with the
kernel.

IMHO, doubt that there is any way u can actually avoid using open(),
read(), write() and close(). Your serial device is actually a *file* and
these are the calls that *actually* map onto the driver developer's
device specific functions.

So, why do u want to duplicate the serial driver? It exists and works
well. If u have a new UART or multiport serial board, right, go ahead,
but then provide the standard API.

For details on driver writing, check out the Linux Device Drivers book,
published by O'Reilly. Indian Edition: Shroff publishers.

sachin