Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cngetsn(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

WSKBD(4)						   BSD Kernel Interfaces Manual 						  WSKBD(4)

NAME
wskbd -- generic keyboard support in wscons SYNOPSIS
wskbd* at pckbd? console ? mux 1 (standard PC keyboard) wskbd* at ukbd? console ? mux 1 (USB keyboard) wskbd* at lkkbd? console ? mux 1 (DEC LK200/400 serial keyboard) wskbd0 at akbd? console ? mux 1 (Apple ADB keyboard) wskbd0 at nextkbd? console ? mux 1 (NeXT keyboard) wskbd* at vrkiu? console ? mux 1 (NEC VR4000 series HPC keyboard) wskbd* at skbd? console ? mux 1 (keyboard of misc hpcmips handheld devices) wskbd* at btkbd? console ? mux 1 (Bluetooth keyboard) DESCRIPTION
The wskbd driver handles common tasks for keyboards within the wscons(4) framework. It is attached to the hardware specific keyboard drivers and provides their connection to ``wsdisplay'' devices and a character device interface. The common keyboard support consists of: o Mapping from keycodes (defined by the specific keyboard driver) to keysyms (hardware independent, defined in /usr/include/dev/wscons/wsksymdef.h). o Handling of ``compose'' sequences. Characters commonly not present as separate key on keyboards can be generated after either a special ``compose'' key is pressed or a ``dead accent'' character is used. o Certain translations, like turning an ``ALT'' modifier into an ``ESC'' prefix. o Automatic key repetition (``typematic''). o Parameter handling for ``keyboard bells''. o Generation of ``keyboard events'' for use by X servers. The wskbd driver provides a number of ioctl functions to control key maps and other parameters. These functions are accessible though the associated ``wsdisplay'' device as well. A complete list is in /usr/include/dev/wscons/wsconsio.h. The wsconsctl(8) utility allows to access key maps and other variables. The console locator in the configuration line refers to the device's use as input part of the operating system console. A device specifica- tion containing a positive value here will only match if the device is in use as system console. (The console device selection in early sys- tem startup is not influenced.) This way, the console device can be connected to a known wskbd device instance. Ioctls The following ioctl(2) calls are provided by the wskbd driver or by devices which use it. Their definitions are found in dev/wscons/wsconsio.h. WSKBDIO_GTYPE Get the keyboard type. WSKBDIO_COMPLEXBELL, WSKBDIO_SETBELL, WSKBDIO_GETBELL, WSKBDIO_SETDEFAULTBELL, WSKBDIO_GETDEFAULTBELL (struct wsmouse_repeat) Get and set keyboard bell settings. WSKBDIO_SETKEYREPEAT, WSKBDIO_GETKEYREPEAT, WSKBDIO_SETDEFAULTKEYREPEAT, WSKBDIO_GETDEFAULTKEYREPEAT (struct wskbd_keyrepeat_data) Get and set keyboard autorepeat settings. WSKBDIO_SETLEDS, WSKBDIO_GETLEDS (int) Get and set keyboard LED settings. WSKBDIO_GETMAP, WSKBDIO_SETMAP (struct wskbd_map_data) Get and set keyboard keymapping settings. WSKBDIO_GETENCODING, WSKBDIO_SETENCODING (kbd_t) Get and set keyboard encoding settings. WSKBDIO_GETKEYCLICK, WSKBDIO_SETKEYCLICK (int) Get and set keyboard keyclick settings. WSKBDIO_SETVERSION (int) Set the wscons_event protocol version. The default is 0 for binary compatibility. The latest version is always available as WSKBD_EVENT_VERSION, and is currently 1. All new code should use a call similar to the below to ensure the correct version is returned. int ver = WSKBD_EVENT_VERSION; if (ioctl(fd, WSKBDIO_SETVERSION, &ver) == -1) err(EXIT_FAILURE, "cannot set version"); FILES
/dev/wskbd* /usr/include/dev/wscons/wsksymdef.h /usr/include/dev/wscons/wsconsio.h. SEE ALSO
btkbd(4), pckbd(4), ukbd(4), wscons(4), wsmux(4), wsconsctl(8), wskbd(9) BSD
May 27, 2012 BSD
Man Page