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 cnflush Waits for all pending output to finish. t Fn cngetc Poll (busy wait) for an input and return the input key. Returns 0 if there is no console input device. .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 cnhalt Terminates the console device (i.e. cleanly shuts down the console hardware.) 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. .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 -offset indent int c; cnpollc(1); for(;;) { c = cngetc(); if ((c == '\er' || (c == '\en')) { printf("\en"); break; } } cnpollc(0); .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 , .Xr wscons 9