linux-console.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about 'device' field of struct console
@ 2010-10-25 18:23 Timur Tabi
  0 siblings, 0 replies; only message in thread
From: Timur Tabi @ 2010-10-25 18:23 UTC (permalink / raw)
  To: linux-console

I'm trying to write a console and TTY driver that's not based on a serial port,
and I'm confused by the "device' field of 'struct console'.  I found this text
in http://www.linux.it/~rubini/docs/sercons/sercons.html:

"The purpose of the UDP console device is sending kernel messages through the
network. Unlike serial or vt consoles, which are associated to real tty devices,
this console has no tty associated, and that's why the device function is not
defined.

In a real console device, the device function is used to return the device
number associated to this console as a kdev_t value. Only one serial port can be
elected as a console, for example, and the device function defined by the serial
driver is used to tell the caller which one is. The function is used in
drivers/char/tty_io.c to redirect any access to /dev/console. Thus, a process
that opens /dev/console will actually open a different device, provided at least
one of the active console drivers has a device function and the device returned
is known to the tty layer. "

I don't really understand this.  What is a "real tty device"?  What am I missing
if I don't have a real TTY device?

Using other drivers as an example, I can fill the 'device' field with a pointer
to this function ehv_bc_console_device():

static struct tty_driver *ehv_bc_driver;

static struct tty_driver *ehv_bc_console_device(struct console *c, int *index)
{
	*index = c->index;

	return ehv_bc_driver;
}

This is what other drivers do, although I don't really understand what it's
doing.  However, I can't figure out how to initialize ehv_bc_driver.  I can
allocate one like this:

	ehv_bc_driver = alloc_tty_driver(1);
	if (!ehv_bc_driver) {
		printk(KERN_INFO "%s:%u\n", __func__, __LINE__);
		return -ENOMEM;
	}

But the problem is that the subsequent call to tty_register_driver() causes a
kernel panic in kobj_map().  I *think* this is because I'm calling
tty_register_driver() inside my console_init() function, which is too early.  If
so, then I have a catch-22.

Can anyone shed some light on this?  There doesn't seem to be any good
documentation on writing a console *and* a TTY driver.

-- 
Timur Tabi
Linux kernel developer at Freescale


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-10-25 18:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-25 18:23 Question about 'device' field of struct console Timur Tabi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).