Re: Opening a /dev file from Kernel space



I want to open the serilal driver (/dev/ttyS0) from the kernel space.
I need to write a character driver in the kernel (the requirements of
the project insist that it will be inside the kernel) that gets special
strings from user and pass them to the serial.

In order to implement that I thought of opening the serial driver as if
I was a user and with the file descriptor to read()/write()/ioctl()
etc...

Can I do this from the kernel space?
Do you have maybe a better idea how to implement?

This sounds like a "line discipline" for a serial device: a special way
to interpret the byte stream flowing between the user and the device:
something other than uninterpreted, 1-for-1 transport.

The most common line discipline is the code for a VGA text console
which performs character echoing (so you can see what you type), handles
backspace-as-delete, rings the bell for control-G, sends SIGINT for
control-C, turns <Enter> ('\r') into newline ('\n') on input, turns
newline ('\n') into carriage_return + linefeed ("\r\n") on ouput, etc.

The user opens the device, performs an ioctl() to choose the line
discipline, then transfers data using read() or write(). The line
discipline is a "filter" which resides inside the kernel, instead
of in a shell pipeline. See linux/Documentation/tty.txt.

--

.



Relevant Pages

  • Re: ntp discipline of local time?
    ... The kernel discipline is almost identical to the daemon discipline with the exception that the fancy code to combine the PLL and FLL near the Allan intercept is absent. ... like the clock state machine and poll-adjust algorithm continue in the daemon. ... The phase error is probably being filtered using an IIR filter, and that is what you are seeing, and also the mechanism ntpd uses to stop wandering off if it stops receiving updates (the frequency measurement error can produce unbounded phase errors, but the phase error correction is bounded). ...
    (comp.protocols.time.ntp)
  • Re: Difference between PPS and PPS plus kernel discipline?
    ... When using kernel discipline, the offset and jitter shown by the ntp ... Bottom line, I'm trying to explain what these plots tell me, other than ...
    (comp.protocols.time.ntp)
  • Difference between PPS and PPS plus kernel discipline?
    ... When using kernel discipline, the offset and jitter shown by the ntp ... Bottom line, I'm trying to explain what these plots tell me, other than ...
    (comp.protocols.time.ntp)
  • Re: Stick to PPS, even if the prefer server fails
    ... Somehow using an HP 5071 to discipline the time without kernel support ... so in principle could go forever without a prefer peer. ... could they tinker _max_disp ...
    (comp.protocols.time.ntp)
  • Re: tinker step 0 (always slew) and kernel time discipline
    ... First, the ntpd discipline algorithm described in various documents and the book is basically a linear, type-II phase-lock loop with characteristics carefully tailored for optimum response. ... The reason for the 0.5 second limitation in the kernel code is that the ntp_adjtimefunction is limited to a one-second interval due to overflow in the 32-bit word. ... In the design of the nanokernel code that leaves here, the time as seen by the application is not stepped backward unless the kernel clock is stepped backward more than two seconds. ...
    (comp.protocols.time.ntp)