Subject: Re: Console Magic redux
To: None <cgd@sibyte.com, eeh@netbsd.org>
From: None <eeh@netbsd.org>
List: tech-kern
Date: 11/14/2000 21:31:58
> > int
> > cn_isconsole(dev_t dev);
>
> This is used by cn_check_magic().
yes, i got that later -- I guess I'm wondering is, why is it valuable
to push this abstraction out of the individual drivers, into common
macros.
I'm not sure what that adds; all i see is a forced (or hard to
override in a driver specific way) check of a global variable, when a
check of a local flags word already in cache or a register might
suffice.
> typically code for drivers which are capable of being the console also
> keep a flag around to note that fact. I'd think that accessing a
> global (via a macro) to test this fairly often would be a lose --
> esp. if the alternative is checking a flag in a flags word defined in
> the softc, that may be needed for other work anyway.
>
> It defaults to comparing the `dev' to the value of `cn_tab->cn_dev' but
> you can override it to do anything you want.
well... each driver could individually clobber it to look in their own
softc struct... but that only happens to work if there's a device
softc ptr in scope with a given name, etc...
I'm just not sure what the value of providing a generic macro to do
this _is_! 8-)
Drivers may think they are the console but be very wrong.
On some machines, like SPARC, one device can register as the console
only to find another device has replaced it later.
Now as for the escape sequence encoding/decoding: it's a hard problem.
It may require some sort of userland helper app to convert the strings
to/from an easier format. If you think you have a better solution
please feel free to change it.
Eduardo