p Console input polling functions .Fn cngetc , .Fn cngetsn and .Fn cnpollc are only to be used during initial system boot, e.g. when asking for root and dump device or to get necessary user input within mountroothooks. Once the system boots, user input is read via standard .Xr tty 4 facilities.
p
The following is a brief description of each function:
l -tag -width "cngetsn()" t Fn cnbell Ring a bell at appropriate
.Fa pitch ,
for duration of
.Fa period
milliseconds at given
.Fa volume .
Note that the
.Fa volume
value is ignored commonly.
t Fn cngetc Poll (busy wait) for a input and return the input key.
.Fn cnpollc
.Em must
be called before
.Fn cngetc
could be used.
.Fn cngetc
should be used during kernel startup only.
t Fn cngetsn Read one line of user input, stop reading once the newline
key is input. Input is echoed back. This
uses
.Fn cnpollc
and
.Fn cngetc .
Number of read characters is
.Fa size
at maximum, user is notified by console bell when the end
of input buffer is reached. <Backspace> key
works as expected. <@> or <CTRL>-u make
.Fn cngetsn
discard input read so far, print newline and
wait for next input.
.Fn cngetsn
returns number of characters actually read, excluding
the final newline.
.Fa cp
is
.Em not
zero-ended before return.
.Fn cngetsn
should be used during kernel startup only.
t Fn cnpollc Switch the console driver to polling mode if
.Fa on
is nonzero, or back to interrupt driven mode if
.Fa on
is zero.
The system priority level has to be raised to splhigh before
he polling mode could be switched on, so that the polled console device would
ot be disturbed by interrupts. The system priority level has to be
estored to previous level once the polling mode is switched back off.
.Fn cnpollc
should be used during kernel startup only.
t Fn cnputc Console kernel output character routine. Commonly, kernel code uses
.Xr printf 9
rather than using this low-level interface.
.El
.Sh EXAMPLES
This waits until a <Enter> key is pressed:
p
d -literal -compact int s, c;
int c;
s = splhigh();
cnpollc(1);
for(;;) {
c = cngetc();
if ((c == '\\r' || (c == '\\n')) {
printf("\\n");
break;
}
}
cnpollc(0);
splx(s);
.Ed
.Sh SEE ALSO
.Xr pckbd 4 ,
.Xr pcppi 4 ,
.Xr tty 4 ,
.Xr wscons 4 ,
.Xr wskbd 4 ,
.Xr printf 9 ,
.Xr spl 9