Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cngetc(9) [netbsd man page]

CONS(9) 						   BSD Kernel Developer's Manual						   CONS(9)

NAME
cnbell, cnflush, cngetc, cngetsn, cnhalt, cnpollc, cnputc -- console access interface SYNOPSIS
#include <dev/cons.h> void cnbell(u_int pitch, u_int period, u_int volume); void cnflush(void); int cngetc(void); int cngetsn(char *cp, int size); void cnhalt(void); void cnpollc(int on); void cnputc(int c); DESCRIPTION
These functions operate over the current console device. The console must be initialized before these functions can be used. Console input polling functions cngetc(), cngetsn() and 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 tty(4) facili- ties. The following is a brief description of each function: cnbell() Ring a bell at appropriate pitch, for duration of period milliseconds at given volume. Note that the volume value is ignored com- monly. cnflush() Waits for all pending output to finish. cngetc() Poll (busy wait) for an input and return the input key. Returns 0 if there is no console input device. cnpollc() must be called before cngetc() could be used. cngetc() should be used during kernel startup only. cngetsn() Read one line of user input, stop reading once the newline key is input. Input is echoed back. This uses cnpollc() and cngetc(). Number of read characters is 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 cngetsn() discard input read so far, print newline and wait for next input. cngetsn() returns number of characters actually read, excluding the final newline. cp is not zero-ended before return. cngetsn() should be used during kernel startup only. cnhalt() Terminates the console device (i.e. cleanly shuts down the console hardware.) cnpollc() Switch the console driver to polling mode if on is nonzero, or back to interrupt driven mode if on is zero. cnpollc() should be used during kernel startup only. cnputc() Console kernel output character routine. Commonly, kernel code uses printf(9) rather than using this low-level interface. EXAMPLES
This waits until a <Enter> key is pressed: int c; cnpollc(1); for(;;) { c = cngetc(); if ((c == ' ' || (c == ' ')) { printf(" "); break; } } cnpollc(0); SEE ALSO
pckbd(4), pcppi(4), tty(4), wscons(4), wskbd(4), printf(9), spl(9), wscons(9) BSD
June 8, 2010 BSD

Check Out this Related Man Page

CONSCONTROL(8)						    BSD System Manager's Manual 					    CONSCONTROL(8)

NAME
conscontrol -- control physical console devices SYNOPSIS
conscontrol [list] conscontrol mute on | off conscontrol add | delete console conscontrol set | unset console DESCRIPTION
The conscontrol utility is used to examine and modify the physical devices which back the virtual console devices. If no arguments (or only the list command) are specified, the current console settings are shown. There are two types of logical consoles; a high level console which is represented by /dev/console, and a low level console. The low level console is used for kernel printf(9) and ddb(4) debugger support, while the high level console is used by user programs like syslogd(8). Multiple device support is implemented only for the low level console; the high level console is set to the first device in the console list. Multiple console support may be invoked by passing the kernel the -D flag from the boot loader, or by using conscontrol to change the list of console devices after the system has booted. The following options are available: add | delete console Add or delete a physical device from the logical console. The device must support low-level console operations. Adding a device will place it at the front of the list of console devices; the first device is used for the high level console. The console argument is the name of a console device in /dev; the name of the directory may be omitted. mute on | off Change the state of console muting. All console output is suppressed when console muting is on. set | unset console Set or unset the virtual console. When unset, output from the system, such as the kernel printf(9), always goes out to the real main console. When set, it goes to another. This is an interface to the tty ioctl TIOCCONS. SEE ALSO
sio(4), syscons(4), tty(4), vt(4), boot(8), loader(8) HISTORY
The conscontrol utility first appeared in FreeBSD 5.0. AUTHORS
Jonathan Lemon BSD
April 14, 2011 BSD
Man Page