Subject: console device selection
To: None <>
From: Garrett D'Amore <>
List: tech-kern
Date: 09/01/2006 23:01:15
I just spent some time looking at the x86 console selection code, mostly
to see if I could come up with any examples for a "clean" way to
implement console selection code.

Boy, was I mistaken.

I think we need to consider a way for the various framebuffers,
keyboards, and serial devices to register with a console selection
framework, which can then do the "right" thing.  I propose, therefore,
something along these lines:

struct cons_device {
    int   preference;
    const char *name;
    int (*initialize)(void);
    int devtypes;  /* 0 = input, 1 = output, 2 = both? */

struct cons_register(&cons_device);

then each driver has a single routine which registers the device(s)


somewhere in common kernel code, we can then have:

#if NRADEON > 0

I suppose we should provide a way for MD code to alter preferences (e.g.
based upon BIOS or OBP, or user selection).  This can be handled by
exporting some routines to walk the list of registered console devices
and manipulate them.

We also need to assume that machdep code might register machdep console
devices, e.g. custom serial ports, etc.  We don't want to store those
all in the common.c, but machdep code can call the cons_register()
routine for those before calling master consinit.

The above is merely a strawman, intended to spark discussion.  I really
don't want to have #if NRADEON, etc. in every port that might have a PCI
bus, for example.

The "devtypes" field above is tricky also, because it has to deal with
matching up input vs. output devices.  One can even imagine a scenario
where the output is 'mixed'.  E.g. a serial port could be used for
input, but a display for output, or vice versa.  This can actually occur
on SPARC class machines with Solaris.  We could easily support it too.

Let me know your thoughts! :-)

Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
Phone: 951 325-2134  Fax: 951 325-2191