Subject: Re: should cngetc block?
To: Bill Studenmund <wrstuden@netbsd.org>
From: Kin Cho <kin@neoscale.com>
List: tech-kern
Date: 02/07/2002 10:43:48
Bill Studenmund <wrstuden@netbsd.org> writes:
> On 5 Feb 2002, Kin Cho wrote:
>
> > eeh@netbsd.org writes:
> >
> > > If you want to change that interface so that cngetc() does not
> > > block, you need to put together a proposal explaining what you
> > > want to do, how you want to do it, and why it's needed.
> >
> > My proposal is this:
> >
> > Objective:
> > * To provide a way to poll for keyboard input in the interface
> > "struct consdev". However, only the "com" driver will support
> > this.
>
> As others have noted, adding a general feature to an MI interface and then
> only implimenting it for one chip won't go over well.
>
> I think it would really help us if you explained more of what you are
> doing. Why do you want to poll for characters? i.e. what else are you
> doing while you're wanting input? More importantly, are interrupts
> enabled?
Well, one of the commands of our "debugger/loader" (basically we
put a command loop where the netbsd "init" would normally be) is
to test our custom hardware. So while this command is running,
we'd like to be able to pause or stop it -- so the need to poll
for keyboard input.
We don't disable interrupts. While the test command is
running, serial interrupts are processed by comintr as
usual. Given the need to pause/stop the test command, I
need a way to get at the characters just stored in
com_softc. Here's what I mean:
/* our "init" */
for (;;) {
/* call cngetsn to get a string */
/* parse and execute command_x */
}
void command_x(void)
{
struct com_softc *sc = (struct com_softc *)finddevice("com0");
com_iflush(sc);
for (;;) {
if ((c = com_iavail(sc)) >= 0) {
com_iflush(sc);
printf("\npress 'y' to stop...");
if ((c = cngetc()) == 'y')
break;
}
if (tickle_hardware())
break;
}
}
Within the existing com driver framework and our limited
kernel, what would com_iavail() look like?
-kin