Line discipline

Samuel Thibault samuel.thibault at ens-lyon.org
Wed Nov 23 09:56:59 EST 2016


Okash Khawaja, on Wed 23 Nov 2016 14:46:59 +0000, wrote:
> So I have a simple kernel module that registers a new ldisc. When userspace
> attaches that ldisc to /dev/ttyS0, the kernel module is able to write to that
> serial port using tty->ops->write().

Ok, good for a start :)

> Currently I'm investigating the core problem of opening /dev/ttyS0 from kernel
> space and attaching our ldisc to it. Are there any existing ideas around this?

What I wrote before:

“
how can speakup open
the port?  We don't have a process context or /dev/, so we can't just
use sys_open and alike.  What we could use is some function which takes
a minor/major pair or a device name, and returns a filp, then we can
tty_set_ldisc(N_SPEAKUP) on file_tty(filp), but I don't know if such
thing exists?  That would probably be building a struct inode (getting
inspired from fs/ramfs/), then just open it? Something like:

struct inode *inode = new_inode(sb);

init_special_inode(inode, S_IFCHR, MKDEV(major, minor));
filp = get_empty_filp();
do_dentry_open(filp, inode, NULL, NULL);
struct tty_struct *tty = file_tty(filp);
tty_set_ldisc(tty, N_SPEAKUP);
”

> Is this worth investigating: to find correct tty without opening /dev/ttyS0 and
> assigning our ldisc to it.

> Realistically, how early in boot process do we want the ldisc
> assigned?

As early as possible :)

That'll mean after tty initialization and after serial driver initialization

Samuel


More information about the Speakup mailing list